Transfer.php 81 KB

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