Transfer.php 81 KB

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