Transfer.php 81 KB

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