Transfer.php 92 KB

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