Transfer.php 86 KB

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