Whlabel_bh.php 80 KB

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