Transfer.php 97 KB

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