Transfer.php 76 KB

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