Transfer.php 109 KB

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