Whlabel_bh.php 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel_bh extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list');
  36. $this->load->_model('Model_whlabel','whlabel');
  37. $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
  38. $this->load->_model('Model_transfer','transfer');
  39. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  40. $this->load->_model("Model_logic_ding","logic_ding");
  41. $this->load->_model("Model_apiyyv1","apiyyv1");
  42. $this->load->_model('Model_settingtest','settingtest');
  43. $this->load->_model("Model_whlabel_bh_transfer_cr","whlabel_bh_transfer_cr");
  44. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg,$arg_array)
  48. {
  49. if($arg == 'add')
  50. {
  51. $this->_add();
  52. }
  53. else if($arg == 'edit')
  54. {
  55. $this->_edit($arg_array);
  56. }
  57. else if($arg == 'del')//删除
  58. {
  59. $this->_del();
  60. }
  61. else if($arg == 'deltransfer')//删除
  62. {
  63. $this->_deltransfer();
  64. }
  65. else if($arg == 'cz')//删除
  66. {
  67. $this->_cz();
  68. }
  69. else if($arg == 'db')//删除
  70. {
  71. $this->_db();
  72. }
  73. else if($arg == 'kc')//删除
  74. {
  75. $this->_kc();
  76. }
  77. else if($arg == 'excel')//删除
  78. {
  79. $this->_excel();
  80. }
  81. else if($arg == 'xxpl')//删除
  82. {
  83. $this->_xxpl();
  84. }
  85. else if($arg == 'bbprint')//删除
  86. {
  87. $this->_bbprint();
  88. }
  89. else if($arg == 'operate')
  90. {
  91. $this->_operate();
  92. }
  93. else if($arg == 'out')
  94. {
  95. $this->_out();
  96. }
  97. else if($arg == 'bdbb')
  98. {
  99. $this->_bdbb();
  100. }
  101. else if($arg == 'rk')
  102. {
  103. $this->_rk();
  104. }
  105. else if($arg == 'ck')
  106. {
  107. $this->_ck();
  108. }
  109. else if($arg == 'ck')
  110. {
  111. $this->_ck();
  112. }
  113. else if($arg == 'transfer_log'){
  114. $this->_transfer_log();
  115. }
  116. else if($arg == 'transfer_detail'){
  117. $this->_transfer_detail($arg_array);
  118. }
  119. else if($arg == 'cj_transfer_log'){
  120. $this->_cj_transfer_log();
  121. }
  122. else if($arg == 'cj_transfer_zklog'){
  123. $this->_cj_transfer_zklog();
  124. }
  125. else if($arg == 'cj_transfer_detail'){
  126. $this->_cj_transfer_detail($arg_array);
  127. }
  128. else if($arg == 'cj_transfer_log_count'){
  129. $this->_cj_transfer_log_count();
  130. }
  131. else if($arg == 'excelwchz'){
  132. $this->_excelwchz();
  133. }
  134. else if($arg == 'wdyindex'){
  135. $this->_wdyindex();
  136. }
  137. else if($arg == 'edit_jgtime'){
  138. $this->_edit_jgtime();
  139. }else if($arg == 'excelcpkhz'){
  140. $this->_excelcpkhz();
  141. }
  142. else
  143. {
  144. $this->_index();
  145. }
  146. }
  147. //管理
  148. public function _index()
  149. {
  150. $post = $this->input->post(NULL, TRUE);
  151. if(isset($post['page']))
  152. {
  153. $page = $this->input->post('page',true);
  154. $perpage = $this->input->post('perpage',true);
  155. $orderinfo = $this->input->post('orderinfo',true);
  156. $jm = $this->input->post('jm',true);
  157. $title = $this->input->post('title',true);
  158. $pm = $this->input->post('pm',true);
  159. $category = $this->input->post('category',true);
  160. $size = $this->input->post('size',true);
  161. $grade = $this->input->post('grade',true);
  162. $color = $this->input->post('color',true);
  163. $lowe = $this->input->post('lowe',true);
  164. $type = $this->input->post('type',true);
  165. $shipremarks = $this->input->post('shipremarks',true);
  166. $type = $this->input->post('type',true);
  167. $state = $this->input->post('state',true);
  168. $timetk = $this->input->post('timetk',true);
  169. $timetj = $this->input->post('timetj',true);
  170. $timetk = strtotime($timetk);
  171. $timetj = strtotime($timetj);
  172. $where = "1=1 ";
  173. if($timetk && $timetj)
  174. {
  175. $where .= " and time > '$timetk' and time < '$timetj'";
  176. }
  177. if($orderinfo)
  178. {
  179. $where .= " and orderinfo like '%$orderinfo%'";
  180. }
  181. if($type != '')
  182. {
  183. $where .= " and type = '$type'";
  184. }
  185. if($jm)
  186. {
  187. $where .= " and jm like '%$jm%'";
  188. }
  189. if($title)
  190. {
  191. $where .= " and title like '%$title%'";
  192. }
  193. if($pm)
  194. {
  195. $where .= " and pm like '%$pm%'";
  196. }
  197. if($category)
  198. {
  199. $where .= " and shipremarks like '%-$category-%'";
  200. }
  201. if($size)
  202. {
  203. $where .= " and shipremarks like '%-$size-%'";
  204. }
  205. if($grade)
  206. {
  207. $where .= " and shipremarks like '%-$grade-%'";
  208. }
  209. if($color)
  210. {
  211. $where .= " and shipremarks like '%-$color-%'";
  212. }
  213. if($lowe)
  214. {
  215. $where .= " and shipremarks like '%-$lowe-%'";
  216. }
  217. if($type)
  218. {
  219. $where .= " and type = '$type'";
  220. }
  221. if($state)
  222. {
  223. $where .= " and state = '$state'";
  224. }
  225. if($shipremarks)
  226. {
  227. $where .= " and shipremarks like '%$shipremarks%'";
  228. }
  229. //数据排序
  230. $order_str = "time desc";
  231. if(empty($page))
  232. {
  233. $start = 0;
  234. $perpage = 1;
  235. }
  236. else
  237. {
  238. $start = ($page - 1)*$perpage;
  239. }
  240. $warehouse = $this->warehouse->find_all();
  241. $ck = array();
  242. foreach ($warehouse as $v)
  243. {
  244. $ck[$v['id']] = $v['title'];
  245. }
  246. //取得信息列表
  247. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,printsl,time,extra_type',$order_str,$start,$perpage);
  248. foreach ($info_list as $key=>$value)
  249. {
  250. $d = $this->whlabel_bh->read($value['id']);
  251. $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  252. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  253. $printnum = array_sum(array_column($printnum,'ts'));
  254. $info_list[$key]['printnum'] = $printnum;
  255. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  256. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  257. if($value['extra_type'] == 1){
  258. $info_list[$key]['extra_type'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  259. }else{
  260. $info_list[$key]['extra_type'] = "";
  261. }
  262. }
  263. $total = $this->whlabel_bh->find_count($where);
  264. $pagenum = ceil($total/$perpage);
  265. $over = $total-($start+$perpage);
  266. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  267. echo json_encode($rows);exit;
  268. /**
  269. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage);
  270. foreach ($info_list as $key=>$value)
  271. {
  272. $d = $this->whlabel_bh->read($value['id']);
  273. if($d['print'] == 0)
  274. {
  275. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  276. }
  277. else
  278. {
  279. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  280. }
  281. if($value['state'] == 0)
  282. {
  283. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  284. }
  285. else if($value['state'] == 1)
  286. {
  287. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  288. }
  289. else if($value['state'] == 2)
  290. {
  291. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  292. }
  293. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  294. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  295. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  296. $zc = '';
  297. foreach ($zd as $v)
  298. {
  299. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  300. }
  301. $info_list[$key]['scapi'] = $zc;
  302. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  303. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  304. }
  305. **/
  306. }
  307. $start_time = time() - 3600*24*29;
  308. $end_time = time() + 3600*24;
  309. $count_list = $this->whlabel_bh->find_all("extra_type = 1 and time > ".$start_time." and time < ".$end_time);
  310. $wdysl = 0;
  311. foreach($count_list as $k=>$v){
  312. $wdysl = $wdysl + ($v['bhnum'] - $v['printsl']);
  313. }
  314. $this->data['wdysl'] = $wdysl;
  315. if(isset($_SESSION['api']))
  316. {
  317. $user = $this->user->get_api($_SESSION['api']);
  318. }
  319. else
  320. {
  321. header('Location: /');exit;
  322. }
  323. $w = $this->shop->find_all("yyid != ''");
  324. $this->data['yyck'] = $w;
  325. if($user['userid'] == 'ch')
  326. {
  327. $user['vip'] = 1;
  328. }
  329. $this->data['vip'] = $user['vip'];
  330. $this->_Template('whlabel_bh',$this->data);
  331. }
  332. public function _wdyindex(){
  333. $post = $this->input->post(NULL, TRUE);
  334. if(isset($post['page']))
  335. {
  336. $page = $this->input->post('page',true);
  337. $perpage = $this->input->post('perpage',true);
  338. $orderinfo = $this->input->post('orderinfo',true);
  339. $jm = $this->input->post('jm',true);
  340. $title = $this->input->post('title',true);
  341. $pm = $this->input->post('pm',true);
  342. $category = $this->input->post('category',true);
  343. $size = $this->input->post('size',true);
  344. $grade = $this->input->post('grade',true);
  345. $color = $this->input->post('color',true);
  346. $lowe = $this->input->post('lowe',true);
  347. $type = $this->input->post('type',true);
  348. $shipremarks = $this->input->post('shipremarks',true);
  349. $timetk = $this->input->post('timetk',true);
  350. $timetj = $this->input->post('timetj',true);
  351. $timetk = strtotime($timetk);
  352. $timetj = strtotime($timetj);
  353. $where = " bhnum > printsl and extra_type = 1 ";
  354. if($timetk && $timetj)
  355. {
  356. $where .= " and time > '$timetk' and time < '$timetj'";
  357. }
  358. if($orderinfo)
  359. {
  360. $where .= " and orderinfo like '%$orderinfo%'";
  361. }
  362. if($jm)
  363. {
  364. $where .= " and jm like '%$jm%'";
  365. }
  366. if($title)
  367. {
  368. $where .= " and title like '%$title%'";
  369. }
  370. if($pm)
  371. {
  372. $where .= " and pm like '%$pm%'";
  373. }
  374. if($category)
  375. {
  376. $where .= " and features like '%-$category-%'";
  377. }
  378. if($size)
  379. {
  380. $where .= " and features like '%-$size-%'";
  381. }
  382. if($grade)
  383. {
  384. $where .= " and features like '%-$grade-%'";
  385. }
  386. if($color)
  387. {
  388. $where .= " and features like '%-$color-%'";
  389. }
  390. if($lowe)
  391. {
  392. $where .= " and features like '%-$lowe-%'";
  393. }
  394. if($type)
  395. {
  396. $where .= " and type = '$type'";
  397. }
  398. if($shipremarks)
  399. {
  400. $where .= " and shipremarks like '%$shipremarks%'";
  401. }
  402. //数据排序
  403. $order_str = "time desc";
  404. if(empty($page))
  405. {
  406. $start = 0;
  407. $perpage = 1;
  408. }
  409. else
  410. {
  411. $start = ($page - 1)*$perpage;
  412. }
  413. //取得信息列表
  414. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,printsl,time,extra_type',$order_str,$start,$perpage);
  415. foreach ($info_list as $key=>$value)
  416. {
  417. $d = $this->whlabel_bh->read($value['id']);
  418. $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  419. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  420. $printnum = array_sum(array_column($printnum,'ts'));
  421. $info_list[$key]['printnum'] = $printnum;
  422. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  423. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  424. if($value['extra_type'] == 1){
  425. if(($value['bhnum']-$printnum > 0) && ($value['printsl'] < $value['bhnum'])){
  426. $info_list[$key]['extra_type'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  427. }else{
  428. $info_list[$key]['extra_type'] = "";
  429. }
  430. }else{
  431. $info_list[$key]['extra_type'] = "";
  432. }
  433. }
  434. $total = $this->whlabel_bh->find_count($where);
  435. $pagenum = ceil($total/$perpage);
  436. $over = $total-($start+$perpage);
  437. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  438. echo json_encode($rows);exit;
  439. }
  440. if(isset($_SESSION['api']))
  441. {
  442. $user = $this->user->get_api($_SESSION['api']);
  443. }
  444. else
  445. {
  446. header('Location: /');exit;
  447. }
  448. $this->_Template('whlabel_bhwdy',$this->data);
  449. }
  450. //入库操作
  451. public function _add()
  452. {
  453. $tc = $this->typeclass->find_all();
  454. $typeclass = array();
  455. foreach ($tc as $v)
  456. {
  457. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  458. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  459. }
  460. $post = $this->input->post(NULL, TRUE);
  461. if(isset($post['num']))
  462. {
  463. $list = array();
  464. $sku = $this->input->post('sku',true);
  465. $category = $this->input->post('category',true);
  466. $list['category'] = $category;
  467. $list['hairtype'] = $this->input->post('hairtype',true);
  468. $list['grade'] = $this->input->post('grade',true);
  469. $size = $this->input->post('size',true);
  470. $xzsku = $this->input->post('xzsku',true);
  471. $list['size'] = rtrim($size,',');
  472. $list['hairnumber'] = $this->input->post('hairnumber',true);
  473. $list['extension'] = $this->input->post('extension',true);
  474. if($category == 1297)
  475. {
  476. $list['sywignumber'] = $this->input->post('sywignumber',true);
  477. }
  478. if($category == 1702)
  479. {
  480. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  481. $list['syother'] = $this->input->post('syother',true);
  482. }
  483. if($category == 133)
  484. {
  485. $list['fittype'] = $this->input->post('fittype',true);
  486. $list['acother'] = $this->input->post('acother',true);
  487. }
  488. $list['color'] = $this->input->post('color',true);
  489. $list['lowe'] = $this->input->post('lowe',true);
  490. if($category == 127)
  491. {
  492. $list['type'] = $this->input->post('type',true);
  493. $list['headroad'] = $this->input->post('headroad',true);
  494. $list['density'] = $this->input->post('density',true);
  495. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  496. {
  497. $list['lacesize'] = $this->input->post('lacesize',true);
  498. }
  499. $list['lacecolor'] = $this->input->post('lacecolor',true);
  500. $list['lacetypes'] = $this->input->post('lacetypes',true);
  501. }
  502. if($category == 128)
  503. {
  504. $list['lacetype'] = $this->input->post('lacetype',true);
  505. $list['haircap'] = $this->input->post('haircap',true);
  506. $list['density'] = $this->input->post('density',true);
  507. $list['lacecolor'] = $this->input->post('lacecolor',true);
  508. $list['lacetypes'] = $this->input->post('lacetypes',true);
  509. $list['wigother'] = $this->input->post('wigother',true);
  510. $list['wigother1'] = $this->input->post('wigother1',true);
  511. $list['wigother2'] = $this->input->post('wigother2',true);
  512. }
  513. if($category == 129)
  514. {
  515. $list['wide'] = $this->input->post('wide',true);
  516. }
  517. if($category == 131)
  518. {
  519. $list['gifttype'] = $this->input->post('gifttype',true);
  520. $list['giftother'] = $this->input->post('giftother',true);
  521. }
  522. if($category == 134)
  523. {
  524. $list['pieceweight'] = $this->input->post('pieceweight',true);
  525. }
  526. if($category == 1297)
  527. {
  528. $list['synthetictype'] = $this->input->post('synthetictype',true);
  529. $list['sywigother'] = $this->input->post('sywigother',true);
  530. }
  531. if($category == 130 || $category == 133 || $category == 1702)
  532. {
  533. $list['items'] = $this->input->post('items',true);
  534. $list['weight'] = $this->input->post('weight',true);
  535. }
  536. if($category == 1702)
  537. {
  538. $list['syhairther'] = $this->input->post('syhairther',true);
  539. }
  540. $classid = $this->classid->sku();
  541. $pm = $classid;
  542. $jm = $classid;
  543. $sku = $sku;
  544. $title = '';$features = '';$cs = array();
  545. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  546. foreach($list as $k=>$v)
  547. {
  548. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  549. {
  550. if($typeclass[$v]['bm'] != '')
  551. {
  552. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  553. }
  554. }
  555. if($v != 0)
  556. {
  557. if($k != 'size')
  558. {
  559. $title .= $typeclass[$v]['title']." ";
  560. }
  561. $features .=$v.'-';
  562. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  563. if(isset($pm[$typeclass[$v]['classid']]))
  564. {
  565. if($typeclass[$v]['title'] == '9A')
  566. {
  567. $pm[$typeclass[$v]['classid']] = '9A';
  568. }
  569. else if($typeclass[$v]['title'] == '10A')
  570. {
  571. $pm[$typeclass[$v]['classid']] = '10A';
  572. }
  573. else
  574. {
  575. $clzh = $typeclass[$v]['zh'];
  576. if(stripos($typeclass[$v]['zh'],'|') !== false)
  577. {
  578. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  579. $clzh = $clzh[0];
  580. }
  581. $pm[$typeclass[$v]['classid']] = $clzh;
  582. }
  583. }
  584. if(isset($jm[$typeclass[$v]['classid']]))
  585. {
  586. if($typeclass[$v]['jm'])
  587. {
  588. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  589. }
  590. }
  591. }
  592. }
  593. $jm = array_filter($jm);//去除空值
  594. $jm = implode("-",$jm);
  595. $sku = array_filter($sku);//去除空值
  596. $sku = implode("-",$sku);
  597. $pm = array_filter($pm);//去除空值
  598. $pm = implode(" ",$pm);
  599. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  600. if($list['size'])
  601. {
  602. $typeclass = $this->typeclass->read($list['size']);
  603. $title .= $typeclass['title'];
  604. }
  605. $title = trim($title,' ');
  606. $post['num'] = $this->input->post('num',true);
  607. $ztime = $this->input->post('ztime',true);
  608. $post['ztime'] = strtotime($ztime);
  609. $post['bm'] = '03'.implode("",$bmpx);
  610. $post['jm'] = $jm;
  611. $post['sku'] = $sku;
  612. $post['pm'] = $pm;
  613. $post['title'] = $title;
  614. $post['features'] = '-'.$features;
  615. $post['number'] = date('YmdHis',time()).rand(1000,9999);
  616. if(!$post['num'])
  617. {
  618. $post['number'] = date("YmdHis").rand(1000,9999);
  619. }
  620. $time = time();
  621. $post['time'] = $time;//操作时间
  622. $post['printnum'] = $time;
  623. $post['type'] = 0;
  624. $post['extra_type'] = (int)trim($post['extra_type'],',');
  625. //传输料号开始
  626. $lc = 0;
  627. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  628. if(isset($lh['Data'][0]))
  629. {
  630. if($lh['Data'][0]['m_isSucess'] != 1)
  631. {
  632. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  633. {
  634. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  635. }
  636. }
  637. }
  638. else
  639. {
  640. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  641. }
  642. if($this->whlabel_bh->insert($post))
  643. {
  644. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  645. }
  646. else
  647. {
  648. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  649. }
  650. }
  651. $w = $this->shop->find_all("yyid != ''");
  652. $this->data['yyck'] = $w;
  653. $purchase = $this->purchase->find_all("yyid != ''");
  654. $this->data['purchase'] = $purchase;
  655. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  656. $this->_Template('whlabel_bh_add',$this->data);
  657. }
  658. public function get_cjlp($data)//创建料品
  659. {
  660. $list["0"]["Code"] = $data['jm'];//料号,SKU
  661. $list["0"]["Code1"] = '';
  662. $list["0"]["Name"] = $data['zh'];//产品名称
  663. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  664. $list["0"]["Org"]["Code"] = 001;
  665. $list["0"]["OtherID"] = 1;
  666. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  667. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  668. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  669. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  670. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  671. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  672. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  673. $list["0"]["InventoryUOM"]["Code"] = '条';
  674. $list["0"]["InventorySecondUOM"]["Code"] = '';
  675. $list["0"]["IsDualUOM"] = false;
  676. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  677. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  678. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  679. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  680. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  681. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  682. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  683. $list["0"]["Description"] = $data['title'];
  684. $list["0"]["ItemForm"] = 2001;
  685. $list["0"]["ItemFormAttribute"] = 10;
  686. $list["0"]["IsInventoryEnable"] = true;
  687. $list["0"]["IsPurchaseEnable"] = true;
  688. $list["0"]["IsSalesEnable"] = true;
  689. $list["0"]["IsBuildEnable"] = true;
  690. $list["0"]["IsOutsideOperationEnable"] = true;
  691. $list["0"]["IsMRPEnable"] = true;
  692. $list["0"]["IsBOMEnable"] = true;
  693. $list["0"]["IsCostCalByGrade"] = false;
  694. $list["0"]["IsCostCalByPotency"] = false;
  695. $list["0"]["IsGradeControl"] = false;
  696. $list["0"]["StandardGrade"] = -1;
  697. $list["0"]["StartGrade"] = -1;
  698. $list["0"]["EndGrade"] = -1;
  699. $list["0"]["IsPotencyControl"] = false;
  700. $list["0"]["StandardPotency"] = -1;
  701. $list["0"]["StartPotency"] = -1;
  702. $list["0"]["EndPotency"] = -1;
  703. $asd = $list;
  704. $list = json_encode($list);
  705. $token = $this->setting->get_yytoken_130();
  706. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  707. $header[] = "Content-Type: application/json";
  708. $header[] = "Token: ".$token;
  709. $ch = curl_init();
  710. curl_setopt($ch, CURLOPT_URL, $url);
  711. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  712. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  713. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  714. curl_setopt($ch, CURLOPT_POST, 1);
  715. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  716. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  717. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  718. $res = curl_exec($ch);
  719. $res = json_decode($res,true);
  720. return $asd;
  721. }
  722. //修改产品
  723. public function _edit($arg_array)
  724. {
  725. $tc = $this->typeclass->find_all();
  726. $typeclass = array();
  727. foreach ($tc as $v)
  728. {
  729. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  730. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  731. }
  732. $post = $this->input->post(NULL, TRUE);
  733. if(isset($post['id']))
  734. {
  735. $id = $this->input->post('id',true);
  736. $list = array();
  737. $sku = $this->input->post('sku',true);
  738. $category = $this->input->post('category',true);
  739. $list['category'] = $category;
  740. $list['hairtype'] = $this->input->post('hairtype',true);
  741. $list['grade'] = $this->input->post('grade',true);
  742. $size = $this->input->post('size',true);
  743. $xzsku = $this->input->post('xzsku',true);
  744. $list['size'] = rtrim($size,',');
  745. $list['hairnumber'] = $this->input->post('hairnumber',true);
  746. $list['extension'] = $this->input->post('extension',true);
  747. if($category == 1297)
  748. {
  749. $list['sywignumber'] = $this->input->post('sywignumber',true);
  750. }
  751. if($category == 1702)
  752. {
  753. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  754. $list['syother'] = $this->input->post('syother',true);
  755. }
  756. if($category == 133)
  757. {
  758. $list['fittype'] = $this->input->post('fittype',true);
  759. $list['acother'] = $this->input->post('acother',true);
  760. }
  761. $list['color'] = $this->input->post('color',true);
  762. $list['lowe'] = $this->input->post('lowe',true);
  763. if($category == 127)
  764. {
  765. $list['type'] = $this->input->post('type',true);
  766. $list['headroad'] = $this->input->post('headroad',true);
  767. $list['density'] = $this->input->post('density',true);
  768. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  769. {
  770. $list['lacesize'] = $this->input->post('lacesize',true);
  771. }
  772. $list['lacecolor'] = $this->input->post('lacecolor',true);
  773. $list['lacetypes'] = $this->input->post('lacetypes',true);
  774. }
  775. if($category == 128)
  776. {
  777. $list['lacetype'] = $this->input->post('lacetype',true);
  778. $list['haircap'] = $this->input->post('haircap',true);
  779. $list['density'] = $this->input->post('density',true);
  780. $list['lacecolor'] = $this->input->post('lacecolor',true);
  781. $list['lacetypes'] = $this->input->post('lacetypes',true);
  782. $list['wigother'] = $this->input->post('wigother',true);
  783. $list['wigother1'] = $this->input->post('wigother1',true);
  784. $list['wigother2'] = $this->input->post('wigother2',true);
  785. }
  786. if($category == 129)
  787. {
  788. $list['wide'] = $this->input->post('wide',true);
  789. }
  790. if($category == 131)
  791. {
  792. $list['gifttype'] = $this->input->post('gifttype',true);
  793. $list['giftother'] = $this->input->post('giftother',true);
  794. }
  795. if($category == 134)
  796. {
  797. $list['pieceweight'] = $this->input->post('pieceweight',true);
  798. }
  799. if($category == 1297)
  800. {
  801. $list['synthetictype'] = $this->input->post('synthetictype',true);
  802. $list['sywigother'] = $this->input->post('sywigother',true);
  803. }
  804. if($category == 130 || $category == 133 || $category == 1702)
  805. {
  806. $list['items'] = $this->input->post('items',true);
  807. $list['weight'] = $this->input->post('weight',true);
  808. }
  809. if($category == 1702)
  810. {
  811. $list['syhairther'] = $this->input->post('syhairther',true);
  812. }
  813. $classid = $this->classid->sku();
  814. $pm = $classid;
  815. $jm = $classid;
  816. $sku = $sku;
  817. $title = '';$features = '';$cs = array();
  818. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  819. foreach($list as $k=>$v)
  820. {
  821. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  822. {
  823. if($typeclass[$v]['bm'] != '')
  824. {
  825. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  826. }
  827. }
  828. if($v != 0)
  829. {
  830. if($k != 'size')
  831. {
  832. $title .= $typeclass[$v]['title']." ";
  833. }
  834. $features .=$v.'-';
  835. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  836. if(isset($pm[$typeclass[$v]['classid']]))
  837. {
  838. if($typeclass[$v]['title'] == '9A')
  839. {
  840. $pm[$typeclass[$v]['classid']] = '9A';
  841. }
  842. else if($typeclass[$v]['title'] == '10A')
  843. {
  844. $pm[$typeclass[$v]['classid']] = '10A';
  845. }
  846. else
  847. {
  848. $clzh = $typeclass[$v]['zh'];
  849. if(stripos($typeclass[$v]['zh'],'|') !== false)
  850. {
  851. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  852. $clzh = $clzh[0];
  853. }
  854. $pm[$typeclass[$v]['classid']] = $clzh;
  855. }
  856. }
  857. if(isset($jm[$typeclass[$v]['classid']]))
  858. {
  859. if($typeclass[$v]['jm'])
  860. {
  861. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  862. }
  863. }
  864. }
  865. }
  866. $jm = array_filter($jm);//去除空值
  867. $jm = implode("-",$jm);
  868. $sku = array_filter($sku);//去除空值
  869. $sku = implode("-",$sku);
  870. $pm = array_filter($pm);//去除空值
  871. $pm = implode(" ",$pm);
  872. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  873. if($list['size'])
  874. {
  875. $typeclass = $this->typeclass->read($list['size']);
  876. $title .= $typeclass['title'];
  877. }
  878. $title = trim($title,' ');
  879. $post['num'] = $this->input->post('num',true);
  880. $ztime = $this->input->post('ztime',true);
  881. $post['ztime'] = strtotime($ztime);
  882. $post['bm'] = '03'.implode("",$bmpx);
  883. $post['jm'] = $jm;
  884. $post['sku'] = $sku;
  885. $post['pm'] = $pm;
  886. $post['title'] = $title;
  887. $post['features'] = '-'.$features;
  888. $ztime = $this->input->post('ztime',true);
  889. if($ztime)
  890. {
  891. $post['ztime'] = strtotime($ztime);
  892. }
  893. if($this->whlabel_bh->save($post,$id))
  894. {
  895. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  896. }
  897. else
  898. {
  899. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  900. }
  901. }
  902. $w = $this->shop->find_all("yyid != ''");
  903. $this->data['yyck'] = $w;
  904. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  905. $this->data['whlabel_bh'] = $whlabel_bh ;
  906. $purchase = $this->purchase->find_all("yyid != ''");
  907. $this->data['purchase'] = $purchase;
  908. $this->_Template('whlabel_bh_edit',$this->data);
  909. }
  910. public function _cz()
  911. {
  912. $post = $this->input->post(NULL, TRUE);
  913. if(isset($post['id']))
  914. {
  915. $id = $this->input->post('id',true);
  916. $cz = $this->input->post('cz',true);
  917. $num = $this->input->post('num',true);
  918. $cz = $cz+1;
  919. $w = $this->whlabel_bh->read($id);
  920. if(!$w)
  921. {
  922. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  923. }
  924. //传输料号开始
  925. $lc = 0;
  926. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  927. if(isset($lh['Data'][0]))
  928. {
  929. if($lh['Data'][0]['m_isSucess'] != 1)
  930. {
  931. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  932. {
  933. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  934. }
  935. }
  936. }
  937. else
  938. {
  939. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  940. }
  941. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  942. /** 投产
  943. if($w['scapi'] != 99)
  944. {
  945. if($w['state'] == $cz)
  946. {
  947. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  948. }
  949. if($w['type'] == '0')
  950. {
  951. $type = '生产';
  952. $bhlx = 0;
  953. }
  954. else
  955. {
  956. $type = '外购';
  957. $bhlx = 1;
  958. }
  959. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  960. if($yy['c'] == 0)
  961. {
  962. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  963. {
  964. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  965. }
  966. else
  967. {
  968. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  969. }
  970. }
  971. else
  972. {
  973. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  974. }
  975. }
  976. else if($w['dbapi'] != 99 && $w['type'] == '0')
  977. {
  978. $cz = 1;
  979. if(!is_numeric($num))
  980. {
  981. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  982. }
  983. if($num > $w['num']-$w['rknum'])
  984. {
  985. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  986. }
  987. if($w['rknum']+$num == $w['num'])
  988. {
  989. $dbapi = 99;
  990. $cz = 2;
  991. }
  992. else
  993. {
  994. $dbapi = 0;
  995. }
  996. $w['ts'] = $num;
  997. $rk = $this->apiyy->_newrk($w);
  998. if($rk['c'] == 0)
  999. {
  1000. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  1001. {
  1002. if($dbapi == 99)
  1003. {
  1004. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  1005. }
  1006. else
  1007. {
  1008. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  1009. }
  1010. }
  1011. else
  1012. {
  1013. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  1014. }
  1015. }
  1016. else
  1017. {
  1018. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  1019. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  1020. }
  1021. }
  1022. else if($w['dbapi'] != 99 && $w['type'] == '1')
  1023. {
  1024. $cz = 1;
  1025. if(!is_numeric($num))
  1026. {
  1027. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  1028. }
  1029. if($num > $w['num']-$w['rknum'])
  1030. {
  1031. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  1032. }
  1033. if($w['rknum']+$num == $w['num'])
  1034. {
  1035. $dbapi = 99;
  1036. $cz = 2;
  1037. }
  1038. else
  1039. {
  1040. $dbapi = 0;
  1041. }
  1042. $scid = explode('~',$w['scid']);
  1043. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  1044. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  1045. {
  1046. if($dbapi == 99)
  1047. {
  1048. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  1049. }
  1050. else
  1051. {
  1052. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  1053. }
  1054. }
  1055. else
  1056. {
  1057. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1058. }
  1059. }
  1060. **/
  1061. }
  1062. }
  1063. public function _db()
  1064. {
  1065. $post = $this->input->post(NULL, TRUE);
  1066. if(isset($post['id']))
  1067. {
  1068. $id = $this->input->post('id',true);
  1069. $num = $this->input->post('num',true);
  1070. $warehouse = $this->input->post('warehouse',true);
  1071. $w = $this->warehouse->read($warehouse);
  1072. $data = $this->whlabel_bh->read($id);
  1073. if(!$data)
  1074. {
  1075. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  1076. }
  1077. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  1078. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  1079. if($num > $data['rknum']-$ydbnum)
  1080. {
  1081. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  1082. }
  1083. $data['dccbm'] = 13001;//默认从许昌仓调出
  1084. $data['ts'] = $num;
  1085. $data['drcbm'] = $w['yybm'];
  1086. $dc = $this->apiyy->get_cpdc($data);
  1087. if(isset($dc['Data'][0]))
  1088. {
  1089. if($dc['Data'][0]['IsSucess'] != 1)
  1090. {
  1091. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  1092. }
  1093. else
  1094. {
  1095. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  1096. if(isset($sh['Data'][0]))
  1097. {
  1098. $code = $sh['Data'][0]['Code'];
  1099. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  1100. }
  1101. else
  1102. {
  1103. $code = '';
  1104. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  1105. }
  1106. $p['uid'] = $id;
  1107. $p['bm'] = $data['bm'];
  1108. $p['sku'] = $data['jm'];
  1109. $p['shipremarks'] = $data['shipremarks'];
  1110. $p['title'] = $data['title'];
  1111. $p['zh'] = $data['pm'];
  1112. $p['fpdata'] = $data['features'];
  1113. $p['num'] = $num;
  1114. $p['warehouse'] = 13;//默认从许昌仓调出
  1115. $p['rwarehouse'] = $warehouse;
  1116. $p['time'] = time();//操作时间
  1117. $p['code'] = $code;
  1118. $this->whlabel_bh_list->insert($p);
  1119. }
  1120. }
  1121. else
  1122. {
  1123. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  1124. }
  1125. }
  1126. }
  1127. public function _del()
  1128. {
  1129. $post = $this->input->post(NULL, TRUE);
  1130. if(isset($post['s']))
  1131. {
  1132. $id_arr = $this->input->post('s');
  1133. $id_arr = explode(',',trim($id_arr,','));
  1134. if(!$id_arr)
  1135. {
  1136. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1137. }
  1138. //循环删除记录
  1139. foreach ($id_arr as $v)
  1140. {
  1141. $w = $this->whlabel_bh->read($v);
  1142. if($w['state'] > 0)
  1143. {
  1144. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  1145. }
  1146. }
  1147. foreach ($id_arr as $v)
  1148. {
  1149. $this->whlabel_bh->remove($v);
  1150. }
  1151. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1152. }
  1153. }
  1154. public function _deltransfer()
  1155. {
  1156. $post = $this->input->post(NULL, TRUE);
  1157. if(isset($post['s']))
  1158. {
  1159. $id_arr = $this->input->post('s');
  1160. $id_arr = explode(',',trim($id_arr,','));
  1161. if(!$id_arr)
  1162. {
  1163. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1164. }
  1165. if(count($id_arr) > 1)
  1166. {
  1167. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  1168. }
  1169. foreach ($id_arr as $v)
  1170. {
  1171. $this->whlabel_bh_transfer->remove($v);
  1172. }
  1173. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1174. }
  1175. }
  1176. public function _kc()
  1177. {
  1178. $post = $this->input->post(NULL, TRUE);
  1179. if(isset($post['category']))
  1180. {
  1181. $list = array();
  1182. $sku = $this->input->post('sku',true);
  1183. $features = $this->input->post('features',true);
  1184. $category = $this->input->post('category',true);
  1185. $list['category'] = $category;
  1186. $list['hairtype'] = $this->input->post('hairtype',true);
  1187. $list['grade'] = $this->input->post('grade',true);
  1188. $size = $this->input->post('size',true);
  1189. $xzsku = $this->input->post('xzsku',true);
  1190. $list['size'] = rtrim($size,',');
  1191. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1192. $list['extension'] = $this->input->post('extension',true);
  1193. if($category == 1297)
  1194. {
  1195. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1196. }
  1197. if($category == 1702)
  1198. {
  1199. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1200. $list['syother'] = $this->input->post('syother',true);
  1201. }
  1202. if($category == 133)
  1203. {
  1204. $list['fittype'] = $this->input->post('fittype',true);
  1205. $list['acother'] = $this->input->post('acother',true);
  1206. }
  1207. $list['color'] = $this->input->post('color',true);
  1208. $list['lowe'] = $this->input->post('lowe',true);
  1209. if($category == 127)
  1210. {
  1211. $list['type'] = $this->input->post('type',true);
  1212. $list['headroad'] = $this->input->post('headroad',true);
  1213. $list['density'] = $this->input->post('density',true);
  1214. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1215. {
  1216. $list['lacesize'] = $this->input->post('lacesize',true);
  1217. }
  1218. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1219. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1220. }
  1221. if($category == 128)
  1222. {
  1223. $list['lacetype'] = $this->input->post('lacetype',true);
  1224. $list['haircap'] = $this->input->post('haircap',true);
  1225. $list['density'] = $this->input->post('density',true);
  1226. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1227. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1228. $list['wigother'] = $this->input->post('wigother',true);
  1229. $list['wigother1'] = $this->input->post('wigother1',true);
  1230. $list['wigother2'] = $this->input->post('wigother2',true);
  1231. }
  1232. if($category == 129)
  1233. {
  1234. $list['wide'] = $this->input->post('wide',true);
  1235. }
  1236. if($category == 131)
  1237. {
  1238. $list['gifttype'] = $this->input->post('gifttype',true);
  1239. $list['giftother'] = $this->input->post('giftother',true);
  1240. }
  1241. if($category == 134)
  1242. {
  1243. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1244. }
  1245. if($category == 1297)
  1246. {
  1247. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1248. $list['sywigother'] = $this->input->post('sywigother',true);
  1249. }
  1250. if($category == 130 || $category == 133 || $category == 1702)
  1251. {
  1252. $list['items'] = $this->input->post('items',true);
  1253. $list['weight'] = $this->input->post('weight',true);
  1254. }
  1255. if($category == 1702)
  1256. {
  1257. $list['syhairther'] = $this->input->post('syhairther',true);
  1258. }
  1259. $shipremarks = '';
  1260. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1261. foreach($list as $k=>$v)
  1262. {
  1263. if($v != 0)
  1264. {
  1265. $shipremarks .=$v.'-';
  1266. }
  1267. }
  1268. $shipremarks = '-'.$shipremarks;
  1269. if($features)
  1270. {
  1271. $shipremarks = $features;
  1272. }
  1273. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1274. if($w > 0)
  1275. {
  1276. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1277. }
  1278. else
  1279. {
  1280. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1281. }
  1282. }
  1283. }
  1284. public function _excel()
  1285. {
  1286. $classid = $this->classid->sku();
  1287. $pm = $classid;
  1288. $typeclass = array();
  1289. $tc = $this->typeclass->find_all();
  1290. foreach ($tc as $v)
  1291. {
  1292. $typeclass[$v['id']] = $v;
  1293. }
  1294. $prc = array();
  1295. $purchase = $this->purchase->find_all();
  1296. foreach($purchase as $k=>$v)
  1297. {
  1298. $prc[$v['id']] = $v['title'];
  1299. }
  1300. if(isset($_GET['excel']))
  1301. {
  1302. $number = $this->input->post('number',true);
  1303. $sku = $this->input->post('sku',true);
  1304. $title = $this->input->post('title',true);
  1305. $pm = $this->input->post('pm',true);
  1306. $category = $this->input->post('category',true);
  1307. $size = $this->input->post('size',true);
  1308. $grade = $this->input->post('grade',true);
  1309. $color = $this->input->post('color',true);
  1310. $lowe = $this->input->post('lowe',true);
  1311. $state = $this->input->post('state',true);
  1312. $shipremarks = $this->input->post('shipremarks',true);
  1313. $type = $this->input->post('type',true);
  1314. $sid = $this->input->get('sid',true);
  1315. $ktime = $this->input->get('ktime',true);
  1316. $jtime = $this->input->get('jtime',true);
  1317. $ktime = strtotime($ktime);
  1318. $jtime = strtotime($jtime);
  1319. $where = "1=1";$gj = "";$ck = "";
  1320. if($number)
  1321. {
  1322. $where .= " and number like '%$number%'";
  1323. }
  1324. if($type != '')
  1325. {
  1326. $where .= " and type = '$type'";
  1327. }
  1328. if($sku)
  1329. {
  1330. $where .= " and sku like '%$sku%'";
  1331. }
  1332. if($title)
  1333. {
  1334. $where .= " and title like '%$title%'";
  1335. }
  1336. if($pm)
  1337. {
  1338. $where .= " and pm like '%$pm%'";
  1339. }
  1340. if($category)
  1341. {
  1342. $where .= " and shipremarks like '%-$category-%'";
  1343. }
  1344. if($size)
  1345. {
  1346. $where .= " and shipremarks like '%-$size-%'";
  1347. }
  1348. if($grade)
  1349. {
  1350. $where .= " and shipremarks like '%-$grade-%'";
  1351. }
  1352. if($color)
  1353. {
  1354. $where .= " and shipremarks like '%-$color-%'";
  1355. }
  1356. if($lowe)
  1357. {
  1358. $where .= " and shipremarks like '%-$lowe-%'";
  1359. }
  1360. if($state)
  1361. {
  1362. $where .= " and state = '$state'";
  1363. }
  1364. if($shipremarks)
  1365. {
  1366. $where .= " and shipremarks like '%$shipremarks%'";
  1367. }
  1368. $sidwhere = '';
  1369. if($sid)
  1370. {
  1371. $sd = "";
  1372. $s = explode(',',trim($sid,','));
  1373. foreach ($s as $value)
  1374. {
  1375. $sd .= " id = ".$value." or";
  1376. }
  1377. $sidwhere = " and (".rtrim($sd,'or').")";
  1378. }
  1379. //数据排序
  1380. $order_str = "time desc";
  1381. if(empty($page))
  1382. {
  1383. $start = 0;
  1384. $perpage = 1;
  1385. }
  1386. else
  1387. {
  1388. $start = ($page - 1)*$perpage;
  1389. }
  1390. //取得信息列表
  1391. /**
  1392. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1393. $rows = array();$list = array();
  1394. foreach ($info_list as $key=>$value)
  1395. {
  1396. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1397. }
  1398. **/
  1399. $warehouse = $this->warehouse->find_all();
  1400. $ck = array();
  1401. foreach ($warehouse as $v)
  1402. {
  1403. $ck[$v['id']] = $v['title'];
  1404. }
  1405. $list = array();
  1406. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1407. foreach ($rows as $key=>$value)
  1408. {
  1409. if($value['state'] == 0)
  1410. {
  1411. $rows[$key]['state'] = "待生产/外购";
  1412. }
  1413. else if($value['state'] == 1)
  1414. {
  1415. $rows[$key]['state'] = "生产/外购中";
  1416. }
  1417. else if($value['state'] == 2)
  1418. {
  1419. $rows[$key]['state'] = "已完成";
  1420. }
  1421. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1422. $zc = '';
  1423. foreach ($zd as $v)
  1424. {
  1425. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1426. }
  1427. $rows[$key]['id'] = $zc;
  1428. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1429. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1430. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1431. }
  1432. $title = '备货详情';
  1433. $titlename = "<table border=1>
  1434. <tr align='center'>
  1435. <td>状态</td>
  1436. <td>标题</td>
  1437. <td>流水码</td>
  1438. <td>简码</td>
  1439. <td>英文</td>
  1440. <td>中文</td>
  1441. <td>备注</td>
  1442. <td>备货数量</td>
  1443. <td>库存数量</td>
  1444. <td>生产/外购数量</td>
  1445. <td>入库数量</td>
  1446. <td>调拨数量</td>
  1447. <td>调拨详情</td>>
  1448. <td>生产时间</td>>
  1449. <td>操作时间</td>>
  1450. </tr>
  1451. </table>";
  1452. $filename = $title.".xls";
  1453. $tail = "";
  1454. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1455. }
  1456. }
  1457. public function _xxpl()
  1458. {
  1459. /* 订单加入键值-j */
  1460. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1461. $config['upload_path'] = '.'.$dir ;
  1462. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1463. $config['allowed_types'] = 'xls|xlsx|csv';
  1464. $config['max_size'] = 10240;
  1465. $this->load->library('upload', $config);
  1466. $this->upload->initialize($config);
  1467. if ($this->upload->do_upload('userfile'))
  1468. {
  1469. $full_path = $dir.$this->upload->data('file_name');
  1470. $fileName = '.' . $full_path;
  1471. if (!file_exists($fileName))
  1472. {
  1473. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1474. }
  1475. else
  1476. {
  1477. require_once "./data/excel/PHPExcel/IOFactory.php";
  1478. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1479. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1480. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1481. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1482. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1483. ++$column;//如果列数大于26行
  1484. $list = array();
  1485. for ($i = 2; $i <= $row; $i++) // 行数循环
  1486. {
  1487. $data = array();
  1488. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1489. {
  1490. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1491. }
  1492. $list[] = $data;
  1493. }
  1494. }
  1495. $tc = $this->typeclass->find_all();
  1496. $typeclass = array();
  1497. foreach ($tc as $v)
  1498. {
  1499. $typeclass[$v['jm']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1500. }
  1501. $i = 0;$j = 0;$ed = array();
  1502. $classid = $this->classid->sku();
  1503. $typeclassid = [];
  1504. foreach($tc as $v){
  1505. $typeclassid[$v['id']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1506. }
  1507. $i = 0;$j = 0;$ed = [];
  1508. $ck = [
  1509. "成品仓"=>'99001',
  1510. "美国仓"=>'02031',
  1511. "AP"=>'0103001',
  1512. "WK"=>'0103002',
  1513. "QV"=>'0103003',
  1514. "AS"=>'0103004',
  1515. "H"=>"0103005",
  1516. "AP英"=>"0103006",
  1517. "YMS"=>"0103007",
  1518. "AP新"=>"0103008",
  1519. "WK新"=>"0103009",
  1520. "H新"=>"0103010",
  1521. "Bilisar"=>"0103011",
  1522. "Estilar"=>"0103012",
  1523. "QM"=>"0103013",
  1524. "Afola"=>"0103014",
  1525. "拼多多-Finsa"=>"0106002",
  1526. "拼多多-艾彩"=>"0105001",
  1527. "拼多多-Estilar"=>"0106001",
  1528. "拼多多-QM"=>"0106003",
  1529. ];
  1530. foreach($list as $k=>$v){
  1531. $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
  1532. if($res['code']==1){
  1533. //传输料号开始
  1534. $post = $res['data'];
  1535. $post['number'] = $post['number'].$k;
  1536. $post['orderinfo'] = $v[2];
  1537. $post['num'] = $v[5];
  1538. $post['state'] = ($v[3] == '生产')?0:1;
  1539. $post['purchase'] = "";//供货商
  1540. $post['shipremarks'] = empty($v[6])?" ":$v[6];//
  1541. $post['rknum'] = 0;
  1542. $post['scapi'] = 0;
  1543. $post['dbapi'] = 0;
  1544. $post['bhnum'] = $v[5];
  1545. $post['extra_type'] = (strpos($v[2],"美国销售-") !== false)?1:0;
  1546. if(isset($ck[$v[4]])){
  1547. $post['kh'] = $ck[$v[4]];
  1548. }else{
  1549. $j++;
  1550. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1551. continue;
  1552. }
  1553. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  1554. $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
  1555. if(isset($lh['Data'][0]))
  1556. {
  1557. if($lh['Data'][0]['m_isSucess'] != 1)
  1558. {
  1559. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1560. {
  1561. $j++;
  1562. $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
  1563. }
  1564. }
  1565. }
  1566. else
  1567. {
  1568. $j++;
  1569. $ed[] = array('料号错误',$post['jm'],$post['bm']);
  1570. }
  1571. if($this->whlabel_bh->insert($post))
  1572. {
  1573. $i++;
  1574. }
  1575. else
  1576. {
  1577. $j++;
  1578. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1579. }
  1580. }else{
  1581. $j++;
  1582. $ed[] = array($res['msg'],$v[1],"");
  1583. }
  1584. }
  1585. if($j > 0)
  1586. {
  1587. $time = date('Ymd',time());
  1588. $title = '错误信息-'.$time;
  1589. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1590. $tail = "\n";
  1591. $filename = $title.".xls";
  1592. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1593. $dir = '/data/excel/'.$time.'/';
  1594. $file_name = 'error_'.$time.rand(1000,9999);
  1595. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1596. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1597. fwrite($myfile,$ecl);
  1598. fclose($myfile);
  1599. $error = $dir.$file_name.'.xls';
  1600. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1601. }
  1602. else
  1603. {
  1604. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1605. }
  1606. }
  1607. else
  1608. {
  1609. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1610. }
  1611. }
  1612. public function _cslh($jm,$title,$pm,$bm)
  1613. {
  1614. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1615. if(isset($lh['Data'][0]))
  1616. {
  1617. if($lh['Data'][0]['m_isSucess'] != 1)
  1618. {
  1619. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1620. {
  1621. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1622. }
  1623. }
  1624. }
  1625. else
  1626. {
  1627. return array('msg'=>'料号错误','x'=>1);exit;
  1628. }
  1629. return array('x'=>2);exit;
  1630. }
  1631. public function _bbprint()
  1632. {
  1633. $time = time();
  1634. $post = $this->input->post(NULL);
  1635. if(isset($post['d']))
  1636. {
  1637. $order = 0;$time = time();
  1638. $d = $this->input->post('d',true);
  1639. $n = $this->input->post('n',true);//打印数量
  1640. $data = $this->whlabel_bh->read($d);
  1641. if(!$data)
  1642. {
  1643. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1644. }
  1645. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1646. $printnum = array_sum(array_column($printnum,'ts'));
  1647. if(($data['bhnum'] + 1)-$printnum-$n < 0)
  1648. {
  1649. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1650. }
  1651. $post['number'] = $data['number'];
  1652. $post['orderinfo'] = $data['orderinfo'];
  1653. $post['type'] = 0;//0生产 1外购
  1654. $post['features'] = $data['features'];
  1655. $post['jm'] = $data['jm'];
  1656. $post['bm'] = $data['bm'];
  1657. $post['pm'] = $data['pm'];
  1658. $post['sku'] = $data['sku'];
  1659. $post['features'] = $data['features'];
  1660. $post['number'] = $data['number'];
  1661. $post['title'] = $data['title'];
  1662. $post['printtime'] = $time;
  1663. $post['ts'] = 1;
  1664. // $post['rk'] = "";//默认订单中心 打印后直接入库
  1665. // $post['rktime'] = "";
  1666. // $post['ctime15'] = $time;
  1667. $post['time'] = $time;
  1668. $post['gtime'] = date('Yms',$time);
  1669. $post['wbid'] = $data['id'];
  1670. $rows = array();
  1671. $label = date("ymdHis").rand(1000,9999);
  1672. $post['label'] = $label;
  1673. // if($this->whlabel_bh_transfer->insert($post))
  1674. // {
  1675. // echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1676. // }
  1677. // else
  1678. // {
  1679. // $this->db->trans_rollback();
  1680. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1681. // }
  1682. if(stripos($post['features'],'-126-') !== false)
  1683. {
  1684. $drck = '12003';//进入发条库
  1685. }
  1686. else if(stripos($post['features'],'-127-') !== false)
  1687. {
  1688. $drck = '12004';//进入发块库
  1689. }
  1690. else
  1691. {
  1692. $drck = '12006';//其它进入完成库
  1693. }
  1694. //创建u9的生产单
  1695. $token = $this->settingtest->get_yytoken_120();
  1696. $params = [
  1697. 'org_code'=>"120",
  1698. 'djhlx'=>'2000',
  1699. 'scbm_code'=>"12008",
  1700. "time"=>time(),
  1701. 'owner_org_code'=>"120",
  1702. 'title'=>$post['orderinfo'],
  1703. 'shipremarks'=>$data['shipremarks'],
  1704. 'list'=>[
  1705. [
  1706. 'drck'=>$drck,
  1707. 'jm'=>$post['jm'],
  1708. 'sl'=>$n,
  1709. 'drck'=>$drck,
  1710. ]
  1711. ]
  1712. ];
  1713. $res = $this->apiyyv1->scdCreate($params,$token);
  1714. $this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
  1715. if(!isset($res[0]['Data'])){
  1716. echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
  1717. }
  1718. if(!$res[0]['Data'][0]['m_isSucess']){
  1719. echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
  1720. }
  1721. $scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
  1722. $post['scid'] = $scid;
  1723. $post['scapi'] = 1;
  1724. $post['dbapi'] = 0;
  1725. $this->db->trans_begin();
  1726. $post['shipremarks'] = $data['shipremarks'];
  1727. for($i = 0;$i < $n;$i++){
  1728. $post['label'] = $label.$i;
  1729. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
  1730. $this->whlabel_bh_transfer->insert($post);
  1731. }
  1732. $printsl = $data['printsl']*1 + $n*1;
  1733. $this->whlabel_bh->save(['printsl'=>$printsl],$data['id']);
  1734. if ($this->db->trans_status() === TRUE)
  1735. {
  1736. $this->db->trans_commit();
  1737. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1738. }else{
  1739. $this->db->trans_rollback();
  1740. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1741. }
  1742. }
  1743. }
  1744. public function _bdbb()
  1745. {
  1746. $post = $this->input->post(NULL, TRUE);
  1747. if(isset($post['s']))
  1748. {
  1749. $id_arr = $this->input->post('s');
  1750. $id_arr = explode(',',trim($id_arr,','));
  1751. if(!$id_arr)
  1752. {
  1753. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1754. }
  1755. //循环删除记录
  1756. foreach ($id_arr as $v)
  1757. {
  1758. $t = $this->whlabel_bh_transfer->read($v);
  1759. if(!isset($t['number']))
  1760. {
  1761. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1762. }
  1763. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>1);
  1764. }
  1765. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1766. }
  1767. }
  1768. public function _out()
  1769. {
  1770. $post = $this->input->post(NULL, TRUE);
  1771. if(isset($post['label']))
  1772. {
  1773. $time = time();
  1774. $label = $this->input->post('label',true);
  1775. $cz = $this->input->post('cz',true);
  1776. $transfer = $this->input->post('transfer',true);
  1777. if(!$label)
  1778. {
  1779. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1780. }
  1781. if(!$transfer)
  1782. {
  1783. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1784. }
  1785. $lb = $this->whlabel_bh_transfer->get_label($label);
  1786. if(!$lb)
  1787. {
  1788. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1789. }
  1790. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1791. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1792. $tdata = $this->transfer->find_all();
  1793. $t = array();
  1794. foreach ($tdata as $v)
  1795. {
  1796. $t[$v['id']] = $v['title'];
  1797. }
  1798. if($cz == 1)
  1799. {
  1800. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1801. {
  1802. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1803. }
  1804. }
  1805. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1806. {
  1807. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1808. }
  1809. if($cz == 1)
  1810. {
  1811. $lb['rk'] .= $transfer.'|';
  1812. $lb['rktime'] .= $time.'|';
  1813. if($lbrk[0] == $transfer)
  1814. {
  1815. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1816. }
  1817. //必须走配货
  1818. if(($transfer != 1) && (strpos($lb['rk'],'|1|') === false) ){
  1819. echo json_encode(array('msg'=>'请先到配货!','success'=>false));exit;
  1820. }
  1821. }
  1822. else if($cz == 2)
  1823. {
  1824. $lb['ck'] .= $transfer.'|';
  1825. $lb['cktime'] .= $time.'|';
  1826. if($lbck[0] == $transfer)
  1827. {
  1828. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1829. }
  1830. }
  1831. $cztime = 'ctime'.$transfer;
  1832. //如果是完成扫出 这样会通知erp生成一个调出单
  1833. //中转库如果扫出的话 应该是马尾 其它的没有
  1834. if(($transfer == 3 || $transfer == 13) && $cz == 2 && $lb['dbapi'] < 99){
  1835. if(empty($lb['scid'])){
  1836. echo json_encode(array('msg'=>'此单在u9的信息异常,通知技术排查1!','success'=>false));exit;
  1837. }
  1838. $tmp_u9_info = explode('~',$lb['scid']);
  1839. if(count($tmp_u9_info)!=3){
  1840. echo json_encode(array('msg'=>'此单在u9的信息异常,通知技术排查2!','success'=>false));exit;
  1841. }
  1842. $doc_no = $tmp_u9_info[1];
  1843. $token = $this->settingtest->get_yytoken_120();
  1844. $res = $this->apiyyv1->cxScdStatus($doc_no,$token);
  1845. if(empty($res[0]['Data'])){
  1846. echo json_encode(array('msg'=>'erp查询u9生产单状态异常,通知技术排查3!','success'=>false));exit;
  1847. }
  1848. if(empty($res[0]['Data'][0]['docno'])){
  1849. echo json_encode(array('msg'=>'查询u9生产单的信息失败,通知技术排查4!','success'=>false));exit;
  1850. }
  1851. if($res[0]['Data'][0]['docno'] != $doc_no){
  1852. echo json_encode(array('msg'=>'查询u9生产单的信息和erp信息不照应,通知技术排查!','success'=>false));exit;
  1853. }
  1854. //docstate 0 开立 1审核 2开工
  1855. if($res[0]['Data'][0]['docstate'] < 2){
  1856. echo json_encode(array('msg'=>$doc_no.'生产单未开工,无法出库!','success'=>false));exit;
  1857. }
  1858. $this->db->trans_begin();
  1859. $this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time,'status'=>2,'dbapi'=>99),$lb['id']);
  1860. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1861. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1862. if($ct_info){
  1863. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1864. }
  1865. $this->zzquque_u9->insert([
  1866. 'platform'=>'',
  1867. 'warehouse'=>0,
  1868. 'type'=>21,
  1869. 'order_no'=>$lb['orderinfo'],
  1870. 'child_order_no'=>$lb['id'],
  1871. 'status'=>0,
  1872. 'create_time'=>time(),
  1873. 'update_time'=>time(),
  1874. ]);
  1875. if ($this->db->trans_status() === TRUE){
  1876. $this->db->trans_commit();
  1877. echo json_encode(array('music'=>'1','success'=>true));exit;
  1878. }else{
  1879. $this->db->trans_rollback();
  1880. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1881. }
  1882. }
  1883. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1884. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1885. {
  1886. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1887. }
  1888. $save_data = [
  1889. 'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time
  1890. ];
  1891. //配货入库需更新一下配货状态
  1892. if($transfer == 2 && $cz == 1 && $lb['status'] == 0){
  1893. $save_data['status'] = 1;
  1894. }
  1895. $this->db->trans_begin();
  1896. $this->whlabel_bh_transfer->save($save_data,$lb['id']);
  1897. if($cz == 2){
  1898. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1899. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1900. if($ct_info){
  1901. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1902. }
  1903. }else{
  1904. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0,'number'=>$lb['number']]);
  1905. }
  1906. if ($this->db->trans_status() === TRUE){
  1907. $this->db->trans_commit();
  1908. echo json_encode(array('music'=>'1','success'=>true));exit;
  1909. }else{
  1910. $this->db->trans_rollback();
  1911. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1912. }
  1913. }
  1914. }
  1915. protected function getOperateList(){
  1916. $api = $this->input->post('api',true);
  1917. $page = $this->input->post('page',true);
  1918. $perpage = $this->input->post('perpage',true);
  1919. $orderinfo = $this->input->post('number',true);
  1920. $color = $this->input->post('color',true);
  1921. $pm = $this->input->post('pm',true);
  1922. $purchase = $this->input->post('purchase',true);
  1923. $transfer = $this->input->post('transfer',true);
  1924. $lx = $this->input->post('lx',true);
  1925. $timetk = $this->input->post('timetk',true);
  1926. $timetj = $this->input->post('timetj',true);
  1927. $timetk = strtotime($timetk);
  1928. $timetj = strtotime($timetj);
  1929. $where = "1=1";
  1930. if($transfer)
  1931. {
  1932. $ctime = 'ctime'.$transfer;
  1933. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1934. }
  1935. else
  1936. {
  1937. $where .= " and time > '$timetk' and time < '$timetj'";
  1938. }
  1939. if($orderinfo)
  1940. {
  1941. $where .= " and orderinfo like '%$orderinfo%'";
  1942. }
  1943. if($transfer)
  1944. {
  1945. $where .= " and rk like '%|".$transfer."|%'";
  1946. }
  1947. if($purchase)
  1948. {
  1949. $where .= " and purchase = '$purchase'";
  1950. }
  1951. if($pm)
  1952. {
  1953. $where .= " and pm like '%$pm%'";
  1954. }
  1955. if($color)
  1956. {
  1957. $where .= " and fpdata like '%-".$color."-%'";
  1958. }
  1959. //数据排序
  1960. $order_str = "id desc";
  1961. if(empty($page))
  1962. {
  1963. $start = 0;
  1964. $perpage = 1;
  1965. }
  1966. else
  1967. {
  1968. $start = ($page - 1)*$perpage;
  1969. }
  1970. //取得信息列表
  1971. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1972. $transfer = $this->transfer->find_all();
  1973. $t = array();$ot = array();
  1974. foreach ($transfer as $v)
  1975. {
  1976. $t[$v['id']] = $v['title'];
  1977. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1978. }
  1979. //格式化数据
  1980. foreach ($info_list as $key=>$value)
  1981. {
  1982. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1983. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1984. $tmp_operate_str = "";
  1985. foreach($log_list as $k=>$v){
  1986. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1987. }
  1988. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1989. }
  1990. $total = $this->whlabel_bh_transfer->find_count($where);
  1991. $pagenum = ceil($total/$perpage);
  1992. $over = $total-($start+$perpage);
  1993. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1994. return $rows;
  1995. }
  1996. public function _operate()
  1997. {
  1998. $post = $this->input->post(NULL, TRUE);
  1999. if(isset($post['page']))
  2000. {
  2001. $rows = $this->getOperateList();
  2002. echo json_encode($rows);exit;
  2003. }
  2004. if(isset($_SESSION['api']))
  2005. {
  2006. $user = $this->user->get_api($_SESSION['api']);
  2007. $usp = $user;
  2008. $pid = "";$tid="";$sid="";$wid="";
  2009. $purchase = explode('|',trim($user['purchase'],'|'));
  2010. $transfer = explode('|',trim($user['transfer'],'|'));
  2011. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2012. foreach ($purchase as $value)
  2013. {
  2014. $pid .= " id = ".$value." or";
  2015. }
  2016. foreach ($transfer as $value)
  2017. {
  2018. $tid .= " id = ".$value." or";
  2019. }
  2020. foreach ($warehouse as $value)
  2021. {
  2022. $wid .= " id = ".$value." or";
  2023. }
  2024. }
  2025. else
  2026. {
  2027. header('Location: /');exit;
  2028. }
  2029. $kx = '';$zjtab = '';
  2030. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2031. $this->data['warehouse'] = $warehouse;
  2032. $purchase = $this->purchase->find_all("yyid != ''");
  2033. $this->data['purchase'] = $purchase;
  2034. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2035. $this->data['transfer'] = $transfer;
  2036. $ids = array_column($transfer,'id');
  2037. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2038. $start_time = $end_time - 14 * 24 * 60 * 60;
  2039. //$count = $this->whlabel_bh_transfer_cr->find_count("type = 1 and is_over = 0 and lx in (".implode(",",$ids).") and time >= ".$start_time." and time <= ".$end_time );
  2040. //$this->data['count'] = $count;
  2041. $this->data['vip'] = $user['vip'];
  2042. $this->_Template('whlabel_bh_operate',$this->data);
  2043. }
  2044. public function _rk()
  2045. {
  2046. $post = $this->input->post(NULL, TRUE);
  2047. if(isset($post['page']))
  2048. {
  2049. $res = $this->getOperateList();
  2050. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  2051. echo json_encode($rows);exit;
  2052. }
  2053. if(isset($_SESSION['api']))
  2054. {
  2055. $user = $this->user->get_api($_SESSION['api']);
  2056. $usp = $user;
  2057. $pid = "";$tid="";$sid="";$wid="";
  2058. $purchase = explode('|',trim($user['purchase'],'|'));
  2059. $transfer = explode('|',trim($user['transfer'],'|'));
  2060. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2061. foreach ($purchase as $value)
  2062. {
  2063. $pid .= " id = ".$value." or";
  2064. }
  2065. foreach ($transfer as $value)
  2066. {
  2067. $tid .= " id = ".$value." or";
  2068. }
  2069. foreach ($warehouse as $value)
  2070. {
  2071. $wid .= " id = ".$value." or";
  2072. }
  2073. }
  2074. else
  2075. {
  2076. header('Location: /');exit;
  2077. }
  2078. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2079. $this->data['transfer'] = $transfer;
  2080. $this->_Template('whlabel_bh_rk',$this->data);
  2081. }
  2082. public function _ck()
  2083. {
  2084. $post = $this->input->post(NULL, TRUE);
  2085. if(isset($post['page']))
  2086. {
  2087. $res = $this->getOperateList();
  2088. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  2089. echo json_encode($rows);exit;
  2090. }
  2091. if(isset($_SESSION['api']))
  2092. {
  2093. $user = $this->user->get_api($_SESSION['api']);
  2094. $usp = $user;
  2095. $pid = "";$tid="";$sid="";$wid="";
  2096. $purchase = explode('|',trim($user['purchase'],'|'));
  2097. $transfer = explode('|',trim($user['transfer'],'|'));
  2098. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2099. foreach ($purchase as $value)
  2100. {
  2101. $pid .= " id = ".$value." or";
  2102. }
  2103. foreach ($transfer as $value)
  2104. {
  2105. $tid .= " id = ".$value." or";
  2106. }
  2107. foreach ($warehouse as $value)
  2108. {
  2109. $wid .= " id = ".$value." or";
  2110. }
  2111. }
  2112. else
  2113. {
  2114. header('Location: /');exit;
  2115. }
  2116. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2117. $this->data['transfer'] = $transfer;
  2118. $this->_Template('whlabel_bh_ck',$this->data);
  2119. }
  2120. //备货流转记录表
  2121. public function _transfer_log(){
  2122. $post = $this->input->post(NULL, TRUE);
  2123. if($post){
  2124. $page = $this->input->post('page',true);
  2125. $perpage = $this->input->post('perpage',true);
  2126. $where = " extra_type = 1 ";
  2127. $orderinfo = $this->input->post('orderinfo',true);
  2128. $timetk = $this->input->post('timetk',true);
  2129. $timetj = $this->input->post('timetj',true);
  2130. $timetk = strtotime($timetk);
  2131. $timetj = strtotime($timetj);
  2132. if($timetk && $timetj)
  2133. {
  2134. $where .= " and time > '$timetk' and time < '$timetj'";
  2135. }
  2136. if($orderinfo){
  2137. $where.= " and orderinfo like '%$orderinfo%' ";
  2138. }
  2139. if(empty($page))
  2140. {
  2141. $start = 0;
  2142. $perpage = 1;
  2143. }
  2144. else
  2145. {
  2146. $start = ($page - 1)*$perpage;
  2147. }
  2148. $list = $this->whlabel_bh->find_pc($where,'orderinfo',"id,orderinfo,jgtime",'id desc',$start,$perpage);
  2149. $rows = [];
  2150. foreach($list as $k=>$v){
  2151. $tmp_order_info = $this->whlabel_bh->find_all(" orderinfo = '".$v['orderinfo']."'","id,orderinfo,bhnum");
  2152. $tmp_ids = [];
  2153. $tmp_bhnum = 0;
  2154. foreach($tmp_order_info as $vv){
  2155. $tmp_ids[] = $vv['id'];
  2156. $tmp_bhnum += $vv['bhnum'];
  2157. }
  2158. $ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;
  2159. if(!empty($tmp_ids)){
  2160. $list = $this->whlabel_bh_transfer->find_all(" wbid in (".implode(",",$tmp_ids).")");
  2161. foreach($list as $vv){
  2162. $ydysl += 1;
  2163. if($vv['status'] > 0){
  2164. $yphsl += 1;
  2165. }
  2166. if($vv['status'] == 2){
  2167. $yjgsj += 1;
  2168. }
  2169. }
  2170. }
  2171. $rows[$k]['id'] = $v['id'];
  2172. $rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='备货单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;
  2173. $rows[$k]['ddsl'] = $tmp_bhnum; //订单数量
  2174. $rows[$k]['ydysl'] = $ydysl; //已打印数量
  2175. $rows[$k]['wdysl'] = $tmp_bhnum - $ydysl; //未打印数量
  2176. $rows[$k]['yphsl'] = $yphsl; //已配货数量
  2177. $rows[$k]['yjgsj'] = $yjgsj; //已完工数量
  2178. $rows[$k]['wwgsl'] = $tmp_bhnum - $yjgsj; //未完工数量
  2179. $rows[$k]['jgtime'] = empty($v['jgtime'])?'<i class="method fa fa-edit" data-id="'.$v['id'].'" onclick="edit_jgtime(this)"></i>':date("Y-m-d ",$v['jgtime']).' <i class="method fa fa-edit" data-id="'.$v['id'].'" onclick="edit_jgtime(this)"></i>';
  2180. }
  2181. $total = $this->whlabel_bh->find_count($where);
  2182. $pagenum = ceil($total/$perpage);
  2183. $over = $total-($start+$perpage);
  2184. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  2185. echo json_encode($rows);exit;
  2186. }
  2187. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2188. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2189. $all_list = $this->whlabel_bh->find_all("extra_type = 1 and time >= ".$start_time." and time <= ".$end_time);
  2190. $orderinfo_list =[];
  2191. $total_num = 0;
  2192. foreach($all_list as $k=>$v){
  2193. $orderinfo_list[$v['id']] = $v['id'];
  2194. $total_num += $v['bhnum'];
  2195. }
  2196. $wbids = array_values($orderinfo_list);
  2197. if(empty($wbids)){
  2198. $over_num = 0;
  2199. }else{
  2200. $over_num = $this->whlabel_bh_transfer->find_count(" status = 2 and wbid in (".implode(",",$wbids).")");
  2201. }
  2202. $this->data['total_num'] = $total_num;
  2203. $this->data['wwcsl'] = $total_num - $over_num;
  2204. $this->_Template('whlabel_bh_transfer_log',$this->data);
  2205. }
  2206. public function _edit_jgtime(){
  2207. $post = $this->input->post(NULL, TRUE);
  2208. $info = $this->whlabel_bh->read($post['id']);
  2209. if(empty($info)){
  2210. echo json_encode(['code'=>-1,'msg'=>'信息异常']);exit;
  2211. }
  2212. $jgtime = strtotime($post['jgtime']);
  2213. $list = $this->whlabel_bh->find_all(" orderinfo = '".$info['orderinfo']."'");
  2214. foreach($list as $k=>$v){
  2215. $this->whlabel_bh->save(['jgtime'=>$jgtime],$v['id']);
  2216. }
  2217. echo json_encode(['code'=>1,'msg'=>'操作成功']);exit;
  2218. }
  2219. public function _transfer_detail($arg_array){
  2220. $id = $arg_array[0];
  2221. $transfer_list = $this->transfer->find_all();
  2222. $t_list = array_column($transfer_list,'title','id');
  2223. $info = $this->whlabel_bh->read($id);
  2224. $list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$info['orderinfo']."'");
  2225. $ids = array_column($list,'id');
  2226. $final_list = [];
  2227. if(!empty($ids)){
  2228. $log_list = $this->whlabel_bh_transfer_cr->find_all( " type = 1 and fid in (".implode(",",$ids).")","*","id asc");
  2229. $collect_list = [];
  2230. foreach($log_list as $k=>$v){
  2231. $collect_list[$v['lx']][$v['fid']] = $v;
  2232. }
  2233. foreach($collect_list as $k=>$v){
  2234. $js_num = $zk_num = $wc_num = 0;
  2235. foreach($v as $kk=>$vv){
  2236. $js_num += 1;
  2237. if($vv['is_over'] == 0){
  2238. $zk_num += 1;
  2239. }
  2240. if($vv['is_over'] == 1){
  2241. $wc_num += 1;
  2242. }
  2243. }
  2244. $final_list[$k] = [
  2245. 'cj' => $t_list[$k],
  2246. 'js_num' => $js_num,
  2247. 'zk_num' => $zk_num,
  2248. 'wc_num' => $wc_num,
  2249. 'list' => $v,
  2250. ];
  2251. }
  2252. }
  2253. // echo "<pre>";
  2254. // print_r($final_list);
  2255. // die;
  2256. $this->data['final_list'] = $final_list;
  2257. $this->_Template('whlabel_bh_transfer_detail',$this->data);
  2258. }
  2259. public function _cj_transfer_log(){
  2260. $post = $this->input->post(NULL, TRUE);
  2261. if(!empty($post)){
  2262. $orderinfo = $this->input->post('orderinfo',true);
  2263. $pm = $this->input->post('pm',true);
  2264. $tid = $this->input->post('tid',true);
  2265. $page = $this->input->post('page',true);
  2266. $perpage = $this->input->post('perpage',true);
  2267. $timetk = $this->input->post('timetk',true);
  2268. $timetj = $this->input->post('timetj',true);
  2269. $timetk = strtotime($timetk);
  2270. $timetj = strtotime($timetj);
  2271. $where = " rk like '%|".$tid."|%' ";
  2272. if($timetk && $timetj)
  2273. {
  2274. $where .= " and time > '$timetk' and time < '$timetj'";
  2275. }
  2276. if($pm){
  2277. if(empty($orderinfo)){
  2278. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]),'cwxx'=>"请先输入订单号");
  2279. echo json_encode($rows);exit;
  2280. }else{
  2281. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2282. $numbers = array_column($number_list,'number');
  2283. if(empty($numbers)){
  2284. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2285. echo json_encode($rows);exit;
  2286. }
  2287. $where.= " and number in (".implode(",",$numbers).") ";
  2288. }
  2289. }else{
  2290. if($orderinfo){
  2291. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2292. $numbers = array_column($number_list,'number');
  2293. if(empty($numbers)){
  2294. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2295. echo json_encode($rows);exit;
  2296. }
  2297. $where.= " and number in (".implode(",",$numbers).") ";
  2298. }
  2299. }
  2300. if(empty($page))
  2301. {
  2302. $start = 0;
  2303. $perpage = 20;
  2304. }
  2305. else
  2306. {
  2307. $start = ($page - 1)*$perpage;
  2308. }
  2309. $list = $this->whlabel_bh_transfer->find_pc($where,'number',"id,number,orderinfo,pm",'id desc',$start,$perpage);
  2310. $count = $this->whlabel_bh_transfer->find_all($where,'COUNT(DISTINCT number) as total');
  2311. $total = $count[0]['total'];
  2312. $pagenum = ceil($total/$perpage);
  2313. $over = $total-($start+$perpage);
  2314. $final_list = [];
  2315. foreach($list as $k=>$v){
  2316. $yjs_arr =[];//避免多次扫入的重复计算
  2317. $yjs = $wck= $yck = 0;
  2318. $log_list = $this->whlabel_bh_transfer_cr->find_all("lx = ".$tid." and type = 1 and number = ".$v['number'],"*",'id desc');
  2319. foreach($log_list as $kk=>$vv){
  2320. if(!isset($yjs_arr[$vv['fid']])){
  2321. $yjs += 1;
  2322. if($vv['is_over'] == 0){
  2323. $wck += 1;
  2324. }
  2325. if($vv['is_over'] == 1){
  2326. $yck += 1;
  2327. }
  2328. $yjs_arr[$vv['fid']] = 1;
  2329. }
  2330. }
  2331. $whlabel_bh_info = $this->whlabel_bh->find("number = ".$v['number']);
  2332. $final_list[$k]['id'] = $v['id'];
  2333. $final_list[$k]['orderinfo'] = $v['orderinfo'] ;
  2334. $final_list[$k]['number'] ="<h9 class='window' data-h='/whlabel_bh/cj_transfer_detail/".$v['number']."/".$tid."' data-t='备货单号:".$v['number']."'><p>".$v['number']."</p></h9>";
  2335. $final_list[$k]['pm'] = $v['pm'];
  2336. $final_list[$k]['ddsl'] = empty($whlabel_bh_info)?0:$whlabel_bh_info['bhnum'];
  2337. $final_list[$k]['yjs'] = $yjs;
  2338. $final_list[$k]['wck'] = $wck;
  2339. $final_list[$k]['yck'] = $yck;
  2340. }
  2341. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2342. echo json_encode($rows);exit;
  2343. }
  2344. if(isset($_SESSION['api']))
  2345. {
  2346. $user = $this->user->get_api($_SESSION['api']);
  2347. $usp = $user;
  2348. $transfer = explode('|',trim($user['transfer'],'|'));
  2349. $stid = "";
  2350. foreach ($transfer as $value)
  2351. {
  2352. $stid .= " id = ".$value." or";
  2353. }
  2354. if(empty($transfer)){
  2355. exit("您的账号没有赋予车间权限");
  2356. }
  2357. // if(count($transfer) > 1){
  2358. // exit("您的账号只能分配一个车间,多车间系统无法处理");
  2359. // }
  2360. $tid = $transfer[0];
  2361. }
  2362. else
  2363. {
  2364. header('Location: /');exit;
  2365. }
  2366. $transfer = $this->transfer->read($tid);
  2367. $this->data['transfer'] = $transfer;
  2368. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2369. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2370. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2371. $log_list = $this->whlabel_bh_transfer_cr->find_all(" lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time,"*","id desc");
  2372. $wwcsl = $jszs = $wgzs = 0;
  2373. $tmp_list = [];
  2374. foreach($log_list as $k=>$v){
  2375. if(!isset($tmp_list[$v['fid']])){
  2376. $tmp_list[$v['fid']] = $v;
  2377. $jszs += 1;
  2378. if($v['is_over'] == 1){
  2379. $wgzs += 1;
  2380. }else{
  2381. $wwcsl += 1;
  2382. }
  2383. }
  2384. }
  2385. $this->data['wwcsl'] = $wwcsl;
  2386. $this->data['jszs'] = $jszs;
  2387. $this->data['wgzs'] = $wgzs;
  2388. $this->data['transfer_list'] = $transfer_list;
  2389. $this->_Template('whlabel_bh_cj_transfer_log',$this->data);
  2390. }
  2391. public function _cj_transfer_zklog(){
  2392. $post = $this->input->post(NULL, TRUE);
  2393. if(!empty($post)){
  2394. $orderinfo = $this->input->post('orderinfo',true);
  2395. $pm = $this->input->post('pm',true);
  2396. $tid = $this->input->post('tid',true);
  2397. $page = $this->input->post('page',true);
  2398. $perpage = $this->input->post('perpage',true);
  2399. $timetk = $this->input->post('timetk',true);
  2400. $timetj = $this->input->post('timetj',true);
  2401. $timetk = strtotime($timetk);
  2402. $timetj = strtotime($timetj);
  2403. $where = " time > '$timetk' and time < '$timetj' and lx = ".$tid." and type = 1 and is_over = 0 ";
  2404. if(empty($page))
  2405. {
  2406. $start = 0;
  2407. $perpage = 20;
  2408. }
  2409. else
  2410. {
  2411. $start = ($page - 1)*$perpage;
  2412. }
  2413. $list = $this->whlabel_bh_transfer_cr->find_all($where,"*",'id asc',$start,$perpage);
  2414. $count = $this->whlabel_bh_transfer_cr->find_all($where,'COUNT(*) as total');
  2415. $total = $count[0]['total'];
  2416. $pagenum = ceil($total/$perpage);
  2417. $over = $total-($start+$perpage);
  2418. $final_list = [];
  2419. foreach($list as $k=>$v){
  2420. $transfer_info = $this->whlabel_bh_transfer->read($v['fid']);
  2421. $final_list[$k]['id'] = $v['id'];
  2422. $final_list[$k]['orderinfo'] = $transfer_info['orderinfo'];
  2423. $final_list[$k]['pm'] = $transfer_info['pm'];
  2424. $final_list[$k]['time'] = date('Y-m-d H:i:s',$v['time']);
  2425. }
  2426. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2427. echo json_encode($rows);exit;
  2428. }
  2429. $tid = $this->input->get('tid',true);
  2430. if(isset($_SESSION['api']))
  2431. {
  2432. $user = $this->user->get_api($_SESSION['api']);
  2433. $transfer = explode('|',trim($user['transfer'],'|'));
  2434. $stid = "";
  2435. foreach ($transfer as $value)
  2436. {
  2437. $stid .= " id = ".$value." or";
  2438. }
  2439. if(empty($transfer)){
  2440. exit("您的账号没有赋予车间权限");
  2441. }
  2442. }
  2443. else
  2444. {
  2445. header('Location: /');exit;
  2446. }
  2447. $transfer = $this->transfer->read($tid);
  2448. $this->data['transfer'] = $transfer;
  2449. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2450. $this->data['transfer_list'] = $transfer_list;
  2451. $this->_Template('whlabel_bh_cj_transfer_zklog',$this->data);
  2452. }
  2453. //针对车间的变动筛选条件的
  2454. public function _cj_transfer_log_count(){
  2455. $orderinfo = $this->input->post('orderinfo',true);
  2456. $tid = $this->input->post('tid',true);
  2457. $timetk = $this->input->post('timetk',true);
  2458. $timetj = $this->input->post('timetj',true);
  2459. $pm = $this->input->post('pm',true);
  2460. $start_time = strtotime($timetk);
  2461. $end_time = strtotime($timetj);
  2462. $where = " lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time;
  2463. // if($orderinfo){
  2464. // $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2465. // $numbers = array_column($number_list,'number');
  2466. // $where.= " and number in (".implode(",",$numbers).") ";
  2467. // }
  2468. if($pm){
  2469. if(empty($orderinfo)){
  2470. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2471. }else{
  2472. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2473. $numbers = array_column($number_list,'number');
  2474. if(empty($numbers)){
  2475. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2476. }
  2477. $where.= " and number in (".implode(",",$numbers).") ";
  2478. }
  2479. }else{
  2480. if($orderinfo){
  2481. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2482. $numbers = array_column($number_list,'number');
  2483. if(empty($numbers)){
  2484. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2485. }
  2486. $where.= " and number in (".implode(",",$numbers).") ";
  2487. }
  2488. }
  2489. $log_list = $this->whlabel_bh_transfer_cr->find_all($where);
  2490. $wwcsl = $jszs = $wgzs = 0;
  2491. $tmp_list = [];
  2492. foreach($log_list as $k=>$v){
  2493. if(!isset($tmp_list[$v['fid']])){
  2494. $tmp_list[$v['fid']] = $v;
  2495. $jszs += 1;
  2496. if($v['is_over'] == 1){
  2497. $wgzs += 1;
  2498. }else{
  2499. $wwcsl += 1;
  2500. }
  2501. }
  2502. }
  2503. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $wwcsl,'jszs'=>$jszs,'wgzs'=>$wgzs]]));
  2504. }
  2505. public function _cj_transfer_detail($arg_array){
  2506. $number = $arg_array[0];
  2507. $tid = $arg_array[1];
  2508. $transfer_info = $this->transfer->read($tid);
  2509. $whlabel_bh_info = $this->whlabel_bh->find(" number = ".$number);
  2510. $final_list = [];
  2511. $log_list = $this->whlabel_bh_transfer_cr->find_all( " number = ".$number." and lx = ".$tid,"*","id asc");
  2512. $collect_list = [];
  2513. foreach($log_list as $k=>$v){
  2514. if(isset($final_list[$v['fid']])){
  2515. if($v['type'] == 1){
  2516. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2517. }else{
  2518. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2519. }
  2520. }else{
  2521. if($v['type'] == 1){
  2522. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2523. }else{
  2524. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2525. }
  2526. }
  2527. }
  2528. $this->data['whlabel_bh_info'] = $whlabel_bh_info;
  2529. $this->data['transfer_info'] = $transfer_info;
  2530. $this->data['final_list'] = $final_list;
  2531. $this->_Template('whlabel_bh_cj_transfer_detail',$this->data);
  2532. }
  2533. public function _excelwchz(){
  2534. $classid = $this->classid->sku();
  2535. $pm = $classid;
  2536. $typeclass = array();
  2537. $tc = $this->typeclass->find_all();
  2538. foreach ($tc as $v)
  2539. {
  2540. $typeclass[$v['id']] = $v;
  2541. }
  2542. $prc = array();
  2543. $purchase = $this->purchase->find_all();
  2544. foreach($purchase as $k=>$v)
  2545. {
  2546. $prc[$v['id']] = $v['title'];
  2547. }
  2548. if(isset($_GET['fexcel']))
  2549. {
  2550. $number = $this->input->get('number',true);
  2551. $pm = $this->input->get('pm',true);
  2552. $color = $this->input->get('color',true);
  2553. $transfer = $this->input->get('transfer',true);
  2554. $ktime = $this->input->get('timetk',true);
  2555. $jtime = $this->input->get('timetj',true);
  2556. $ktime = strtotime($ktime);
  2557. $jtime = strtotime($jtime);
  2558. $where = " time >= ".$ktime." and time <= ".$jtime." ";$gj = "";$ck = "";
  2559. $where .=" and status = 2 and ck like '%|".$transfer."|' ";
  2560. if($number)
  2561. {
  2562. $where .= " and number like '%$number%'";
  2563. }
  2564. if($pm)
  2565. {
  2566. $where .= " and pm like '%$pm%'";
  2567. }
  2568. if($color)
  2569. {
  2570. $where .= " and features like '%-$color-%'";
  2571. }
  2572. $list = array();
  2573. $rows = $this->whlabel_bh_transfer->find_all($where,'id,wbid,orderinfo,jm,pm,time,label,rktime');
  2574. foreach($rows as $k=>$v){
  2575. $cktime = explode("|",trim($v['rktime'],"|"));
  2576. $f_cktime = end($cktime);
  2577. if(isset($list[$v['wbid']])){
  2578. $list[$v['wbid']]['sl'] = $list[$v['wbid']]['sl'] + 1;
  2579. $list[$v['wbid']]['time'][] = date("Y-m-d H:i:s",$f_cktime);
  2580. $list[$v['wbid']]['label'][] = $v['label'];
  2581. }else{
  2582. $list[$v['wbid']] = [
  2583. 'wbid'=>$v['wbid'],
  2584. 'orderinfo'=>$v['orderinfo'],
  2585. 'jm'=>$v['jm'],
  2586. 'pm'=>$v['pm'],
  2587. 'sl'=>1,
  2588. 'time'=>[
  2589. date("Y-m-d H:i:s",$f_cktime)
  2590. ],
  2591. 'label'=>[
  2592. $v['label'],
  2593. ]
  2594. ];
  2595. }
  2596. }
  2597. $filename = date("Y-m-d")."工厂备货完成汇总.xls";
  2598. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2599. <head>
  2600. <!--[if gte mso 9]><xml>
  2601. <x:ExcelWorkbook>
  2602. <x:ExcelWorksheets>
  2603. <x:ExcelWorksheet>
  2604. <x:Name>EXCEL</x:Name>
  2605. <x:WorksheetOptions>
  2606. <x:Print>
  2607. <x:ValidPrinterInfo />
  2608. </x:Print>
  2609. </x:WorksheetOptions>
  2610. </x:ExcelWorksheet>
  2611. </x:ExcelWorksheets>
  2612. </x:ExcelWorkbook>
  2613. </xml>
  2614. <![endif]-->
  2615. </head><body>";
  2616. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2617. $str .= "<tr><td>ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";
  2618. foreach ($list as $key=>$value)
  2619. {
  2620. $str .= "<tr>";
  2621. $str .= "<td>". $value['wbid']. "</td>";
  2622. $str .= "<td>". $value['orderinfo']. "</td>";
  2623. $str .= "<td>". $value['jm']. "</td>";
  2624. $str .= "<td>". $value['pm']. "</td>";
  2625. $str .= "<td>". $value['sl']. "</td>";
  2626. $str .="<td>";
  2627. $tmp = "";
  2628. foreach($value['time'] as $kk=>$vv){
  2629. $tmp .=$vv."<br/>";
  2630. }
  2631. $str .= trim($tmp,"<br/>");
  2632. $str .="</td>";
  2633. $str .="<td>";
  2634. $tmp_l = "";
  2635. foreach($value['label'] as $kk=>$vv){
  2636. $tmp_l .= "`".$vv."<br/>";
  2637. }
  2638. $str .= trim($tmp_l,"<br/>");
  2639. $str .="</td>";
  2640. $str .= "</tr>";
  2641. }
  2642. $str .= "</table></body></html>";
  2643. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2644. header( "Content-type: application/octet-stream" );
  2645. header( "Content-Disposition: attachment; filename=".$filename );
  2646. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2647. header( "Pragma: no-cache" );
  2648. header( "Expires: 0" );
  2649. exit($str);
  2650. }
  2651. }
  2652. public function _excelcpkhz(){
  2653. // $classid = $this->classid->sku();
  2654. // $pm = $classid;
  2655. // $typeclass = array();
  2656. // $tc = $this->typeclass->find_all();
  2657. // foreach ($tc as $v)
  2658. // {
  2659. // $typeclass[$v['id']] = $v;
  2660. // }
  2661. // $prc = array();
  2662. // $purchase = $this->purchase->find_all();
  2663. // foreach($purchase as $k=>$v)
  2664. // {
  2665. // $prc[$v['id']] = $v['title'];
  2666. // }
  2667. if(isset($_GET['fexcel']))
  2668. {
  2669. $transfer = $this->input->get('transfer',true);
  2670. $ktime = $this->input->get('timetk',true);
  2671. $jtime = $this->input->get('timetj',true);
  2672. $ktime = strtotime($ktime);
  2673. $jtime = strtotime($jtime);
  2674. $where = " time >= ".$ktime." and time <= ".$jtime." and lx = " .$transfer." and type = 1 " ;$gj = "";$ck = "";
  2675. $list = array();
  2676. $rows = $this->whlabel_bh_transfer_cr->find_all($where,'*');
  2677. foreach($rows as $k=>$v){
  2678. if(!isset($list['fid'])){
  2679. $list[$v['fid']] = [
  2680. 'fid'=>$v['fid'],
  2681. 'time'=>date("Y-m-d H:i:s",$v['time'])
  2682. ];
  2683. }
  2684. }
  2685. $fid_list = array_column($list,'fid');
  2686. if(!empty($fid_list)){
  2687. $tmp_list = $this->whlabel_bh_transfer->find_all(" id in (".implode(",",$fid_list).") ","id,wbid,orderinfo,jm,pm,time,label","id asc");
  2688. $tmp_list = array_column($tmp_list,null,'id');
  2689. foreach($list as $k=>$v){
  2690. if(isset($tmp_list[$k])){
  2691. $list[$v['fid']]['wbid'] = $tmp_list[$k]['wbid'];
  2692. $list[$v['fid']]['orderinfo'] = $tmp_list[$k]['orderinfo'];
  2693. $list[$v['fid']]['jm'] = $tmp_list[$k]['jm'];
  2694. $list[$v['fid']]['pm'] = $tmp_list[$k]['pm'];
  2695. $list[$v['fid']]['sl'] = 1;
  2696. $list[$v['fid']]['label'] = $tmp_list[$k]['label'];
  2697. }
  2698. }
  2699. }else{
  2700. $list = [];
  2701. }
  2702. $filename = date("YmdHi",$ktime)."~".date("YmdHi",$jtime)."工厂成品库扫入库汇总.xls";
  2703. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2704. <head>
  2705. <!--[if gte mso 9]><xml>
  2706. <x:ExcelWorkbook>
  2707. <x:ExcelWorksheets>
  2708. <x:ExcelWorksheet>
  2709. <x:Name>EXCEL</x:Name>
  2710. <x:WorksheetOptions>
  2711. <x:Print>
  2712. <x:ValidPrinterInfo />
  2713. </x:Print>
  2714. </x:WorksheetOptions>
  2715. </x:ExcelWorksheet>
  2716. </x:ExcelWorksheets>
  2717. </x:ExcelWorkbook>
  2718. </xml>
  2719. <![endif]-->
  2720. </head><body>";
  2721. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2722. $str .= "<tr><td>布标ID</td><td>订单ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";
  2723. foreach ($list as $key=>$value)
  2724. {
  2725. $str .= "<tr>";
  2726. $str .= "<td>". $key. "</td>";
  2727. $str .= "<td>". $value['wbid']. "</td>";
  2728. $str .= "<td>". $value['orderinfo']. "</td>";
  2729. $str .= "<td>". $value['jm']. "</td>";
  2730. $str .= "<td>". $value['pm']. "</td>";
  2731. $str .= "<td>". $value['sl']. "</td>";
  2732. $str .= "<td>".$value['time']."</td>";
  2733. $str .= "<td>`".$value['label']."</td>";
  2734. $str .= "</tr>";
  2735. }
  2736. $str .= "</table></body></html>";
  2737. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2738. header( "Content-type: application/octet-stream" );
  2739. header( "Content-Disposition: attachment; filename=".$filename );
  2740. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2741. header( "Pragma: no-cache" );
  2742. header( "Expires: 0" );
  2743. exit($str);
  2744. }
  2745. }
  2746. }