Transfer.php 81 KB

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