Transfer.php 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Transfer extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_transfer','transfer');
  8. $this->load->_model('Model_typeclass','typeclass');
  9. $this->load->_model('Model_warehouse','warehouse');
  10. $this->load->_model('Model_systemtransfer','systemtransfer');
  11. $this->load->_model('Model_excel','excel');
  12. $this->load->_model('Model_fullorder','fullorder');
  13. $this->load->_model('Model_fullordertt','fullordertt');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_purchase','purchase');
  16. $this->load->_model('Model_classid','classid');
  17. $this->load->_model('Model_express','express');
  18. $this->load->_model('Model_apiyy','apiyy');
  19. $this->load->_model('Model_shop','shop');
  20. $this->load->_model('Model_systemtransfer_cr','systemtransfer_cr');
  21. $this->load->_model("Model_logic_ding","logic_ding");
  22. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  23. $this->load->_model("Model_logic_order","logic_order");
  24. }
  25. //定义方法的调用规则 获取URI第二段值
  26. public function _remap($arg,$arg_array)
  27. {
  28. if($arg == 'add')
  29. {
  30. $this->_add();
  31. }
  32. else if($arg == 'edit')
  33. {
  34. $this->_edit($arg_array);
  35. }
  36. else if($arg == 'del')
  37. {
  38. $this->_del();
  39. }
  40. else if($arg == 'print')
  41. {
  42. $this->_print();
  43. }
  44. else if($arg == 'number')
  45. {
  46. $this->_number();
  47. }
  48. else if($arg == 'numberprint')
  49. {
  50. $this->_numberprint();
  51. }
  52. else if($arg == 'operate')
  53. {
  54. $this->_operate();
  55. }
  56. else if($arg == 'out')
  57. {
  58. $this->_out();
  59. }
  60. else if($arg == 'excel')
  61. {
  62. $this->_excel();
  63. }
  64. else if($arg == 'bdbb')
  65. {
  66. $this->_bdbb();
  67. }
  68. else if($arg == 'rk')
  69. {
  70. $this->_rk();
  71. }
  72. else if($arg == 'cqrk'){
  73. $this->_cqrk();
  74. }
  75. else if($arg == 'ck')
  76. {
  77. $this->_ck();
  78. }
  79. else if($arg == 'jgl')//交工率
  80. {
  81. $this->_jgl();
  82. }
  83. else if($arg == 'linqi')
  84. {
  85. $this->_linqi();
  86. }
  87. else if($arg == 'jiaji'){
  88. $this->_jiaji();
  89. }
  90. else if($arg == 'overtime_export'){
  91. $this->_overtime_export();
  92. }
  93. else if($arg == 'scz'){
  94. $this->_scz();
  95. }
  96. else if($arg == 'wjsrk'){
  97. $this->_wjsrk();
  98. }
  99. else if($arg == 'wjsrkexcel'){
  100. $this->_wjsrkexcel();
  101. }
  102. else if($arg == 'cqrkexcel'){
  103. $this->_cqrkexcel();
  104. }
  105. else if($arg == 'sczexcel'){
  106. $this->_sczexcel();
  107. }else if($arg == 'czbmsfcz'){
  108. $this->_czbmIsOutExcel();
  109. }else if($arg == 'ycrk'){
  110. $this->_ycrk();
  111. }else if($arg == 'ycrkindex'){
  112. $this->_ycrkindex();
  113. }
  114. else
  115. {
  116. $this->_index();
  117. }
  118. }
  119. //管理
  120. public function _index()
  121. {
  122. $t = array();
  123. $typeclass = $this->typeclass->find_all();
  124. foreach ($typeclass as $v)
  125. {
  126. $t[$v['id']] = $v['title'];
  127. }
  128. $post = $this->input->post(NULL, TRUE);
  129. if(isset($post['page']))
  130. {
  131. $page = $this->input->post('page',true);
  132. $perpage = $this->input->post('perpage',true);
  133. $type = $this->input->post('type',true);
  134. $where = "1=1 ";
  135. //数据排序
  136. $order_str = "id asc";
  137. if($type)
  138. {
  139. $where .= "and type = '$type'";
  140. }
  141. if(empty($page))
  142. {
  143. $start = 0;
  144. $perpage = 1;
  145. }
  146. else
  147. {
  148. $start = ($page - 1)*$perpage;
  149. }
  150. //取得信息列表
  151. $info_list = $this->transfer->find_all($where,'id,title,orvertime,overtime_one,overtime_two',$order_str,$start,$perpage);
  152. $total = $this->transfer->find_count($where);
  153. $pagenum = ceil($total/$perpage);
  154. $over = $total-($start+$perpage);
  155. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  156. echo json_encode($rows);exit;
  157. }
  158. $this->_Template('transfer',$this->data);
  159. }
  160. //添加
  161. public function _add()
  162. {
  163. $post = $this->input->post(NULL, TRUE);
  164. if(isset($post['title']))
  165. {
  166. $title = $this->input->post('title',true);
  167. if($this->transfer->find_all("title = '$title'"))
  168. {
  169. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  170. }
  171. if($this->transfer->insert($post))
  172. {
  173. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  174. }
  175. else
  176. {
  177. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  178. }
  179. }
  180. $this->_Template('transfer_add',$this->data);
  181. }
  182. //修改
  183. public function _edit($arg_array)
  184. {
  185. $post = $this->input->post(NULL, TRUE);
  186. if(isset($post['id']))
  187. {
  188. $id = $this->input->post('id',true);
  189. $title = $this->input->post('title',true);
  190. if($this->transfer->find_all("title = '$title' and id != '".$id."'"))
  191. {
  192. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  193. }
  194. if($this->transfer->save($post,$id))
  195. {
  196. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  197. }
  198. else
  199. {
  200. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  201. }
  202. }
  203. $arg_array = $arg_array[0];
  204. $transfer = $this->transfer->read($arg_array);
  205. $this->data['transfer'] = $transfer;
  206. $this->_Template('transfer_edit',$this->data);
  207. }
  208. //删除
  209. public function _del()
  210. {
  211. $post = $this->input->post(NULL, TRUE);
  212. if(isset($post['s']))
  213. {
  214. $id_arr = $this->input->post('s');
  215. $id_arr = explode(',',$id_arr);
  216. if(!$id_arr)
  217. {
  218. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  219. }
  220. //循环删除记录
  221. foreach ($id_arr as $v)
  222. {
  223. $this->transfer->remove($v);
  224. }
  225. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  226. }
  227. }
  228. public function _print()
  229. {
  230. if(isset($_SESSION['api']))
  231. {
  232. $user = $this->user->get_api($_SESSION['api']);
  233. $usp = $user;
  234. $sid = "";$wid="";$wtype="";
  235. $userwh = explode('|',trim($user['warehouse'],'|'));
  236. foreach ($userwh as $value)
  237. {
  238. $wid .= " id = ".$value." or";
  239. $wtype .= " type = ".$value." or";
  240. }
  241. }
  242. $post = $this->input->post(NULL, TRUE);
  243. $classid = $this->classid->sku();
  244. $pm = $classid;
  245. $scsku = $classid;
  246. if(isset($post['category']))
  247. {
  248. $list = array();$num = "";$title = "";$features = "";
  249. $order = 0;
  250. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  251. $t = $this->input->post('t',true);//打印数量
  252. if($xbqnum > 99)
  253. {
  254. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  255. }
  256. if($xbqnum < 1)
  257. {
  258. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  259. }
  260. $post['purchase'] = $this->input->post('purchase',true);//所属工厂
  261. $category = $this->input->post('category',true);
  262. $list['category'] = $category;
  263. $list['hairtype'] = $this->input->post('hairtype',true);
  264. $list['grade'] = $this->input->post('grade',true);
  265. $size = $this->input->post('size',true);
  266. $xzsku = $this->input->post('xzsku',true);
  267. $list['size'] = rtrim($size,',');
  268. $list['hairnumber'] = $this->input->post('hairnumber',true);
  269. $list['extension'] = $this->input->post('extension',true);
  270. if($category == 1297)
  271. {
  272. $list['sywignumber'] = $this->input->post('sywignumber',true);
  273. }
  274. if($category == 1702)
  275. {
  276. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  277. $list['syother'] = $this->input->post('syother',true);
  278. }
  279. if($category == 133)
  280. {
  281. $list['fittype'] = $this->input->post('fittype',true);
  282. $list['acother'] = $this->input->post('acother',true);
  283. }
  284. $list['color'] = $this->input->post('color',true);
  285. $list['lowe'] = $this->input->post('lowe',true);
  286. if($category == 127)
  287. {
  288. $list['type'] = $this->input->post('type',true);
  289. $list['headroad'] = $this->input->post('headroad',true);
  290. $list['density'] = $this->input->post('density',true);
  291. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  292. {
  293. $list['lacesize'] = $this->input->post('lacesize',true);
  294. }
  295. $list['lacecolor'] = $this->input->post('lacecolor',true);
  296. $list['lacetypes'] = $this->input->post('lacetypes',true);
  297. }
  298. if($category == 128)
  299. {
  300. $list['lacetype'] = $this->input->post('lacetype',true);
  301. $list['haircap'] = $this->input->post('haircap',true);
  302. $list['density'] = $this->input->post('density',true);
  303. $list['lacecolor'] = $this->input->post('lacecolor',true);
  304. $list['lacetypes'] = $this->input->post('lacetypes',true);
  305. $list['wigother'] = $this->input->post('wigother',true);
  306. $list['wigother1'] = $this->input->post('wigother1',true);
  307. $list['wigother2'] = $this->input->post('wigother2',true);
  308. }
  309. if($category == 129)
  310. {
  311. $list['wide'] = $this->input->post('wide',true);
  312. }
  313. if($category == 131)
  314. {
  315. $list['gifttype'] = $this->input->post('gifttype',true);
  316. $list['giftother'] = $this->input->post('giftother',true);
  317. }
  318. if($category == 134)
  319. {
  320. $list['pieceweight'] = $this->input->post('pieceweight',true);
  321. }
  322. if($category == 1297)
  323. {
  324. $list['synthetictype'] = $this->input->post('synthetictype',true);
  325. $list['sywigother'] = $this->input->post('sywigother',true);
  326. }
  327. if($category == 130 || $category == 133 || $category == 1702)
  328. {
  329. $list['items'] = $this->input->post('items',true);
  330. $list['weight'] = $this->input->post('weight',true);
  331. }
  332. if($category == 1702)
  333. {
  334. $list['syhairther'] = $this->input->post('syhairther',true);
  335. }
  336. if($category == 130){
  337. $list['jfother'] = $this->input->post('jfother', true);
  338. }
  339. foreach($list as $k=>$v)
  340. {
  341. if($v != 0)
  342. {
  343. $num .=$v;
  344. $features .=$v.'-';
  345. $post[$k] = $v;
  346. $typeclass = $this->typeclass->read($v);
  347. if(isset($pm[$typeclass['classid']]))
  348. {
  349. $pm[$typeclass['classid']] = $typeclass['zh'];
  350. }
  351. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  352. if($k != 'size')
  353. {
  354. $title .= $typeclass['title']." ";
  355. }
  356. }
  357. }
  358. $typeclass = $this->typeclass->read($list['size']);
  359. $title .= $typeclass['title'];
  360. $time = time();
  361. $post['printtime'] = $time;
  362. $post['title'] = rtrim($title,' ');
  363. $post['number'] = $num;
  364. $post['features'] = '-'.$features;
  365. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  366. $featurespp = explode('-',trim($featurespp,'-'));
  367. if(isset($featurespp[5]))
  368. {
  369. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  370. }
  371. else
  372. {
  373. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  374. }
  375. $post['time'] = $time;//操作时间
  376. $scsku = implode("-",$scsku);
  377. $zh = implode(" ",$pm);
  378. $zh = str_replace('自然色 ','',trim($zh,' '));
  379. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  380. $post['shipremarks'] = $zh;
  381. $scsku = str_replace('- ','-',trim($scsku,'-'));
  382. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  383. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;
  384. $post['sku'] = $bqsku;
  385. $post['rk'] = "|1|";//默认配货 打印后直接入库
  386. $post['rktime'] = "|".$time."|";
  387. $rows = array();
  388. $this->db->trans_begin();
  389. for($i=0;$i<$xbqnum;$i++)
  390. {
  391. $label = substr($time,1)*100;
  392. $post['label'] = $label+$i;
  393. $rows[] = array('num'=>$post['label'],'number'=>'','shipremarks'=>$zh,'ex'=>'','t'=>$t,'time'=>'布标打印时间:'.date('Y-m-d H:i:s',$time),'s'=>'('.($i+1).'/'.$xbqnum.')');
  394. $this->systemtransfer->insert($post);
  395. }
  396. if ($this->db->trans_status() === TRUE)
  397. {
  398. $this->db->trans_commit();
  399. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  400. }
  401. else
  402. {
  403. $this->db->trans_rollback();
  404. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  405. }
  406. }
  407. $purchase = $this->purchase->find_all("yyid != ''");
  408. $this->data['purchase'] = $purchase;
  409. $this->_Template('transfer_print',$this->data);
  410. }
  411. public function _number()
  412. {
  413. if(isset($_SESSION['api']))
  414. {
  415. $user = $this->user->get_api($_SESSION['api']);
  416. $pid = "";$tid="";$sid="";$wid="";
  417. $purchase = explode('|',trim($user['purchase'],'|'));
  418. $transfer = explode('|',trim($user['transfer'],'|'));
  419. foreach ($purchase as $value)
  420. {
  421. $pid .= " id = ".$value." or";
  422. }
  423. foreach ($transfer as $value)
  424. {
  425. $tid .= " id = ".$value." or";
  426. }
  427. }
  428. else
  429. {
  430. header('Location: /');exit;
  431. }
  432. $post = $this->input->post(NULL, TRUE);
  433. if(isset($post['number']))
  434. {
  435. $number = $this->input->post('number',true);
  436. $type = $this->input->post('type',true);
  437. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  438. $purchase = $this->input->post('purchase',true);
  439. // $f = 'fullorder';
  440. // $y = $this->fullorder->get_number($number);
  441. // if(!$y)
  442. // {
  443. // $f = 'fullordersmt';
  444. // $y = $this->fullordersmt->get_number($number);
  445. // if(!$y)
  446. // {
  447. // $f = 'fullordertt';
  448. // $y = $this->fullordertt->get_number($number);
  449. // if(!$y)
  450. // {
  451. // echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  452. // }
  453. // }
  454. // }
  455. $y = $this->logic_order->getInfo("number = '".$number."'");
  456. if(!$y)
  457. {
  458. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  459. }
  460. $f = $y['lv_platform'];
  461. if($y['librarytime'] > 0)
  462. {
  463. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  464. }
  465. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;$typeclass = array();
  466. $classid = $this->classid->sku();
  467. $tc = $this->typeclass->find_all();
  468. foreach($tc as $v)
  469. {
  470. $typeclass[$v['id']] = $v;
  471. }
  472. $bm = '03';
  473. $fpdata = explode(';',trim($y['fpdata'],';'));
  474. $whlabelsc = explode('|',trim($y['whlabel'],'|'));
  475. foreach($fpdata as $key=>$val)
  476. {
  477. $pm = $classid;
  478. $jm = $classid;
  479. $sku = $classid;
  480. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  481. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  482. $jvnr = explode('|',trim($features,'|'));
  483. if(stripos($jvnr[0],',') !== false)
  484. {
  485. $ft = explode(',',$jvnr[0]);
  486. $features = explode('-',trim($ft[1],'-'));
  487. array_splice($features,2,0,$ft[0]);
  488. }
  489. else
  490. {
  491. $features = explode('-',trim($jvnr[0],'-'));
  492. }
  493. $title = $jvnr[1];
  494. foreach($features as $k=>$v)
  495. {
  496. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  497. {
  498. if($typeclass[$v]['bm'] != '')
  499. {
  500. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  501. }
  502. }
  503. if($v != 0)
  504. {
  505. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  506. if(isset($pm[$typeclass[$v]['classid']]))
  507. {
  508. if($typeclass[$v]['title'] == '9A')
  509. {
  510. $pm[$typeclass[$v]['classid']] = '9A';
  511. }
  512. else if($typeclass[$v]['title'] == '10A')
  513. {
  514. $pm[$typeclass[$v]['classid']] = '10A';
  515. }
  516. else
  517. {
  518. $clzh = $typeclass[$v]['zh'];
  519. if(stripos($typeclass[$v]['zh'],'|') !== false)
  520. {
  521. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  522. $clzh = $clzh[0];
  523. }
  524. $pm[$typeclass[$v]['classid']] = $clzh;
  525. }
  526. }
  527. if(isset($jm[$typeclass[$v]['classid']]))
  528. {
  529. if($typeclass[$v]['jm'])
  530. {
  531. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  532. }
  533. }
  534. }
  535. }
  536. $jm = array_filter($jm);//去除空值
  537. $jm = implode("-",$jm);
  538. $sku = array_filter($sku);//去除空值
  539. $sku = implode("-",$sku);
  540. $pm = array_filter($pm);//去除空值
  541. $zh = implode(" ",$pm);
  542. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  543. $features = implode("-",$features);
  544. $y['shipremarks'] = str_replace("'",'"',$y['shipremarks']);
  545. $cp[] = array('ordernumber'=>$number,'title'=>$title,'sku'=>$sku,'jm'=>$jm,'zh'=>$zh,'n'=>$jvnr[2],'b'=>$y['shipremarks'],'is_jiaji'=>$y['is_jiaji'],'data'=>json_encode(array('ordernumber'=>$number,'features'=>$features,'number'=>$number,'title'=>$title,'jm'=>$jm,'sku'=>$sku,'pm'=>$zh,'bm'=>$bm.implode("",$bmpx))));
  546. }
  547. ob_clean();
  548. echo json_encode(array('rows'=>$cp,'success'=>true));exit;
  549. }
  550. $purchase = $this->purchase->find_all("yyid != ''");
  551. $this->data['purchase'] = $purchase;
  552. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  553. $this->data['transfer'] = $transfer;
  554. $this->_Template('transfer_number',$this->data);
  555. }
  556. public function _numberprint()
  557. {
  558. $time = time();
  559. $post = $this->input->post(NULL);
  560. $classid = $this->classid->sku();
  561. $pm = $classid;
  562. $scsku = $classid;
  563. if(isset($post['data']))
  564. {
  565. $data = json_decode($post['data'],true);
  566. // $f = 'fullorder';
  567. // $y = $this->fullorder->get_number($data['ordernumber']);
  568. // if(!$y)
  569. // {
  570. // $f = 'fullordersmt';
  571. // $y = $this->fullordersmt->get_number($data['ordernumber']);
  572. // if(!$y)
  573. // {
  574. // $f = 'fullordertt';
  575. // $y = $this->fullordertt->get_number($data['ordernumber']);
  576. // if(!$y)
  577. // {
  578. // echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  579. // }
  580. // }
  581. // }
  582. $y = $this->logic_order->getInfo("number = '".$data['ordernumber']."'");
  583. if(!$y)
  584. {
  585. echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  586. }
  587. $f = $y['lv_platform'];
  588. if($y['printtime'] == 0)
  589. {
  590. echo json_encode(array('msg'=>'此单已重置,请询问梦体','success'=>false));exit;
  591. }
  592. $order = 0;$time = time();
  593. $xbqnum = $this->input->post('n',true);//打印数量
  594. if($xbqnum > 99)
  595. {
  596. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  597. }
  598. if($xbqnum < 1)
  599. {
  600. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  601. }
  602. $transfer = $this->input->post('transfer',true);
  603. $post['type'] = $this->input->post('type',true);
  604. $post['shipremarks'] = $this->input->post('b',true);
  605. $post['ph'] = $this->input->post('ph',true);
  606. $is_jiaji = $this->input->post('is_jiaji',true);
  607. if($is_jiaji == 2){
  608. $post['is_jiaji'] = 2;
  609. }else{
  610. $post['is_jiaji'] = 0;
  611. }
  612. $zps = $this->input->post('zps',true);
  613. $post['purchase'] = $this->input->post('purchase',true);//供应商
  614. $post['time'] = $time;//操作时间
  615. $post['jm'] = $data['jm'];
  616. $post['bm'] = $data['bm'];
  617. $post['pm'] = $data['pm'];
  618. $post['features'] = $data['features'];
  619. $post['number'] = $data['number'];
  620. $post['title'] = $data['title'];
  621. $post['sku'] = $data['sku'];
  622. $post['printtime'] = $y['printtime'];
  623. $post['rk'] = "|12|";//默认订单中心 打印后直接入库
  624. $post['ck'] = "|12|";
  625. $post['rktime'] = "|".$time."|";
  626. $post['cktime'] = $post['rktime'];
  627. $post['ctime12'] = $time;
  628. $express = $this->express->read($y['express']);
  629. $rows = array();$t='';
  630. $this->db->trans_begin();
  631. $post['xbqnum'] = $xbqnum;
  632. $kh = $this->shop->read($y['shop']);
  633. $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']);
  634. //$this->logic_ding->sendToDing("小布表打印异常".json_encode($yy)."|".json_encode($y['number']));
  635. if($yy['c'] == 0)
  636. {
  637. $post['scapi'] = '99';
  638. $post['scid'] = $yy['scid'];
  639. if(!$post['purchase'])
  640. {
  641. $post['purchase'] = '';
  642. }
  643. $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'");
  644. //able_ext 实在打印小单布标时判断是否可以打印备货单
  645. $able_ext = 0;
  646. $tmp_fetaures = explode('-',$data['features']);
  647. //只有头套和马尾才会要配货单
  648. if(in_array(128, $tmp_fetaures)){
  649. $able_ext = 1;
  650. }
  651. if(in_array(133, $tmp_fetaures)){
  652. if(in_array(673, $tmp_fetaures)){
  653. $able_ext = 1;
  654. }
  655. }
  656. for($i=0;$i<$xbqnum;$i++)
  657. {
  658. if($post['zps'])
  659. {
  660. if($post['zps'] > 0)
  661. {
  662. $t = '总量:'.($mqsl+$i+1).'/'.$zps;
  663. }
  664. }
  665. $label = $time.rand(1000,9999); //substr($time,1)*100;
  666. $post['label'] = $label+$i;
  667. $rows[] = array('num'=>$post['label'],'number'=>$post['number'],'shipremarks'=>$post['shipremarks'],'ph'=>$post['ph'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$post['printtime']),'gtime'=>date('YmdH',time()),'s'=>'('.($i+1).'/'.$xbqnum.')','t'=>$t,'able_ext'=>$able_ext,'is_jiaji'=>$is_jiaji);
  668. $this->systemtransfer->insert($post);
  669. }
  670. }
  671. else
  672. {
  673. $this->db->trans_rollback();
  674. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  675. }
  676. if($this->db->trans_status() === TRUE)
  677. {
  678. $this->db->trans_commit();
  679. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  680. }
  681. else
  682. {
  683. $this->db->trans_rollback();
  684. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  685. }
  686. }
  687. }
  688. public function _operate()
  689. {
  690. $post = $this->input->post(NULL, TRUE);
  691. if(isset($post['page']))
  692. {
  693. $api = $this->input->post('api',true);
  694. $page = $this->input->post('page',true);
  695. $perpage = $this->input->post('perpage',true);
  696. $number = $this->input->post('number',true);
  697. $color = $this->input->post('color',true);
  698. $purchase = $this->input->post('purchase',true);
  699. $transfer = $this->input->post('transfer',true);
  700. $lx = $this->input->post('lx',true);
  701. $type = $this->input->post('type',true);
  702. $pm = $this->input->post('pm',true);
  703. $jiaji = $this->input->post('jiaji',true);
  704. $xztime = $this->input->post('xztime',true);
  705. $timetk = $this->input->post('timetk',true);
  706. $timetj = $this->input->post('timetj',true);
  707. $timetk = strtotime($timetk);
  708. $timetj = strtotime($timetj);
  709. $where = '1=1';
  710. if($number)
  711. {
  712. $where .= " and number = '$number'";
  713. }
  714. if($pm){
  715. $where .= " and pm like '%".$pm."%'";
  716. }
  717. if($purchase)
  718. {
  719. $where .= " and purchase = '$purchase'";
  720. }
  721. if($color)
  722. {
  723. $where .= " and fpdata like '%-".$color."-%'";
  724. }
  725. if($lx)
  726. {
  727. if($lx == 1)
  728. {
  729. $where .= " and ordernumber = ''";
  730. }
  731. else
  732. {
  733. $where .= " and ordernumber != ''";
  734. }
  735. }
  736. if($jiaji){
  737. if($jiaji == 1){
  738. $where .= " and is_jiaji = 0";
  739. }
  740. if($jiaji == 2){
  741. $where .= " and is_jiaji = 2";
  742. }
  743. }
  744. //数据排序
  745. $order_str = "id desc";
  746. if(empty($page))
  747. {
  748. $start = 0;
  749. $perpage = 1;
  750. }
  751. else
  752. {
  753. $start = ($page - 1)*$perpage;
  754. }
  755. if($xztime == 'printtime')
  756. {
  757. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  758. if($type)
  759. {
  760. if($type == 3){
  761. if($transfer)
  762. {
  763. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  764. }
  765. }else{
  766. $type = ($type==1)?'rk':'ck';
  767. if($transfer)
  768. {
  769. $where .= " and $type like '%|".$transfer."|%'";
  770. }
  771. }
  772. }
  773. else
  774. {
  775. if($transfer)
  776. {
  777. $where .= " and rk like '%|".$transfer."|%'";
  778. }
  779. }
  780. }
  781. else
  782. {
  783. $cr = "time > '$timetk' and time < '$timetj'";
  784. if($transfer)
  785. {
  786. $cr .= " and lx = '".$transfer."' ";
  787. }
  788. if($type)
  789. {
  790. if($type == 3){
  791. $cr .= " and is_over = 0 ";
  792. }else{
  793. $cr .= " and type = '".$type."' ";
  794. }
  795. }
  796. $fid = '';
  797. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  798. foreach ($info_list_cr as $v)
  799. {
  800. $fid .= "id = '".$v['fid']."' or ";
  801. }
  802. if($fid)
  803. {
  804. $where .= ' and ('.trim($fid,'or ').')';
  805. }
  806. else
  807. {
  808. $where .= ' and id = 0';
  809. }
  810. }
  811. //取得信息列表
  812. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12,ycrk_type',$order_str,$start,$perpage);
  813. $transfer = $this->transfer->find_all();
  814. $t = array();
  815. $t[0] = "";
  816. foreach ($transfer as $v)
  817. {
  818. $t[$v['id']] = $v['title'];
  819. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  820. }
  821. //格式化数据
  822. foreach ($info_list as $key=>$value)
  823. {
  824. if($value['is_jiaji'] == 2){
  825. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  826. }else{
  827. $info_list[$key]['is_jiaji'] = "常规";
  828. }
  829. if(empty($value['ycrk_type'])){
  830. $info_list[$key]['ycrk_type'] = "<p style='background-color: #f0f0f0 !important;color:#000 !important' onclick='addYcrk(".$value['id'].")'>异常入库</p>";
  831. }else{
  832. $info_list[$key]['ycrk_type'] = "";
  833. }
  834. $dd = $this->systemtransfer->read($value['id']);
  835. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  836. $rk = explode('|',trim($dd['rk'],'|'));
  837. $rktime = explode('|',trim($dd['rktime'],'|'));
  838. $ck = explode('|',trim($dd['ck'],'|'));
  839. $cktime = explode('|',trim($dd['cktime'],'|'));
  840. $info_list[$key]['time'] = '';
  841. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  842. //"<h9 class='window' data-h='/returngoods/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>"
  843. $info_list[$key]['number'] = "<h9 class='window' data-h='/colour/seebynumber/".$value['number']."' data-t='订单号:".$value['number']."'><p>".$value['number']."</p></h9>";
  844. /**
  845. for($i=0;$i<count($rk);$i++)
  846. {
  847. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  848. {
  849. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  850. }
  851. else
  852. {
  853. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  854. }
  855. $info_list[$key]['time'] .= $d;
  856. if(isset($ck[$i]) && $ck[$i] != '')
  857. {
  858. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  859. }
  860. }
  861. **/
  862. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  863. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  864. foreach ($data as $k=>$v)
  865. {
  866. // $type = ($v['type']==1)?'入库':'出库';
  867. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  868. $type = ($v['type']==1)?'入库':'出库';
  869. if($v['orver_flag'] == 1){
  870. if($v['is_over'] == 0){
  871. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>";
  872. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  873. }else{
  874. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  875. }
  876. }elseif($v['orver_flag'] == 2){
  877. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>";
  878. }elseif($v['orver_flag'] == 3){
  879. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>";
  880. }elseif(($v['orver_flag'] == 0)&&(empty($v['lx']))){
  881. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:red'>订单已完成:".date('Y-m-d H:i',$v['time']) ."</a>";
  882. }else{
  883. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  884. }
  885. if($v['extra_status'] == 1){
  886. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  887. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  888. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  889. }else{
  890. $info_list[$key]['time'] .= "<br>";
  891. }
  892. }
  893. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  894. unset($info_list[$key]['ctime12']);
  895. }
  896. $total = $this->systemtransfer->find_count($where);
  897. $pagenum = ceil($total/$perpage);
  898. $over = $total-($start+$perpage);
  899. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  900. echo json_encode($rows);exit;
  901. }
  902. if(isset($_SESSION['api']))
  903. {
  904. $user = $this->user->get_api($_SESSION['api']);
  905. $usp = $user;
  906. $pid = "";$tid="";$sid="";$wid="";
  907. $purchase = explode('|',trim($user['purchase'],'|'));
  908. $transfer = explode('|',trim($user['transfer'],'|'));
  909. $warehouse = explode('|',trim($user['warehouse'],'|'));
  910. foreach ($purchase as $value)
  911. {
  912. $pid .= " id = ".$value." or";
  913. }
  914. foreach ($transfer as $value)
  915. {
  916. $tid .= " id = ".$value." or";
  917. }
  918. foreach ($warehouse as $value)
  919. {
  920. $wid .= " id = ".$value." or";
  921. }
  922. }
  923. else
  924. {
  925. header('Location: /');exit;
  926. }
  927. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  928. //只有admin和toutao用户可以查看
  929. if(in_array($user['id'],[10,44,50])){
  930. $sc_flag = 1;
  931. }
  932. $this->data['sc_flag'] = $sc_flag;
  933. $kx = '';$zjtab = '';
  934. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  935. $this->data['warehouse'] = $warehouse;
  936. $purchase = $this->purchase->find_all("yyid != ''");
  937. $this->data['purchase'] = $purchase;
  938. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  939. $this->data['transfer'] = $transfer;
  940. $this->data['vip'] = $user['vip'];
  941. $transfer_ids = array_column($transfer,'id');
  942. $transfer_str = implode(",",$transfer_ids);
  943. $this->data['cz_1_num'] = $this->systemtransfer_cr->find_count("orver_flag = 1 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  944. $this->data['cz_2_num'] = $this->systemtransfer_cr->find_count("orver_flag = 2 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  945. //$jiaji_num = 0;
  946. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  947. foreach($transfer_ids as $k=>$v){
  948. if($v == 11){
  949. unset($transfer_ids[$k]);
  950. }
  951. }
  952. if(empty($transfer_ids)){
  953. $this->data['jiaji_num'] = -1;
  954. }else{
  955. $transfer_str = implode(",",$transfer_ids);
  956. $sql_r = $this->db->query("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*14) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  957. // print_r("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*7) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  958. $tmp_list= $sql_r->result_array();
  959. $this->data['jiaji_num'] = count($tmp_list);
  960. }
  961. $this->_Template('transfer_operate',$this->data);
  962. }
  963. public function _out()
  964. {
  965. $post = $this->input->post(NULL, TRUE);
  966. if(isset($post['label']))
  967. {
  968. $time = time();
  969. $label = $this->input->post('label',true);
  970. $cz = $this->input->post('cz',true);
  971. $transfer = $this->input->post('transfer',true);
  972. if(!$label)
  973. {
  974. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  975. }
  976. if(!$transfer)
  977. {
  978. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  979. }
  980. $lb = $this->systemtransfer->get_label($label);
  981. if(!$lb)
  982. {
  983. $this->logic_ding->sendToDing("检测货物流转异常的编码".$transfer."|".$label);
  984. echo json_encode(array('msg'=>'错误!未找到此条码,请联系申天','success'=>false));exit;
  985. }
  986. if($lb['id'] == 136872 || $label == '17573171077300'){
  987. echo json_encode(array('msg'=>'此单请退 回配货库','success'=>false));exit;
  988. }
  989. //东恒的如果扫过完成 就不允许再扫入
  990. if($lb['type'] == 2){
  991. if((strpos($lb['rk'],3)!== false) && ($transfer !=3)){
  992. echo json_encode(array('msg'=>'东恒的货物不允许重复扫描!','success'=>false));exit;
  993. }
  994. }
  995. if($lb['number']!='')
  996. {
  997. $nu = $this->fullorder->get_number($lb['number']);
  998. if(!$nu)
  999. {
  1000. $nu = $this->fullordersmt->get_number($lb['number']);
  1001. if(!$nu)
  1002. {
  1003. $nu = $this->fullordertt->get_number($lb['number']);
  1004. }
  1005. }
  1006. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  1007. // if($nu['state'] == '214' || $nu['state'] == '217')
  1008. // {
  1009. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  1010. // }
  1011. }
  1012. $tdata = $this->transfer->find_all();
  1013. $t = array();
  1014. foreach ($tdata as $v)
  1015. {
  1016. $t[$v['id']] = $v['title'];
  1017. }
  1018. /**
  1019. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  1020. {
  1021. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  1022. }
  1023. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  1024. {
  1025. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  1026. }
  1027. **/
  1028. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  1029. // {
  1030. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  1031. // }
  1032. //如果是外销单 成品库不许扫入
  1033. if($transfer == 11 && $cz == 1 && $lb['type'] == 2){
  1034. echo json_encode(array('msg'=>'工厂的外销单成品库不许扫入!','success'=>false));exit;
  1035. }
  1036. //重新定义配货的原则问题
  1037. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  1038. $sku_arr = explode("-",$lb['features']);
  1039. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  1040. // 145 Full Lace Wig
  1041. // 1170 HDFullLaceWig
  1042. // 1249 FullLaceBobwithBang
  1043. // 1484 FullLaceBob
  1044. //如果是这4中全蕾丝那么配货就不处理
  1045. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  1046. }else{
  1047. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  1048. {
  1049. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  1050. }
  1051. }
  1052. }
  1053. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  1054. {
  1055. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  1056. }
  1057. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1058. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1059. if($transfer != 3 && $transfer != 11 )
  1060. {
  1061. if($cz == 1)
  1062. {
  1063. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1064. {
  1065. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1066. }
  1067. }
  1068. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1069. {
  1070. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1071. }
  1072. }
  1073. if($cz == 1)
  1074. {
  1075. $lb['rk'] .= $transfer.'|';
  1076. $lb['rktime'] .= $time.'|';
  1077. if($lbrk[0] == $transfer)
  1078. {
  1079. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1080. }
  1081. }
  1082. else if($cz == 2)
  1083. {
  1084. $lb['ck'] .= $transfer.'|';
  1085. $lb['cktime'] .= $time.'|';
  1086. if($lbck[0] == $transfer)
  1087. {
  1088. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1089. }
  1090. }
  1091. $this->_doCancelWlz($lb['id']);
  1092. $cztime = 'ctime'.$transfer;
  1093. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1094. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1095. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1096. {
  1097. if($lb['type'] == 0)
  1098. {
  1099. $s = $this->shop->read($nu['shop']);
  1100. $lb['kh'] = $s['yyid'];
  1101. $lb['ts'] = 1;
  1102. $rk = $this->apiyy->_newrk($lb);
  1103. if($rk['c'] == 0)
  1104. {
  1105. $this->db->trans_begin();
  1106. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$rk['scid'].time(),$cztime=>$time),$lb['id']);
  1107. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1108. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1109. if($cz == 2){
  1110. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1111. }
  1112. if ($this->db->trans_status() === TRUE)
  1113. {
  1114. $this->db->trans_commit();
  1115. if($nu['state'] == '216')
  1116. {
  1117. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1118. }
  1119. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1120. //标记订单已经取消
  1121. $this->_doCheckCancelFlag($lb['id']);
  1122. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1123. }
  1124. else
  1125. {
  1126. if($lb['is_jiaji'] == 2){
  1127. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1128. }elseif($lb['type'] == 2){
  1129. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1130. }else{
  1131. echo json_encode(array('music'=>'1','success'=>true));exit;
  1132. }
  1133. }
  1134. }
  1135. else
  1136. {
  1137. $this->db->trans_rollback();
  1138. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1139. }
  1140. }
  1141. else
  1142. {
  1143. if(stripos($rk['error'],'DocNo') !== false)
  1144. {
  1145. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1146. }
  1147. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1148. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1149. }
  1150. }elseif($lb['type'] == 2){
  1151. $this->db->trans_begin();
  1152. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,$cztime=>$time),$lb['id']);
  1153. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1154. $this->zzquque_u9->insert([
  1155. 'platform'=>'',
  1156. 'warehouse'=>0,
  1157. 'type'=>20, //5代表美仓
  1158. 'order_no'=>$lb['number'],
  1159. 'child_order_no'=>$lb['id'],
  1160. 'status'=>0,
  1161. 'create_time'=>time(),
  1162. 'update_time'=>time(),
  1163. ]);
  1164. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1165. if($cz == 2){
  1166. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1167. }
  1168. if ($this->db->trans_status() === TRUE)
  1169. {
  1170. $this->db->trans_commit();
  1171. if($nu['state'] == '216')
  1172. {
  1173. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1174. }
  1175. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1176. //标记订单已经取消
  1177. $this->_doCheckCancelFlag($lb['id']);
  1178. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1179. }
  1180. else
  1181. {
  1182. if($lb['is_jiaji'] == 2){
  1183. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1184. }elseif($lb['type'] == 2){
  1185. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1186. }else{
  1187. echo json_encode(array('music'=>'1','success'=>true));exit;
  1188. }
  1189. }
  1190. }
  1191. else
  1192. {
  1193. $this->db->trans_rollback();
  1194. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1195. }
  1196. }
  1197. else
  1198. {
  1199. $scid = explode('~',$lb['scid']);
  1200. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1201. $rk = $this->apiyy->get_bzsh($rkdata);
  1202. if(isset($rk['Data'][0]))
  1203. {
  1204. if($rk['Data'][0]['IsSucess'] == 1)
  1205. {
  1206. $this->db->trans_begin();
  1207. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$lb['scid'].'~'.$rk['Data'][0]['Code'],$cztime=>$time),$lb['id']);
  1208. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1209. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1210. if($cz == 2){
  1211. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1212. }
  1213. if ($this->db->trans_status() === TRUE)
  1214. {
  1215. $this->db->trans_commit();
  1216. if($nu['state'] == '216')
  1217. {
  1218. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1219. }
  1220. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1221. //标记订单已经取消
  1222. $this->_doCheckCancelFlag($lb['id']);
  1223. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1224. }
  1225. else
  1226. {
  1227. if($lb['is_jiaji'] == 2){
  1228. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1229. }else{
  1230. echo json_encode(array('music'=>'1','success'=>true));exit;
  1231. }
  1232. }
  1233. }
  1234. else
  1235. {
  1236. $this->db->trans_rollback();
  1237. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1238. }
  1239. }
  1240. else
  1241. {
  1242. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1243. }
  1244. }
  1245. else
  1246. {
  1247. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1248. }
  1249. }
  1250. }
  1251. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1252. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1253. {
  1254. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1255. }
  1256. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']);
  1257. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1258. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1259. if($cz == 2){
  1260. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1261. }
  1262. if ($this->db->trans_status() === TRUE)
  1263. {
  1264. $this->db->trans_commit();
  1265. if($nu['state'] == '216')
  1266. {
  1267. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1268. }
  1269. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1270. //标记订单已经取消
  1271. $this->_doCheckCancelFlag($lb['id']);
  1272. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1273. }
  1274. else
  1275. {
  1276. if($lb['is_jiaji'] == 2){
  1277. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1278. }else{
  1279. echo json_encode(array('music'=>'1','success'=>true));exit;
  1280. }
  1281. }
  1282. }
  1283. else
  1284. {
  1285. $this->db->trans_rollback();
  1286. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1287. }
  1288. }
  1289. }
  1290. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1291. private function _doCheckCancelFlag($fid){
  1292. $info = $this->systemtransfer->read($fid);
  1293. if($info['status'] != 11){
  1294. $this->systemtransfer->save(['status'=>11],$fid);
  1295. }
  1296. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1297. if(empty($list)){
  1298. return;
  1299. }
  1300. $is_cancel = false;
  1301. foreach($list as $val){
  1302. if($val['orver_flag'] == 3){
  1303. $is_cancel = true;
  1304. }
  1305. }
  1306. if($is_cancel){
  1307. return ;
  1308. }
  1309. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1310. }
  1311. //检测是否可以取消长期未流转
  1312. private function _doCancelWlz($fid){
  1313. //$info = $this->systemtransfer->read($fid);
  1314. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1315. if(empty($list)){
  1316. return;
  1317. }
  1318. $id = $list[0]['id'];
  1319. $scan_time = $list[0]['time'];
  1320. if($list[0]['type'] == 2){
  1321. if(time() - $scan_time < 3600 * 24 * 3){
  1322. $this->systemtransfer_cr->save([
  1323. 'extra_status'=>0,
  1324. ],$id);
  1325. }else{
  1326. $this->systemtransfer_cr->save([
  1327. 'extra_status'=>3,
  1328. ],$id);
  1329. }
  1330. }
  1331. }
  1332. //检测是否超时 车间流转环节
  1333. private function _doCheckIsOverTime($fid,$transfer){
  1334. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1335. if(count($list) < 2){
  1336. return ;
  1337. }
  1338. if($list[0]['type'] != 2){
  1339. return;
  1340. }
  1341. if($list[1]['type'] != 1){
  1342. return;
  1343. }
  1344. if($list[1]['orver_flag'] == 2){
  1345. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1346. }else{
  1347. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1348. }
  1349. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1350. }
  1351. public function _bdbb()
  1352. {
  1353. $post = $this->input->post(NULL, TRUE);
  1354. if(isset($post['s']))
  1355. {
  1356. $id_arr = $this->input->post('s');
  1357. $id_arr = explode(',',trim($id_arr,','));
  1358. if(!$id_arr)
  1359. {
  1360. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1361. }
  1362. //循环删除记录
  1363. foreach ($id_arr as $v)
  1364. {
  1365. $t = $this->systemtransfer->read($v);
  1366. if(!isset($t['number']))
  1367. {
  1368. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1369. }
  1370. $y = $this->fullorder->get_number($t['number']);
  1371. if(!$y)
  1372. {
  1373. $y = $this->fullordersmt->get_number($t['number']);
  1374. if(!$y)
  1375. {
  1376. $y = $this->fullordertt->get_number($t['number']);
  1377. if(!$y)
  1378. {
  1379. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1380. }
  1381. }
  1382. }
  1383. $time = time();
  1384. $label = $time.rand(10000,99999); //substr($time,1)*100
  1385. $this->systemtransfer->save(array('label'=>$label),$v);
  1386. $express = $this->express->read($y['express']);
  1387. $rows[] = array('num'=>$label,'number'=>$t['number'],'shipremarks'=>$t['shipremarks'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$t['printtime']),'gtime'=>date('YmdH',time()),'s'=>'1/1','t'=>"补打");
  1388. }
  1389. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1390. }
  1391. }
  1392. public function _excel()
  1393. {
  1394. if(isset($_GET['fexcel']))
  1395. {
  1396. $tc = array();$zh = array();
  1397. $typeclass = $this->typeclass->find_all();
  1398. foreach ($typeclass as $v)
  1399. {
  1400. $tc[$v['id']] = $v;
  1401. }
  1402. $number = $this->input->get('number',true);
  1403. $color = $this->input->get('color',true);
  1404. $gs = $this->input->get('gs',true);
  1405. $transfer = $this->input->get('transfer',true);
  1406. $type = $this->input->get('type',true);
  1407. $timetk = $this->input->get('timetk',true);
  1408. $timetj = $this->input->get('timetj',true);
  1409. $purchase = $this->input->get('purchase',true);
  1410. $lx = $this->input->get('lx',true);
  1411. $timetk = strtotime($timetk);
  1412. $timetj = strtotime($timetj);
  1413. $where = "1=1";
  1414. $cr = "time > '$timetk' and time < '$timetj'";
  1415. if($number)
  1416. {
  1417. $where .= " and number = '$number'";
  1418. }
  1419. if($transfer)
  1420. {
  1421. $cr .= " and lx = '".$transfer."'";
  1422. }
  1423. if($type)
  1424. {
  1425. //$cr .= " and type = '".$type."'";
  1426. if($type == 3){
  1427. $cr .= " and is_over = 0 ";
  1428. }else{
  1429. $cr .= " and type = '".$type."' ";
  1430. }
  1431. }
  1432. if($purchase)
  1433. {
  1434. $where .= " and purchase = '$purchase'";
  1435. }
  1436. if($color)
  1437. {
  1438. $where .= " and fpdata like '%-".$color."-%'";
  1439. }
  1440. if($lx)
  1441. {
  1442. if($lx == 1)
  1443. {
  1444. $where .= " and ordernumber = ''";
  1445. }
  1446. else
  1447. {
  1448. $where .= " and ordernumber != ''";
  1449. }
  1450. }
  1451. $fid = '';
  1452. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1453. foreach ($info_list_cr as $v)
  1454. {
  1455. $fid .= "id = '".$v['fid']."' or ";
  1456. }
  1457. if($fid)
  1458. {
  1459. $where .= ' and ('.trim($fid,'or ').')';
  1460. }
  1461. else
  1462. {
  1463. $where .= ' and id = 0';
  1464. }
  1465. $data = array();
  1466. $datafy = array();
  1467. $j = 0;
  1468. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1469. $lzbm = $this->transfer->find_all();
  1470. foreach ($info_list as $key=>$value)
  1471. {
  1472. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1473. $d = $this->systemtransfer->read($value['id']);
  1474. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1475. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1476. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1477. $cp = explode('-',trim($d['features'],'-'));
  1478. $rk = explode('|',trim($d['rk'],'|'));
  1479. $rktime = explode('|',trim($d['rktime'],'|'));
  1480. foreach ($cp as $v)
  1481. {
  1482. if(isset($tc[$v]))
  1483. {
  1484. if($tc[$v]['classid'] == 13)
  1485. {
  1486. $dj = $tc[$v]['title'];
  1487. }
  1488. else if($tc[$v]['classid'] == 8)
  1489. {
  1490. $ys = $tc[$v]['title'];
  1491. }
  1492. else if($tc[$v]['classid'] == 14)
  1493. {
  1494. $cc = $tc[$v]['title'];
  1495. }
  1496. else if($tc[$v]['classid'] == 15)
  1497. {
  1498. $hx = $tc[$v]['title'];
  1499. }
  1500. else if($tc[$v]['classid'] == 10)
  1501. {
  1502. $md = $tc[$v]['title'];
  1503. }
  1504. }
  1505. }
  1506. $rt = array();
  1507. foreach ($rk as $k=>$v)
  1508. {
  1509. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1510. }
  1511. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1512. foreach ($lzbm as $v)
  1513. {
  1514. if(isset($rt[count($fpdata[0])]))
  1515. {
  1516. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1517. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1518. if($num > 0){
  1519. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1520. }else{
  1521. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1522. }
  1523. }
  1524. else
  1525. {
  1526. $fpdata[0][count($fpdata[0])] = '';
  1527. }
  1528. }
  1529. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1530. unset($info_list[$key]['id']);
  1531. }
  1532. //echo "<pre>";print_r($info_list);exit;
  1533. $lzxq = '';
  1534. foreach ($lzbm as $v)
  1535. {
  1536. $lzxq .= '<td>'.$v['title'].'</td>';
  1537. }
  1538. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1539. $titlename = "<table border=1>
  1540. <tr>
  1541. <td>订单编号</td>
  1542. <td>品名</td>
  1543. <td>简码</td>
  1544. <td>备注</td>
  1545. <td>打印时间</td>
  1546. <td>
  1547. <table border=1>
  1548. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1549. <tr>
  1550. <td>产品名称</td>
  1551. <td>尺寸</td>
  1552. <td>等级</td>
  1553. <td>颜色</td>
  1554. <td>花型</td>
  1555. <td>密度</td>
  1556. ".$lzxq."
  1557. </tr>
  1558. </table>
  1559. </td>
  1560. </tr>
  1561. </table>";
  1562. $filename = $title.".xls";
  1563. $tail = "\n";
  1564. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1565. }
  1566. }
  1567. public function _rk()
  1568. {
  1569. $post = $this->input->post(NULL, TRUE);
  1570. if(isset($post['page']))
  1571. {
  1572. $api = $this->input->post('api',true);
  1573. $page = $this->input->post('page',true);
  1574. $perpage = $this->input->post('perpage',true);
  1575. $number = $this->input->post('number',true);
  1576. $color = $this->input->post('color',true);
  1577. $purchase = $this->input->post('purchase',true);
  1578. $transfer = $this->input->post('transfer',true);
  1579. $lx = $this->input->post('lx',true);
  1580. $timetk = $this->input->post('timetk',true);
  1581. $timetj = $this->input->post('timetj',true);
  1582. $timetk = strtotime($timetk);
  1583. $timetj = strtotime($timetj);
  1584. $where = "1=1";
  1585. if($transfer)
  1586. {
  1587. $ctime = 'ctime'.$transfer;
  1588. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1589. }
  1590. else
  1591. {
  1592. $where .= " and time > '$timetk' and time < '$timetj'";
  1593. }
  1594. if($number)
  1595. {
  1596. $where .= " and number = '$number'";
  1597. }
  1598. if($transfer)
  1599. {
  1600. $where .= " and rk like '%|".$transfer."|%'";
  1601. }
  1602. if($purchase)
  1603. {
  1604. $where .= " and purchase = '$purchase'";
  1605. }
  1606. if($color)
  1607. {
  1608. $where .= " and fpdata like '%-".$color."-%'";
  1609. }
  1610. if($lx)
  1611. {
  1612. if($lx == 1)
  1613. {
  1614. $where .= " and ordernumber = ''";
  1615. }
  1616. else
  1617. {
  1618. $where .= " and ordernumber != ''";
  1619. }
  1620. }
  1621. //数据排序
  1622. $order_str = "id desc";
  1623. if(empty($page))
  1624. {
  1625. $start = 0;
  1626. $perpage = 1;
  1627. }
  1628. else
  1629. {
  1630. $start = ($page - 1)*$perpage;
  1631. }
  1632. //取得信息列表
  1633. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1634. $transfer = $this->transfer->find_all();
  1635. $t = array();
  1636. foreach ($transfer as $v)
  1637. {
  1638. $t[$v['id']] = $v['title'];
  1639. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1640. }
  1641. //格式化数据
  1642. foreach ($info_list as $key=>$value)
  1643. {
  1644. $dd = $this->systemtransfer->read($value['id']);
  1645. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1646. $rk = explode('|',trim($dd['rk'],'|'));
  1647. $rktime = explode('|',trim($dd['rktime'],'|'));
  1648. $ck = explode('|',trim($dd['ck'],'|'));
  1649. $cktime = explode('|',trim($dd['cktime'],'|'));
  1650. $info_list[$key]['time'] = '';
  1651. for($i=0;$i<count($rk);$i++)
  1652. {
  1653. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1654. {
  1655. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1656. }
  1657. else
  1658. {
  1659. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1660. }
  1661. $info_list[$key]['time'] .= $d;
  1662. if(isset($ck[$i]) && $ck[$i] != '')
  1663. {
  1664. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1665. }
  1666. }
  1667. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1668. }
  1669. $total = $this->systemtransfer->find_count($where);
  1670. $pagenum = ceil($total/$perpage);
  1671. $over = $total-($start+$perpage);
  1672. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1673. echo json_encode($rows);exit;
  1674. }
  1675. if(isset($_SESSION['api']))
  1676. {
  1677. $user = $this->user->get_api($_SESSION['api']);
  1678. $usp = $user;
  1679. $pid = "";$tid="";$sid="";$wid="";
  1680. $purchase = explode('|',trim($user['purchase'],'|'));
  1681. $transfer = explode('|',trim($user['transfer'],'|'));
  1682. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1683. foreach ($purchase as $value)
  1684. {
  1685. $pid .= " id = ".$value." or";
  1686. }
  1687. foreach ($transfer as $value)
  1688. {
  1689. $tid .= " id = ".$value." or";
  1690. }
  1691. foreach ($warehouse as $value)
  1692. {
  1693. $wid .= " id = ".$value." or";
  1694. }
  1695. }
  1696. else
  1697. {
  1698. header('Location: /');exit;
  1699. }
  1700. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1701. $this->data['transfer'] = $transfer;
  1702. $this->_Template('transfer_rk',$this->data);
  1703. }
  1704. public function _ck()
  1705. {
  1706. $post = $this->input->post(NULL, TRUE);
  1707. if(isset($post['page']))
  1708. {
  1709. $api = $this->input->post('api',true);
  1710. $page = $this->input->post('page',true);
  1711. $perpage = $this->input->post('perpage',true);
  1712. $number = $this->input->post('number',true);
  1713. $color = $this->input->post('color',true);
  1714. $purchase = $this->input->post('purchase',true);
  1715. $transfer = $this->input->post('transfer',true);
  1716. $lx = $this->input->post('lx',true);
  1717. $timetk = $this->input->post('timetk',true);
  1718. $timetj = $this->input->post('timetj',true);
  1719. $timetk = strtotime($timetk);
  1720. $timetj = strtotime($timetj);
  1721. $where = "1=1";
  1722. if($transfer)
  1723. {
  1724. $ctime = 'ctime'.$transfer;
  1725. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1726. }
  1727. else
  1728. {
  1729. $where .= " and time > '$timetk' and time < '$timetj'";
  1730. }
  1731. if($number)
  1732. {
  1733. $where .= " and number = '$number'";
  1734. }
  1735. if($transfer)
  1736. {
  1737. $where .= " and ck like '%|".$transfer."|%'";
  1738. }
  1739. if($purchase)
  1740. {
  1741. $where .= " and purchase = '$purchase'";
  1742. }
  1743. if($color)
  1744. {
  1745. $where .= " and fpdata like '%-".$color."-%'";
  1746. }
  1747. if($lx)
  1748. {
  1749. if($lx == 1)
  1750. {
  1751. $where .= " and ordernumber = ''";
  1752. }
  1753. else
  1754. {
  1755. $where .= " and ordernumber != ''";
  1756. }
  1757. }
  1758. //数据排序
  1759. $order_str = "id desc";
  1760. if(empty($page))
  1761. {
  1762. $start = 0;
  1763. $perpage = 1;
  1764. }
  1765. else
  1766. {
  1767. $start = ($page - 1)*$perpage;
  1768. }
  1769. //取得信息列表
  1770. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1771. $transfer = $this->transfer->find_all();
  1772. $t = array();
  1773. foreach ($transfer as $v)
  1774. {
  1775. $t[$v['id']] = $v['title'];
  1776. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1777. }
  1778. //格式化数据
  1779. foreach ($info_list as $key=>$value)
  1780. {
  1781. $dd = $this->systemtransfer->read($value['id']);
  1782. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1783. $rk = explode('|',trim($dd['rk'],'|'));
  1784. $rktime = explode('|',trim($dd['rktime'],'|'));
  1785. $ck = explode('|',trim($dd['ck'],'|'));
  1786. $cktime = explode('|',trim($dd['cktime'],'|'));
  1787. $info_list[$key]['time'] = '';
  1788. for($i=0;$i<count($rk);$i++)
  1789. {
  1790. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1791. {
  1792. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1793. }
  1794. else
  1795. {
  1796. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1797. }
  1798. $info_list[$key]['time'] .= $d;
  1799. if(isset($ck[$i]) && $ck[$i] != '')
  1800. {
  1801. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1802. }
  1803. }
  1804. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1805. }
  1806. $total = $this->systemtransfer->find_count($where);
  1807. $pagenum = ceil($total/$perpage);
  1808. $over = $total-($start+$perpage);
  1809. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1810. echo json_encode($rows);exit;
  1811. }
  1812. if(isset($_SESSION['api']))
  1813. {
  1814. $user = $this->user->get_api($_SESSION['api']);
  1815. $usp = $user;
  1816. $pid = "";$tid="";$sid="";$wid="";
  1817. $purchase = explode('|',trim($user['purchase'],'|'));
  1818. $transfer = explode('|',trim($user['transfer'],'|'));
  1819. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1820. foreach ($purchase as $value)
  1821. {
  1822. $pid .= " id = ".$value." or";
  1823. }
  1824. foreach ($transfer as $value)
  1825. {
  1826. $tid .= " id = ".$value." or";
  1827. }
  1828. foreach ($warehouse as $value)
  1829. {
  1830. $wid .= " id = ".$value." or";
  1831. }
  1832. }
  1833. else
  1834. {
  1835. header('Location: /');exit;
  1836. }
  1837. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1838. $this->data['transfer'] = $transfer;
  1839. $this->_Template('transfer_ck',$this->data);
  1840. }
  1841. public function _jgl()
  1842. {
  1843. $post = $this->input->post(NULL, TRUE);
  1844. if(isset($post['printtime']))
  1845. {
  1846. $pt = $this->input->post('printtime',true);
  1847. $wt = $this->input->post('wgtime',true);
  1848. $printtime = strtotime($pt);
  1849. $wgtime = strtotime($wt);
  1850. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1851. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1852. if($printtime == $wgtime || $printtime > $wgtime)
  1853. {
  1854. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1855. }
  1856. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>".(($wgtime-$printtime)/86400)."天 完工数量:".$wg.", 总数量:".$sy.", 完工率:".number_format(($wg/$sy*100),2)."%</p>",'success'=>true));exit;
  1857. }
  1858. $this->_Template('transfer_wgl',$this->data);
  1859. }
  1860. public function _linqi(){
  1861. $post = $this->input->post(NULL, TRUE);
  1862. if(isset($post['page']))
  1863. {
  1864. $api = $this->input->post('api',true);
  1865. $page = $this->input->post('page',true);
  1866. $perpage = $this->input->post('perpage',true);
  1867. $transfer = $this->input->post('transfer',true);
  1868. $transfer_ids = $this->input->post('transfer_ids',true);
  1869. $orver_flag = $this->input->post('orver_flag',true);
  1870. $timetk = $this->input->post('timetk',true);
  1871. $timetj = $this->input->post('timetj',true);
  1872. $timetk = strtotime($timetk);
  1873. $timetj = strtotime($timetj);
  1874. $transfer_list = $this->transfer->find_all();
  1875. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1876. $t[0] = "";
  1877. $where = 'type = 1 ';
  1878. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1879. //数据排序
  1880. $order_str = "id desc";
  1881. if(empty($page))
  1882. {
  1883. $start = 0;
  1884. $perpage = 1;
  1885. }
  1886. else
  1887. {
  1888. $start = ($page - 1)*$perpage;
  1889. }
  1890. if($transfer){
  1891. $where .= " and lx = '$transfer'";
  1892. }else{
  1893. $where .= " and lx in (".$transfer_ids.") ";
  1894. }
  1895. $where .= " and time > '$timetk' and time < '$timetj'";
  1896. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1897. $final_list = [];
  1898. foreach ($list as $key => $value) {
  1899. $info = $this->systemtransfer->read($value['fid']);
  1900. $final_list[$key]['id'] = $value['id'];
  1901. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1902. if($info['is_jiaji'] == 2){
  1903. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1904. }else{
  1905. $final_list[$key]['is_jiaji'] = "常规";
  1906. }
  1907. $final_list[$key]['pm'] = $info['pm'];
  1908. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1909. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1910. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1911. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1912. foreach ($data as $k=>$v)
  1913. {
  1914. $type = ($v['type']==1)?'入库':'出库';
  1915. if($v['orver_flag'] == 1){
  1916. if($v['is_over'] == 0){
  1917. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  1918. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1919. }else{
  1920. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1921. }
  1922. }elseif($v['orver_flag'] == 2){
  1923. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  1924. }else{
  1925. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1926. }
  1927. }
  1928. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1929. }
  1930. $total = $this->systemtransfer_cr->find_count($where);
  1931. $pagenum = ceil($total/$perpage);
  1932. $over = $total-($start+$perpage);
  1933. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1934. echo json_encode($rows);exit;
  1935. }
  1936. if(isset($_SESSION['api']))
  1937. {
  1938. $user = $this->user->get_api($_SESSION['api']);
  1939. $usp = $user;
  1940. $pid = "";$tid="";$sid="";$wid="";
  1941. $purchase = explode('|',trim($user['purchase'],'|'));
  1942. $transfer = explode('|',trim($user['transfer'],'|'));
  1943. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1944. foreach ($purchase as $value)
  1945. {
  1946. $pid .= " id = ".$value." or";
  1947. }
  1948. foreach ($transfer as $value)
  1949. {
  1950. $tid .= " id = ".$value." or";
  1951. }
  1952. foreach ($warehouse as $value)
  1953. {
  1954. $wid .= " id = ".$value." or";
  1955. }
  1956. }
  1957. else
  1958. {
  1959. header('Location: /');exit;
  1960. }
  1961. $kx = '';$zjtab = '';
  1962. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1963. $this->data['transfer'] = $transfer;
  1964. $transfer_ids = array_column($transfer, 'id');
  1965. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1966. $this->data['vip'] = $user['vip'];
  1967. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1968. $this->_Template('transfer_linqi',$this->data);
  1969. }
  1970. //按照条件导出超时车间
  1971. public function _overtime_export(){
  1972. $transfer_id = $this->input->get('transfer', TRUE);
  1973. $timetk = $this->input->get('timetk', TRUE);
  1974. $timetj = $this->input->get('timetj', TRUE);
  1975. $timetk = strtotime($timetk);
  1976. $timetj = strtotime($timetj);
  1977. if(isset($_SESSION['api']))
  1978. {
  1979. $user = $this->user->get_api($_SESSION['api']);
  1980. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1981. $tmp_transfer_list = $this->transfer->find_all();
  1982. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1983. }
  1984. else
  1985. {
  1986. header('Location: /');exit;
  1987. }
  1988. $where = " orver_flag = 2 and type = 1";
  1989. if(empty($transfer_id)){
  1990. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1991. }else{
  1992. $where .= " and lx = ".$transfer_id." ";
  1993. }
  1994. $where .= " and time > '$timetk' and time < '$timetj'";
  1995. $list = $this->systemtransfer_cr->find_all($where,'*');
  1996. $fid_list = array_column($list, 'fid');
  1997. if(empty($fid_list)){
  1998. echo "没有数据" ;
  1999. die ;
  2000. }
  2001. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  2002. $where_two = " orver_flag = 2 and type = 2";
  2003. if(empty($transfer_id)){
  2004. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  2005. }else{
  2006. $where_two .= " and lx = ".$transfer_id." ";
  2007. }
  2008. $where_two .= " and time > '$timetk' and time < '$timetj'";
  2009. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  2010. $final_list = [];
  2011. // foreach($list as $k => $v){
  2012. // $final_list[$v['fid']]['fid'] = $v['fid'];
  2013. // $final_list[$v['fid']]['lx'] = $v['lx'];
  2014. // $final_list[$v['fid']]['start_type'] = $v['type'];
  2015. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  2016. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  2017. // $final_list[$v['fid']]['end_time'] = "";
  2018. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  2019. // }
  2020. // foreach($order_list as $k=>$v){
  2021. // if(isset($final_list[$v['id']])){
  2022. // $final_list[$v['id']]['number'] = $v['number'];
  2023. // $final_list[$v['id']]['pm'] = $v['pm'];
  2024. // }
  2025. // }
  2026. // foreach($list_two as $k => $v){
  2027. // if(isset($final_list[$v['fid']])){
  2028. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  2029. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2030. // }
  2031. // }
  2032. // }
  2033. foreach($list as $k => $v){
  2034. $final_list[] = [
  2035. 'fid' => $v['fid'],
  2036. 'lx' => $v['lx'],
  2037. 'start_type' => $v['type'],
  2038. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  2039. 'condition' => json_decode($v['limit_time_str'],true),
  2040. 'end_time' => "",
  2041. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  2042. ];
  2043. }
  2044. foreach($order_list as $k=>$v){
  2045. foreach($final_list as $kk => $vv){
  2046. if($v['id'] == $vv['fid']){
  2047. $final_list[$kk]['number'] = $v['number'];
  2048. $final_list[$kk]['pm'] = $v['pm'];
  2049. }
  2050. }
  2051. }
  2052. foreach($list_two as $k => $v){
  2053. foreach($final_list as $kk => $vv){
  2054. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  2055. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2056. }
  2057. }
  2058. }
  2059. $filename = date("Y-m-d")."超时单导出.xls";
  2060. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2061. <head>
  2062. <!--[if gte mso 9]><xml>
  2063. <x:ExcelWorkbook>
  2064. <x:ExcelWorksheets>
  2065. <x:ExcelWorksheet>
  2066. <x:Name>EXCEL</x:Name>
  2067. <x:WorksheetOptions>
  2068. <x:Print>
  2069. <x:ValidPrinterInfo />
  2070. </x:Print>
  2071. </x:WorksheetOptions>
  2072. </x:ExcelWorksheet>
  2073. </x:ExcelWorksheets>
  2074. </x:ExcelWorkbook>
  2075. </xml>
  2076. <![endif]-->
  2077. </head><body>";
  2078. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2079. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  2080. foreach ($final_list as $key=>$value)
  2081. {
  2082. if(empty($value['number'])){
  2083. continue;
  2084. }
  2085. $str .= "<tr>";
  2086. $str .= "<td>". $value['number']. "</td>";
  2087. $str .= "<td>". $value['pm']. "</td>";
  2088. $str .= "<td>". $value['lx_name']. "</td>";
  2089. $str .= "<td>". $value['start_time']. "</td>";
  2090. $str .= "<td>". $value['end_time']. "</td>";
  2091. $str .= "</tr>";
  2092. }
  2093. $str .= "</table></body></html>";
  2094. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2095. header( "Content-type: application/octet-stream" );
  2096. header( "Content-Disposition: attachment; filename=".$filename );
  2097. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2098. header( "Pragma: no-cache" );
  2099. header( "Expires: 0" );
  2100. exit($str);
  2101. }
  2102. public function _jiaji(){
  2103. $post = $this->input->post(NULL, TRUE);
  2104. if(isset($post['page']))
  2105. {
  2106. $api = $this->input->post('api',true);
  2107. $page = $this->input->post('page',true);
  2108. $perpage = $this->input->post('perpage',true);
  2109. $transfer = $this->input->post('transfer',true);
  2110. $transfer_ids = $this->input->post('transfer_ids',true);
  2111. $orver_flag = $this->input->post('orver_flag',true);
  2112. $timetk = $this->input->post('timetk',true);
  2113. $timetj = $this->input->post('timetj',true);
  2114. $timetk = strtotime($timetk);
  2115. $timetj = strtotime($timetj);
  2116. $transfer_list = $this->transfer->find_all();
  2117. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2118. if(isset($_SESSION['api']))
  2119. {
  2120. $user = $this->user->get_api($_SESSION['api']);
  2121. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  2122. }
  2123. else
  2124. {
  2125. $transfer_ids = array_keys($t);
  2126. }
  2127. if(empty($page))
  2128. {
  2129. $start = 0;
  2130. $perpage = 1;
  2131. }
  2132. else
  2133. {
  2134. $start = ($page - 1)*$perpage;
  2135. }
  2136. $sql_r = "select s.* from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".$timetk ." and c.time < ".$timetj." ";
  2137. if($transfer){
  2138. $sql_r .= " and c.lx = ".$transfer." ";
  2139. }else{
  2140. foreach($transfer_ids as $k=>$v){
  2141. if($v == 11){
  2142. unset($transfer_ids[$k]);
  2143. }
  2144. }
  2145. $transfer_str = implode(",",$transfer_ids);
  2146. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2147. }
  2148. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2149. $rows_r = $this->db->query($sql_r);
  2150. $get_list = $rows_r->result_array();
  2151. $total = count($get_list);
  2152. $split_list = array_chunk($get_list,$perpage);
  2153. $pagenum = ceil(count($split_list));
  2154. $key = $page - 1;
  2155. $list = isset($split_list[$key])?$split_list[$key]:[];
  2156. $final_list = [];
  2157. foreach ($list as $key => $value) {
  2158. $final_list[$key]['id'] = $value['id'];
  2159. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2160. if($value['is_jiaji'] == 2){
  2161. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2162. }else{
  2163. $final_list[$key]['is_jiaji'] = "常规";
  2164. }
  2165. $final_list[$key]['pm'] = $value['pm'];
  2166. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2167. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2168. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2169. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2170. foreach ($data as $k=>$v)
  2171. {
  2172. $type = ($v['type']==1)?'入库':'出库';
  2173. if($v['orver_flag'] == 1){
  2174. if($v['is_over'] == 0){
  2175. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  2176. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2177. }else{
  2178. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2179. }
  2180. }elseif($v['orver_flag'] == 2){
  2181. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  2182. }else{
  2183. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2184. }
  2185. }
  2186. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2187. }
  2188. $over = $total-($start+$perpage);
  2189. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2190. echo json_encode($rows);exit;
  2191. }
  2192. if(isset($_SESSION['api']))
  2193. {
  2194. $user = $this->user->get_api($_SESSION['api']);
  2195. $usp = $user;
  2196. $pid = "";$tid="";$sid="";$wid="";
  2197. $purchase = explode('|',trim($user['purchase'],'|'));
  2198. $transfer = explode('|',trim($user['transfer'],'|'));
  2199. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2200. foreach ($purchase as $value)
  2201. {
  2202. $pid .= " id = ".$value." or";
  2203. }
  2204. foreach ($transfer as $value)
  2205. {
  2206. if($value){
  2207. if($value != 11){
  2208. $tid .= " id = ".$value." or";
  2209. }
  2210. }
  2211. }
  2212. foreach ($warehouse as $value)
  2213. {
  2214. $wid .= " id = ".$value." or";
  2215. }
  2216. }
  2217. else
  2218. {
  2219. header('Location: /');exit;
  2220. }
  2221. $kx = '';$zjtab = '';
  2222. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2223. $this->data['transfer'] = $transfer;
  2224. $transfer_ids = array_column($transfer, 'id');
  2225. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2226. $this->data['vip'] = $user['vip'];
  2227. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2228. $this->_Template('transfer_jiaji',$this->data);
  2229. }
  2230. public function _scz(){
  2231. $post = $this->input->post(NULL, TRUE);
  2232. if(isset($post['page']))
  2233. {
  2234. $page = $this->input->post('page',true);
  2235. $perpage = $this->input->post('perpage',true);
  2236. $transfer = $this->input->post('transfer',true);
  2237. $transfer_ids = $this->input->post('transfer_ids',true);
  2238. $timetk = $this->input->post('timetk',true);
  2239. $timetj = $this->input->post('timetj',true);
  2240. $timetk = strtotime($timetk);
  2241. $timetj = strtotime($timetj);
  2242. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2243. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2244. // $transfer_ids = array_keys($t);
  2245. if(empty($page))
  2246. {
  2247. $start = 0;
  2248. $perpage = 1;
  2249. }
  2250. else
  2251. {
  2252. $start = ($page - 1)*$perpage;
  2253. }
  2254. $where = "time > '$timetk' and time < '$timetj'";
  2255. $where .= " and rk not like '%11|' ";
  2256. if(!empty($transfer)){
  2257. $where .= " and rk like '%|".$transfer."|%' ";
  2258. }
  2259. // if($transfer)
  2260. // {
  2261. // $cr .= " and lx = '".$transfer."' ";
  2262. // }else{
  2263. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2264. // }
  2265. // $cr .= " and is_over = 0 ";
  2266. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2267. // $fid = [];
  2268. // foreach ($info_list_cr as $v)
  2269. // {
  2270. // $fid[] = $v['fid'];
  2271. // }
  2272. // if(empty($fid)){
  2273. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2274. // echo json_encode($rows);exit;
  2275. // }
  2276. // $fid = array_unique($fid);
  2277. $order_str = "id desc";
  2278. //取得信息列表
  2279. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2280. $transfer = $this->transfer->find_all();
  2281. $t = array();
  2282. foreach ($transfer as $v)
  2283. {
  2284. $t[$v['id']] = $v['title'];
  2285. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2286. }
  2287. //格式化数据
  2288. foreach ($info_list as $key=>$value)
  2289. {
  2290. if($value['is_jiaji'] == 2){
  2291. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2292. }else{
  2293. $info_list[$key]['is_jiaji'] = "常规";
  2294. }
  2295. $dd = $this->systemtransfer->read($value['id']);
  2296. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2297. $rk = explode('|',trim($dd['rk'],'|'));
  2298. $rktime = explode('|',trim($dd['rktime'],'|'));
  2299. $ck = explode('|',trim($dd['ck'],'|'));
  2300. $cktime = explode('|',trim($dd['cktime'],'|'));
  2301. $info_list[$key]['time'] = '';
  2302. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2303. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2304. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2305. foreach ($data as $k=>$v)
  2306. {
  2307. // $type = ($v['type']==1)?'入库':'出库';
  2308. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2309. $type = ($v['type']==1)?'入库':'出库';
  2310. if($v['orver_flag'] == 1){
  2311. if($v['is_over'] == 0){
  2312. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>".'<br>';
  2313. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2314. }else{
  2315. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2316. }
  2317. }elseif($v['orver_flag'] == 2){
  2318. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>".'<br>';
  2319. }elseif($v['orver_flag'] == 3){
  2320. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>".'<br>';
  2321. }else{
  2322. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2323. }
  2324. }
  2325. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2326. unset($info_list[$key]['ctime12']);
  2327. }
  2328. $total = $this->systemtransfer->find_count($where);
  2329. $pagenum = ceil($total/$perpage);
  2330. $over = $total-($start+$perpage);
  2331. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2332. echo json_encode($rows);exit;
  2333. }
  2334. if(isset($_SESSION['api']))
  2335. {
  2336. $user = $this->user->get_api($_SESSION['api']);
  2337. if(!in_array($user['id'],[10,44,50])){
  2338. exit('No direct script access allowed');
  2339. }
  2340. }
  2341. else
  2342. {
  2343. header('Location: /');exit;
  2344. }
  2345. $kx = '';$zjtab = '';
  2346. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2347. $this->data['transfer'] = $transfer;
  2348. $transfer_ids = array_column($transfer, 'id');
  2349. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2350. $this->_Template('transfer_scz',$this->data);
  2351. }
  2352. public function _sczexcel(){
  2353. $timetk = $this->input->get('timetk',true);
  2354. $timetj = $this->input->get('timetj',true);
  2355. $timetk = strtotime($timetk);
  2356. $timetj = strtotime($timetj);
  2357. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2358. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2359. // $transfer_ids = array_keys($t);
  2360. $where = "time > '$timetk' and time < '$timetj'";
  2361. $where .= " and rk not like '%11|' ";
  2362. if(!empty($transfer)){
  2363. $where .= " and rk like '%|".$transfer."|%' ";
  2364. }
  2365. $order_str = "id desc";
  2366. //取得信息列表
  2367. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2368. $transfer = $this->transfer->find_all();
  2369. $t = array();
  2370. foreach ($transfer as $v)
  2371. {
  2372. $t[$v['id']] = $v['title'];
  2373. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2374. }
  2375. //格式化数据
  2376. foreach ($info_list as $key=>$value)
  2377. {
  2378. if($value['is_jiaji'] == 2){
  2379. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2380. }else{
  2381. $info_list[$key]['is_jiaji'] = "常规";
  2382. }
  2383. $dd = $this->systemtransfer->read($value['id']);
  2384. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2385. $rk = explode('|',trim($dd['rk'],'|'));
  2386. $rktime = explode('|',trim($dd['rktime'],'|'));
  2387. $ck = explode('|',trim($dd['ck'],'|'));
  2388. $cktime = explode('|',trim($dd['cktime'],'|'));
  2389. $info_list[$key]['time'] = '';
  2390. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2391. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2392. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2393. foreach ($data as $k=>$v)
  2394. {
  2395. // $type = ($v['type']==1)?'入库':'出库';
  2396. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2397. $type = ($v['type']==1)?'入库':'出库';
  2398. if($v['orver_flag'] == 1){
  2399. if($v['is_over'] == 0){
  2400. $info_list[$key]['time'] .= "<span style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></span>".'<br>';
  2401. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2402. }else{
  2403. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2404. }
  2405. }elseif($v['orver_flag'] == 2){
  2406. $info_list[$key]['time'] .= "<span style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></span>".'<br>';
  2407. }elseif($v['orver_flag'] == 3){
  2408. $info_list[$key]['time'] .= "<span style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></span>".'<br>';
  2409. }else{
  2410. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2411. }
  2412. }
  2413. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2414. unset($info_list[$key]['ctime12']);
  2415. }
  2416. $filename = date("Y-m-d")."生产中订单.xls";
  2417. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2418. <head>
  2419. <!--[if gte mso 9]><xml>
  2420. <x:ExcelWorkbook>
  2421. <x:ExcelWorksheets>
  2422. <x:ExcelWorksheet>
  2423. <x:Name>EXCEL</x:Name>
  2424. <x:WorksheetOptions>
  2425. <x:Print>
  2426. <x:ValidPrinterInfo />
  2427. </x:Print>
  2428. </x:WorksheetOptions>
  2429. </x:ExcelWorksheet>
  2430. </x:ExcelWorksheets>
  2431. </x:ExcelWorkbook>
  2432. </xml>
  2433. <![endif]-->
  2434. </head><body>";
  2435. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2436. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2437. foreach ($info_list as $key=>$value)
  2438. {
  2439. $str .= "<tr>";
  2440. $str .= "<td>". $value['number']. "</td>";
  2441. $str .= "<td>". $value['is_jiaji']. "</td>";
  2442. $str .= "<td>". $value['pm']. "</td>";
  2443. $str .= "<td>". $value['shipremarks']. "</td>";
  2444. $str .= "<td>". $value['printtime']. "</td>";
  2445. $str .= "<td>". $value['time']. "</td>";
  2446. $str .= "</tr>";
  2447. }
  2448. $str .= "</table></body></html>";
  2449. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2450. header( "Content-type: application/octet-stream" );
  2451. header( "Content-Disposition: attachment; filename=".$filename );
  2452. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2453. header( "Pragma: no-cache" );
  2454. header( "Expires: 0" );
  2455. exit($str);
  2456. }
  2457. public function _wjsrk(){
  2458. $post = $this->input->post(NULL, TRUE);
  2459. if(isset($post['page']))
  2460. {
  2461. $api = $this->input->post('api',true);
  2462. $page = $this->input->post('page',true);
  2463. $perpage = $this->input->post('perpage',true);
  2464. $transfer = $this->input->post('transfer',true);
  2465. $transfer_ids = $this->input->post('transfer_ids',true);
  2466. $orver_flag = $this->input->post('orver_flag',true);
  2467. $timetk = $this->input->post('timetk',true);
  2468. $timetj = $this->input->post('timetj',true);
  2469. $timetk = strtotime($timetk);
  2470. $timetj = strtotime($timetj);
  2471. $transfer_list = $this->transfer->find_all();
  2472. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2473. $where = 'extra_status in (1,2) ';
  2474. //数据排序
  2475. $order_str = "id desc";
  2476. if(empty($page))
  2477. {
  2478. $start = 0;
  2479. $perpage = 1;
  2480. }
  2481. else
  2482. {
  2483. $start = ($page - 1)*$perpage;
  2484. }
  2485. if($transfer){
  2486. $where .= " and lx = '$transfer'";
  2487. }else{
  2488. $where .= " and lx in (".$transfer_ids.") ";
  2489. }
  2490. $where .= " and time > '$timetk' and time < '$timetj'";
  2491. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2492. $final_list = [];
  2493. foreach ($list as $key => $value) {
  2494. $info = $this->systemtransfer->read($value['fid']);
  2495. $final_list[$key]['id'] = $value['id'];
  2496. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2497. if($info['is_jiaji'] == 2){
  2498. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2499. }else{
  2500. $final_list[$key]['is_jiaji'] = "常规";
  2501. }
  2502. $final_list[$key]['pm'] = $info['pm'];
  2503. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2504. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2505. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2506. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2507. foreach ($data as $k=>$v)
  2508. {
  2509. $type = ($v['type']==1)?'入库':'出库';
  2510. if($v['orver_flag'] == 1){
  2511. if($v['is_over'] == 0){
  2512. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2513. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2514. }else{
  2515. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2516. }
  2517. }elseif($v['orver_flag'] == 2){
  2518. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2519. }else{
  2520. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2521. }
  2522. if($v['extra_status'] == 1){
  2523. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2524. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2525. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2526. }else{
  2527. $info_list[$key]['time'] .= "<br>";
  2528. }
  2529. }
  2530. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2531. }
  2532. $total = $this->systemtransfer_cr->find_count($where);
  2533. $pagenum = ceil($total/$perpage);
  2534. $over = $total-($start+$perpage);
  2535. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2536. echo json_encode($rows);exit;
  2537. }
  2538. if(isset($_SESSION['api']))
  2539. {
  2540. $user = $this->user->get_api($_SESSION['api']);
  2541. $usp = $user;
  2542. $pid = "";$tid="";$sid="";$wid="";
  2543. $purchase = explode('|',trim($user['purchase'],'|'));
  2544. $transfer = explode('|',trim($user['transfer'],'|'));
  2545. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2546. foreach ($purchase as $value)
  2547. {
  2548. $pid .= " id = ".$value." or";
  2549. }
  2550. foreach ($transfer as $value)
  2551. {
  2552. $tid .= " id = ".$value." or";
  2553. }
  2554. foreach ($warehouse as $value)
  2555. {
  2556. $wid .= " id = ".$value." or";
  2557. }
  2558. }
  2559. else
  2560. {
  2561. header('Location: /');exit;
  2562. }
  2563. $kx = '';$zjtab = '';
  2564. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2565. $this->data['transfer'] = $transfer;
  2566. $transfer_ids = array_column($transfer, 'id');
  2567. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2568. $this->data['vip'] = $user['vip'];
  2569. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2570. $this->_Template('transfer_wjsrk',$this->data);
  2571. }
  2572. public function _wjsrkexcel(){
  2573. $api = $this->input->get('api',true);
  2574. $transfer = $this->input->get('transfer',true);
  2575. $timetk = $this->input->get('timetk',true);
  2576. $timetj = $this->input->get('timetj',true);
  2577. $timetk = strtotime($timetk);
  2578. $timetj = strtotime($timetj);
  2579. $transfer_list = $this->transfer->find_all();
  2580. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2581. $where = 'extra_status in (1,2) ';
  2582. //数据排序
  2583. $order_str = "id desc";
  2584. if($transfer){
  2585. $where .= " and lx = '$transfer'";
  2586. }else{
  2587. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2588. $transfer_ids = array_column($transfer, 'id');
  2589. $transfer_ids = implode(",",$transfer_ids);
  2590. $where .= " and lx in (".$transfer_ids.") ";
  2591. }
  2592. $where .= " and time > '$timetk' and time < '$timetj'";
  2593. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2594. $final_list = [];
  2595. foreach ($list as $key => $value) {
  2596. $info = $this->systemtransfer->read($value['fid']);
  2597. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2598. $final_list[$key]['pm'] = $info['pm'];
  2599. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2600. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2601. }
  2602. $filename = date("Y-m-d")."超期未流转单导出.xls";
  2603. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2604. <head>
  2605. <!--[if gte mso 9]><xml>
  2606. <x:ExcelWorkbook>
  2607. <x:ExcelWorksheets>
  2608. <x:ExcelWorksheet>
  2609. <x:Name>EXCEL</x:Name>
  2610. <x:WorksheetOptions>
  2611. <x:Print>
  2612. <x:ValidPrinterInfo />
  2613. </x:Print>
  2614. </x:WorksheetOptions>
  2615. </x:ExcelWorksheet>
  2616. </x:ExcelWorksheets>
  2617. </x:ExcelWorkbook>
  2618. </xml>
  2619. <![endif]-->
  2620. </head><body>";
  2621. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2622. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2623. foreach ($final_list as $key=>$value)
  2624. {
  2625. if(empty($value['number'])){
  2626. continue;
  2627. }
  2628. $str .= "<tr>";
  2629. $str .= "<td>". $value['number']. "</td>";
  2630. $str .= "<td>". $value['pm']. "</td>";
  2631. $str .= "<td>". $value['lx_name']. "</td>";
  2632. $str .= "<td>". $value['time']. "</td>";
  2633. $str .= "</tr>";
  2634. }
  2635. $str .= "</table></body></html>";
  2636. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2637. header( "Content-type: application/octet-stream" );
  2638. header( "Content-Disposition: attachment; filename=".$filename );
  2639. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2640. header( "Pragma: no-cache" );
  2641. header( "Expires: 0" );
  2642. exit($str);
  2643. }
  2644. public function _cqrk(){
  2645. $post = $this->input->post(NULL, TRUE);
  2646. if(isset($post['page']))
  2647. {
  2648. $api = $this->input->post('api',true);
  2649. $page = $this->input->post('page',true);
  2650. $perpage = $this->input->post('perpage',true);
  2651. $transfer = $this->input->post('transfer',true);
  2652. $transfer_ids = $this->input->post('transfer_ids',true);
  2653. $orver_flag = $this->input->post('orver_flag',true);
  2654. $timetk = $this->input->post('timetk',true);
  2655. $timetj = $this->input->post('timetj',true);
  2656. $timetk = strtotime($timetk);
  2657. $timetj = strtotime($timetj);
  2658. $transfer_list = $this->transfer->find_all();
  2659. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2660. $where = 'extra_status in (2,3) ';
  2661. //数据排序
  2662. $order_str = "id desc";
  2663. if(empty($page))
  2664. {
  2665. $start = 0;
  2666. $perpage = 1;
  2667. }
  2668. else
  2669. {
  2670. $start = ($page - 1)*$perpage;
  2671. }
  2672. if($transfer){
  2673. $where .= " and lx = '$transfer'";
  2674. }else{
  2675. $where .= " and lx in (".$transfer_ids.") ";
  2676. }
  2677. $where .= " and time > '$timetk' and time < '$timetj'";
  2678. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2679. $final_list = [];
  2680. foreach ($list as $key => $value) {
  2681. $info = $this->systemtransfer->read($value['fid']);
  2682. $final_list[$key]['id'] = $value['id'];
  2683. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2684. if($info['is_jiaji'] == 2){
  2685. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2686. }else{
  2687. $final_list[$key]['is_jiaji'] = "常规";
  2688. }
  2689. $final_list[$key]['pm'] = $info['pm'];
  2690. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2691. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2692. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2693. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2694. foreach ($data as $k=>$v)
  2695. {
  2696. $type = ($v['type']==1)?'入库':'出库';
  2697. if($v['orver_flag'] == 1){
  2698. if($v['is_over'] == 0){
  2699. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2700. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2701. }else{
  2702. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2703. }
  2704. }elseif($v['orver_flag'] == 2){
  2705. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2706. }else{
  2707. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2708. }
  2709. if($v['extra_status'] == 1){
  2710. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2711. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2712. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2713. }else{
  2714. $info_list[$key]['time'] .= "<br>";
  2715. }
  2716. }
  2717. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2718. }
  2719. $total = $this->systemtransfer_cr->find_count($where);
  2720. $pagenum = ceil($total/$perpage);
  2721. $over = $total-($start+$perpage);
  2722. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2723. echo json_encode($rows);exit;
  2724. }
  2725. if(isset($_SESSION['api']))
  2726. {
  2727. $user = $this->user->get_api($_SESSION['api']);
  2728. $usp = $user;
  2729. $pid = "";$tid="";$sid="";$wid="";
  2730. $purchase = explode('|',trim($user['purchase'],'|'));
  2731. $transfer = explode('|',trim($user['transfer'],'|'));
  2732. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2733. foreach ($purchase as $value)
  2734. {
  2735. $pid .= " id = ".$value." or";
  2736. }
  2737. foreach ($transfer as $value)
  2738. {
  2739. $tid .= " id = ".$value." or";
  2740. }
  2741. foreach ($warehouse as $value)
  2742. {
  2743. $wid .= " id = ".$value." or";
  2744. }
  2745. }
  2746. else
  2747. {
  2748. header('Location: /');exit;
  2749. }
  2750. $kx = '';$zjtab = '';
  2751. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2752. $this->data['transfer'] = $transfer;
  2753. $transfer_ids = array_column($transfer, 'id');
  2754. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2755. $this->data['vip'] = $user['vip'];
  2756. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2757. $this->_Template('transfer_cqrk',$this->data);
  2758. }
  2759. public function _cqrkexcel(){
  2760. $api = $this->input->get('api',true);
  2761. $transfer = $this->input->get('transfer',true);
  2762. $timetk = $this->input->get('timetk',true);
  2763. $timetj = $this->input->get('timetj',true);
  2764. $timetk = strtotime($timetk);
  2765. $timetj = strtotime($timetj);
  2766. $transfer_list = $this->transfer->find_all();
  2767. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2768. $where = 'extra_status in (2,3) ';
  2769. //数据排序
  2770. $order_str = "id desc";
  2771. if($transfer){
  2772. $where .= " and lx = '$transfer'";
  2773. }else{
  2774. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2775. $transfer_ids = array_column($transfer, 'id');
  2776. $transfer_ids = implode(",",$transfer_ids);
  2777. $where .= " and lx in (".$transfer_ids.") ";
  2778. }
  2779. $where .= " and time > '$timetk' and time < '$timetj'";
  2780. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2781. $final_list = [];
  2782. foreach ($list as $key => $value) {
  2783. $info = $this->systemtransfer->read($value['fid']);
  2784. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2785. $final_list[$key]['pm'] = $info['pm'];
  2786. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2787. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2788. }
  2789. $filename = date("Y-m-d")."超期3天未流转单导出.xls";
  2790. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2791. <head>
  2792. <!--[if gte mso 9]><xml>
  2793. <x:ExcelWorkbook>
  2794. <x:ExcelWorksheets>
  2795. <x:ExcelWorksheet>
  2796. <x:Name>EXCEL</x:Name>
  2797. <x:WorksheetOptions>
  2798. <x:Print>
  2799. <x:ValidPrinterInfo />
  2800. </x:Print>
  2801. </x:WorksheetOptions>
  2802. </x:ExcelWorksheet>
  2803. </x:ExcelWorksheets>
  2804. </x:ExcelWorkbook>
  2805. </xml>
  2806. <![endif]-->
  2807. </head><body>";
  2808. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2809. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2810. foreach ($final_list as $key=>$value)
  2811. {
  2812. if(empty($value['number'])){
  2813. continue;
  2814. }
  2815. $str .= "<tr>";
  2816. $str .= "<td>". $value['number']. "</td>";
  2817. $str .= "<td>". $value['pm']. "</td>";
  2818. $str .= "<td>". $value['lx_name']. "</td>";
  2819. $str .= "<td>". $value['time']. "</td>";
  2820. $str .= "</tr>";
  2821. }
  2822. $str .= "</table></body></html>";
  2823. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2824. header( "Content-type: application/octet-stream" );
  2825. header( "Content-Disposition: attachment; filename=".$filename );
  2826. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2827. header( "Pragma: no-cache" );
  2828. header( "Expires: 0" );
  2829. exit($str);
  2830. }
  2831. /**
  2832. * 导出excel 操作部门是否出库
  2833. */
  2834. public function _czbmIsOutExcel(){
  2835. if($this->input->method() == 'get'){
  2836. $number = $this->input->get('number',true);
  2837. $color = $this->input->get('color',true);
  2838. $purchase = $this->input->get('purchase',true);
  2839. $transfer = $this->input->get('transfer',true);
  2840. $lx = $this->input->get('lx',true);
  2841. $type = $this->input->get('type',true);
  2842. $pm = $this->input->get('pm',true);
  2843. $jiaji = $this->input->get('jiaji',true);
  2844. $timetk = $this->input->get('timetk',true);
  2845. $timetj = $this->input->get('timetj',true);
  2846. $timetk = strtotime($timetk);
  2847. $timetj = strtotime($timetj);
  2848. $where = '1=1';
  2849. if($number)
  2850. {
  2851. $where .= " and number = '$number'";
  2852. }
  2853. if($pm){
  2854. $where .= " and pm like '%".$pm."%'";
  2855. }
  2856. if($purchase)
  2857. {
  2858. $where .= " and purchase = '$purchase'";
  2859. }
  2860. if($color)
  2861. {
  2862. $where .= " and fpdata like '%-".$color."-%'";
  2863. }
  2864. if($lx)
  2865. {
  2866. if($lx == 1)
  2867. {
  2868. $where .= " and ordernumber = ''";
  2869. }
  2870. else
  2871. {
  2872. $where .= " and ordernumber != ''";
  2873. }
  2874. }
  2875. if($jiaji){
  2876. if($jiaji == 1){
  2877. $where .= " and is_jiaji = 0";
  2878. }
  2879. if($jiaji == 2){
  2880. $where .= " and is_jiaji = 2";
  2881. }
  2882. }
  2883. //数据排序
  2884. $order_str = "id desc";
  2885. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  2886. if($type)
  2887. {
  2888. if($type == 3){
  2889. if($transfer)
  2890. {
  2891. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  2892. }
  2893. }else{
  2894. $type = ($type==1)?'rk':'ck';
  2895. if($transfer)
  2896. {
  2897. $where .= " and $type like '%|".$transfer."|%'";
  2898. }
  2899. }
  2900. }
  2901. else
  2902. {
  2903. if($transfer)
  2904. {
  2905. $where .= " and rk like '%|".$transfer."|%'";
  2906. }
  2907. }
  2908. //取得信息列表
  2909. $info_list = $this->systemtransfer->find_all($where,'*',$order_str);
  2910. $transfer = $this->transfer->find_all();
  2911. $t = array();
  2912. foreach ($transfer as $v)
  2913. {
  2914. $t[$v['id']] = $v['title'];
  2915. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2916. }
  2917. $final_list = [];
  2918. //格式化数据
  2919. foreach ($info_list as $key=>$value)
  2920. {
  2921. $transfer_list = $this->_get_transfer_data($value,$t);
  2922. $final_list[] = [
  2923. 'number'=>$value['number'],
  2924. 'pm'=>$value['pm'],
  2925. 'transfer_list'=>$transfer_list,
  2926. ];
  2927. }
  2928. $filename = date("Y-m-d")."操作部门库存是否存在.xls";
  2929. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2930. <head>
  2931. <!--[if gte mso 9]><xml>
  2932. <x:ExcelWorkbook>
  2933. <x:ExcelWorksheets>
  2934. <x:ExcelWorksheet>
  2935. <x:Name>EXCEL</x:Name>
  2936. <x:WorksheetOptions>
  2937. <x:Print>
  2938. <x:ValidPrinterInfo />
  2939. </x:Print>
  2940. </x:WorksheetOptions>
  2941. </x:ExcelWorksheet>
  2942. </x:ExcelWorksheets>
  2943. </x:ExcelWorkbook>
  2944. </xml>
  2945. <![endif]-->
  2946. </head><body>";
  2947. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2948. $str .= "<tr><td>订单编号</td><td>品名</td><td>操作部门</td><td>扫入日期</td><td>扫出日期</td><td>是否出库</td></tr>";
  2949. foreach ($final_list as $key=>$value)
  2950. {
  2951. if(empty($value['number'])){
  2952. continue;
  2953. }
  2954. $str .= "<tr>";
  2955. $str .= "<td>". $value['number']. "</td>";
  2956. $str .= "<td>". $value['pm']. "</td>";
  2957. $tmp_czbm = '';
  2958. $tmp_srrq = '';
  2959. $tmp_scrq = '';
  2960. $tmp_is_out = '';
  2961. foreach ($value['transfer_list'] as $k=>$v)
  2962. {
  2963. $tmp_czbm .= $v['lx_show'].'<br/>';
  2964. $tmp_srrq .= empty($v['rk_time'])?'无<br/>': date('Y-m-d H:i:s',$v['rk_time']).'<br/>';
  2965. $tmp_scrq .= empty($v['ck_time'])?'无<br/>': date('Y-m-d H:i:s',$v['ck_time']).'<br/>';
  2966. if($v['is_over'] == 2){
  2967. $tmp_is_out .= '是<br/>';
  2968. }elseif($v['is_over'] == 1){
  2969. $tmp_is_out .= '否<br/>';
  2970. }else{
  2971. $tmp_is_out .= '异常<br/>';
  2972. }
  2973. }
  2974. $tmp_czbm = trim($tmp_czbm,'<br/>');
  2975. $tmp_srrq = trim($tmp_srrq,'<br/>');
  2976. $tmp_scrq = trim($tmp_scrq,'<br/>');
  2977. $tmp_is_out = trim($tmp_is_out,'<br/>');
  2978. $str .= "<td>". $tmp_czbm. "</td>";
  2979. $str .= "<td>". $tmp_srrq. "</td>";
  2980. $str .= "<td>". $tmp_scrq. "</td>";
  2981. $str .= "<td>". $tmp_is_out. "</td>";
  2982. $str .= "</tr>";
  2983. }
  2984. $str .= "</table></body></html>";
  2985. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2986. header( "Content-type: application/octet-stream" );
  2987. header( "Content-Disposition: attachment; filename=".$filename );
  2988. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2989. header( "Pragma: no-cache" );
  2990. header( "Expires: 0" );
  2991. exit($str);
  2992. }
  2993. }
  2994. public function _get_transfer_data($info,$t){
  2995. $rk_list = explode('|',trim($info['rk'],'|'));
  2996. $rk_time = explode('|',trim($info['rktime'],'|'));
  2997. $ck_list = explode('|',trim($info['ck'],'|'));
  2998. $ck_time = explode('|',trim($info['cktime'],'|'));
  2999. if(count($rk_time) < count($ck_time)){
  3000. return [
  3001. 'code'=>-1,
  3002. 'msg'=>'数据异常,('.$info['id'].')联系技术',
  3003. ];
  3004. }
  3005. $tran_list = [];
  3006. $len = count($rk_list);
  3007. $ck_index = 0;
  3008. for($i = 0;$i < $len;$i++){
  3009. if(isset($rk_list[$i]) && empty($ck_list[$ck_index]) ){
  3010. $tran_list[] = [
  3011. 'lx'=>$rk_list[$i],
  3012. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3013. 'rk_time'=>$rk_time[$i],
  3014. 'ck_time'=>'',
  3015. 'is_over'=>1,//未出库
  3016. ];
  3017. }else{
  3018. if($rk_list[$i] == $ck_list[$ck_index]){
  3019. $tran_list[] = [
  3020. 'lx'=>$rk_list[$i],
  3021. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3022. 'rk_time'=>$rk_time[$i],
  3023. 'ck_time'=>$ck_time[$ck_index],
  3024. 'is_over'=>2,//已出库
  3025. ];
  3026. $ck_index++;
  3027. }else if($rk_list[$i] != $ck_list[$ck_index]){
  3028. if($rk_list[$i] == $ck_list[$ck_index-1]){
  3029. //估计是之前完成 或者 成品库 强制扫入
  3030. $tran_list[] = [
  3031. 'lx'=>$rk_list[$i],
  3032. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3033. 'rk_time'=>$rk_time[$i],
  3034. 'ck_time'=>$ck_time[$ck_index-1],
  3035. 'is_over'=>2,//已出库
  3036. ];
  3037. }else if( !empty($ck_list[$ck_index+1]) &&($rk_list[$i] == $ck_list[$ck_index+1])){
  3038. //估计是完成 或者 成品库 强制扫出了
  3039. $tran_list[] = [
  3040. 'lx'=>$rk_list[$i],
  3041. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3042. 'rk_time'=>$rk_time[$i],
  3043. 'ck_time'=>$ck_time[$ck_index+1],
  3044. 'is_over'=>2,//已出库
  3045. ];
  3046. $ck_index++;
  3047. $ck_index++;
  3048. }else{
  3049. //估计是完成 或者 成品库 强制扫出了
  3050. $tran_list[] = [
  3051. 'lx'=>$rk_list[$i],
  3052. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3053. 'rk_time'=>$rk_time[$i],
  3054. 'ck_time'=>'',
  3055. 'is_over'=>-3,//已出库
  3056. ];
  3057. }
  3058. }
  3059. }
  3060. }
  3061. return $tran_list;
  3062. }
  3063. public function _ycrk(){
  3064. if($this->input->method() == 'get'){
  3065. echo json_encode(array('msg'=>'请求方式不正确','success'=>false));exit;
  3066. }
  3067. $id = $this->input->post('id',true);
  3068. $type = $this->input->post('type',true);
  3069. if(!in_array($type,[1,2,3])){
  3070. echo json_encode(array('msg'=>'入库类别异常,联系技术','success'=>false));exit;
  3071. }
  3072. $info = $this->systemtransfer->read($id);
  3073. if(empty($info)){
  3074. echo json_encode(array('msg'=>'数据不存在','success'=>false));exit;
  3075. }
  3076. if(!empty($info['ycrk_type'])){
  3077. echo json_encode(array('msg'=>'已添加异常入库,不要重复添加','success'=>false));exit;
  3078. }
  3079. //更新数据
  3080. $this->systemtransfer->save([
  3081. 'ycrk_type'=>$type,
  3082. ],$id);
  3083. $list = $this->systemtransfer_cr->find_all('fid = '.$id,'*','id desc');
  3084. foreach ($list as $key=>$value) {
  3085. $this->systemtransfer_cr->save([
  3086. 'ycrk_type'=>$type,
  3087. ],$value['id']);
  3088. }
  3089. $this->systemtransfer_cr->insert([
  3090. 'fid'=>$id,'lx'=>0,'type'=>$type,'time'=>time(),'is_over'=>0,'over_flag'=>0,
  3091. 'extra_status'=>0,'ycrk_type'=>$type,
  3092. ]);
  3093. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  3094. }
  3095. public function _ycrkindex(){
  3096. if($this->input->method() == 'get'){
  3097. if(isset($_SESSION['api']))
  3098. {
  3099. $user = $this->user->get_api($_SESSION['api']);
  3100. $usp = $user;
  3101. $pid = "";$tid="";$sid="";$wid="";
  3102. $purchase = explode('|',trim($user['purchase'],'|'));
  3103. $transfer = explode('|',trim($user['transfer'],'|'));
  3104. $warehouse = explode('|',trim($user['warehouse'],'|'));
  3105. foreach ($purchase as $value)
  3106. {
  3107. $pid .= " id = ".$value." or";
  3108. }
  3109. foreach ($transfer as $value)
  3110. {
  3111. $tid .= " id = ".$value." or";
  3112. }
  3113. foreach ($warehouse as $value)
  3114. {
  3115. $wid .= " id = ".$value." or";
  3116. }
  3117. }
  3118. else
  3119. {
  3120. header('Location: /');exit;
  3121. }
  3122. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  3123. $this->data['transfer'] = $transfer;
  3124. $transfer_ids = array_column($transfer, 'id');
  3125. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  3126. $this->_Template('transfer_ycrkindex',$this->data);
  3127. }else{
  3128. $page = $this->input->post('page',true);
  3129. $perpage = $this->input->post('perpage',true);
  3130. $transfer_ids = $this->input->post('transfer_ids',true);
  3131. $timetk = $this->input->post('timetk',true);
  3132. $timetj = $this->input->post('timetj',true);
  3133. $timetk = strtotime($timetk);
  3134. $timetj = strtotime($timetj);
  3135. $transfer_list = $this->transfer->find_all();
  3136. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  3137. $where = 'lx = 0 and ycrk_type != 0 ';
  3138. //数据排序
  3139. $order_str = "id desc";
  3140. if(empty($page))
  3141. {
  3142. $start = 0;
  3143. $perpage = 1;
  3144. }
  3145. else
  3146. {
  3147. $start = ($page - 1)*$perpage;
  3148. }
  3149. $where .= " and time > '$timetk' and time < '$timetj'";
  3150. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  3151. $final_list = [];
  3152. foreach ($list as $key => $value) {
  3153. $info = $this->systemtransfer->read($value['fid']);
  3154. $final_list[$key]['id'] = $value['id'];
  3155. $final_list[$key]['number'] = $info['number'];
  3156. $ycrk_type_str = "";
  3157. if($value['ycrk_type'] == 3){
  3158. $ycrk_type_str = "外销单入库";
  3159. }else if($value['ycrk_type'] == 2){
  3160. $ycrk_type_str = "成品库入库";
  3161. }else{
  3162. $ycrk_type_str = "配货入库";
  3163. }
  3164. $final_list[$key]['ycrk_type'] = $ycrk_type_str;
  3165. $final_list[$key]['pm'] = $info['pm'];
  3166. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  3167. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  3168. $final_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  3169. }
  3170. $total = $this->systemtransfer_cr->find_count($where);
  3171. $pagenum = ceil($total/$perpage);
  3172. $over = $total-($start+$perpage);
  3173. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  3174. echo json_encode($rows);exit;
  3175. }
  3176. }
  3177. }