Transfer.php 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596
  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. $cztime = 'ctime'.$transfer;
  1026. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1027. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1028. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1029. {
  1030. if($lb['type'] == 0)
  1031. {
  1032. $s = $this->shop->read($nu['shop']);
  1033. $lb['kh'] = $s['yyid'];
  1034. $lb['ts'] = 1;
  1035. $rk = $this->apiyy->_newrk($lb);
  1036. if($rk['c'] == 0)
  1037. {
  1038. $this->db->trans_begin();
  1039. $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']);
  1040. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1041. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1042. if($cz == 2){
  1043. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1044. }
  1045. if ($this->db->trans_status() === TRUE)
  1046. {
  1047. $this->db->trans_commit();
  1048. if($nu['state'] == '216')
  1049. {
  1050. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1051. }
  1052. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1053. //标记订单已经取消
  1054. $this->_doCheckCancelFlag($lb['id']);
  1055. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1056. }
  1057. else
  1058. {
  1059. if($lb['is_jiaji'] == 2){
  1060. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1061. }else{
  1062. echo json_encode(array('music'=>'1','success'=>true));exit;
  1063. }
  1064. }
  1065. }
  1066. else
  1067. {
  1068. $this->db->trans_rollback();
  1069. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1070. }
  1071. }
  1072. else
  1073. {
  1074. if(stripos($rk['error'],'DocNo') !== false)
  1075. {
  1076. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1077. }
  1078. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1079. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1080. }
  1081. }
  1082. else
  1083. {
  1084. $scid = explode('~',$lb['scid']);
  1085. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1086. $rk = $this->apiyy->get_bzsh($rkdata);
  1087. if(isset($rk['Data'][0]))
  1088. {
  1089. if($rk['Data'][0]['IsSucess'] == 1)
  1090. {
  1091. $this->db->trans_begin();
  1092. $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']);
  1093. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1094. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1095. if($cz == 2){
  1096. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1097. }
  1098. if ($this->db->trans_status() === TRUE)
  1099. {
  1100. $this->db->trans_commit();
  1101. if($nu['state'] == '216')
  1102. {
  1103. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1104. }
  1105. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1106. //标记订单已经取消
  1107. $this->_doCheckCancelFlag($lb['id']);
  1108. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1109. }
  1110. else
  1111. {
  1112. if($lb['is_jiaji'] == 2){
  1113. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1114. }else{
  1115. echo json_encode(array('music'=>'1','success'=>true));exit;
  1116. }
  1117. }
  1118. }
  1119. else
  1120. {
  1121. $this->db->trans_rollback();
  1122. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1123. }
  1124. }
  1125. else
  1126. {
  1127. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1128. }
  1129. }
  1130. else
  1131. {
  1132. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1133. }
  1134. }
  1135. }
  1136. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1137. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1138. {
  1139. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1140. }
  1141. $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']);
  1142. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1143. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1144. if($cz == 2){
  1145. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1146. }
  1147. if ($this->db->trans_status() === TRUE)
  1148. {
  1149. $this->db->trans_commit();
  1150. if($nu['state'] == '216')
  1151. {
  1152. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1153. }
  1154. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1155. //标记订单已经取消
  1156. $this->_doCheckCancelFlag($lb['id']);
  1157. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1158. }
  1159. else
  1160. {
  1161. if($lb['is_jiaji'] == 2){
  1162. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1163. }else{
  1164. echo json_encode(array('music'=>'1','success'=>true));exit;
  1165. }
  1166. }
  1167. }
  1168. else
  1169. {
  1170. $this->db->trans_rollback();
  1171. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1172. }
  1173. }
  1174. }
  1175. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1176. private function _doCheckCancelFlag($fid){
  1177. $info = $this->systemtransfer->read($fid);
  1178. if($info['status'] != 11){
  1179. $this->systemtransfer->save(['status'=>11],$fid);
  1180. }
  1181. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1182. if(empty($list)){
  1183. return;
  1184. }
  1185. $is_cancel = false;
  1186. foreach($list as $val){
  1187. if($val['orver_flag'] == 3){
  1188. $is_cancel = true;
  1189. }
  1190. }
  1191. if($is_cancel){
  1192. return ;
  1193. }
  1194. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1195. }
  1196. //检测是否超时 车间流转环节
  1197. private function _doCheckIsOverTime($fid,$transfer){
  1198. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1199. if(count($list) < 2){
  1200. return ;
  1201. }
  1202. if($list[0]['type'] != 2){
  1203. return;
  1204. }
  1205. if($list[1]['type'] != 1){
  1206. return;
  1207. }
  1208. if($list[1]['orver_flag'] == 2){
  1209. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1210. }else{
  1211. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1212. }
  1213. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1214. }
  1215. public function _bdbb()
  1216. {
  1217. $post = $this->input->post(NULL, TRUE);
  1218. if(isset($post['s']))
  1219. {
  1220. $id_arr = $this->input->post('s');
  1221. $id_arr = explode(',',trim($id_arr,','));
  1222. if(!$id_arr)
  1223. {
  1224. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1225. }
  1226. //循环删除记录
  1227. foreach ($id_arr as $v)
  1228. {
  1229. $t = $this->systemtransfer->read($v);
  1230. if(!isset($t['number']))
  1231. {
  1232. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1233. }
  1234. $y = $this->fullorder->get_number($t['number']);
  1235. if(!$y)
  1236. {
  1237. $y = $this->fullordersmt->get_number($t['number']);
  1238. if(!$y)
  1239. {
  1240. $y = $this->fullordertt->get_number($t['number']);
  1241. if(!$y)
  1242. {
  1243. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1244. }
  1245. }
  1246. }
  1247. $express = $this->express->read($y['express']);
  1248. $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'=>"补打");
  1249. }
  1250. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1251. }
  1252. }
  1253. public function _excel()
  1254. {
  1255. if(isset($_GET['fexcel']))
  1256. {
  1257. $tc = array();$zh = array();
  1258. $typeclass = $this->typeclass->find_all();
  1259. foreach ($typeclass as $v)
  1260. {
  1261. $tc[$v['id']] = $v;
  1262. }
  1263. $number = $this->input->get('number',true);
  1264. $color = $this->input->get('color',true);
  1265. $gs = $this->input->get('gs',true);
  1266. $transfer = $this->input->get('transfer',true);
  1267. $type = $this->input->get('type',true);
  1268. $timetk = $this->input->get('timetk',true);
  1269. $timetj = $this->input->get('timetj',true);
  1270. $purchase = $this->input->get('purchase',true);
  1271. $lx = $this->input->get('lx',true);
  1272. $timetk = strtotime($timetk);
  1273. $timetj = strtotime($timetj);
  1274. $where = "1=1";
  1275. $cr = "time > '$timetk' and time < '$timetj'";
  1276. if($number)
  1277. {
  1278. $where .= " and number = '$number'";
  1279. }
  1280. if($transfer)
  1281. {
  1282. $cr .= " and lx = '".$transfer."'";
  1283. }
  1284. if($type)
  1285. {
  1286. //$cr .= " and type = '".$type."'";
  1287. if($type == 3){
  1288. $cr .= " and is_over = 0 ";
  1289. }else{
  1290. $cr .= " and type = '".$type."' ";
  1291. }
  1292. }
  1293. if($purchase)
  1294. {
  1295. $where .= " and purchase = '$purchase'";
  1296. }
  1297. if($color)
  1298. {
  1299. $where .= " and fpdata like '%-".$color."-%'";
  1300. }
  1301. if($lx)
  1302. {
  1303. if($lx == 1)
  1304. {
  1305. $where .= " and ordernumber = ''";
  1306. }
  1307. else
  1308. {
  1309. $where .= " and ordernumber != ''";
  1310. }
  1311. }
  1312. $fid = '';
  1313. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1314. foreach ($info_list_cr as $v)
  1315. {
  1316. $fid .= "id = '".$v['fid']."' or ";
  1317. }
  1318. if($fid)
  1319. {
  1320. $where .= ' and ('.trim($fid,'or ').')';
  1321. }
  1322. else
  1323. {
  1324. $where .= ' and id = 0';
  1325. }
  1326. $data = array();
  1327. $datafy = array();
  1328. $j = 0;
  1329. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1330. $lzbm = $this->transfer->find_all();
  1331. foreach ($info_list as $key=>$value)
  1332. {
  1333. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1334. $d = $this->systemtransfer->read($value['id']);
  1335. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1336. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1337. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1338. $cp = explode('-',trim($d['features'],'-'));
  1339. $rk = explode('|',trim($d['rk'],'|'));
  1340. $rktime = explode('|',trim($d['rktime'],'|'));
  1341. foreach ($cp as $v)
  1342. {
  1343. if(isset($tc[$v]))
  1344. {
  1345. if($tc[$v]['classid'] == 13)
  1346. {
  1347. $dj = $tc[$v]['title'];
  1348. }
  1349. else if($tc[$v]['classid'] == 8)
  1350. {
  1351. $ys = $tc[$v]['title'];
  1352. }
  1353. else if($tc[$v]['classid'] == 14)
  1354. {
  1355. $cc = $tc[$v]['title'];
  1356. }
  1357. else if($tc[$v]['classid'] == 15)
  1358. {
  1359. $hx = $tc[$v]['title'];
  1360. }
  1361. else if($tc[$v]['classid'] == 10)
  1362. {
  1363. $md = $tc[$v]['title'];
  1364. }
  1365. }
  1366. }
  1367. $rt = array();
  1368. foreach ($rk as $k=>$v)
  1369. {
  1370. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1371. }
  1372. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1373. foreach ($lzbm as $v)
  1374. {
  1375. if(isset($rt[count($fpdata[0])]))
  1376. {
  1377. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1378. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1379. if($num > 0){
  1380. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1381. }else{
  1382. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1383. }
  1384. }
  1385. else
  1386. {
  1387. $fpdata[0][count($fpdata[0])] = '';
  1388. }
  1389. }
  1390. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1391. unset($info_list[$key]['id']);
  1392. }
  1393. //echo "<pre>";print_r($info_list);exit;
  1394. $lzxq = '';
  1395. foreach ($lzbm as $v)
  1396. {
  1397. $lzxq .= '<td>'.$v['title'].'</td>';
  1398. }
  1399. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1400. $titlename = "<table border=1>
  1401. <tr>
  1402. <td>订单编号</td>
  1403. <td>品名</td>
  1404. <td>简码</td>
  1405. <td>备注</td>
  1406. <td>打印时间</td>
  1407. <td>
  1408. <table border=1>
  1409. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1410. <tr>
  1411. <td>产品名称</td>
  1412. <td>尺寸</td>
  1413. <td>等级</td>
  1414. <td>颜色</td>
  1415. <td>花型</td>
  1416. <td>密度</td>
  1417. ".$lzxq."
  1418. </tr>
  1419. </table>
  1420. </td>
  1421. </tr>
  1422. </table>";
  1423. $filename = $title.".xls";
  1424. $tail = "\n";
  1425. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1426. }
  1427. }
  1428. public function _rk()
  1429. {
  1430. $post = $this->input->post(NULL, TRUE);
  1431. if(isset($post['page']))
  1432. {
  1433. $api = $this->input->post('api',true);
  1434. $page = $this->input->post('page',true);
  1435. $perpage = $this->input->post('perpage',true);
  1436. $number = $this->input->post('number',true);
  1437. $color = $this->input->post('color',true);
  1438. $purchase = $this->input->post('purchase',true);
  1439. $transfer = $this->input->post('transfer',true);
  1440. $lx = $this->input->post('lx',true);
  1441. $timetk = $this->input->post('timetk',true);
  1442. $timetj = $this->input->post('timetj',true);
  1443. $timetk = strtotime($timetk);
  1444. $timetj = strtotime($timetj);
  1445. $where = "1=1";
  1446. if($transfer)
  1447. {
  1448. $ctime = 'ctime'.$transfer;
  1449. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1450. }
  1451. else
  1452. {
  1453. $where .= " and time > '$timetk' and time < '$timetj'";
  1454. }
  1455. if($number)
  1456. {
  1457. $where .= " and number = '$number'";
  1458. }
  1459. if($transfer)
  1460. {
  1461. $where .= " and rk like '%|".$transfer."|%'";
  1462. }
  1463. if($purchase)
  1464. {
  1465. $where .= " and purchase = '$purchase'";
  1466. }
  1467. if($color)
  1468. {
  1469. $where .= " and fpdata like '%-".$color."-%'";
  1470. }
  1471. if($lx)
  1472. {
  1473. if($lx == 1)
  1474. {
  1475. $where .= " and ordernumber = ''";
  1476. }
  1477. else
  1478. {
  1479. $where .= " and ordernumber != ''";
  1480. }
  1481. }
  1482. //数据排序
  1483. $order_str = "id desc";
  1484. if(empty($page))
  1485. {
  1486. $start = 0;
  1487. $perpage = 1;
  1488. }
  1489. else
  1490. {
  1491. $start = ($page - 1)*$perpage;
  1492. }
  1493. //取得信息列表
  1494. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1495. $transfer = $this->transfer->find_all();
  1496. $t = array();
  1497. foreach ($transfer as $v)
  1498. {
  1499. $t[$v['id']] = $v['title'];
  1500. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1501. }
  1502. //格式化数据
  1503. foreach ($info_list as $key=>$value)
  1504. {
  1505. $dd = $this->systemtransfer->read($value['id']);
  1506. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1507. $rk = explode('|',trim($dd['rk'],'|'));
  1508. $rktime = explode('|',trim($dd['rktime'],'|'));
  1509. $ck = explode('|',trim($dd['ck'],'|'));
  1510. $cktime = explode('|',trim($dd['cktime'],'|'));
  1511. $info_list[$key]['time'] = '';
  1512. for($i=0;$i<count($rk);$i++)
  1513. {
  1514. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1515. {
  1516. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1517. }
  1518. else
  1519. {
  1520. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1521. }
  1522. $info_list[$key]['time'] .= $d;
  1523. if(isset($ck[$i]) && $ck[$i] != '')
  1524. {
  1525. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1526. }
  1527. }
  1528. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1529. }
  1530. $total = $this->systemtransfer->find_count($where);
  1531. $pagenum = ceil($total/$perpage);
  1532. $over = $total-($start+$perpage);
  1533. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1534. echo json_encode($rows);exit;
  1535. }
  1536. if(isset($_SESSION['api']))
  1537. {
  1538. $user = $this->user->get_api($_SESSION['api']);
  1539. $usp = $user;
  1540. $pid = "";$tid="";$sid="";$wid="";
  1541. $purchase = explode('|',trim($user['purchase'],'|'));
  1542. $transfer = explode('|',trim($user['transfer'],'|'));
  1543. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1544. foreach ($purchase as $value)
  1545. {
  1546. $pid .= " id = ".$value." or";
  1547. }
  1548. foreach ($transfer as $value)
  1549. {
  1550. $tid .= " id = ".$value." or";
  1551. }
  1552. foreach ($warehouse as $value)
  1553. {
  1554. $wid .= " id = ".$value." or";
  1555. }
  1556. }
  1557. else
  1558. {
  1559. header('Location: /');exit;
  1560. }
  1561. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1562. $this->data['transfer'] = $transfer;
  1563. $this->_Template('transfer_rk',$this->data);
  1564. }
  1565. public function _ck()
  1566. {
  1567. $post = $this->input->post(NULL, TRUE);
  1568. if(isset($post['page']))
  1569. {
  1570. $api = $this->input->post('api',true);
  1571. $page = $this->input->post('page',true);
  1572. $perpage = $this->input->post('perpage',true);
  1573. $number = $this->input->post('number',true);
  1574. $color = $this->input->post('color',true);
  1575. $purchase = $this->input->post('purchase',true);
  1576. $transfer = $this->input->post('transfer',true);
  1577. $lx = $this->input->post('lx',true);
  1578. $timetk = $this->input->post('timetk',true);
  1579. $timetj = $this->input->post('timetj',true);
  1580. $timetk = strtotime($timetk);
  1581. $timetj = strtotime($timetj);
  1582. $where = "1=1";
  1583. if($transfer)
  1584. {
  1585. $ctime = 'ctime'.$transfer;
  1586. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1587. }
  1588. else
  1589. {
  1590. $where .= " and time > '$timetk' and time < '$timetj'";
  1591. }
  1592. if($number)
  1593. {
  1594. $where .= " and number = '$number'";
  1595. }
  1596. if($transfer)
  1597. {
  1598. $where .= " and ck like '%|".$transfer."|%'";
  1599. }
  1600. if($purchase)
  1601. {
  1602. $where .= " and purchase = '$purchase'";
  1603. }
  1604. if($color)
  1605. {
  1606. $where .= " and fpdata like '%-".$color."-%'";
  1607. }
  1608. if($lx)
  1609. {
  1610. if($lx == 1)
  1611. {
  1612. $where .= " and ordernumber = ''";
  1613. }
  1614. else
  1615. {
  1616. $where .= " and ordernumber != ''";
  1617. }
  1618. }
  1619. //数据排序
  1620. $order_str = "id desc";
  1621. if(empty($page))
  1622. {
  1623. $start = 0;
  1624. $perpage = 1;
  1625. }
  1626. else
  1627. {
  1628. $start = ($page - 1)*$perpage;
  1629. }
  1630. //取得信息列表
  1631. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1632. $transfer = $this->transfer->find_all();
  1633. $t = array();
  1634. foreach ($transfer as $v)
  1635. {
  1636. $t[$v['id']] = $v['title'];
  1637. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1638. }
  1639. //格式化数据
  1640. foreach ($info_list as $key=>$value)
  1641. {
  1642. $dd = $this->systemtransfer->read($value['id']);
  1643. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1644. $rk = explode('|',trim($dd['rk'],'|'));
  1645. $rktime = explode('|',trim($dd['rktime'],'|'));
  1646. $ck = explode('|',trim($dd['ck'],'|'));
  1647. $cktime = explode('|',trim($dd['cktime'],'|'));
  1648. $info_list[$key]['time'] = '';
  1649. for($i=0;$i<count($rk);$i++)
  1650. {
  1651. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1652. {
  1653. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1654. }
  1655. else
  1656. {
  1657. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1658. }
  1659. $info_list[$key]['time'] .= $d;
  1660. if(isset($ck[$i]) && $ck[$i] != '')
  1661. {
  1662. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1663. }
  1664. }
  1665. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1666. }
  1667. $total = $this->systemtransfer->find_count($where);
  1668. $pagenum = ceil($total/$perpage);
  1669. $over = $total-($start+$perpage);
  1670. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1671. echo json_encode($rows);exit;
  1672. }
  1673. if(isset($_SESSION['api']))
  1674. {
  1675. $user = $this->user->get_api($_SESSION['api']);
  1676. $usp = $user;
  1677. $pid = "";$tid="";$sid="";$wid="";
  1678. $purchase = explode('|',trim($user['purchase'],'|'));
  1679. $transfer = explode('|',trim($user['transfer'],'|'));
  1680. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1681. foreach ($purchase as $value)
  1682. {
  1683. $pid .= " id = ".$value." or";
  1684. }
  1685. foreach ($transfer as $value)
  1686. {
  1687. $tid .= " id = ".$value." or";
  1688. }
  1689. foreach ($warehouse as $value)
  1690. {
  1691. $wid .= " id = ".$value." or";
  1692. }
  1693. }
  1694. else
  1695. {
  1696. header('Location: /');exit;
  1697. }
  1698. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1699. $this->data['transfer'] = $transfer;
  1700. $this->_Template('transfer_ck',$this->data);
  1701. }
  1702. public function _jgl()
  1703. {
  1704. $post = $this->input->post(NULL, TRUE);
  1705. if(isset($post['printtime']))
  1706. {
  1707. $pt = $this->input->post('printtime',true);
  1708. $wt = $this->input->post('wgtime',true);
  1709. $printtime = strtotime($pt);
  1710. $wgtime = strtotime($wt);
  1711. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1712. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1713. if($printtime == $wgtime || $printtime > $wgtime)
  1714. {
  1715. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1716. }
  1717. 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;
  1718. }
  1719. $this->_Template('transfer_wgl',$this->data);
  1720. }
  1721. public function _linqi(){
  1722. $post = $this->input->post(NULL, TRUE);
  1723. if(isset($post['page']))
  1724. {
  1725. $api = $this->input->post('api',true);
  1726. $page = $this->input->post('page',true);
  1727. $perpage = $this->input->post('perpage',true);
  1728. $transfer = $this->input->post('transfer',true);
  1729. $transfer_ids = $this->input->post('transfer_ids',true);
  1730. $orver_flag = $this->input->post('orver_flag',true);
  1731. $timetk = $this->input->post('timetk',true);
  1732. $timetj = $this->input->post('timetj',true);
  1733. $timetk = strtotime($timetk);
  1734. $timetj = strtotime($timetj);
  1735. $transfer_list = $this->transfer->find_all();
  1736. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1737. $where = 'type = 1 ';
  1738. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1739. //数据排序
  1740. $order_str = "id desc";
  1741. if(empty($page))
  1742. {
  1743. $start = 0;
  1744. $perpage = 1;
  1745. }
  1746. else
  1747. {
  1748. $start = ($page - 1)*$perpage;
  1749. }
  1750. if($transfer){
  1751. $where .= " and lx = '$transfer'";
  1752. }else{
  1753. $where .= " and lx in (".$transfer_ids.") ";
  1754. }
  1755. $where .= " and time > '$timetk' and time < '$timetj'";
  1756. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1757. $final_list = [];
  1758. foreach ($list as $key => $value) {
  1759. $info = $this->systemtransfer->read($value['fid']);
  1760. $final_list[$key]['id'] = $value['id'];
  1761. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1762. if($info['is_jiaji'] == 2){
  1763. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1764. }else{
  1765. $final_list[$key]['is_jiaji'] = "常规";
  1766. }
  1767. $final_list[$key]['pm'] = $info['pm'];
  1768. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1769. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1770. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1771. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1772. foreach ($data as $k=>$v)
  1773. {
  1774. $type = ($v['type']==1)?'入库':'出库';
  1775. if($v['orver_flag'] == 1){
  1776. if($v['is_over'] == 0){
  1777. $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>';
  1778. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1779. }else{
  1780. $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>';
  1781. }
  1782. }elseif($v['orver_flag'] == 2){
  1783. $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>';
  1784. }else{
  1785. $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>';
  1786. }
  1787. }
  1788. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1789. }
  1790. $total = $this->systemtransfer_cr->find_count($where);
  1791. $pagenum = ceil($total/$perpage);
  1792. $over = $total-($start+$perpage);
  1793. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1794. echo json_encode($rows);exit;
  1795. }
  1796. if(isset($_SESSION['api']))
  1797. {
  1798. $user = $this->user->get_api($_SESSION['api']);
  1799. $usp = $user;
  1800. $pid = "";$tid="";$sid="";$wid="";
  1801. $purchase = explode('|',trim($user['purchase'],'|'));
  1802. $transfer = explode('|',trim($user['transfer'],'|'));
  1803. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1804. foreach ($purchase as $value)
  1805. {
  1806. $pid .= " id = ".$value." or";
  1807. }
  1808. foreach ($transfer as $value)
  1809. {
  1810. $tid .= " id = ".$value." or";
  1811. }
  1812. foreach ($warehouse as $value)
  1813. {
  1814. $wid .= " id = ".$value." or";
  1815. }
  1816. }
  1817. else
  1818. {
  1819. header('Location: /');exit;
  1820. }
  1821. $kx = '';$zjtab = '';
  1822. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1823. $this->data['transfer'] = $transfer;
  1824. $transfer_ids = array_column($transfer, 'id');
  1825. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1826. $this->data['vip'] = $user['vip'];
  1827. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1828. $this->_Template('transfer_linqi',$this->data);
  1829. }
  1830. //按照条件导出超时车间
  1831. public function _overtime_export(){
  1832. $transfer_id = $this->input->get('transfer', TRUE);
  1833. $timetk = $this->input->get('timetk', TRUE);
  1834. $timetj = $this->input->get('timetj', TRUE);
  1835. $timetk = strtotime($timetk);
  1836. $timetj = strtotime($timetj);
  1837. if(isset($_SESSION['api']))
  1838. {
  1839. $user = $this->user->get_api($_SESSION['api']);
  1840. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1841. $tmp_transfer_list = $this->transfer->find_all();
  1842. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1843. }
  1844. else
  1845. {
  1846. header('Location: /');exit;
  1847. }
  1848. $where = " orver_flag = 2 and type = 1";
  1849. if(empty($transfer_id)){
  1850. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1851. }else{
  1852. $where .= " and lx = ".$transfer_id." ";
  1853. }
  1854. $where .= " and time > '$timetk' and time < '$timetj'";
  1855. $list = $this->systemtransfer_cr->find_all($where,'*');
  1856. $fid_list = array_column($list, 'fid');
  1857. if(empty($fid_list)){
  1858. echo "没有数据" ;
  1859. die ;
  1860. }
  1861. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  1862. $where_two = " orver_flag = 2 and type = 2";
  1863. if(empty($transfer_id)){
  1864. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  1865. }else{
  1866. $where_two .= " and lx = ".$transfer_id." ";
  1867. }
  1868. $where_two .= " and time > '$timetk' and time < '$timetj'";
  1869. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  1870. $final_list = [];
  1871. // foreach($list as $k => $v){
  1872. // $final_list[$v['fid']]['fid'] = $v['fid'];
  1873. // $final_list[$v['fid']]['lx'] = $v['lx'];
  1874. // $final_list[$v['fid']]['start_type'] = $v['type'];
  1875. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  1876. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  1877. // $final_list[$v['fid']]['end_time'] = "";
  1878. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  1879. // }
  1880. // foreach($order_list as $k=>$v){
  1881. // if(isset($final_list[$v['id']])){
  1882. // $final_list[$v['id']]['number'] = $v['number'];
  1883. // $final_list[$v['id']]['pm'] = $v['pm'];
  1884. // }
  1885. // }
  1886. // foreach($list_two as $k => $v){
  1887. // if(isset($final_list[$v['fid']])){
  1888. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  1889. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  1890. // }
  1891. // }
  1892. // }
  1893. foreach($list as $k => $v){
  1894. $final_list[] = [
  1895. 'fid' => $v['fid'],
  1896. 'lx' => $v['lx'],
  1897. 'start_type' => $v['type'],
  1898. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  1899. 'condition' => json_decode($v['limit_time_str'],true),
  1900. 'end_time' => "",
  1901. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  1902. ];
  1903. }
  1904. foreach($order_list as $k=>$v){
  1905. foreach($final_list as $kk => $vv){
  1906. if($v['id'] == $vv['fid']){
  1907. $final_list[$kk]['number'] = $v['number'];
  1908. $final_list[$kk]['pm'] = $v['pm'];
  1909. }
  1910. }
  1911. }
  1912. foreach($list_two as $k => $v){
  1913. foreach($final_list as $kk => $vv){
  1914. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  1915. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  1916. }
  1917. }
  1918. }
  1919. $filename = date("Y-m-d")."超时单导出.xls";
  1920. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1921. <head>
  1922. <!--[if gte mso 9]><xml>
  1923. <x:ExcelWorkbook>
  1924. <x:ExcelWorksheets>
  1925. <x:ExcelWorksheet>
  1926. <x:Name>EXCEL</x:Name>
  1927. <x:WorksheetOptions>
  1928. <x:Print>
  1929. <x:ValidPrinterInfo />
  1930. </x:Print>
  1931. </x:WorksheetOptions>
  1932. </x:ExcelWorksheet>
  1933. </x:ExcelWorksheets>
  1934. </x:ExcelWorkbook>
  1935. </xml>
  1936. <![endif]-->
  1937. </head><body>";
  1938. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  1939. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  1940. foreach ($final_list as $key=>$value)
  1941. {
  1942. if(empty($value['number'])){
  1943. continue;
  1944. }
  1945. $str .= "<tr>";
  1946. $str .= "<td>". $value['number']. "</td>";
  1947. $str .= "<td>". $value['pm']. "</td>";
  1948. $str .= "<td>". $value['lx_name']. "</td>";
  1949. $str .= "<td>". $value['start_time']. "</td>";
  1950. $str .= "<td>". $value['end_time']. "</td>";
  1951. $str .= "</tr>";
  1952. }
  1953. $str .= "</table></body></html>";
  1954. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1955. header( "Content-type: application/octet-stream" );
  1956. header( "Content-Disposition: attachment; filename=".$filename );
  1957. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1958. header( "Pragma: no-cache" );
  1959. header( "Expires: 0" );
  1960. exit($str);
  1961. }
  1962. public function _jiaji(){
  1963. $post = $this->input->post(NULL, TRUE);
  1964. if(isset($post['page']))
  1965. {
  1966. $api = $this->input->post('api',true);
  1967. $page = $this->input->post('page',true);
  1968. $perpage = $this->input->post('perpage',true);
  1969. $transfer = $this->input->post('transfer',true);
  1970. $transfer_ids = $this->input->post('transfer_ids',true);
  1971. $orver_flag = $this->input->post('orver_flag',true);
  1972. $timetk = $this->input->post('timetk',true);
  1973. $timetj = $this->input->post('timetj',true);
  1974. $timetk = strtotime($timetk);
  1975. $timetj = strtotime($timetj);
  1976. $transfer_list = $this->transfer->find_all();
  1977. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1978. if(isset($_SESSION['api']))
  1979. {
  1980. $user = $this->user->get_api($_SESSION['api']);
  1981. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1982. }
  1983. else
  1984. {
  1985. $transfer_ids = array_keys($t);
  1986. }
  1987. if(empty($page))
  1988. {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. }
  1992. else
  1993. {
  1994. $start = ($page - 1)*$perpage;
  1995. }
  1996. $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." ";
  1997. if($transfer){
  1998. $sql_r .= " and c.lx = ".$transfer." ";
  1999. }else{
  2000. foreach($transfer_ids as $k=>$v){
  2001. if($v == 11){
  2002. unset($transfer_ids[$k]);
  2003. }
  2004. }
  2005. $transfer_str = implode(",",$transfer_ids);
  2006. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2007. }
  2008. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2009. $rows_r = $this->db->query($sql_r);
  2010. $get_list = $rows_r->result_array();
  2011. $total = count($get_list);
  2012. $split_list = array_chunk($get_list,$perpage);
  2013. $pagenum = ceil(count($split_list));
  2014. $key = $page - 1;
  2015. $list = isset($split_list[$key])?$split_list[$key]:[];
  2016. $final_list = [];
  2017. foreach ($list as $key => $value) {
  2018. $final_list[$key]['id'] = $value['id'];
  2019. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2020. if($value['is_jiaji'] == 2){
  2021. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2022. }else{
  2023. $final_list[$key]['is_jiaji'] = "常规";
  2024. }
  2025. $final_list[$key]['pm'] = $value['pm'];
  2026. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2027. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2028. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2029. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2030. foreach ($data as $k=>$v)
  2031. {
  2032. $type = ($v['type']==1)?'入库':'出库';
  2033. if($v['orver_flag'] == 1){
  2034. if($v['is_over'] == 0){
  2035. $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>';
  2036. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2037. }else{
  2038. $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>';
  2039. }
  2040. }elseif($v['orver_flag'] == 2){
  2041. $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>';
  2042. }else{
  2043. $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>';
  2044. }
  2045. }
  2046. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2047. }
  2048. $over = $total-($start+$perpage);
  2049. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2050. echo json_encode($rows);exit;
  2051. }
  2052. if(isset($_SESSION['api']))
  2053. {
  2054. $user = $this->user->get_api($_SESSION['api']);
  2055. $usp = $user;
  2056. $pid = "";$tid="";$sid="";$wid="";
  2057. $purchase = explode('|',trim($user['purchase'],'|'));
  2058. $transfer = explode('|',trim($user['transfer'],'|'));
  2059. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2060. foreach ($purchase as $value)
  2061. {
  2062. $pid .= " id = ".$value." or";
  2063. }
  2064. foreach ($transfer as $value)
  2065. {
  2066. if($value){
  2067. if($value != 11){
  2068. $tid .= " id = ".$value." or";
  2069. }
  2070. }
  2071. }
  2072. foreach ($warehouse as $value)
  2073. {
  2074. $wid .= " id = ".$value." or";
  2075. }
  2076. }
  2077. else
  2078. {
  2079. header('Location: /');exit;
  2080. }
  2081. $kx = '';$zjtab = '';
  2082. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2083. $this->data['transfer'] = $transfer;
  2084. $transfer_ids = array_column($transfer, 'id');
  2085. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2086. $this->data['vip'] = $user['vip'];
  2087. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2088. $this->_Template('transfer_jiaji',$this->data);
  2089. }
  2090. public function _scz(){
  2091. $post = $this->input->post(NULL, TRUE);
  2092. if(isset($post['page']))
  2093. {
  2094. $page = $this->input->post('page',true);
  2095. $perpage = $this->input->post('perpage',true);
  2096. $transfer = $this->input->post('transfer',true);
  2097. $transfer_ids = $this->input->post('transfer_ids',true);
  2098. $timetk = $this->input->post('timetk',true);
  2099. $timetj = $this->input->post('timetj',true);
  2100. $timetk = strtotime($timetk);
  2101. $timetj = strtotime($timetj);
  2102. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2103. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2104. // $transfer_ids = array_keys($t);
  2105. if(empty($page))
  2106. {
  2107. $start = 0;
  2108. $perpage = 1;
  2109. }
  2110. else
  2111. {
  2112. $start = ($page - 1)*$perpage;
  2113. }
  2114. $where = "time > '$timetk' and time < '$timetj'";
  2115. $where .= " and rk not like '%11|' ";
  2116. if(!empty($transfer)){
  2117. $where .= " and rk like '%|".$transfer."|%' ";
  2118. }
  2119. // if($transfer)
  2120. // {
  2121. // $cr .= " and lx = '".$transfer."' ";
  2122. // }else{
  2123. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2124. // }
  2125. // $cr .= " and is_over = 0 ";
  2126. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2127. // $fid = [];
  2128. // foreach ($info_list_cr as $v)
  2129. // {
  2130. // $fid[] = $v['fid'];
  2131. // }
  2132. // if(empty($fid)){
  2133. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2134. // echo json_encode($rows);exit;
  2135. // }
  2136. // $fid = array_unique($fid);
  2137. $order_str = "id desc";
  2138. //取得信息列表
  2139. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2140. $transfer = $this->transfer->find_all();
  2141. $t = array();
  2142. foreach ($transfer as $v)
  2143. {
  2144. $t[$v['id']] = $v['title'];
  2145. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2146. }
  2147. //格式化数据
  2148. foreach ($info_list as $key=>$value)
  2149. {
  2150. if($value['is_jiaji'] == 2){
  2151. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2152. }else{
  2153. $info_list[$key]['is_jiaji'] = "常规";
  2154. }
  2155. $dd = $this->systemtransfer->read($value['id']);
  2156. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2157. $rk = explode('|',trim($dd['rk'],'|'));
  2158. $rktime = explode('|',trim($dd['rktime'],'|'));
  2159. $ck = explode('|',trim($dd['ck'],'|'));
  2160. $cktime = explode('|',trim($dd['cktime'],'|'));
  2161. $info_list[$key]['time'] = '';
  2162. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2163. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2164. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2165. foreach ($data as $k=>$v)
  2166. {
  2167. // $type = ($v['type']==1)?'入库':'出库';
  2168. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2169. $type = ($v['type']==1)?'入库':'出库';
  2170. if($v['orver_flag'] == 1){
  2171. if($v['is_over'] == 0){
  2172. $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>';
  2173. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2174. }else{
  2175. $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>';
  2176. }
  2177. }elseif($v['orver_flag'] == 2){
  2178. $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>';
  2179. }elseif($v['orver_flag'] == 3){
  2180. $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>';
  2181. }else{
  2182. $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>';
  2183. }
  2184. }
  2185. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2186. unset($info_list[$key]['ctime12']);
  2187. }
  2188. $total = $this->systemtransfer->find_count($where);
  2189. $pagenum = ceil($total/$perpage);
  2190. $over = $total-($start+$perpage);
  2191. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2192. echo json_encode($rows);exit;
  2193. }
  2194. if(isset($_SESSION['api']))
  2195. {
  2196. $user = $this->user->get_api($_SESSION['api']);
  2197. if(!in_array($user['id'],[10,44,50])){
  2198. exit('No direct script access allowed');
  2199. }
  2200. }
  2201. else
  2202. {
  2203. header('Location: /');exit;
  2204. }
  2205. $kx = '';$zjtab = '';
  2206. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2207. $this->data['transfer'] = $transfer;
  2208. $transfer_ids = array_column($transfer, 'id');
  2209. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2210. $this->_Template('transfer_scz',$this->data);
  2211. }
  2212. public function _sczexcel(){
  2213. $timetk = $this->input->get('timetk',true);
  2214. $timetj = $this->input->get('timetj',true);
  2215. $timetk = strtotime($timetk);
  2216. $timetj = strtotime($timetj);
  2217. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2218. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2219. // $transfer_ids = array_keys($t);
  2220. $where = "time > '$timetk' and time < '$timetj'";
  2221. $where .= " and rk not like '%11|' ";
  2222. if(!empty($transfer)){
  2223. $where .= " and rk like '%|".$transfer."|%' ";
  2224. }
  2225. $order_str = "id desc";
  2226. //取得信息列表
  2227. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2228. $transfer = $this->transfer->find_all();
  2229. $t = array();
  2230. foreach ($transfer as $v)
  2231. {
  2232. $t[$v['id']] = $v['title'];
  2233. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2234. }
  2235. //格式化数据
  2236. foreach ($info_list as $key=>$value)
  2237. {
  2238. if($value['is_jiaji'] == 2){
  2239. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2240. }else{
  2241. $info_list[$key]['is_jiaji'] = "常规";
  2242. }
  2243. $dd = $this->systemtransfer->read($value['id']);
  2244. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2245. $rk = explode('|',trim($dd['rk'],'|'));
  2246. $rktime = explode('|',trim($dd['rktime'],'|'));
  2247. $ck = explode('|',trim($dd['ck'],'|'));
  2248. $cktime = explode('|',trim($dd['cktime'],'|'));
  2249. $info_list[$key]['time'] = '';
  2250. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2251. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2252. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2253. foreach ($data as $k=>$v)
  2254. {
  2255. // $type = ($v['type']==1)?'入库':'出库';
  2256. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2257. $type = ($v['type']==1)?'入库':'出库';
  2258. if($v['orver_flag'] == 1){
  2259. if($v['is_over'] == 0){
  2260. $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>';
  2261. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2262. }else{
  2263. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2264. }
  2265. }elseif($v['orver_flag'] == 2){
  2266. $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>';
  2267. }elseif($v['orver_flag'] == 3){
  2268. $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>';
  2269. }else{
  2270. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2271. }
  2272. }
  2273. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2274. unset($info_list[$key]['ctime12']);
  2275. }
  2276. $filename = date("Y-m-d")."生产中订单.xls";
  2277. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2278. <head>
  2279. <!--[if gte mso 9]><xml>
  2280. <x:ExcelWorkbook>
  2281. <x:ExcelWorksheets>
  2282. <x:ExcelWorksheet>
  2283. <x:Name>EXCEL</x:Name>
  2284. <x:WorksheetOptions>
  2285. <x:Print>
  2286. <x:ValidPrinterInfo />
  2287. </x:Print>
  2288. </x:WorksheetOptions>
  2289. </x:ExcelWorksheet>
  2290. </x:ExcelWorksheets>
  2291. </x:ExcelWorkbook>
  2292. </xml>
  2293. <![endif]-->
  2294. </head><body>";
  2295. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2296. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2297. foreach ($info_list as $key=>$value)
  2298. {
  2299. $str .= "<tr>";
  2300. $str .= "<td>". $value['number']. "</td>";
  2301. $str .= "<td>". $value['is_jiaji']. "</td>";
  2302. $str .= "<td>". $value['pm']. "</td>";
  2303. $str .= "<td>". $value['shipremarks']. "</td>";
  2304. $str .= "<td>". $value['printtime']. "</td>";
  2305. $str .= "<td>". $value['time']. "</td>";
  2306. $str .= "</tr>";
  2307. }
  2308. $str .= "</table></body></html>";
  2309. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2310. header( "Content-type: application/octet-stream" );
  2311. header( "Content-Disposition: attachment; filename=".$filename );
  2312. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2313. header( "Pragma: no-cache" );
  2314. header( "Expires: 0" );
  2315. exit($str);
  2316. }
  2317. public function _wjsrk(){
  2318. $post = $this->input->post(NULL, TRUE);
  2319. if(isset($post['page']))
  2320. {
  2321. $api = $this->input->post('api',true);
  2322. $page = $this->input->post('page',true);
  2323. $perpage = $this->input->post('perpage',true);
  2324. $transfer = $this->input->post('transfer',true);
  2325. $transfer_ids = $this->input->post('transfer_ids',true);
  2326. $orver_flag = $this->input->post('orver_flag',true);
  2327. $timetk = $this->input->post('timetk',true);
  2328. $timetj = $this->input->post('timetj',true);
  2329. $timetk = strtotime($timetk);
  2330. $timetj = strtotime($timetj);
  2331. $transfer_list = $this->transfer->find_all();
  2332. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2333. $where = 'extra_status = 1 or extra_status = 2';
  2334. //数据排序
  2335. $order_str = "id desc";
  2336. if(empty($page))
  2337. {
  2338. $start = 0;
  2339. $perpage = 1;
  2340. }
  2341. else
  2342. {
  2343. $start = ($page - 1)*$perpage;
  2344. }
  2345. if($transfer){
  2346. $where .= " and lx = '$transfer'";
  2347. }else{
  2348. $where .= " and lx in (".$transfer_ids.") ";
  2349. }
  2350. $where .= " and time > '$timetk' and time < '$timetj'";
  2351. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2352. $final_list = [];
  2353. foreach ($list as $key => $value) {
  2354. $info = $this->systemtransfer->read($value['fid']);
  2355. $final_list[$key]['id'] = $value['id'];
  2356. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2357. if($info['is_jiaji'] == 2){
  2358. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2359. }else{
  2360. $final_list[$key]['is_jiaji'] = "常规";
  2361. }
  2362. $final_list[$key]['pm'] = $info['pm'];
  2363. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2364. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2365. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2366. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2367. foreach ($data as $k=>$v)
  2368. {
  2369. $type = ($v['type']==1)?'入库':'出库';
  2370. if($v['orver_flag'] == 1){
  2371. if($v['is_over'] == 0){
  2372. $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>";
  2373. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2374. }else{
  2375. $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>";
  2376. }
  2377. }elseif($v['orver_flag'] == 2){
  2378. $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>";
  2379. }else{
  2380. $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>";
  2381. }
  2382. if(in_array($v['extra_status'],[1,2])){
  2383. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2384. }else{
  2385. $info_list[$key]['time'] .= "<br>";
  2386. }
  2387. }
  2388. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2389. }
  2390. $total = $this->systemtransfer_cr->find_count($where);
  2391. $pagenum = ceil($total/$perpage);
  2392. $over = $total-($start+$perpage);
  2393. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2394. echo json_encode($rows);exit;
  2395. }
  2396. if(isset($_SESSION['api']))
  2397. {
  2398. $user = $this->user->get_api($_SESSION['api']);
  2399. $usp = $user;
  2400. $pid = "";$tid="";$sid="";$wid="";
  2401. $purchase = explode('|',trim($user['purchase'],'|'));
  2402. $transfer = explode('|',trim($user['transfer'],'|'));
  2403. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2404. foreach ($purchase as $value)
  2405. {
  2406. $pid .= " id = ".$value." or";
  2407. }
  2408. foreach ($transfer as $value)
  2409. {
  2410. $tid .= " id = ".$value." or";
  2411. }
  2412. foreach ($warehouse as $value)
  2413. {
  2414. $wid .= " id = ".$value." or";
  2415. }
  2416. }
  2417. else
  2418. {
  2419. header('Location: /');exit;
  2420. }
  2421. $kx = '';$zjtab = '';
  2422. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2423. $this->data['transfer'] = $transfer;
  2424. $transfer_ids = array_column($transfer, 'id');
  2425. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2426. $this->data['vip'] = $user['vip'];
  2427. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2428. $this->_Template('transfer_wjsrk',$this->data);
  2429. }
  2430. }