Transfer.php 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446
  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. }
  23. //定义方法的调用规则 获取URI第二段值
  24. public function _remap($arg,$arg_array)
  25. {
  26. if($arg == 'add')
  27. {
  28. $this->_add();
  29. }
  30. else if($arg == 'edit')
  31. {
  32. $this->_edit($arg_array);
  33. }
  34. else if($arg == 'del')
  35. {
  36. $this->_del();
  37. }
  38. else if($arg == 'print')
  39. {
  40. $this->_print();
  41. }
  42. else if($arg == 'number')
  43. {
  44. $this->_number();
  45. }
  46. else if($arg == 'numberprint')
  47. {
  48. $this->_numberprint();
  49. }
  50. else if($arg == 'operate')
  51. {
  52. $this->_operate();
  53. }
  54. else if($arg == 'out')
  55. {
  56. $this->_out();
  57. }
  58. else if($arg == 'excel')
  59. {
  60. $this->_excel();
  61. }
  62. else if($arg == 'bdbb')
  63. {
  64. $this->_bdbb();
  65. }
  66. else if($arg == 'rk')
  67. {
  68. $this->_rk();
  69. }
  70. else if($arg == 'ck')
  71. {
  72. $this->_ck();
  73. }
  74. else if($arg == 'jgl')//交工率
  75. {
  76. $this->_jgl();
  77. }
  78. else if($arg == 'linqi')
  79. {
  80. $this->_linqi();
  81. }
  82. else if($arg == 'jiaji'){
  83. $this->_jiaji();
  84. }
  85. else if($arg == 'overtime_export'){
  86. $this->_overtime_export();
  87. }
  88. else if($arg == 'scz'){
  89. $this->_scz();
  90. }
  91. else if($arg == 'sczexcel'){
  92. $this->_sczexcel();
  93. }
  94. else
  95. {
  96. $this->_index();
  97. }
  98. }
  99. //管理
  100. public function _index()
  101. {
  102. $t = array();
  103. $typeclass = $this->typeclass->find_all();
  104. foreach ($typeclass as $v)
  105. {
  106. $t[$v['id']] = $v['title'];
  107. }
  108. $post = $this->input->post(NULL, TRUE);
  109. if(isset($post['page']))
  110. {
  111. $page = $this->input->post('page',true);
  112. $perpage = $this->input->post('perpage',true);
  113. $type = $this->input->post('type',true);
  114. $where = "1=1 ";
  115. //数据排序
  116. $order_str = "id asc";
  117. if($type)
  118. {
  119. $where .= "and type = '$type'";
  120. }
  121. if(empty($page))
  122. {
  123. $start = 0;
  124. $perpage = 1;
  125. }
  126. else
  127. {
  128. $start = ($page - 1)*$perpage;
  129. }
  130. //取得信息列表
  131. $info_list = $this->transfer->find_all($where,'id,title,orvertime,overtime_one,overtime_two',$order_str,$start,$perpage);
  132. $total = $this->transfer->find_count($where);
  133. $pagenum = ceil($total/$perpage);
  134. $over = $total-($start+$perpage);
  135. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  136. echo json_encode($rows);exit;
  137. }
  138. $this->_Template('transfer',$this->data);
  139. }
  140. //添加
  141. public function _add()
  142. {
  143. $post = $this->input->post(NULL, TRUE);
  144. if(isset($post['title']))
  145. {
  146. $title = $this->input->post('title',true);
  147. if($this->transfer->find_all("title = '$title'"))
  148. {
  149. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  150. }
  151. if($this->transfer->insert($post))
  152. {
  153. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  154. }
  155. else
  156. {
  157. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  158. }
  159. }
  160. $this->_Template('transfer_add',$this->data);
  161. }
  162. //修改
  163. public function _edit($arg_array)
  164. {
  165. $post = $this->input->post(NULL, TRUE);
  166. if(isset($post['id']))
  167. {
  168. $id = $this->input->post('id',true);
  169. $title = $this->input->post('title',true);
  170. if($this->transfer->find_all("title = '$title' and id != '".$id."'"))
  171. {
  172. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  173. }
  174. if($this->transfer->save($post,$id))
  175. {
  176. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  177. }
  178. else
  179. {
  180. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  181. }
  182. }
  183. $arg_array = $arg_array[0];
  184. $transfer = $this->transfer->read($arg_array);
  185. $this->data['transfer'] = $transfer;
  186. $this->_Template('transfer_edit',$this->data);
  187. }
  188. //删除
  189. public function _del()
  190. {
  191. $post = $this->input->post(NULL, TRUE);
  192. if(isset($post['s']))
  193. {
  194. $id_arr = $this->input->post('s');
  195. $id_arr = explode(',',$id_arr);
  196. if(!$id_arr)
  197. {
  198. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  199. }
  200. //循环删除记录
  201. foreach ($id_arr as $v)
  202. {
  203. $this->transfer->remove($v);
  204. }
  205. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  206. }
  207. }
  208. public function _print()
  209. {
  210. if(isset($_SESSION['api']))
  211. {
  212. $user = $this->user->get_api($_SESSION['api']);
  213. $usp = $user;
  214. $sid = "";$wid="";$wtype="";
  215. $userwh = explode('|',trim($user['warehouse'],'|'));
  216. foreach ($userwh as $value)
  217. {
  218. $wid .= " id = ".$value." or";
  219. $wtype .= " type = ".$value." or";
  220. }
  221. }
  222. $post = $this->input->post(NULL, TRUE);
  223. $classid = $this->classid->sku();
  224. $pm = $classid;
  225. $scsku = $classid;
  226. if(isset($post['category']))
  227. {
  228. $list = array();$num = "";$title = "";$features = "";
  229. $order = 0;
  230. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  231. $t = $this->input->post('t',true);//打印数量
  232. if($xbqnum > 99)
  233. {
  234. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  235. }
  236. if($xbqnum < 1)
  237. {
  238. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  239. }
  240. $post['purchase'] = $this->input->post('purchase',true);//所属工厂
  241. $category = $this->input->post('category',true);
  242. $list['category'] = $category;
  243. $list['hairtype'] = $this->input->post('hairtype',true);
  244. $list['grade'] = $this->input->post('grade',true);
  245. $size = $this->input->post('size',true);
  246. $xzsku = $this->input->post('xzsku',true);
  247. $list['size'] = rtrim($size,',');
  248. $list['hairnumber'] = $this->input->post('hairnumber',true);
  249. $list['extension'] = $this->input->post('extension',true);
  250. if($category == 1297)
  251. {
  252. $list['sywignumber'] = $this->input->post('sywignumber',true);
  253. }
  254. if($category == 1702)
  255. {
  256. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  257. $list['syother'] = $this->input->post('syother',true);
  258. }
  259. if($category == 133)
  260. {
  261. $list['fittype'] = $this->input->post('fittype',true);
  262. $list['acother'] = $this->input->post('acother',true);
  263. }
  264. $list['color'] = $this->input->post('color',true);
  265. $list['lowe'] = $this->input->post('lowe',true);
  266. if($category == 127)
  267. {
  268. $list['type'] = $this->input->post('type',true);
  269. $list['headroad'] = $this->input->post('headroad',true);
  270. $list['density'] = $this->input->post('density',true);
  271. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  272. {
  273. $list['lacesize'] = $this->input->post('lacesize',true);
  274. }
  275. $list['lacecolor'] = $this->input->post('lacecolor',true);
  276. $list['lacetypes'] = $this->input->post('lacetypes',true);
  277. }
  278. if($category == 128)
  279. {
  280. $list['lacetype'] = $this->input->post('lacetype',true);
  281. $list['haircap'] = $this->input->post('haircap',true);
  282. $list['density'] = $this->input->post('density',true);
  283. $list['lacecolor'] = $this->input->post('lacecolor',true);
  284. $list['lacetypes'] = $this->input->post('lacetypes',true);
  285. $list['wigother'] = $this->input->post('wigother',true);
  286. $list['wigother2'] = $this->input->post('wigother2',true);
  287. }
  288. if($category == 129)
  289. {
  290. $list['wide'] = $this->input->post('wide',true);
  291. }
  292. if($category == 131)
  293. {
  294. $list['gifttype'] = $this->input->post('gifttype',true);
  295. $list['giftother'] = $this->input->post('giftother',true);
  296. }
  297. if($category == 134)
  298. {
  299. $list['pieceweight'] = $this->input->post('pieceweight',true);
  300. }
  301. if($category == 1297)
  302. {
  303. $list['synthetictype'] = $this->input->post('synthetictype',true);
  304. $list['sywigother'] = $this->input->post('sywigother',true);
  305. }
  306. if($category == 130 || $category == 133 || $category == 1702)
  307. {
  308. $list['items'] = $this->input->post('items',true);
  309. }
  310. if($category == 1702)
  311. {
  312. $list['syhairther'] = $this->input->post('syhairther',true);
  313. }
  314. foreach($list as $k=>$v)
  315. {
  316. if($v != 0)
  317. {
  318. $num .=$v;
  319. $features .=$v.'-';
  320. $post[$k] = $v;
  321. $typeclass = $this->typeclass->read($v);
  322. if(isset($pm[$typeclass['classid']]))
  323. {
  324. $pm[$typeclass['classid']] = $typeclass['zh'];
  325. }
  326. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  327. if($k != 'size')
  328. {
  329. $title .= $typeclass['title']." ";
  330. }
  331. }
  332. }
  333. $typeclass = $this->typeclass->read($list['size']);
  334. $title .= $typeclass['title'];
  335. $time = time();
  336. $post['printtime'] = $time;
  337. $post['title'] = rtrim($title,' ');
  338. $post['number'] = $num;
  339. $post['features'] = '-'.$features;
  340. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  341. $featurespp = explode('-',trim($featurespp,'-'));
  342. if(isset($featurespp[5]))
  343. {
  344. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  345. }
  346. else
  347. {
  348. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  349. }
  350. $post['time'] = $time;//操作时间
  351. $scsku = implode("-",$scsku);
  352. $zh = implode(" ",$pm);
  353. $zh = str_replace('自然色 ','',trim($zh,' '));
  354. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  355. $post['shipremarks'] = $zh;
  356. $scsku = str_replace('- ','-',trim($scsku,'-'));
  357. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  358. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;
  359. $post['sku'] = $bqsku;
  360. $post['rk'] = "|1|";//默认配货 打印后直接入库
  361. $post['rktime'] = "|".$time."|";
  362. $rows = array();
  363. $this->db->trans_begin();
  364. for($i=0;$i<$xbqnum;$i++)
  365. {
  366. $label = substr($time,1)*100;
  367. $post['label'] = $label+$i;
  368. $rows[] = array('num'=>$post['label'],'number'=>'','shipremarks'=>$zh,'ex'=>'','t'=>$t,'time'=>'布标打印时间:'.date('Y-m-d H:i:s',$time),'s'=>'('.($i+1).'/'.$xbqnum.')');
  369. $this->systemtransfer->insert($post);
  370. }
  371. if ($this->db->trans_status() === TRUE)
  372. {
  373. $this->db->trans_commit();
  374. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  375. }
  376. else
  377. {
  378. $this->db->trans_rollback();
  379. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  380. }
  381. }
  382. $purchase = $this->purchase->find_all("yyid != ''");
  383. $this->data['purchase'] = $purchase;
  384. $this->_Template('transfer_print',$this->data);
  385. }
  386. public function _number()
  387. {
  388. if(isset($_SESSION['api']))
  389. {
  390. $user = $this->user->get_api($_SESSION['api']);
  391. $pid = "";$tid="";$sid="";$wid="";
  392. $purchase = explode('|',trim($user['purchase'],'|'));
  393. $transfer = explode('|',trim($user['transfer'],'|'));
  394. foreach ($purchase as $value)
  395. {
  396. $pid .= " id = ".$value." or";
  397. }
  398. foreach ($transfer as $value)
  399. {
  400. $tid .= " id = ".$value." or";
  401. }
  402. }
  403. else
  404. {
  405. header('Location: /');exit;
  406. }
  407. $post = $this->input->post(NULL, TRUE);
  408. if(isset($post['number']))
  409. {
  410. $number = $this->input->post('number',true);
  411. $type = $this->input->post('type',true);
  412. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  413. $purchase = $this->input->post('purchase',true);
  414. $f = 'fullorder';
  415. $y = $this->fullorder->get_number($number);
  416. if(!$y)
  417. {
  418. $f = 'fullordersmt';
  419. $y = $this->fullordersmt->get_number($number);
  420. if(!$y)
  421. {
  422. $f = 'fullordertt';
  423. $y = $this->fullordertt->get_number($number);
  424. if(!$y)
  425. {
  426. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  427. }
  428. }
  429. }
  430. if($y['librarytime'] > 0)
  431. {
  432. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  433. }
  434. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;$typeclass = array();
  435. $classid = $this->classid->sku();
  436. $tc = $this->typeclass->find_all();
  437. foreach($tc as $v)
  438. {
  439. $typeclass[$v['id']] = $v;
  440. }
  441. $bm = '03';
  442. $fpdata = explode(';',trim($y['fpdata'],';'));
  443. $whlabelsc = explode('|',trim($y['whlabel'],'|'));
  444. foreach($fpdata as $key=>$val)
  445. {
  446. $pm = $classid;
  447. $jm = $classid;
  448. $sku = $classid;
  449. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  450. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  451. $jvnr = explode('|',trim($features,'|'));
  452. if(stripos($jvnr[0],',') !== false)
  453. {
  454. $ft = explode(',',$jvnr[0]);
  455. $features = explode('-',trim($ft[1],'-'));
  456. array_splice($features,2,0,$ft[0]);
  457. }
  458. else
  459. {
  460. $features = explode('-',trim($jvnr[0],'-'));
  461. }
  462. $title = $jvnr[1];
  463. foreach($features as $k=>$v)
  464. {
  465. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  466. {
  467. if($typeclass[$v]['bm'] != '')
  468. {
  469. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  470. }
  471. }
  472. if($v != 0)
  473. {
  474. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  475. if(isset($pm[$typeclass[$v]['classid']]))
  476. {
  477. if($typeclass[$v]['title'] == '9A')
  478. {
  479. $pm[$typeclass[$v]['classid']] = '9A';
  480. }
  481. else if($typeclass[$v]['title'] == '10A')
  482. {
  483. $pm[$typeclass[$v]['classid']] = '10A';
  484. }
  485. else
  486. {
  487. $clzh = $typeclass[$v]['zh'];
  488. if(stripos($typeclass[$v]['zh'],'|') !== false)
  489. {
  490. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  491. $clzh = $clzh[0];
  492. }
  493. $pm[$typeclass[$v]['classid']] = $clzh;
  494. }
  495. }
  496. if(isset($jm[$typeclass[$v]['classid']]))
  497. {
  498. if($typeclass[$v]['jm'])
  499. {
  500. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  501. }
  502. }
  503. }
  504. }
  505. $jm = array_filter($jm);//去除空值
  506. $jm = implode("-",$jm);
  507. $sku = array_filter($sku);//去除空值
  508. $sku = implode("-",$sku);
  509. $pm = array_filter($pm);//去除空值
  510. $zh = implode(" ",$pm);
  511. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  512. $features = implode("-",$features);
  513. $cp[] = array('ordernumber'=>$number,'title'=>$title,'sku'=>$sku,'jm'=>$jm,'zh'=>$zh,'n'=>$jvnr[2],'b'=>$y['shipremarks'],'data'=>json_encode(array('ordernumber'=>$number,'features'=>$features,'number'=>$number,'title'=>$title,'jm'=>$jm,'sku'=>$sku,'pm'=>$zh,'bm'=>$bm.implode("",$bmpx))));
  514. }
  515. echo json_encode(array('rows'=>$cp,'success'=>true));exit;
  516. }
  517. $purchase = $this->purchase->find_all("yyid != ''");
  518. $this->data['purchase'] = $purchase;
  519. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  520. $this->data['transfer'] = $transfer;
  521. $this->_Template('transfer_number',$this->data);
  522. }
  523. public function _numberprint()
  524. {
  525. $time = time();
  526. $post = $this->input->post(NULL);
  527. $classid = $this->classid->sku();
  528. $pm = $classid;
  529. $scsku = $classid;
  530. if(isset($post['data']))
  531. {
  532. $data = json_decode($post['data'],true);
  533. $f = 'fullorder';
  534. $y = $this->fullorder->get_number($data['ordernumber']);
  535. if(!$y)
  536. {
  537. $f = 'fullordersmt';
  538. $y = $this->fullordersmt->get_number($data['ordernumber']);
  539. if(!$y)
  540. {
  541. $f = 'fullordertt';
  542. $y = $this->fullordertt->get_number($data['ordernumber']);
  543. if(!$y)
  544. {
  545. echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  546. }
  547. }
  548. }
  549. if($y['printtime'] == 0)
  550. {
  551. echo json_encode(array('msg'=>'此单已重置,请询问梦体','success'=>false));exit;
  552. }
  553. $order = 0;$time = time();
  554. $xbqnum = $this->input->post('n',true);//打印数量
  555. if($xbqnum > 99)
  556. {
  557. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  558. }
  559. if($xbqnum < 1)
  560. {
  561. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  562. }
  563. $transfer = $this->input->post('transfer',true);
  564. $post['type'] = $this->input->post('type',true);
  565. $post['shipremarks'] = $this->input->post('b',true);
  566. $post['ph'] = $this->input->post('ph',true);
  567. $is_jiaji = $this->input->post('is_jiaji',true);
  568. if($is_jiaji == 2){
  569. $post['is_jiaji'] = 2;
  570. }else{
  571. $post['is_jiaji'] = 0;
  572. }
  573. $zps = $this->input->post('zps',true);
  574. $post['purchase'] = $this->input->post('purchase',true);//供应商
  575. $post['time'] = $time;//操作时间
  576. $post['jm'] = $data['jm'];
  577. $post['bm'] = $data['bm'];
  578. $post['pm'] = $data['pm'];
  579. $post['features'] = $data['features'];
  580. $post['number'] = $data['number'];
  581. $post['title'] = $data['title'];
  582. $post['sku'] = $data['sku'];
  583. $post['printtime'] = $y['printtime'];
  584. $post['rk'] = "|12|";//默认订单中心 打印后直接入库
  585. $post['ck'] = "|12|";
  586. $post['rktime'] = "|".$time."|";
  587. $post['cktime'] = $post['rktime'];
  588. $post['ctime12'] = $time;
  589. $express = $this->express->read($y['express']);
  590. $rows = array();$t='';
  591. $this->db->trans_begin();
  592. $post['xbqnum'] = $xbqnum;
  593. $kh = $this->shop->read($y['shop']);
  594. $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']);
  595. if($yy['c'] == 0)
  596. {
  597. $post['scapi'] = '99';
  598. $post['scid'] = $yy['scid'];
  599. if(!$post['purchase'])
  600. {
  601. $post['purchase'] = '';
  602. }
  603. $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'");
  604. //able_ext 实在打印小单布标时判断是否可以打印备货单
  605. $able_ext = 0;
  606. $tmp_fetaures = explode('-',$data['features']);
  607. //只有头套和马尾才会要配货单
  608. if(in_array(128, $tmp_fetaures)){
  609. $able_ext = 1;
  610. }
  611. if(in_array(133, $tmp_fetaures)){
  612. if(in_array(673, $tmp_fetaures)){
  613. $able_ext = 1;
  614. }
  615. }
  616. for($i=0;$i<$xbqnum;$i++)
  617. {
  618. if($post['zps'])
  619. {
  620. if($post['zps'] > 0)
  621. {
  622. $t = '总量:'.($mqsl+$i+1).'/'.$zps;
  623. }
  624. }
  625. $label = substr($time,1)*100;
  626. $post['label'] = $label+$i;
  627. $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);
  628. $this->systemtransfer->insert($post);
  629. }
  630. }
  631. else
  632. {
  633. $this->db->trans_rollback();
  634. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  635. }
  636. if($this->db->trans_status() === TRUE)
  637. {
  638. $this->db->trans_commit();
  639. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  640. }
  641. else
  642. {
  643. $this->db->trans_rollback();
  644. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  645. }
  646. }
  647. }
  648. public function _operate()
  649. {
  650. $post = $this->input->post(NULL, TRUE);
  651. if(isset($post['page']))
  652. {
  653. $api = $this->input->post('api',true);
  654. $page = $this->input->post('page',true);
  655. $perpage = $this->input->post('perpage',true);
  656. $number = $this->input->post('number',true);
  657. $color = $this->input->post('color',true);
  658. $purchase = $this->input->post('purchase',true);
  659. $transfer = $this->input->post('transfer',true);
  660. $lx = $this->input->post('lx',true);
  661. $type = $this->input->post('type',true);
  662. $jiaji = $this->input->post('jiaji',true);
  663. $xztime = $this->input->post('xztime',true);
  664. $timetk = $this->input->post('timetk',true);
  665. $timetj = $this->input->post('timetj',true);
  666. $timetk = strtotime($timetk);
  667. $timetj = strtotime($timetj);
  668. $where = '1=1';
  669. if($number)
  670. {
  671. $where .= " and number = '$number'";
  672. }
  673. if($purchase)
  674. {
  675. $where .= " and purchase = '$purchase'";
  676. }
  677. if($color)
  678. {
  679. $where .= " and fpdata like '%-".$color."-%'";
  680. }
  681. if($lx)
  682. {
  683. if($lx == 1)
  684. {
  685. $where .= " and ordernumber = ''";
  686. }
  687. else
  688. {
  689. $where .= " and ordernumber != ''";
  690. }
  691. }
  692. if($jiaji){
  693. if($jiaji == 1){
  694. $where .= " and is_jiaji = 0";
  695. }
  696. if($jiaji == 2){
  697. $where .= " and is_jiaji = 2";
  698. }
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if(empty($page))
  703. {
  704. $start = 0;
  705. $perpage = 1;
  706. }
  707. else
  708. {
  709. $start = ($page - 1)*$perpage;
  710. }
  711. if($xztime == 'printtime')
  712. {
  713. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  714. if($type)
  715. {
  716. if($type == 3){
  717. if($transfer)
  718. {
  719. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  720. }
  721. }else{
  722. $type = ($type==1)?'rk':'ck';
  723. if($transfer)
  724. {
  725. $where .= " and $type like '%|".$transfer."|%'";
  726. }
  727. }
  728. }
  729. else
  730. {
  731. if($transfer)
  732. {
  733. $where .= " and rk like '%|".$transfer."|%'";
  734. }
  735. }
  736. }
  737. else
  738. {
  739. $cr = "time > '$timetk' and time < '$timetj'";
  740. if($transfer)
  741. {
  742. $cr .= " and lx = '".$transfer."' ";
  743. }
  744. if($type)
  745. {
  746. if($type == 3){
  747. $cr .= " and is_over = 0 ";
  748. }else{
  749. $cr .= " and type = '".$type."' ";
  750. }
  751. }
  752. $fid = '';
  753. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  754. foreach ($info_list_cr as $v)
  755. {
  756. $fid .= "id = '".$v['fid']."' or ";
  757. }
  758. if($fid)
  759. {
  760. $where .= ' and ('.trim($fid,'or ').')';
  761. }
  762. else
  763. {
  764. $where .= ' and id = 0';
  765. }
  766. }
  767. //取得信息列表
  768. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  769. $transfer = $this->transfer->find_all();
  770. $t = array();
  771. foreach ($transfer as $v)
  772. {
  773. $t[$v['id']] = $v['title'];
  774. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  775. }
  776. //格式化数据
  777. foreach ($info_list as $key=>$value)
  778. {
  779. if($value['is_jiaji'] == 2){
  780. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  781. }else{
  782. $info_list[$key]['is_jiaji'] = "常规";
  783. }
  784. $dd = $this->systemtransfer->read($value['id']);
  785. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  786. $rk = explode('|',trim($dd['rk'],'|'));
  787. $rktime = explode('|',trim($dd['rktime'],'|'));
  788. $ck = explode('|',trim($dd['ck'],'|'));
  789. $cktime = explode('|',trim($dd['cktime'],'|'));
  790. $info_list[$key]['time'] = '';
  791. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  792. /**
  793. for($i=0;$i<count($rk);$i++)
  794. {
  795. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  796. {
  797. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  798. }
  799. else
  800. {
  801. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  802. }
  803. $info_list[$key]['time'] .= $d;
  804. if(isset($ck[$i]) && $ck[$i] != '')
  805. {
  806. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  807. }
  808. }
  809. **/
  810. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  811. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  812. foreach ($data as $k=>$v)
  813. {
  814. // $type = ($v['type']==1)?'入库':'出库';
  815. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  816. $type = ($v['type']==1)?'入库':'出库';
  817. if($v['orver_flag'] == 1){
  818. if($v['is_over'] == 0){
  819. $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>';
  820. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  821. }else{
  822. $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>';
  823. }
  824. }elseif($v['orver_flag'] == 2){
  825. $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>';
  826. }elseif($v['orver_flag'] == 3){
  827. $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>';
  828. }else{
  829. $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>';
  830. }
  831. }
  832. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  833. unset($info_list[$key]['ctime12']);
  834. }
  835. $total = $this->systemtransfer->find_count($where);
  836. $pagenum = ceil($total/$perpage);
  837. $over = $total-($start+$perpage);
  838. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  839. echo json_encode($rows);exit;
  840. }
  841. if(isset($_SESSION['api']))
  842. {
  843. $user = $this->user->get_api($_SESSION['api']);
  844. $usp = $user;
  845. $pid = "";$tid="";$sid="";$wid="";
  846. $purchase = explode('|',trim($user['purchase'],'|'));
  847. $transfer = explode('|',trim($user['transfer'],'|'));
  848. $warehouse = explode('|',trim($user['warehouse'],'|'));
  849. foreach ($purchase as $value)
  850. {
  851. $pid .= " id = ".$value." or";
  852. }
  853. foreach ($transfer as $value)
  854. {
  855. $tid .= " id = ".$value." or";
  856. }
  857. foreach ($warehouse as $value)
  858. {
  859. $wid .= " id = ".$value." or";
  860. }
  861. }
  862. else
  863. {
  864. header('Location: /');exit;
  865. }
  866. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  867. //只有admin和toutao用户可以查看
  868. if(in_array($user['id'],[10,44,50])){
  869. $sc_flag = 1;
  870. }
  871. $this->data['sc_flag'] = $sc_flag;
  872. $kx = '';$zjtab = '';
  873. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  874. $this->data['warehouse'] = $warehouse;
  875. $purchase = $this->purchase->find_all("yyid != ''");
  876. $this->data['purchase'] = $purchase;
  877. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  878. $this->data['transfer'] = $transfer;
  879. $this->data['vip'] = $user['vip'];
  880. $transfer_ids = array_column($transfer,'id');
  881. $transfer_str = implode(",",$transfer_ids);
  882. $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.")");
  883. $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.")");
  884. //$jiaji_num = 0;
  885. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  886. foreach($transfer_ids as $k=>$v){
  887. if($v == 11){
  888. unset($transfer_ids[$k]);
  889. }
  890. }
  891. if(empty($transfer_ids)){
  892. $this->data['jiaji_num'] = -1;
  893. }else{
  894. $transfer_str = implode(",",$transfer_ids);
  895. $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|%'");
  896. // 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|%'");
  897. $tmp_list= $sql_r->result_array();
  898. $this->data['jiaji_num'] = count($tmp_list);
  899. }
  900. $this->_Template('transfer_operate',$this->data);
  901. }
  902. public function _out()
  903. {
  904. $post = $this->input->post(NULL, TRUE);
  905. if(isset($post['label']))
  906. {
  907. $time = time();
  908. $label = $this->input->post('label',true);
  909. $cz = $this->input->post('cz',true);
  910. $transfer = $this->input->post('transfer',true);
  911. if(!$label)
  912. {
  913. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  914. }
  915. if(!$transfer)
  916. {
  917. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  918. }
  919. $lb = $this->systemtransfer->get_label($label);
  920. if(!$lb)
  921. {
  922. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  923. }
  924. if($lb['number']!='')
  925. {
  926. $nu = $this->fullorder->get_number($lb['number']);
  927. if(!$nu)
  928. {
  929. $nu = $this->fullordersmt->get_number($lb['number']);
  930. if(!$nu)
  931. {
  932. $nu = $this->fullordertt->get_number($lb['number']);
  933. }
  934. }
  935. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  936. // if($nu['state'] == '214' || $nu['state'] == '217')
  937. // {
  938. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  939. // }
  940. }
  941. $tdata = $this->transfer->find_all();
  942. $t = array();
  943. foreach ($tdata as $v)
  944. {
  945. $t[$v['id']] = $v['title'];
  946. }
  947. /**
  948. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  949. {
  950. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  951. }
  952. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  953. {
  954. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  955. }
  956. **/
  957. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  958. // {
  959. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  960. // }
  961. //重新定义配货的原则问题
  962. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  963. $sku_arr = explode("-",$lb['features']);
  964. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  965. // 145 Full Lace Wig
  966. // 1170 HDFullLaceWig
  967. // 1249 FullLaceBobwithBang
  968. // 1484 FullLaceBob
  969. //如果是这4中全蕾丝那么配货就不处理
  970. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  971. }else{
  972. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  973. {
  974. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  975. }
  976. }
  977. }
  978. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  979. {
  980. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  981. }
  982. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  983. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  984. if($transfer != 3 && $transfer != 11 && $transfer != 2)
  985. {
  986. if($cz == 1)
  987. {
  988. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  989. {
  990. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  991. }
  992. }
  993. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  994. {
  995. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  996. }
  997. }
  998. if($cz == 1)
  999. {
  1000. $lb['rk'] .= $transfer.'|';
  1001. $lb['rktime'] .= $time.'|';
  1002. if($lbrk[0] == $transfer)
  1003. {
  1004. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1005. }
  1006. }
  1007. else if($cz == 2)
  1008. {
  1009. $lb['ck'] .= $transfer.'|';
  1010. $lb['cktime'] .= $time.'|';
  1011. if($lbck[0] == $transfer)
  1012. {
  1013. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1014. }
  1015. }
  1016. $cztime = 'ctime'.$transfer;
  1017. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1018. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1019. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1020. {
  1021. if($lb['type'] == 0)
  1022. {
  1023. $s = $this->shop->read($nu['shop']);
  1024. $lb['kh'] = $s['yyid'];
  1025. $lb['ts'] = 1;
  1026. $rk = $this->apiyy->_newrk($lb);
  1027. if($rk['c'] == 0)
  1028. {
  1029. $this->db->trans_begin();
  1030. $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']);
  1031. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1032. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1033. if($cz == 2){
  1034. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1035. }
  1036. if ($this->db->trans_status() === TRUE)
  1037. {
  1038. $this->db->trans_commit();
  1039. if($nu['state'] == '216')
  1040. {
  1041. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1042. }
  1043. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1044. //标记订单已经取消
  1045. $this->_doCheckCancelFlag($lb['id']);
  1046. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1047. }
  1048. else
  1049. {
  1050. if($lb['is_jiaji'] == 2){
  1051. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1052. }else{
  1053. echo json_encode(array('music'=>'1','success'=>true));exit;
  1054. }
  1055. }
  1056. }
  1057. else
  1058. {
  1059. $this->db->trans_rollback();
  1060. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1061. }
  1062. }
  1063. else
  1064. {
  1065. if(stripos($rk['error'],'DocNo') !== false)
  1066. {
  1067. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1068. }
  1069. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1070. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1071. }
  1072. }
  1073. else
  1074. {
  1075. $scid = explode('~',$lb['scid']);
  1076. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1077. $rk = $this->apiyy->get_bzsh($rkdata);
  1078. if(isset($rk['Data'][0]))
  1079. {
  1080. if($rk['Data'][0]['IsSucess'] == 1)
  1081. {
  1082. $this->db->trans_begin();
  1083. $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']);
  1084. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1085. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1086. if($cz == 2){
  1087. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1088. }
  1089. if ($this->db->trans_status() === TRUE)
  1090. {
  1091. $this->db->trans_commit();
  1092. if($nu['state'] == '216')
  1093. {
  1094. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1095. }
  1096. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1097. //标记订单已经取消
  1098. $this->_doCheckCancelFlag($lb['id']);
  1099. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1100. }
  1101. else
  1102. {
  1103. if($lb['is_jiaji'] == 2){
  1104. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1105. }else{
  1106. echo json_encode(array('music'=>'1','success'=>true));exit;
  1107. }
  1108. }
  1109. }
  1110. else
  1111. {
  1112. $this->db->trans_rollback();
  1113. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1114. }
  1115. }
  1116. else
  1117. {
  1118. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1119. }
  1120. }
  1121. else
  1122. {
  1123. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1124. }
  1125. }
  1126. }
  1127. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1128. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1129. {
  1130. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1131. }
  1132. $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']);
  1133. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1134. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1135. if($cz == 2){
  1136. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1137. }
  1138. if ($this->db->trans_status() === TRUE)
  1139. {
  1140. $this->db->trans_commit();
  1141. if($nu['state'] == '216')
  1142. {
  1143. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1144. }
  1145. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1146. //标记订单已经取消
  1147. $this->_doCheckCancelFlag($lb['id']);
  1148. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1149. }
  1150. else
  1151. {
  1152. if($lb['is_jiaji'] == 2){
  1153. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1154. }else{
  1155. echo json_encode(array('music'=>'1','success'=>true));exit;
  1156. }
  1157. }
  1158. }
  1159. else
  1160. {
  1161. $this->db->trans_rollback();
  1162. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1163. }
  1164. }
  1165. }
  1166. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1167. private function _doCheckCancelFlag($fid){
  1168. $info = $this->systemtransfer->read($fid);
  1169. if($info['status'] != 11){
  1170. $this->systemtransfer->save(['status'=>11],$fid);
  1171. }
  1172. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1173. if(empty($list)){
  1174. return;
  1175. }
  1176. $is_cancel = false;
  1177. foreach($list as $val){
  1178. if($val['orver_flag'] == 3){
  1179. $is_cancel = true;
  1180. }
  1181. }
  1182. if($is_cancel){
  1183. return ;
  1184. }
  1185. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1186. }
  1187. //检测是否超时 车间流转环节
  1188. private function _doCheckIsOverTime($fid,$transfer){
  1189. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1190. if(count($list) < 2){
  1191. return ;
  1192. }
  1193. if($list[0]['type'] != 2){
  1194. return;
  1195. }
  1196. if($list[1]['type'] != 1){
  1197. return;
  1198. }
  1199. if($list[1]['orver_flag'] == 2){
  1200. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1201. }else{
  1202. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1203. }
  1204. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1205. }
  1206. public function _bdbb()
  1207. {
  1208. $post = $this->input->post(NULL, TRUE);
  1209. if(isset($post['s']))
  1210. {
  1211. $id_arr = $this->input->post('s');
  1212. $id_arr = explode(',',trim($id_arr,','));
  1213. if(!$id_arr)
  1214. {
  1215. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1216. }
  1217. //循环删除记录
  1218. foreach ($id_arr as $v)
  1219. {
  1220. $t = $this->systemtransfer->read($v);
  1221. if(!isset($t['number']))
  1222. {
  1223. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1224. }
  1225. $y = $this->fullorder->get_number($t['number']);
  1226. if(!$y)
  1227. {
  1228. $y = $this->fullordersmt->get_number($t['number']);
  1229. if(!$y)
  1230. {
  1231. $y = $this->fullordertt->get_number($t['number']);
  1232. if(!$y)
  1233. {
  1234. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1235. }
  1236. }
  1237. }
  1238. $express = $this->express->read($y['express']);
  1239. $rows[] = array('num'=>$t['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'=>"补打");
  1240. }
  1241. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1242. }
  1243. }
  1244. public function _excel()
  1245. {
  1246. if(isset($_GET['fexcel']))
  1247. {
  1248. $tc = array();$zh = array();
  1249. $typeclass = $this->typeclass->find_all();
  1250. foreach ($typeclass as $v)
  1251. {
  1252. $tc[$v['id']] = $v;
  1253. }
  1254. $number = $this->input->get('number',true);
  1255. $color = $this->input->get('color',true);
  1256. $gs = $this->input->get('gs',true);
  1257. $transfer = $this->input->get('transfer',true);
  1258. $type = $this->input->get('type',true);
  1259. $timetk = $this->input->get('timetk',true);
  1260. $timetj = $this->input->get('timetj',true);
  1261. $purchase = $this->input->get('purchase',true);
  1262. $lx = $this->input->get('lx',true);
  1263. $timetk = strtotime($timetk);
  1264. $timetj = strtotime($timetj);
  1265. $where = "1=1";
  1266. $cr = "time > '$timetk' and time < '$timetj'";
  1267. if($number)
  1268. {
  1269. $where .= " and number = '$number'";
  1270. }
  1271. if($transfer)
  1272. {
  1273. $cr .= " and lx = '".$transfer."'";
  1274. }
  1275. if($type)
  1276. {
  1277. //$cr .= " and type = '".$type."'";
  1278. if($type == 3){
  1279. $cr .= " and is_over = 0 ";
  1280. }else{
  1281. $cr .= " and type = '".$type."' ";
  1282. }
  1283. }
  1284. if($purchase)
  1285. {
  1286. $where .= " and purchase = '$purchase'";
  1287. }
  1288. if($color)
  1289. {
  1290. $where .= " and fpdata like '%-".$color."-%'";
  1291. }
  1292. if($lx)
  1293. {
  1294. if($lx == 1)
  1295. {
  1296. $where .= " and ordernumber = ''";
  1297. }
  1298. else
  1299. {
  1300. $where .= " and ordernumber != ''";
  1301. }
  1302. }
  1303. $fid = '';
  1304. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1305. foreach ($info_list_cr as $v)
  1306. {
  1307. $fid .= "id = '".$v['fid']."' or ";
  1308. }
  1309. if($fid)
  1310. {
  1311. $where .= ' and ('.trim($fid,'or ').')';
  1312. }
  1313. else
  1314. {
  1315. $where .= ' and id = 0';
  1316. }
  1317. $data = array();
  1318. $datafy = array();
  1319. $j = 0;
  1320. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1321. $lzbm = $this->transfer->find_all();
  1322. foreach ($info_list as $key=>$value)
  1323. {
  1324. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1325. $d = $this->systemtransfer->read($value['id']);
  1326. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1327. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1328. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1329. $cp = explode('-',trim($d['features'],'-'));
  1330. $rk = explode('|',trim($d['rk'],'|'));
  1331. $rktime = explode('|',trim($d['rktime'],'|'));
  1332. foreach ($cp as $v)
  1333. {
  1334. if(isset($tc[$v]))
  1335. {
  1336. if($tc[$v]['classid'] == 13)
  1337. {
  1338. $dj = $tc[$v]['title'];
  1339. }
  1340. else if($tc[$v]['classid'] == 8)
  1341. {
  1342. $ys = $tc[$v]['title'];
  1343. }
  1344. else if($tc[$v]['classid'] == 14)
  1345. {
  1346. $cc = $tc[$v]['title'];
  1347. }
  1348. else if($tc[$v]['classid'] == 15)
  1349. {
  1350. $hx = $tc[$v]['title'];
  1351. }
  1352. else if($tc[$v]['classid'] == 10)
  1353. {
  1354. $md = $tc[$v]['title'];
  1355. }
  1356. }
  1357. }
  1358. $rt = array();
  1359. foreach ($rk as $k=>$v)
  1360. {
  1361. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1362. }
  1363. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1364. foreach ($lzbm as $v)
  1365. {
  1366. if(isset($rt[count($fpdata[0])]))
  1367. {
  1368. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1369. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1370. if($num > 0){
  1371. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1372. }else{
  1373. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1374. }
  1375. }
  1376. else
  1377. {
  1378. $fpdata[0][count($fpdata[0])] = '';
  1379. }
  1380. }
  1381. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1382. unset($info_list[$key]['id']);
  1383. }
  1384. //echo "<pre>";print_r($info_list);exit;
  1385. $lzxq = '';
  1386. foreach ($lzbm as $v)
  1387. {
  1388. $lzxq .= '<td>'.$v['title'].'</td>';
  1389. }
  1390. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1391. $titlename = "<table border=1>
  1392. <tr>
  1393. <td>订单编号</td>
  1394. <td>品名</td>
  1395. <td>简码</td>
  1396. <td>备注</td>
  1397. <td>打印时间</td>
  1398. <td>
  1399. <table border=1>
  1400. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1401. <tr>
  1402. <td>产品名称</td>
  1403. <td>尺寸</td>
  1404. <td>等级</td>
  1405. <td>颜色</td>
  1406. <td>花型</td>
  1407. <td>密度</td>
  1408. ".$lzxq."
  1409. </tr>
  1410. </table>
  1411. </td>
  1412. </tr>
  1413. </table>";
  1414. $filename = $title.".xls";
  1415. $tail = "\n";
  1416. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1417. }
  1418. }
  1419. public function _rk()
  1420. {
  1421. $post = $this->input->post(NULL, TRUE);
  1422. if(isset($post['page']))
  1423. {
  1424. $api = $this->input->post('api',true);
  1425. $page = $this->input->post('page',true);
  1426. $perpage = $this->input->post('perpage',true);
  1427. $number = $this->input->post('number',true);
  1428. $color = $this->input->post('color',true);
  1429. $purchase = $this->input->post('purchase',true);
  1430. $transfer = $this->input->post('transfer',true);
  1431. $lx = $this->input->post('lx',true);
  1432. $timetk = $this->input->post('timetk',true);
  1433. $timetj = $this->input->post('timetj',true);
  1434. $timetk = strtotime($timetk);
  1435. $timetj = strtotime($timetj);
  1436. $where = "1=1";
  1437. if($transfer)
  1438. {
  1439. $ctime = 'ctime'.$transfer;
  1440. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1441. }
  1442. else
  1443. {
  1444. $where .= " and time > '$timetk' and time < '$timetj'";
  1445. }
  1446. if($number)
  1447. {
  1448. $where .= " and number = '$number'";
  1449. }
  1450. if($transfer)
  1451. {
  1452. $where .= " and rk like '%|".$transfer."|%'";
  1453. }
  1454. if($purchase)
  1455. {
  1456. $where .= " and purchase = '$purchase'";
  1457. }
  1458. if($color)
  1459. {
  1460. $where .= " and fpdata like '%-".$color."-%'";
  1461. }
  1462. if($lx)
  1463. {
  1464. if($lx == 1)
  1465. {
  1466. $where .= " and ordernumber = ''";
  1467. }
  1468. else
  1469. {
  1470. $where .= " and ordernumber != ''";
  1471. }
  1472. }
  1473. //数据排序
  1474. $order_str = "id desc";
  1475. if(empty($page))
  1476. {
  1477. $start = 0;
  1478. $perpage = 1;
  1479. }
  1480. else
  1481. {
  1482. $start = ($page - 1)*$perpage;
  1483. }
  1484. //取得信息列表
  1485. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1486. $transfer = $this->transfer->find_all();
  1487. $t = array();
  1488. foreach ($transfer as $v)
  1489. {
  1490. $t[$v['id']] = $v['title'];
  1491. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1492. }
  1493. //格式化数据
  1494. foreach ($info_list as $key=>$value)
  1495. {
  1496. $dd = $this->systemtransfer->read($value['id']);
  1497. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1498. $rk = explode('|',trim($dd['rk'],'|'));
  1499. $rktime = explode('|',trim($dd['rktime'],'|'));
  1500. $ck = explode('|',trim($dd['ck'],'|'));
  1501. $cktime = explode('|',trim($dd['cktime'],'|'));
  1502. $info_list[$key]['time'] = '';
  1503. for($i=0;$i<count($rk);$i++)
  1504. {
  1505. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1506. {
  1507. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1508. }
  1509. else
  1510. {
  1511. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1512. }
  1513. $info_list[$key]['time'] .= $d;
  1514. if(isset($ck[$i]) && $ck[$i] != '')
  1515. {
  1516. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1517. }
  1518. }
  1519. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1520. }
  1521. $total = $this->systemtransfer->find_count($where);
  1522. $pagenum = ceil($total/$perpage);
  1523. $over = $total-($start+$perpage);
  1524. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1525. echo json_encode($rows);exit;
  1526. }
  1527. if(isset($_SESSION['api']))
  1528. {
  1529. $user = $this->user->get_api($_SESSION['api']);
  1530. $usp = $user;
  1531. $pid = "";$tid="";$sid="";$wid="";
  1532. $purchase = explode('|',trim($user['purchase'],'|'));
  1533. $transfer = explode('|',trim($user['transfer'],'|'));
  1534. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1535. foreach ($purchase as $value)
  1536. {
  1537. $pid .= " id = ".$value." or";
  1538. }
  1539. foreach ($transfer as $value)
  1540. {
  1541. $tid .= " id = ".$value." or";
  1542. }
  1543. foreach ($warehouse as $value)
  1544. {
  1545. $wid .= " id = ".$value." or";
  1546. }
  1547. }
  1548. else
  1549. {
  1550. header('Location: /');exit;
  1551. }
  1552. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1553. $this->data['transfer'] = $transfer;
  1554. $this->_Template('transfer_rk',$this->data);
  1555. }
  1556. public function _ck()
  1557. {
  1558. $post = $this->input->post(NULL, TRUE);
  1559. if(isset($post['page']))
  1560. {
  1561. $api = $this->input->post('api',true);
  1562. $page = $this->input->post('page',true);
  1563. $perpage = $this->input->post('perpage',true);
  1564. $number = $this->input->post('number',true);
  1565. $color = $this->input->post('color',true);
  1566. $purchase = $this->input->post('purchase',true);
  1567. $transfer = $this->input->post('transfer',true);
  1568. $lx = $this->input->post('lx',true);
  1569. $timetk = $this->input->post('timetk',true);
  1570. $timetj = $this->input->post('timetj',true);
  1571. $timetk = strtotime($timetk);
  1572. $timetj = strtotime($timetj);
  1573. $where = "1=1";
  1574. if($transfer)
  1575. {
  1576. $ctime = 'ctime'.$transfer;
  1577. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1578. }
  1579. else
  1580. {
  1581. $where .= " and time > '$timetk' and time < '$timetj'";
  1582. }
  1583. if($number)
  1584. {
  1585. $where .= " and number = '$number'";
  1586. }
  1587. if($transfer)
  1588. {
  1589. $where .= " and ck like '%|".$transfer."|%'";
  1590. }
  1591. if($purchase)
  1592. {
  1593. $where .= " and purchase = '$purchase'";
  1594. }
  1595. if($color)
  1596. {
  1597. $where .= " and fpdata like '%-".$color."-%'";
  1598. }
  1599. if($lx)
  1600. {
  1601. if($lx == 1)
  1602. {
  1603. $where .= " and ordernumber = ''";
  1604. }
  1605. else
  1606. {
  1607. $where .= " and ordernumber != ''";
  1608. }
  1609. }
  1610. //数据排序
  1611. $order_str = "id desc";
  1612. if(empty($page))
  1613. {
  1614. $start = 0;
  1615. $perpage = 1;
  1616. }
  1617. else
  1618. {
  1619. $start = ($page - 1)*$perpage;
  1620. }
  1621. //取得信息列表
  1622. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1623. $transfer = $this->transfer->find_all();
  1624. $t = array();
  1625. foreach ($transfer as $v)
  1626. {
  1627. $t[$v['id']] = $v['title'];
  1628. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1629. }
  1630. //格式化数据
  1631. foreach ($info_list as $key=>$value)
  1632. {
  1633. $dd = $this->systemtransfer->read($value['id']);
  1634. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1635. $rk = explode('|',trim($dd['rk'],'|'));
  1636. $rktime = explode('|',trim($dd['rktime'],'|'));
  1637. $ck = explode('|',trim($dd['ck'],'|'));
  1638. $cktime = explode('|',trim($dd['cktime'],'|'));
  1639. $info_list[$key]['time'] = '';
  1640. for($i=0;$i<count($rk);$i++)
  1641. {
  1642. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1643. {
  1644. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1645. }
  1646. else
  1647. {
  1648. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1649. }
  1650. $info_list[$key]['time'] .= $d;
  1651. if(isset($ck[$i]) && $ck[$i] != '')
  1652. {
  1653. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1654. }
  1655. }
  1656. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1657. }
  1658. $total = $this->systemtransfer->find_count($where);
  1659. $pagenum = ceil($total/$perpage);
  1660. $over = $total-($start+$perpage);
  1661. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1662. echo json_encode($rows);exit;
  1663. }
  1664. if(isset($_SESSION['api']))
  1665. {
  1666. $user = $this->user->get_api($_SESSION['api']);
  1667. $usp = $user;
  1668. $pid = "";$tid="";$sid="";$wid="";
  1669. $purchase = explode('|',trim($user['purchase'],'|'));
  1670. $transfer = explode('|',trim($user['transfer'],'|'));
  1671. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1672. foreach ($purchase as $value)
  1673. {
  1674. $pid .= " id = ".$value." or";
  1675. }
  1676. foreach ($transfer as $value)
  1677. {
  1678. $tid .= " id = ".$value." or";
  1679. }
  1680. foreach ($warehouse as $value)
  1681. {
  1682. $wid .= " id = ".$value." or";
  1683. }
  1684. }
  1685. else
  1686. {
  1687. header('Location: /');exit;
  1688. }
  1689. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1690. $this->data['transfer'] = $transfer;
  1691. $this->_Template('transfer_ck',$this->data);
  1692. }
  1693. public function _jgl()
  1694. {
  1695. $post = $this->input->post(NULL, TRUE);
  1696. if(isset($post['printtime']))
  1697. {
  1698. $pt = $this->input->post('printtime',true);
  1699. $wt = $this->input->post('wgtime',true);
  1700. $printtime = strtotime($pt);
  1701. $wgtime = strtotime($wt);
  1702. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1703. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1704. if($printtime == $wgtime || $printtime > $wgtime)
  1705. {
  1706. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1707. }
  1708. 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;
  1709. }
  1710. $this->_Template('transfer_wgl',$this->data);
  1711. }
  1712. public function _linqi(){
  1713. $post = $this->input->post(NULL, TRUE);
  1714. if(isset($post['page']))
  1715. {
  1716. $api = $this->input->post('api',true);
  1717. $page = $this->input->post('page',true);
  1718. $perpage = $this->input->post('perpage',true);
  1719. $transfer = $this->input->post('transfer',true);
  1720. $transfer_ids = $this->input->post('transfer_ids',true);
  1721. $orver_flag = $this->input->post('orver_flag',true);
  1722. $timetk = $this->input->post('timetk',true);
  1723. $timetj = $this->input->post('timetj',true);
  1724. $timetk = strtotime($timetk);
  1725. $timetj = strtotime($timetj);
  1726. $transfer_list = $this->transfer->find_all();
  1727. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1728. $where = 'type = 1 ';
  1729. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1730. //数据排序
  1731. $order_str = "id desc";
  1732. if(empty($page))
  1733. {
  1734. $start = 0;
  1735. $perpage = 1;
  1736. }
  1737. else
  1738. {
  1739. $start = ($page - 1)*$perpage;
  1740. }
  1741. if($transfer){
  1742. $where .= " and lx = '$transfer'";
  1743. }else{
  1744. $where .= " and lx in (".$transfer_ids.") ";
  1745. }
  1746. $where .= " and time > '$timetk' and time < '$timetj'";
  1747. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1748. $final_list = [];
  1749. foreach ($list as $key => $value) {
  1750. $info = $this->systemtransfer->read($value['fid']);
  1751. $final_list[$key]['id'] = $value['id'];
  1752. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1753. if($info['is_jiaji'] == 2){
  1754. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1755. }else{
  1756. $final_list[$key]['is_jiaji'] = "常规";
  1757. }
  1758. $final_list[$key]['pm'] = $info['pm'];
  1759. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1760. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1761. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1762. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1763. foreach ($data as $k=>$v)
  1764. {
  1765. $type = ($v['type']==1)?'入库':'出库';
  1766. if($v['orver_flag'] == 1){
  1767. if($v['is_over'] == 0){
  1768. $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>';
  1769. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1770. }else{
  1771. $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>';
  1772. }
  1773. }elseif($v['orver_flag'] == 2){
  1774. $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>';
  1775. }else{
  1776. $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>';
  1777. }
  1778. }
  1779. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1780. }
  1781. $total = $this->systemtransfer_cr->find_count($where);
  1782. $pagenum = ceil($total/$perpage);
  1783. $over = $total-($start+$perpage);
  1784. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1785. echo json_encode($rows);exit;
  1786. }
  1787. if(isset($_SESSION['api']))
  1788. {
  1789. $user = $this->user->get_api($_SESSION['api']);
  1790. $usp = $user;
  1791. $pid = "";$tid="";$sid="";$wid="";
  1792. $purchase = explode('|',trim($user['purchase'],'|'));
  1793. $transfer = explode('|',trim($user['transfer'],'|'));
  1794. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1795. foreach ($purchase as $value)
  1796. {
  1797. $pid .= " id = ".$value." or";
  1798. }
  1799. foreach ($transfer as $value)
  1800. {
  1801. $tid .= " id = ".$value." or";
  1802. }
  1803. foreach ($warehouse as $value)
  1804. {
  1805. $wid .= " id = ".$value." or";
  1806. }
  1807. }
  1808. else
  1809. {
  1810. header('Location: /');exit;
  1811. }
  1812. $kx = '';$zjtab = '';
  1813. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1814. $this->data['transfer'] = $transfer;
  1815. $transfer_ids = array_column($transfer, 'id');
  1816. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1817. $this->data['vip'] = $user['vip'];
  1818. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1819. $this->_Template('transfer_linqi',$this->data);
  1820. }
  1821. //按照条件导出超时车间
  1822. public function _overtime_export(){
  1823. $transfer_id = $this->input->get('transfer', TRUE);
  1824. $timetk = $this->input->get('timetk', TRUE);
  1825. $timetj = $this->input->get('timetj', TRUE);
  1826. $timetk = strtotime($timetk);
  1827. $timetj = strtotime($timetj);
  1828. if(isset($_SESSION['api']))
  1829. {
  1830. $user = $this->user->get_api($_SESSION['api']);
  1831. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1832. $tmp_transfer_list = $this->transfer->find_all();
  1833. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1834. }
  1835. else
  1836. {
  1837. header('Location: /');exit;
  1838. }
  1839. $where = " orver_flag = 2 and type = 1";
  1840. if(empty($transfer_id)){
  1841. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1842. }else{
  1843. $where .= " and lx = ".$transfer_id." ";
  1844. }
  1845. $where .= " and time > '$timetk' and time < '$timetj'";
  1846. $list = $this->systemtransfer_cr->find_all($where,'*');
  1847. $fid_list = array_column($list, 'fid');
  1848. if(empty($fid_list)){
  1849. echo "没有数据" ;
  1850. die ;
  1851. }
  1852. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  1853. $where_two = " orver_flag = 2 and type = 2";
  1854. if(empty($transfer_id)){
  1855. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  1856. }else{
  1857. $where_two .= " and lx = ".$transfer_id." ";
  1858. }
  1859. $where_two .= " and time > '$timetk' and time < '$timetj'";
  1860. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  1861. $final_list = [];
  1862. // foreach($list as $k => $v){
  1863. // $final_list[$v['fid']]['fid'] = $v['fid'];
  1864. // $final_list[$v['fid']]['lx'] = $v['lx'];
  1865. // $final_list[$v['fid']]['start_type'] = $v['type'];
  1866. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  1867. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  1868. // $final_list[$v['fid']]['end_time'] = "";
  1869. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  1870. // }
  1871. // foreach($order_list as $k=>$v){
  1872. // if(isset($final_list[$v['id']])){
  1873. // $final_list[$v['id']]['number'] = $v['number'];
  1874. // $final_list[$v['id']]['pm'] = $v['pm'];
  1875. // }
  1876. // }
  1877. // foreach($list_two as $k => $v){
  1878. // if(isset($final_list[$v['fid']])){
  1879. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  1880. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  1881. // }
  1882. // }
  1883. // }
  1884. foreach($list as $k => $v){
  1885. $final_list[] = [
  1886. 'fid' => $v['fid'],
  1887. 'lx' => $v['lx'],
  1888. 'start_type' => $v['type'],
  1889. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  1890. 'condition' => json_decode($v['limit_time_str'],true),
  1891. 'end_time' => "",
  1892. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  1893. ];
  1894. }
  1895. foreach($order_list as $k=>$v){
  1896. foreach($final_list as $kk => $vv){
  1897. if($v['id'] == $vv['fid']){
  1898. $final_list[$kk]['number'] = $v['number'];
  1899. $final_list[$kk]['pm'] = $v['pm'];
  1900. }
  1901. }
  1902. }
  1903. foreach($list_two as $k => $v){
  1904. foreach($final_list as $kk => $vv){
  1905. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  1906. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  1907. }
  1908. }
  1909. }
  1910. $filename = date("Y-m-d")."超时单导出.xls";
  1911. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1912. <head>
  1913. <!--[if gte mso 9]><xml>
  1914. <x:ExcelWorkbook>
  1915. <x:ExcelWorksheets>
  1916. <x:ExcelWorksheet>
  1917. <x:Name>EXCEL</x:Name>
  1918. <x:WorksheetOptions>
  1919. <x:Print>
  1920. <x:ValidPrinterInfo />
  1921. </x:Print>
  1922. </x:WorksheetOptions>
  1923. </x:ExcelWorksheet>
  1924. </x:ExcelWorksheets>
  1925. </x:ExcelWorkbook>
  1926. </xml>
  1927. <![endif]-->
  1928. </head><body>";
  1929. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  1930. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  1931. foreach ($final_list as $key=>$value)
  1932. {
  1933. if(empty($value['number'])){
  1934. continue;
  1935. }
  1936. $str .= "<tr>";
  1937. $str .= "<td>". $value['number']. "</td>";
  1938. $str .= "<td>". $value['pm']. "</td>";
  1939. $str .= "<td>". $value['lx_name']. "</td>";
  1940. $str .= "<td>". $value['start_time']. "</td>";
  1941. $str .= "<td>". $value['end_time']. "</td>";
  1942. $str .= "</tr>";
  1943. }
  1944. $str .= "</table></body></html>";
  1945. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1946. header( "Content-type: application/octet-stream" );
  1947. header( "Content-Disposition: attachment; filename=".$filename );
  1948. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1949. header( "Pragma: no-cache" );
  1950. header( "Expires: 0" );
  1951. exit($str);
  1952. }
  1953. public function _jiaji(){
  1954. $post = $this->input->post(NULL, TRUE);
  1955. if(isset($post['page']))
  1956. {
  1957. $api = $this->input->post('api',true);
  1958. $page = $this->input->post('page',true);
  1959. $perpage = $this->input->post('perpage',true);
  1960. $transfer = $this->input->post('transfer',true);
  1961. $transfer_ids = $this->input->post('transfer_ids',true);
  1962. $orver_flag = $this->input->post('orver_flag',true);
  1963. $timetk = $this->input->post('timetk',true);
  1964. $timetj = $this->input->post('timetj',true);
  1965. $timetk = strtotime($timetk);
  1966. $timetj = strtotime($timetj);
  1967. $transfer_list = $this->transfer->find_all();
  1968. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1969. if(isset($_SESSION['api']))
  1970. {
  1971. $user = $this->user->get_api($_SESSION['api']);
  1972. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1973. }
  1974. else
  1975. {
  1976. $transfer_ids = array_keys($t);
  1977. }
  1978. if(empty($page))
  1979. {
  1980. $start = 0;
  1981. $perpage = 1;
  1982. }
  1983. else
  1984. {
  1985. $start = ($page - 1)*$perpage;
  1986. }
  1987. $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." ";
  1988. if($transfer){
  1989. $sql_r .= " and c.lx = ".$transfer." ";
  1990. }else{
  1991. foreach($transfer_ids as $k=>$v){
  1992. if($v == 11){
  1993. unset($transfer_ids[$k]);
  1994. }
  1995. }
  1996. $transfer_str = implode(",",$transfer_ids);
  1997. $sql_r .= " and c.lx in (".$transfer_str.") ";
  1998. }
  1999. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2000. $rows_r = $this->db->query($sql_r);
  2001. $get_list = $rows_r->result_array();
  2002. $total = count($get_list);
  2003. $split_list = array_chunk($get_list,$perpage);
  2004. $pagenum = ceil(count($split_list));
  2005. $key = $page - 1;
  2006. $list = isset($split_list[$key])?$split_list[$key]:[];
  2007. $final_list = [];
  2008. foreach ($list as $key => $value) {
  2009. $final_list[$key]['id'] = $value['id'];
  2010. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2011. if($value['is_jiaji'] == 2){
  2012. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2013. }else{
  2014. $final_list[$key]['is_jiaji'] = "常规";
  2015. }
  2016. $final_list[$key]['pm'] = $value['pm'];
  2017. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2018. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2019. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2020. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2021. foreach ($data as $k=>$v)
  2022. {
  2023. $type = ($v['type']==1)?'入库':'出库';
  2024. if($v['orver_flag'] == 1){
  2025. if($v['is_over'] == 0){
  2026. $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>';
  2027. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2028. }else{
  2029. $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>';
  2030. }
  2031. }elseif($v['orver_flag'] == 2){
  2032. $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>';
  2033. }else{
  2034. $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>';
  2035. }
  2036. }
  2037. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2038. }
  2039. $over = $total-($start+$perpage);
  2040. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2041. echo json_encode($rows);exit;
  2042. }
  2043. if(isset($_SESSION['api']))
  2044. {
  2045. $user = $this->user->get_api($_SESSION['api']);
  2046. $usp = $user;
  2047. $pid = "";$tid="";$sid="";$wid="";
  2048. $purchase = explode('|',trim($user['purchase'],'|'));
  2049. $transfer = explode('|',trim($user['transfer'],'|'));
  2050. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2051. foreach ($purchase as $value)
  2052. {
  2053. $pid .= " id = ".$value." or";
  2054. }
  2055. foreach ($transfer as $value)
  2056. {
  2057. if($value){
  2058. if($value != 11){
  2059. $tid .= " id = ".$value." or";
  2060. }
  2061. }
  2062. }
  2063. foreach ($warehouse as $value)
  2064. {
  2065. $wid .= " id = ".$value." or";
  2066. }
  2067. }
  2068. else
  2069. {
  2070. header('Location: /');exit;
  2071. }
  2072. $kx = '';$zjtab = '';
  2073. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2074. $this->data['transfer'] = $transfer;
  2075. $transfer_ids = array_column($transfer, 'id');
  2076. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2077. $this->data['vip'] = $user['vip'];
  2078. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2079. $this->_Template('transfer_jiaji',$this->data);
  2080. }
  2081. public function _scz(){
  2082. $post = $this->input->post(NULL, TRUE);
  2083. if(isset($post['page']))
  2084. {
  2085. $page = $this->input->post('page',true);
  2086. $perpage = $this->input->post('perpage',true);
  2087. $transfer = $this->input->post('transfer',true);
  2088. $transfer_ids = $this->input->post('transfer_ids',true);
  2089. $timetk = $this->input->post('timetk',true);
  2090. $timetj = $this->input->post('timetj',true);
  2091. $timetk = strtotime($timetk);
  2092. $timetj = strtotime($timetj);
  2093. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2094. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2095. // $transfer_ids = array_keys($t);
  2096. if(empty($page))
  2097. {
  2098. $start = 0;
  2099. $perpage = 1;
  2100. }
  2101. else
  2102. {
  2103. $start = ($page - 1)*$perpage;
  2104. }
  2105. $where = "time > '$timetk' and time < '$timetj'";
  2106. $where .= " and rk not like '%11|' ";
  2107. if(!empty($transfer)){
  2108. $where .= " and rk like '%|".$transfer."|%' ";
  2109. }
  2110. // if($transfer)
  2111. // {
  2112. // $cr .= " and lx = '".$transfer."' ";
  2113. // }else{
  2114. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2115. // }
  2116. // $cr .= " and is_over = 0 ";
  2117. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2118. // $fid = [];
  2119. // foreach ($info_list_cr as $v)
  2120. // {
  2121. // $fid[] = $v['fid'];
  2122. // }
  2123. // if(empty($fid)){
  2124. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2125. // echo json_encode($rows);exit;
  2126. // }
  2127. // $fid = array_unique($fid);
  2128. $order_str = "id desc";
  2129. //取得信息列表
  2130. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2131. $transfer = $this->transfer->find_all();
  2132. $t = array();
  2133. foreach ($transfer as $v)
  2134. {
  2135. $t[$v['id']] = $v['title'];
  2136. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2137. }
  2138. //格式化数据
  2139. foreach ($info_list as $key=>$value)
  2140. {
  2141. if($value['is_jiaji'] == 2){
  2142. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2143. }else{
  2144. $info_list[$key]['is_jiaji'] = "常规";
  2145. }
  2146. $dd = $this->systemtransfer->read($value['id']);
  2147. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2148. $rk = explode('|',trim($dd['rk'],'|'));
  2149. $rktime = explode('|',trim($dd['rktime'],'|'));
  2150. $ck = explode('|',trim($dd['ck'],'|'));
  2151. $cktime = explode('|',trim($dd['cktime'],'|'));
  2152. $info_list[$key]['time'] = '';
  2153. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2154. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2155. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2156. foreach ($data as $k=>$v)
  2157. {
  2158. // $type = ($v['type']==1)?'入库':'出库';
  2159. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2160. $type = ($v['type']==1)?'入库':'出库';
  2161. if($v['orver_flag'] == 1){
  2162. if($v['is_over'] == 0){
  2163. $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>';
  2164. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2165. }else{
  2166. $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>';
  2167. }
  2168. }elseif($v['orver_flag'] == 2){
  2169. $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>';
  2170. }elseif($v['orver_flag'] == 3){
  2171. $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>';
  2172. }else{
  2173. $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>';
  2174. }
  2175. }
  2176. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2177. unset($info_list[$key]['ctime12']);
  2178. }
  2179. $total = $this->systemtransfer->find_count($where);
  2180. $pagenum = ceil($total/$perpage);
  2181. $over = $total-($start+$perpage);
  2182. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2183. echo json_encode($rows);exit;
  2184. }
  2185. if(isset($_SESSION['api']))
  2186. {
  2187. $user = $this->user->get_api($_SESSION['api']);
  2188. if(!in_array($user['id'],[10,44,50])){
  2189. exit('No direct script access allowed');
  2190. }
  2191. }
  2192. else
  2193. {
  2194. header('Location: /');exit;
  2195. }
  2196. $kx = '';$zjtab = '';
  2197. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2198. $this->data['transfer'] = $transfer;
  2199. $transfer_ids = array_column($transfer, 'id');
  2200. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2201. $this->_Template('transfer_scz',$this->data);
  2202. }
  2203. public function _sczexcel(){
  2204. $timetk = $this->input->get('timetk',true);
  2205. $timetj = $this->input->get('timetj',true);
  2206. $timetk = strtotime($timetk);
  2207. $timetj = strtotime($timetj);
  2208. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2209. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2210. // $transfer_ids = array_keys($t);
  2211. $where = "time > '$timetk' and time < '$timetj'";
  2212. $where .= " and rk not like '%11|' ";
  2213. if(!empty($transfer)){
  2214. $where .= " and rk like '%|".$transfer."|%' ";
  2215. }
  2216. $order_str = "id desc";
  2217. //取得信息列表
  2218. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2219. $transfer = $this->transfer->find_all();
  2220. $t = array();
  2221. foreach ($transfer as $v)
  2222. {
  2223. $t[$v['id']] = $v['title'];
  2224. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2225. }
  2226. //格式化数据
  2227. foreach ($info_list as $key=>$value)
  2228. {
  2229. if($value['is_jiaji'] == 2){
  2230. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2231. }else{
  2232. $info_list[$key]['is_jiaji'] = "常规";
  2233. }
  2234. $dd = $this->systemtransfer->read($value['id']);
  2235. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2236. $rk = explode('|',trim($dd['rk'],'|'));
  2237. $rktime = explode('|',trim($dd['rktime'],'|'));
  2238. $ck = explode('|',trim($dd['ck'],'|'));
  2239. $cktime = explode('|',trim($dd['cktime'],'|'));
  2240. $info_list[$key]['time'] = '';
  2241. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2242. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2243. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2244. foreach ($data as $k=>$v)
  2245. {
  2246. // $type = ($v['type']==1)?'入库':'出库';
  2247. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2248. $type = ($v['type']==1)?'入库':'出库';
  2249. if($v['orver_flag'] == 1){
  2250. if($v['is_over'] == 0){
  2251. $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>';
  2252. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2253. }else{
  2254. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2255. }
  2256. }elseif($v['orver_flag'] == 2){
  2257. $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>';
  2258. }elseif($v['orver_flag'] == 3){
  2259. $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>';
  2260. }else{
  2261. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2262. }
  2263. }
  2264. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2265. unset($info_list[$key]['ctime12']);
  2266. }
  2267. $filename = date("Y-m-d")."生产中订单.xls";
  2268. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2269. <head>
  2270. <!--[if gte mso 9]><xml>
  2271. <x:ExcelWorkbook>
  2272. <x:ExcelWorksheets>
  2273. <x:ExcelWorksheet>
  2274. <x:Name>EXCEL</x:Name>
  2275. <x:WorksheetOptions>
  2276. <x:Print>
  2277. <x:ValidPrinterInfo />
  2278. </x:Print>
  2279. </x:WorksheetOptions>
  2280. </x:ExcelWorksheet>
  2281. </x:ExcelWorksheets>
  2282. </x:ExcelWorkbook>
  2283. </xml>
  2284. <![endif]-->
  2285. </head><body>";
  2286. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2287. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2288. foreach ($info_list as $key=>$value)
  2289. {
  2290. $str .= "<tr>";
  2291. $str .= "<td>". $value['number']. "</td>";
  2292. $str .= "<td>". $value['is_jiaji']. "</td>";
  2293. $str .= "<td>". $value['pm']. "</td>";
  2294. $str .= "<td>". $value['shipremarks']. "</td>";
  2295. $str .= "<td>". $value['printtime']. "</td>";
  2296. $str .= "<td>". $value['time']. "</td>";
  2297. $str .= "</tr>";
  2298. }
  2299. $str .= "</table></body></html>";
  2300. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2301. header( "Content-type: application/octet-stream" );
  2302. header( "Content-Disposition: attachment; filename=".$filename );
  2303. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2304. header( "Pragma: no-cache" );
  2305. header( "Expires: 0" );
  2306. exit($str);
  2307. }
  2308. }