Transfer.php 95 KB

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