Whlabel_bh.php 97 KB

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