Whlabel_bh.php 85 KB

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