Whlabel_bh.php 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977
  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
  110. {
  111. $this->_index();
  112. }
  113. }
  114. //管理
  115. public function _index()
  116. {
  117. $post = $this->input->post(NULL, TRUE);
  118. if(isset($post['page']))
  119. {
  120. $page = $this->input->post('page',true);
  121. $perpage = $this->input->post('perpage',true);
  122. $orderinfo = $this->input->post('orderinfo',true);
  123. $jm = $this->input->post('jm',true);
  124. $title = $this->input->post('title',true);
  125. $pm = $this->input->post('pm',true);
  126. $category = $this->input->post('category',true);
  127. $size = $this->input->post('size',true);
  128. $grade = $this->input->post('grade',true);
  129. $color = $this->input->post('color',true);
  130. $lowe = $this->input->post('lowe',true);
  131. $type = $this->input->post('type',true);
  132. $shipremarks = $this->input->post('shipremarks',true);
  133. $type = $this->input->post('type',true);
  134. $state = $this->input->post('state',true);
  135. $timetk = $this->input->post('timetk',true);
  136. $timetj = $this->input->post('timetj',true);
  137. $timetk = strtotime($timetk);
  138. $timetj = strtotime($timetj);
  139. $where = "1=1 ";
  140. if($timetk && $timetj)
  141. {
  142. $where .= " and time > '$timetk' and time < '$timetj'";
  143. }
  144. if($orderinfo)
  145. {
  146. $where .= " and orderinfo like '%$orderinfo%'";
  147. }
  148. if($type != '')
  149. {
  150. $where .= " and type = '$type'";
  151. }
  152. if($jm)
  153. {
  154. $where .= " and jm like '%$jm%'";
  155. }
  156. if($title)
  157. {
  158. $where .= " and title like '%$title%'";
  159. }
  160. if($pm)
  161. {
  162. $where .= " and pm like '%$pm%'";
  163. }
  164. if($category)
  165. {
  166. $where .= " and shipremarks like '%-$category-%'";
  167. }
  168. if($size)
  169. {
  170. $where .= " and shipremarks like '%-$size-%'";
  171. }
  172. if($grade)
  173. {
  174. $where .= " and shipremarks like '%-$grade-%'";
  175. }
  176. if($color)
  177. {
  178. $where .= " and shipremarks like '%-$color-%'";
  179. }
  180. if($lowe)
  181. {
  182. $where .= " and shipremarks like '%-$lowe-%'";
  183. }
  184. if($type)
  185. {
  186. $where .= " and type = '$type'";
  187. }
  188. if($state)
  189. {
  190. $where .= " and state = '$state'";
  191. }
  192. if($shipremarks)
  193. {
  194. $where .= " and shipremarks like '%$shipremarks%'";
  195. }
  196. //数据排序
  197. $order_str = "time desc";
  198. if(empty($page))
  199. {
  200. $start = 0;
  201. $perpage = 1;
  202. }
  203. else
  204. {
  205. $start = ($page - 1)*$perpage;
  206. }
  207. $warehouse = $this->warehouse->find_all();
  208. $ck = array();
  209. foreach ($warehouse as $v)
  210. {
  211. $ck[$v['id']] = $v['title'];
  212. }
  213. //取得信息列表
  214. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,time,cscg',$order_str,$start,$perpage);
  215. foreach ($info_list as $key=>$value)
  216. {
  217. $d = $this->whlabel_bh->read($value['id']);
  218. $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'];
  219. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  220. $printnum = array_sum(array_column($printnum,'ts'));
  221. $info_list[$key]['printnum'] = $printnum;
  222. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  223. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  224. $info_list[$key]['cscg'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  225. }
  226. $total = $this->whlabel_bh->find_count($where);
  227. $pagenum = ceil($total/$perpage);
  228. $over = $total-($start+$perpage);
  229. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  230. echo json_encode($rows);exit;
  231. /**
  232. $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);
  233. foreach ($info_list as $key=>$value)
  234. {
  235. $d = $this->whlabel_bh->read($value['id']);
  236. if($d['print'] == 0)
  237. {
  238. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  239. }
  240. else
  241. {
  242. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  243. }
  244. if($value['state'] == 0)
  245. {
  246. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  247. }
  248. else if($value['state'] == 1)
  249. {
  250. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  251. }
  252. else if($value['state'] == 2)
  253. {
  254. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  255. }
  256. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  257. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  258. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  259. $zc = '';
  260. foreach ($zd as $v)
  261. {
  262. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  263. }
  264. $info_list[$key]['scapi'] = $zc;
  265. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  266. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  267. }
  268. **/
  269. }
  270. if(isset($_SESSION['api']))
  271. {
  272. $user = $this->user->get_api($_SESSION['api']);
  273. }
  274. else
  275. {
  276. header('Location: /');exit;
  277. }
  278. $w = $this->shop->find_all("yyid != ''");
  279. $this->data['yyck'] = $w;
  280. if($user['userid'] == 'ch')
  281. {
  282. $user['vip'] = 1;
  283. }
  284. $this->data['vip'] = $user['vip'];
  285. $this->_Template('whlabel_bh',$this->data);
  286. }
  287. //入库操作
  288. public function _add()
  289. {
  290. $tc = $this->typeclass->find_all();
  291. $typeclass = array();
  292. foreach ($tc as $v)
  293. {
  294. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  295. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  296. }
  297. $post = $this->input->post(NULL, TRUE);
  298. if(isset($post['num']))
  299. {
  300. $list = array();
  301. $sku = $this->input->post('sku',true);
  302. $category = $this->input->post('category',true);
  303. $list['category'] = $category;
  304. $list['hairtype'] = $this->input->post('hairtype',true);
  305. $list['grade'] = $this->input->post('grade',true);
  306. $size = $this->input->post('size',true);
  307. $xzsku = $this->input->post('xzsku',true);
  308. $list['size'] = rtrim($size,',');
  309. $list['hairnumber'] = $this->input->post('hairnumber',true);
  310. $list['extension'] = $this->input->post('extension',true);
  311. if($category == 1297)
  312. {
  313. $list['sywignumber'] = $this->input->post('sywignumber',true);
  314. }
  315. if($category == 1702)
  316. {
  317. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  318. $list['syother'] = $this->input->post('syother',true);
  319. }
  320. if($category == 133)
  321. {
  322. $list['fittype'] = $this->input->post('fittype',true);
  323. $list['acother'] = $this->input->post('acother',true);
  324. }
  325. $list['color'] = $this->input->post('color',true);
  326. $list['lowe'] = $this->input->post('lowe',true);
  327. if($category == 127)
  328. {
  329. $list['type'] = $this->input->post('type',true);
  330. $list['headroad'] = $this->input->post('headroad',true);
  331. $list['density'] = $this->input->post('density',true);
  332. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  333. {
  334. $list['lacesize'] = $this->input->post('lacesize',true);
  335. }
  336. $list['lacecolor'] = $this->input->post('lacecolor',true);
  337. $list['lacetypes'] = $this->input->post('lacetypes',true);
  338. }
  339. if($category == 128)
  340. {
  341. $list['lacetype'] = $this->input->post('lacetype',true);
  342. $list['haircap'] = $this->input->post('haircap',true);
  343. $list['density'] = $this->input->post('density',true);
  344. $list['lacecolor'] = $this->input->post('lacecolor',true);
  345. $list['lacetypes'] = $this->input->post('lacetypes',true);
  346. $list['wigother'] = $this->input->post('wigother',true);
  347. $list['wigother1'] = $this->input->post('wigother1',true);
  348. $list['wigother2'] = $this->input->post('wigother2',true);
  349. }
  350. if($category == 129)
  351. {
  352. $list['wide'] = $this->input->post('wide',true);
  353. }
  354. if($category == 131)
  355. {
  356. $list['gifttype'] = $this->input->post('gifttype',true);
  357. $list['giftother'] = $this->input->post('giftother',true);
  358. }
  359. if($category == 134)
  360. {
  361. $list['pieceweight'] = $this->input->post('pieceweight',true);
  362. }
  363. if($category == 1297)
  364. {
  365. $list['synthetictype'] = $this->input->post('synthetictype',true);
  366. $list['sywigother'] = $this->input->post('sywigother',true);
  367. }
  368. if($category == 130 || $category == 133 || $category == 1702)
  369. {
  370. $list['items'] = $this->input->post('items',true);
  371. $list['weight'] = $this->input->post('weight',true);
  372. }
  373. if($category == 1702)
  374. {
  375. $list['syhairther'] = $this->input->post('syhairther',true);
  376. }
  377. $classid = $this->classid->sku();
  378. $pm = $classid;
  379. $jm = $classid;
  380. $sku = $sku;
  381. $title = '';$features = '';$cs = array();
  382. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  383. foreach($list as $k=>$v)
  384. {
  385. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  386. {
  387. if($typeclass[$v]['bm'] != '')
  388. {
  389. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  390. }
  391. }
  392. if($v != 0)
  393. {
  394. if($k != 'size')
  395. {
  396. $title .= $typeclass[$v]['title']." ";
  397. }
  398. $features .=$v.'-';
  399. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  400. if(isset($pm[$typeclass[$v]['classid']]))
  401. {
  402. if($typeclass[$v]['title'] == '9A')
  403. {
  404. $pm[$typeclass[$v]['classid']] = '9A';
  405. }
  406. else if($typeclass[$v]['title'] == '10A')
  407. {
  408. $pm[$typeclass[$v]['classid']] = '10A';
  409. }
  410. else
  411. {
  412. $clzh = $typeclass[$v]['zh'];
  413. if(stripos($typeclass[$v]['zh'],'|') !== false)
  414. {
  415. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  416. $clzh = $clzh[0];
  417. }
  418. $pm[$typeclass[$v]['classid']] = $clzh;
  419. }
  420. }
  421. if(isset($jm[$typeclass[$v]['classid']]))
  422. {
  423. if($typeclass[$v]['jm'])
  424. {
  425. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  426. }
  427. }
  428. }
  429. }
  430. $jm = array_filter($jm);//去除空值
  431. $jm = implode("-",$jm);
  432. $sku = array_filter($sku);//去除空值
  433. $sku = implode("-",$sku);
  434. $pm = array_filter($pm);//去除空值
  435. $pm = implode(" ",$pm);
  436. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  437. if($list['size'])
  438. {
  439. $typeclass = $this->typeclass->read($list['size']);
  440. $title .= $typeclass['title'];
  441. }
  442. $title = trim($title,' ');
  443. $post['num'] = $this->input->post('num',true);
  444. $ztime = $this->input->post('ztime',true);
  445. $post['ztime'] = strtotime($ztime);
  446. $post['bm'] = '03'.implode("",$bmpx);
  447. $post['jm'] = $jm;
  448. $post['sku'] = $sku;
  449. $post['pm'] = $pm;
  450. $post['title'] = $title;
  451. $post['features'] = '-'.$features;
  452. $post['number'] = date('YmdHis',time()).rand(100,999);
  453. if(!$post['num'])
  454. {
  455. $post['number'] = date("YmdHis").rand(100,999);
  456. }
  457. $time = time();
  458. $post['time'] = $time;//操作时间
  459. $post['printnum'] = $time;
  460. $post['type'] = 0;
  461. //传输料号开始
  462. $lc = 0;
  463. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  464. if(isset($lh['Data'][0]))
  465. {
  466. if($lh['Data'][0]['m_isSucess'] != 1)
  467. {
  468. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  469. {
  470. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  471. }
  472. }
  473. }
  474. else
  475. {
  476. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  477. }
  478. if($this->whlabel_bh->insert($post))
  479. {
  480. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  481. }
  482. else
  483. {
  484. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  485. }
  486. }
  487. $w = $this->shop->find_all("yyid != ''");
  488. $this->data['yyck'] = $w;
  489. $purchase = $this->purchase->find_all("yyid != ''");
  490. $this->data['purchase'] = $purchase;
  491. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  492. $this->_Template('whlabel_bh_add',$this->data);
  493. }
  494. public function get_cjlp($data)//创建料品
  495. {
  496. $list["0"]["Code"] = $data['jm'];//料号,SKU
  497. $list["0"]["Code1"] = '';
  498. $list["0"]["Name"] = $data['zh'];//产品名称
  499. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  500. $list["0"]["Org"]["Code"] = 001;
  501. $list["0"]["OtherID"] = 1;
  502. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  503. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  504. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  505. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  506. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  507. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  508. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  509. $list["0"]["InventoryUOM"]["Code"] = '条';
  510. $list["0"]["InventorySecondUOM"]["Code"] = '';
  511. $list["0"]["IsDualUOM"] = false;
  512. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  513. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  514. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  515. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  516. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  517. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  518. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  519. $list["0"]["Description"] = $data['title'];
  520. $list["0"]["ItemForm"] = 2001;
  521. $list["0"]["ItemFormAttribute"] = 10;
  522. $list["0"]["IsInventoryEnable"] = true;
  523. $list["0"]["IsPurchaseEnable"] = true;
  524. $list["0"]["IsSalesEnable"] = true;
  525. $list["0"]["IsBuildEnable"] = true;
  526. $list["0"]["IsOutsideOperationEnable"] = true;
  527. $list["0"]["IsMRPEnable"] = true;
  528. $list["0"]["IsBOMEnable"] = true;
  529. $list["0"]["IsCostCalByGrade"] = false;
  530. $list["0"]["IsCostCalByPotency"] = false;
  531. $list["0"]["IsGradeControl"] = false;
  532. $list["0"]["StandardGrade"] = -1;
  533. $list["0"]["StartGrade"] = -1;
  534. $list["0"]["EndGrade"] = -1;
  535. $list["0"]["IsPotencyControl"] = false;
  536. $list["0"]["StandardPotency"] = -1;
  537. $list["0"]["StartPotency"] = -1;
  538. $list["0"]["EndPotency"] = -1;
  539. $asd = $list;
  540. $list = json_encode($list);
  541. $token = $this->setting->get_yytoken_130();
  542. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  543. $header[] = "Content-Type: application/json";
  544. $header[] = "Token: ".$token;
  545. $ch = curl_init();
  546. curl_setopt($ch, CURLOPT_URL, $url);
  547. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  548. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  549. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  550. curl_setopt($ch, CURLOPT_POST, 1);
  551. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  552. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  553. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  554. $res = curl_exec($ch);
  555. $res = json_decode($res,true);
  556. return $asd;
  557. }
  558. //修改产品
  559. public function _edit($arg_array)
  560. {
  561. $tc = $this->typeclass->find_all();
  562. $typeclass = array();
  563. foreach ($tc as $v)
  564. {
  565. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  566. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  567. }
  568. $post = $this->input->post(NULL, TRUE);
  569. if(isset($post['id']))
  570. {
  571. $id = $this->input->post('id',true);
  572. $list = array();
  573. $sku = $this->input->post('sku',true);
  574. $category = $this->input->post('category',true);
  575. $list['category'] = $category;
  576. $list['hairtype'] = $this->input->post('hairtype',true);
  577. $list['grade'] = $this->input->post('grade',true);
  578. $size = $this->input->post('size',true);
  579. $xzsku = $this->input->post('xzsku',true);
  580. $list['size'] = rtrim($size,',');
  581. $list['hairnumber'] = $this->input->post('hairnumber',true);
  582. $list['extension'] = $this->input->post('extension',true);
  583. if($category == 1297)
  584. {
  585. $list['sywignumber'] = $this->input->post('sywignumber',true);
  586. }
  587. if($category == 1702)
  588. {
  589. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  590. $list['syother'] = $this->input->post('syother',true);
  591. }
  592. if($category == 133)
  593. {
  594. $list['fittype'] = $this->input->post('fittype',true);
  595. $list['acother'] = $this->input->post('acother',true);
  596. }
  597. $list['color'] = $this->input->post('color',true);
  598. $list['lowe'] = $this->input->post('lowe',true);
  599. if($category == 127)
  600. {
  601. $list['type'] = $this->input->post('type',true);
  602. $list['headroad'] = $this->input->post('headroad',true);
  603. $list['density'] = $this->input->post('density',true);
  604. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  605. {
  606. $list['lacesize'] = $this->input->post('lacesize',true);
  607. }
  608. $list['lacecolor'] = $this->input->post('lacecolor',true);
  609. $list['lacetypes'] = $this->input->post('lacetypes',true);
  610. }
  611. if($category == 128)
  612. {
  613. $list['lacetype'] = $this->input->post('lacetype',true);
  614. $list['haircap'] = $this->input->post('haircap',true);
  615. $list['density'] = $this->input->post('density',true);
  616. $list['lacecolor'] = $this->input->post('lacecolor',true);
  617. $list['lacetypes'] = $this->input->post('lacetypes',true);
  618. $list['wigother'] = $this->input->post('wigother',true);
  619. $list['wigother1'] = $this->input->post('wigother1',true);
  620. $list['wigother2'] = $this->input->post('wigother2',true);
  621. }
  622. if($category == 129)
  623. {
  624. $list['wide'] = $this->input->post('wide',true);
  625. }
  626. if($category == 131)
  627. {
  628. $list['gifttype'] = $this->input->post('gifttype',true);
  629. $list['giftother'] = $this->input->post('giftother',true);
  630. }
  631. if($category == 134)
  632. {
  633. $list['pieceweight'] = $this->input->post('pieceweight',true);
  634. }
  635. if($category == 1297)
  636. {
  637. $list['synthetictype'] = $this->input->post('synthetictype',true);
  638. $list['sywigother'] = $this->input->post('sywigother',true);
  639. }
  640. if($category == 130 || $category == 133 || $category == 1702)
  641. {
  642. $list['items'] = $this->input->post('items',true);
  643. $list['weight'] = $this->input->post('weight',true);
  644. }
  645. if($category == 1702)
  646. {
  647. $list['syhairther'] = $this->input->post('syhairther',true);
  648. }
  649. $classid = $this->classid->sku();
  650. $pm = $classid;
  651. $jm = $classid;
  652. $sku = $sku;
  653. $title = '';$features = '';$cs = array();
  654. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  655. foreach($list as $k=>$v)
  656. {
  657. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  658. {
  659. if($typeclass[$v]['bm'] != '')
  660. {
  661. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  662. }
  663. }
  664. if($v != 0)
  665. {
  666. if($k != 'size')
  667. {
  668. $title .= $typeclass[$v]['title']." ";
  669. }
  670. $features .=$v.'-';
  671. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  672. if(isset($pm[$typeclass[$v]['classid']]))
  673. {
  674. if($typeclass[$v]['title'] == '9A')
  675. {
  676. $pm[$typeclass[$v]['classid']] = '9A';
  677. }
  678. else if($typeclass[$v]['title'] == '10A')
  679. {
  680. $pm[$typeclass[$v]['classid']] = '10A';
  681. }
  682. else
  683. {
  684. $clzh = $typeclass[$v]['zh'];
  685. if(stripos($typeclass[$v]['zh'],'|') !== false)
  686. {
  687. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  688. $clzh = $clzh[0];
  689. }
  690. $pm[$typeclass[$v]['classid']] = $clzh;
  691. }
  692. }
  693. if(isset($jm[$typeclass[$v]['classid']]))
  694. {
  695. if($typeclass[$v]['jm'])
  696. {
  697. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  698. }
  699. }
  700. }
  701. }
  702. $jm = array_filter($jm);//去除空值
  703. $jm = implode("-",$jm);
  704. $sku = array_filter($sku);//去除空值
  705. $sku = implode("-",$sku);
  706. $pm = array_filter($pm);//去除空值
  707. $pm = implode(" ",$pm);
  708. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  709. if($list['size'])
  710. {
  711. $typeclass = $this->typeclass->read($list['size']);
  712. $title .= $typeclass['title'];
  713. }
  714. $title = trim($title,' ');
  715. $post['num'] = $this->input->post('num',true);
  716. $ztime = $this->input->post('ztime',true);
  717. $post['ztime'] = strtotime($ztime);
  718. $post['bm'] = '03'.implode("",$bmpx);
  719. $post['jm'] = $jm;
  720. $post['sku'] = $sku;
  721. $post['pm'] = $pm;
  722. $post['title'] = $title;
  723. $post['features'] = '-'.$features;
  724. $ztime = $this->input->post('ztime',true);
  725. if($ztime)
  726. {
  727. $post['ztime'] = strtotime($ztime);
  728. }
  729. if($this->whlabel_bh->save($post,$id))
  730. {
  731. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  732. }
  733. else
  734. {
  735. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  736. }
  737. }
  738. $w = $this->shop->find_all("yyid != ''");
  739. $this->data['yyck'] = $w;
  740. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  741. $this->data['whlabel_bh'] = $whlabel_bh ;
  742. $purchase = $this->purchase->find_all("yyid != ''");
  743. $this->data['purchase'] = $purchase;
  744. $this->_Template('whlabel_bh_edit',$this->data);
  745. }
  746. public function _cz()
  747. {
  748. $post = $this->input->post(NULL, TRUE);
  749. if(isset($post['id']))
  750. {
  751. $id = $this->input->post('id',true);
  752. $cz = $this->input->post('cz',true);
  753. $num = $this->input->post('num',true);
  754. $cz = $cz+1;
  755. $w = $this->whlabel_bh->read($id);
  756. if(!$w)
  757. {
  758. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  759. }
  760. //传输料号开始
  761. $lc = 0;
  762. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  763. if(isset($lh['Data'][0]))
  764. {
  765. if($lh['Data'][0]['m_isSucess'] != 1)
  766. {
  767. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  768. {
  769. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  770. }
  771. }
  772. }
  773. else
  774. {
  775. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  776. }
  777. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  778. /** 投产
  779. if($w['scapi'] != 99)
  780. {
  781. if($w['state'] == $cz)
  782. {
  783. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  784. }
  785. if($w['type'] == '0')
  786. {
  787. $type = '生产';
  788. $bhlx = 0;
  789. }
  790. else
  791. {
  792. $type = '外购';
  793. $bhlx = 1;
  794. }
  795. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  796. if($yy['c'] == 0)
  797. {
  798. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  799. {
  800. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  801. }
  802. else
  803. {
  804. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  805. }
  806. }
  807. else
  808. {
  809. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  810. }
  811. }
  812. else if($w['dbapi'] != 99 && $w['type'] == '0')
  813. {
  814. $cz = 1;
  815. if(!is_numeric($num))
  816. {
  817. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  818. }
  819. if($num > $w['num']-$w['rknum'])
  820. {
  821. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  822. }
  823. if($w['rknum']+$num == $w['num'])
  824. {
  825. $dbapi = 99;
  826. $cz = 2;
  827. }
  828. else
  829. {
  830. $dbapi = 0;
  831. }
  832. $w['ts'] = $num;
  833. $rk = $this->apiyy->_newrk($w);
  834. if($rk['c'] == 0)
  835. {
  836. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  837. {
  838. if($dbapi == 99)
  839. {
  840. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  841. }
  842. else
  843. {
  844. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  845. }
  846. }
  847. else
  848. {
  849. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  850. }
  851. }
  852. else
  853. {
  854. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  855. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  856. }
  857. }
  858. else if($w['dbapi'] != 99 && $w['type'] == '1')
  859. {
  860. $cz = 1;
  861. if(!is_numeric($num))
  862. {
  863. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  864. }
  865. if($num > $w['num']-$w['rknum'])
  866. {
  867. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  868. }
  869. if($w['rknum']+$num == $w['num'])
  870. {
  871. $dbapi = 99;
  872. $cz = 2;
  873. }
  874. else
  875. {
  876. $dbapi = 0;
  877. }
  878. $scid = explode('~',$w['scid']);
  879. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  880. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  881. {
  882. if($dbapi == 99)
  883. {
  884. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  885. }
  886. else
  887. {
  888. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  889. }
  890. }
  891. else
  892. {
  893. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  894. }
  895. }
  896. **/
  897. }
  898. }
  899. public function _db()
  900. {
  901. $post = $this->input->post(NULL, TRUE);
  902. if(isset($post['id']))
  903. {
  904. $id = $this->input->post('id',true);
  905. $num = $this->input->post('num',true);
  906. $warehouse = $this->input->post('warehouse',true);
  907. $w = $this->warehouse->read($warehouse);
  908. $data = $this->whlabel_bh->read($id);
  909. if(!$data)
  910. {
  911. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  912. }
  913. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  914. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  915. if($num > $data['rknum']-$ydbnum)
  916. {
  917. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  918. }
  919. $data['dccbm'] = 13001;//默认从许昌仓调出
  920. $data['ts'] = $num;
  921. $data['drcbm'] = $w['yybm'];
  922. $dc = $this->apiyy->get_cpdc($data);
  923. if(isset($dc['Data'][0]))
  924. {
  925. if($dc['Data'][0]['IsSucess'] != 1)
  926. {
  927. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  928. }
  929. else
  930. {
  931. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  932. if(isset($sh['Data'][0]))
  933. {
  934. $code = $sh['Data'][0]['Code'];
  935. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  936. }
  937. else
  938. {
  939. $code = '';
  940. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  941. }
  942. $p['uid'] = $id;
  943. $p['bm'] = $data['bm'];
  944. $p['sku'] = $data['jm'];
  945. $p['shipremarks'] = $data['shipremarks'];
  946. $p['title'] = $data['title'];
  947. $p['zh'] = $data['pm'];
  948. $p['fpdata'] = $data['features'];
  949. $p['num'] = $num;
  950. $p['warehouse'] = 13;//默认从许昌仓调出
  951. $p['rwarehouse'] = $warehouse;
  952. $p['time'] = time();//操作时间
  953. $p['code'] = $code;
  954. $this->whlabel_bh_list->insert($p);
  955. }
  956. }
  957. else
  958. {
  959. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  960. }
  961. }
  962. }
  963. public function _del()
  964. {
  965. $post = $this->input->post(NULL, TRUE);
  966. if(isset($post['s']))
  967. {
  968. $id_arr = $this->input->post('s');
  969. $id_arr = explode(',',trim($id_arr,','));
  970. if(!$id_arr)
  971. {
  972. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  973. }
  974. //循环删除记录
  975. foreach ($id_arr as $v)
  976. {
  977. $w = $this->whlabel_bh->read($v);
  978. if($w['state'] > 0)
  979. {
  980. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  981. }
  982. }
  983. foreach ($id_arr as $v)
  984. {
  985. $this->whlabel_bh->remove($v);
  986. }
  987. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  988. }
  989. }
  990. public function _deltransfer()
  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. if(count($id_arr) > 1)
  1002. {
  1003. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  1004. }
  1005. foreach ($id_arr as $v)
  1006. {
  1007. $this->whlabel_bh_transfer->remove($v);
  1008. }
  1009. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1010. }
  1011. }
  1012. public function _kc()
  1013. {
  1014. $post = $this->input->post(NULL, TRUE);
  1015. if(isset($post['category']))
  1016. {
  1017. $list = array();
  1018. $sku = $this->input->post('sku',true);
  1019. $features = $this->input->post('features',true);
  1020. $category = $this->input->post('category',true);
  1021. $list['category'] = $category;
  1022. $list['hairtype'] = $this->input->post('hairtype',true);
  1023. $list['grade'] = $this->input->post('grade',true);
  1024. $size = $this->input->post('size',true);
  1025. $xzsku = $this->input->post('xzsku',true);
  1026. $list['size'] = rtrim($size,',');
  1027. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1028. $list['extension'] = $this->input->post('extension',true);
  1029. if($category == 1297)
  1030. {
  1031. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1032. }
  1033. if($category == 1702)
  1034. {
  1035. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1036. $list['syother'] = $this->input->post('syother',true);
  1037. }
  1038. if($category == 133)
  1039. {
  1040. $list['fittype'] = $this->input->post('fittype',true);
  1041. $list['acother'] = $this->input->post('acother',true);
  1042. }
  1043. $list['color'] = $this->input->post('color',true);
  1044. $list['lowe'] = $this->input->post('lowe',true);
  1045. if($category == 127)
  1046. {
  1047. $list['type'] = $this->input->post('type',true);
  1048. $list['headroad'] = $this->input->post('headroad',true);
  1049. $list['density'] = $this->input->post('density',true);
  1050. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1051. {
  1052. $list['lacesize'] = $this->input->post('lacesize',true);
  1053. }
  1054. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1055. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1056. }
  1057. if($category == 128)
  1058. {
  1059. $list['lacetype'] = $this->input->post('lacetype',true);
  1060. $list['haircap'] = $this->input->post('haircap',true);
  1061. $list['density'] = $this->input->post('density',true);
  1062. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1063. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1064. $list['wigother'] = $this->input->post('wigother',true);
  1065. $list['wigother1'] = $this->input->post('wigother1',true);
  1066. $list['wigother2'] = $this->input->post('wigother2',true);
  1067. }
  1068. if($category == 129)
  1069. {
  1070. $list['wide'] = $this->input->post('wide',true);
  1071. }
  1072. if($category == 131)
  1073. {
  1074. $list['gifttype'] = $this->input->post('gifttype',true);
  1075. $list['giftother'] = $this->input->post('giftother',true);
  1076. }
  1077. if($category == 134)
  1078. {
  1079. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1080. }
  1081. if($category == 1297)
  1082. {
  1083. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1084. $list['sywigother'] = $this->input->post('sywigother',true);
  1085. }
  1086. if($category == 130 || $category == 133 || $category == 1702)
  1087. {
  1088. $list['items'] = $this->input->post('items',true);
  1089. $list['weight'] = $this->input->post('weight',true);
  1090. }
  1091. if($category == 1702)
  1092. {
  1093. $list['syhairther'] = $this->input->post('syhairther',true);
  1094. }
  1095. $shipremarks = '';
  1096. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1097. foreach($list as $k=>$v)
  1098. {
  1099. if($v != 0)
  1100. {
  1101. $shipremarks .=$v.'-';
  1102. }
  1103. }
  1104. $shipremarks = '-'.$shipremarks;
  1105. if($features)
  1106. {
  1107. $shipremarks = $features;
  1108. }
  1109. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1110. if($w > 0)
  1111. {
  1112. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1113. }
  1114. else
  1115. {
  1116. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1117. }
  1118. }
  1119. }
  1120. public function _excel()
  1121. {
  1122. $classid = $this->classid->sku();
  1123. $pm = $classid;
  1124. $typeclass = array();
  1125. $tc = $this->typeclass->find_all();
  1126. foreach ($tc as $v)
  1127. {
  1128. $typeclass[$v['id']] = $v;
  1129. }
  1130. $prc = array();
  1131. $purchase = $this->purchase->find_all();
  1132. foreach($purchase as $k=>$v)
  1133. {
  1134. $prc[$v['id']] = $v['title'];
  1135. }
  1136. if(isset($_GET['excel']))
  1137. {
  1138. $number = $this->input->post('number',true);
  1139. $sku = $this->input->post('sku',true);
  1140. $title = $this->input->post('title',true);
  1141. $pm = $this->input->post('pm',true);
  1142. $category = $this->input->post('category',true);
  1143. $size = $this->input->post('size',true);
  1144. $grade = $this->input->post('grade',true);
  1145. $color = $this->input->post('color',true);
  1146. $lowe = $this->input->post('lowe',true);
  1147. $state = $this->input->post('state',true);
  1148. $shipremarks = $this->input->post('shipremarks',true);
  1149. $type = $this->input->post('type',true);
  1150. $sid = $this->input->get('sid',true);
  1151. $ktime = $this->input->get('ktime',true);
  1152. $jtime = $this->input->get('jtime',true);
  1153. $ktime = strtotime($ktime);
  1154. $jtime = strtotime($jtime);
  1155. $where = "1=1";$gj = "";$ck = "";
  1156. if($number)
  1157. {
  1158. $where .= " and number like '%$number%'";
  1159. }
  1160. if($type != '')
  1161. {
  1162. $where .= " and type = '$type'";
  1163. }
  1164. if($sku)
  1165. {
  1166. $where .= " and sku like '%$sku%'";
  1167. }
  1168. if($title)
  1169. {
  1170. $where .= " and title like '%$title%'";
  1171. }
  1172. if($pm)
  1173. {
  1174. $where .= " and pm like '%$pm%'";
  1175. }
  1176. if($category)
  1177. {
  1178. $where .= " and shipremarks like '%-$category-%'";
  1179. }
  1180. if($size)
  1181. {
  1182. $where .= " and shipremarks like '%-$size-%'";
  1183. }
  1184. if($grade)
  1185. {
  1186. $where .= " and shipremarks like '%-$grade-%'";
  1187. }
  1188. if($color)
  1189. {
  1190. $where .= " and shipremarks like '%-$color-%'";
  1191. }
  1192. if($lowe)
  1193. {
  1194. $where .= " and shipremarks like '%-$lowe-%'";
  1195. }
  1196. if($state)
  1197. {
  1198. $where .= " and state = '$state'";
  1199. }
  1200. if($shipremarks)
  1201. {
  1202. $where .= " and shipremarks like '%$shipremarks%'";
  1203. }
  1204. $sidwhere = '';
  1205. if($sid)
  1206. {
  1207. $sd = "";
  1208. $s = explode(',',trim($sid,','));
  1209. foreach ($s as $value)
  1210. {
  1211. $sd .= " id = ".$value." or";
  1212. }
  1213. $sidwhere = " and (".rtrim($sd,'or').")";
  1214. }
  1215. //数据排序
  1216. $order_str = "time desc";
  1217. if(empty($page))
  1218. {
  1219. $start = 0;
  1220. $perpage = 1;
  1221. }
  1222. else
  1223. {
  1224. $start = ($page - 1)*$perpage;
  1225. }
  1226. //取得信息列表
  1227. /**
  1228. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1229. $rows = array();$list = array();
  1230. foreach ($info_list as $key=>$value)
  1231. {
  1232. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1233. }
  1234. **/
  1235. $warehouse = $this->warehouse->find_all();
  1236. $ck = array();
  1237. foreach ($warehouse as $v)
  1238. {
  1239. $ck[$v['id']] = $v['title'];
  1240. }
  1241. $list = array();
  1242. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1243. foreach ($rows as $key=>$value)
  1244. {
  1245. if($value['state'] == 0)
  1246. {
  1247. $rows[$key]['state'] = "待生产/外购";
  1248. }
  1249. else if($value['state'] == 1)
  1250. {
  1251. $rows[$key]['state'] = "生产/外购中";
  1252. }
  1253. else if($value['state'] == 2)
  1254. {
  1255. $rows[$key]['state'] = "已完成";
  1256. }
  1257. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1258. $zc = '';
  1259. foreach ($zd as $v)
  1260. {
  1261. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1262. }
  1263. $rows[$key]['id'] = $zc;
  1264. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1265. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1266. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1267. }
  1268. $title = '备货详情';
  1269. $titlename = "<table border=1>
  1270. <tr align='center'>
  1271. <td>状态</td>
  1272. <td>标题</td>
  1273. <td>流水码</td>
  1274. <td>简码</td>
  1275. <td>英文</td>
  1276. <td>中文</td>
  1277. <td>备注</td>
  1278. <td>备货数量</td>
  1279. <td>库存数量</td>
  1280. <td>生产/外购数量</td>
  1281. <td>入库数量</td>
  1282. <td>调拨数量</td>
  1283. <td>调拨详情</td>>
  1284. <td>生产时间</td>>
  1285. <td>操作时间</td>>
  1286. </tr>
  1287. </table>";
  1288. $filename = $title.".xls";
  1289. $tail = "";
  1290. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1291. }
  1292. }
  1293. public function _xxpl()
  1294. {
  1295. /* 订单加入键值-j */
  1296. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1297. $config['upload_path'] = '.'.$dir ;
  1298. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1299. $config['allowed_types'] = 'xls|xlsx|csv';
  1300. $config['max_size'] = 10240;
  1301. $this->load->library('upload', $config);
  1302. $this->upload->initialize($config);
  1303. if ($this->upload->do_upload('userfile'))
  1304. {
  1305. $full_path = $dir.$this->upload->data('file_name');
  1306. $fileName = '.' . $full_path;
  1307. if (!file_exists($fileName))
  1308. {
  1309. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1310. }
  1311. else
  1312. {
  1313. require_once "./data/excel/PHPExcel/IOFactory.php";
  1314. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1315. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1316. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1317. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1318. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1319. ++$column;//如果列数大于26行
  1320. $list = array();
  1321. for ($i = 2; $i <= $row; $i++) // 行数循环
  1322. {
  1323. $data = array();
  1324. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1325. {
  1326. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1327. }
  1328. $list[] = $data;
  1329. }
  1330. }
  1331. $tc = $this->typeclass->find_all();
  1332. $typeclass = array();
  1333. foreach ($tc as $v)
  1334. {
  1335. $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']);
  1336. }
  1337. $i = 0;$j = 0;$ed = array();
  1338. $classid = $this->classid->sku();
  1339. $typeclassid = [];
  1340. foreach($tc as $v){
  1341. $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']);
  1342. }
  1343. $i = 0;$j = 0;$ed = [];
  1344. $ck = [
  1345. "成品仓"=>'99001',
  1346. "美国仓"=>'02031',
  1347. "AP"=>'0103001',
  1348. "WK"=>'0103002',
  1349. "QV"=>'0103003',
  1350. "AS"=>'0103004',
  1351. "H"=>"0103005",
  1352. "AP英"=>"0103006",
  1353. "YMS"=>"0103007",
  1354. "AP新"=>"0103008",
  1355. "WK新"=>"0103009",
  1356. "H新"=>"0103010",
  1357. "Bilisar"=>"0103011",
  1358. "Estilar"=>"0103012",
  1359. "QM"=>"0103013",
  1360. "Afola"=>"0103014",
  1361. "拼多多-Finsa"=>"0106002",
  1362. "拼多多-艾彩"=>"0105001",
  1363. "拼多多-Estilar"=>"0106001",
  1364. "拼多多-QM"=>"0106003",
  1365. ];
  1366. foreach($list as $k=>$v){
  1367. $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
  1368. if($res['code']==1){
  1369. //传输料号开始
  1370. $post = $res['data'];
  1371. $post['orderinfo'] = $v[2];
  1372. $post['num'] = $v[5];
  1373. $post['state'] = ($v[3] == '生产')?0:1;
  1374. $post['purchase'] = "";//供货商
  1375. $post['shipremarks'] = empty($v[6])?" ":$v[6];//
  1376. $post['rknum'] = 0;
  1377. $post['scapi'] = 0;
  1378. $post['dbapi'] = 0;
  1379. $post['bhnum'] = $v[5];
  1380. if(isset($ck[$v[4]])){
  1381. $post['kh'] = $ck[$v[4]];
  1382. }else{
  1383. $j++;
  1384. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1385. continue;
  1386. }
  1387. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  1388. $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
  1389. if(isset($lh['Data'][0]))
  1390. {
  1391. if($lh['Data'][0]['m_isSucess'] != 1)
  1392. {
  1393. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1394. {
  1395. $j++;
  1396. $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
  1397. }
  1398. }
  1399. }
  1400. else
  1401. {
  1402. $j++;
  1403. $ed[] = array('料号错误',$post['jm'],$post['bm']);
  1404. }
  1405. if($this->whlabel_bh->insert($post))
  1406. {
  1407. $i++;
  1408. }
  1409. else
  1410. {
  1411. $j++;
  1412. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1413. }
  1414. }else{
  1415. $j++;
  1416. $ed[] = array($res['msg'],$v[1],"");
  1417. }
  1418. }
  1419. if($j > 0)
  1420. {
  1421. $time = date('Ymd',time());
  1422. $title = '错误信息-'.$time;
  1423. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1424. $tail = "\n";
  1425. $filename = $title.".xls";
  1426. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1427. $dir = '/data/excel/'.$time.'/';
  1428. $file_name = 'error_'.$time.rand(1000,9999);
  1429. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1430. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1431. fwrite($myfile,$ecl);
  1432. fclose($myfile);
  1433. $error = $dir.$file_name.'.xls';
  1434. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1435. }
  1436. else
  1437. {
  1438. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1439. }
  1440. }
  1441. else
  1442. {
  1443. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1444. }
  1445. }
  1446. public function _cslh($jm,$title,$pm,$bm)
  1447. {
  1448. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1449. if(isset($lh['Data'][0]))
  1450. {
  1451. if($lh['Data'][0]['m_isSucess'] != 1)
  1452. {
  1453. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1454. {
  1455. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1456. }
  1457. }
  1458. }
  1459. else
  1460. {
  1461. return array('msg'=>'料号错误','x'=>1);exit;
  1462. }
  1463. return array('x'=>2);exit;
  1464. }
  1465. public function _bbprint()
  1466. {
  1467. $time = time();
  1468. $post = $this->input->post(NULL);
  1469. if(isset($post['d']))
  1470. {
  1471. $order = 0;$time = time();
  1472. $d = $this->input->post('d',true);
  1473. $n = $this->input->post('n',true);//打印数量
  1474. $data = $this->whlabel_bh->read($d);
  1475. if(!$data)
  1476. {
  1477. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1478. }
  1479. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1480. $printnum = array_sum(array_column($printnum,'ts'));
  1481. if(($data['bhnum'] + 1)-$printnum-$n < 0)
  1482. {
  1483. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1484. }
  1485. $post['number'] = $data['number'];
  1486. $post['orderinfo'] = $data['orderinfo'];
  1487. $post['type'] = 0;//0生产 1外购
  1488. $post['features'] = $data['features'];
  1489. $post['jm'] = $data['jm'];
  1490. $post['bm'] = $data['bm'];
  1491. $post['pm'] = $data['pm'];
  1492. $post['sku'] = $data['sku'];
  1493. $post['features'] = $data['features'];
  1494. $post['number'] = $data['number'];
  1495. $post['title'] = $data['title'];
  1496. $post['printtime'] = $time;
  1497. $post['ts'] = 1;
  1498. // $post['rk'] = "";//默认订单中心 打印后直接入库
  1499. // $post['rktime'] = "";
  1500. // $post['ctime15'] = $time;
  1501. $post['time'] = $time;
  1502. $post['gtime'] = date('Yms',$time);
  1503. $rows = array();
  1504. $label = date("ymdHis").rand(1000,9999);
  1505. $post['label'] = $label;
  1506. // if($this->whlabel_bh_transfer->insert($post))
  1507. // {
  1508. // echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1509. // }
  1510. // else
  1511. // {
  1512. // $this->db->trans_rollback();
  1513. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1514. // }
  1515. if(stripos($post['features'],'-126-') !== false)
  1516. {
  1517. $drck = '12003';//进入发条库
  1518. }
  1519. else if(stripos($post['features'],'-127-') !== false)
  1520. {
  1521. $drck = '12004';//进入发块库
  1522. }
  1523. else
  1524. {
  1525. $drck = '12006';//其它进入完成库
  1526. }
  1527. //创建u9的生产单
  1528. $token = $this->settingtest->get_yytoken_120();
  1529. $params = [
  1530. 'org_code'=>"120",
  1531. 'djhlx'=>'2000',
  1532. 'scbm_code'=>"12008",
  1533. "time"=>time(),
  1534. 'owner_org_code'=>"120",
  1535. 'title'=>$post['orderinfo'],
  1536. 'shipremarks'=>$data['shipremarks'],
  1537. 'list'=>[
  1538. [
  1539. 'drck'=>$drck,
  1540. 'jm'=>$post['jm'],
  1541. 'sl'=>$n,
  1542. 'drck'=>$drck,
  1543. ]
  1544. ]
  1545. ];
  1546. $res = $this->apiyyv1->scdCreate($params,$token);
  1547. $this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
  1548. if(!isset($res[0]['Data'])){
  1549. echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
  1550. }
  1551. if(!$res[0]['Data'][0]['m_isSucess']){
  1552. echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
  1553. }
  1554. $scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
  1555. $post['scid'] = $scid;
  1556. $post['scapi'] = 1;
  1557. $post['dbapi'] = 0;
  1558. $this->db->trans_begin();
  1559. $post['shipremarks'] = $data['shipremarks'];
  1560. for($i = 0;$i < $n;$i++){
  1561. $post['label'] = $label.$i;
  1562. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
  1563. $this->whlabel_bh_transfer->insert($post);
  1564. }
  1565. if ($this->db->trans_status() === TRUE)
  1566. {
  1567. $this->db->trans_commit();
  1568. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1569. }else{
  1570. $this->db->trans_rollback();
  1571. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1572. }
  1573. }
  1574. }
  1575. public function _bdbb()
  1576. {
  1577. $post = $this->input->post(NULL, TRUE);
  1578. if(isset($post['s']))
  1579. {
  1580. $id_arr = $this->input->post('s');
  1581. $id_arr = explode(',',trim($id_arr,','));
  1582. if(!$id_arr)
  1583. {
  1584. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1585. }
  1586. //循环删除记录
  1587. foreach ($id_arr as $v)
  1588. {
  1589. $t = $this->whlabel_bh_transfer->read($v);
  1590. if(!isset($t['number']))
  1591. {
  1592. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1593. }
  1594. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
  1595. }
  1596. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1597. }
  1598. }
  1599. public function _out()
  1600. {
  1601. $post = $this->input->post(NULL, TRUE);
  1602. if(isset($post['label']))
  1603. {
  1604. $time = time();
  1605. $label = $this->input->post('label',true);
  1606. $cz = $this->input->post('cz',true);
  1607. $transfer = $this->input->post('transfer',true);
  1608. if(!$label)
  1609. {
  1610. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1611. }
  1612. if(!$transfer)
  1613. {
  1614. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1615. }
  1616. $lb = $this->whlabel_bh_transfer->get_label($label);
  1617. if(!$lb)
  1618. {
  1619. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1620. }
  1621. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1622. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1623. $tdata = $this->transfer->find_all();
  1624. $t = array();
  1625. foreach ($tdata as $v)
  1626. {
  1627. $t[$v['id']] = $v['title'];
  1628. }
  1629. if($cz == 1)
  1630. {
  1631. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1632. {
  1633. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1634. }
  1635. }
  1636. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1637. {
  1638. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1639. }
  1640. if($cz == 1)
  1641. {
  1642. $lb['rk'] .= $transfer.'|';
  1643. $lb['rktime'] .= $time.'|';
  1644. if($lbrk[0] == $transfer)
  1645. {
  1646. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1647. }
  1648. }
  1649. else if($cz == 2)
  1650. {
  1651. $lb['ck'] .= $transfer.'|';
  1652. $lb['cktime'] .= $time.'|';
  1653. if($lbck[0] == $transfer)
  1654. {
  1655. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1656. }
  1657. }
  1658. $cztime = 'ctime'.$transfer;
  1659. //如果是完成扫出 这样会通知erp生成一个调出单
  1660. if($transfer == 3 && $cz == 2 && $lb['dbapi'] < 99){
  1661. $this->db->trans_begin();
  1662. $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,'dbapi'=>99),$lb['id']);
  1663. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time()]);
  1664. $this->zzquque_u9->insert([
  1665. 'platform'=>'',
  1666. 'warehouse'=>0,
  1667. 'type'=>21,
  1668. 'order_no'=>$lb['orderinfo'],
  1669. 'child_order_no'=>$lb['id'],
  1670. 'status'=>0,
  1671. 'create_time'=>time(),
  1672. 'update_time'=>time(),
  1673. ]);
  1674. if ($this->db->trans_status() === TRUE){
  1675. $this->db->trans_commit();
  1676. echo json_encode(array('music'=>'1','success'=>true));exit;
  1677. }else{
  1678. $this->db->trans_rollback();
  1679. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1680. }
  1681. }
  1682. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1683. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1684. {
  1685. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1686. }
  1687. $this->db->trans_begin();
  1688. $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),$lb['id']);
  1689. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time()]);
  1690. if ($this->db->trans_status() === TRUE){
  1691. $this->db->trans_commit();
  1692. echo json_encode(array('music'=>'1','success'=>true));exit;
  1693. }else{
  1694. $this->db->trans_rollback();
  1695. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1696. }
  1697. }
  1698. }
  1699. protected function getOperateList(){
  1700. $api = $this->input->post('api',true);
  1701. $page = $this->input->post('page',true);
  1702. $perpage = $this->input->post('perpage',true);
  1703. $orderinfo = $this->input->post('number',true);
  1704. $color = $this->input->post('color',true);
  1705. $pm = $this->input->post('pm',true);
  1706. $purchase = $this->input->post('purchase',true);
  1707. $transfer = $this->input->post('transfer',true);
  1708. $lx = $this->input->post('lx',true);
  1709. $timetk = $this->input->post('timetk',true);
  1710. $timetj = $this->input->post('timetj',true);
  1711. $timetk = strtotime($timetk);
  1712. $timetj = strtotime($timetj);
  1713. $where = "1=1";
  1714. if($transfer)
  1715. {
  1716. $ctime = 'ctime'.$transfer;
  1717. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1718. }
  1719. else
  1720. {
  1721. $where .= " and time > '$timetk' and time < '$timetj'";
  1722. }
  1723. if($orderinfo)
  1724. {
  1725. $where .= " and orderinfo like '%$orderinfo%'";
  1726. }
  1727. if($transfer)
  1728. {
  1729. $where .= " and rk like '%|".$transfer."|%'";
  1730. }
  1731. if($purchase)
  1732. {
  1733. $where .= " and purchase = '$purchase'";
  1734. }
  1735. if($pm)
  1736. {
  1737. $where .= " and pm like '%$pm%'";
  1738. }
  1739. if($color)
  1740. {
  1741. $where .= " and fpdata like '%-".$color."-%'";
  1742. }
  1743. //数据排序
  1744. $order_str = "id desc";
  1745. if(empty($page))
  1746. {
  1747. $start = 0;
  1748. $perpage = 1;
  1749. }
  1750. else
  1751. {
  1752. $start = ($page - 1)*$perpage;
  1753. }
  1754. //取得信息列表
  1755. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1756. $transfer = $this->transfer->find_all();
  1757. $t = array();$ot = array();
  1758. foreach ($transfer as $v)
  1759. {
  1760. $t[$v['id']] = $v['title'];
  1761. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1762. }
  1763. //格式化数据
  1764. foreach ($info_list as $key=>$value)
  1765. {
  1766. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1767. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1768. $tmp_operate_str = "";
  1769. foreach($log_list as $k=>$v){
  1770. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1771. }
  1772. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1773. }
  1774. $total = $this->whlabel_bh_transfer->find_count($where);
  1775. $pagenum = ceil($total/$perpage);
  1776. $over = $total-($start+$perpage);
  1777. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1778. return $rows;
  1779. }
  1780. public function _operate()
  1781. {
  1782. $post = $this->input->post(NULL, TRUE);
  1783. if(isset($post['page']))
  1784. {
  1785. $rows = $this->getOperateList();
  1786. echo json_encode($rows);exit;
  1787. }
  1788. if(isset($_SESSION['api']))
  1789. {
  1790. $user = $this->user->get_api($_SESSION['api']);
  1791. $usp = $user;
  1792. $pid = "";$tid="";$sid="";$wid="";
  1793. $purchase = explode('|',trim($user['purchase'],'|'));
  1794. $transfer = explode('|',trim($user['transfer'],'|'));
  1795. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1796. foreach ($purchase as $value)
  1797. {
  1798. $pid .= " id = ".$value." or";
  1799. }
  1800. foreach ($transfer as $value)
  1801. {
  1802. $tid .= " id = ".$value." or";
  1803. }
  1804. foreach ($warehouse as $value)
  1805. {
  1806. $wid .= " id = ".$value." or";
  1807. }
  1808. }
  1809. else
  1810. {
  1811. header('Location: /');exit;
  1812. }
  1813. $kx = '';$zjtab = '';
  1814. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1815. $this->data['warehouse'] = $warehouse;
  1816. $purchase = $this->purchase->find_all("yyid != ''");
  1817. $this->data['purchase'] = $purchase;
  1818. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1819. $this->data['transfer'] = $transfer;
  1820. $this->data['vip'] = $user['vip'];
  1821. $this->_Template('whlabel_bh_operate',$this->data);
  1822. }
  1823. public function _rk()
  1824. {
  1825. $post = $this->input->post(NULL, TRUE);
  1826. if(isset($post['page']))
  1827. {
  1828. $res = $this->getOperateList();
  1829. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1830. echo json_encode($rows);exit;
  1831. }
  1832. if(isset($_SESSION['api']))
  1833. {
  1834. $user = $this->user->get_api($_SESSION['api']);
  1835. $usp = $user;
  1836. $pid = "";$tid="";$sid="";$wid="";
  1837. $purchase = explode('|',trim($user['purchase'],'|'));
  1838. $transfer = explode('|',trim($user['transfer'],'|'));
  1839. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1840. foreach ($purchase as $value)
  1841. {
  1842. $pid .= " id = ".$value." or";
  1843. }
  1844. foreach ($transfer as $value)
  1845. {
  1846. $tid .= " id = ".$value." or";
  1847. }
  1848. foreach ($warehouse as $value)
  1849. {
  1850. $wid .= " id = ".$value." or";
  1851. }
  1852. }
  1853. else
  1854. {
  1855. header('Location: /');exit;
  1856. }
  1857. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1858. $this->data['transfer'] = $transfer;
  1859. $this->_Template('whlabel_bh_rk',$this->data);
  1860. }
  1861. public function _ck()
  1862. {
  1863. $post = $this->input->post(NULL, TRUE);
  1864. if(isset($post['page']))
  1865. {
  1866. $res = $this->getOperateList();
  1867. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1868. echo json_encode($rows);exit;
  1869. }
  1870. if(isset($_SESSION['api']))
  1871. {
  1872. $user = $this->user->get_api($_SESSION['api']);
  1873. $usp = $user;
  1874. $pid = "";$tid="";$sid="";$wid="";
  1875. $purchase = explode('|',trim($user['purchase'],'|'));
  1876. $transfer = explode('|',trim($user['transfer'],'|'));
  1877. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1878. foreach ($purchase as $value)
  1879. {
  1880. $pid .= " id = ".$value." or";
  1881. }
  1882. foreach ($transfer as $value)
  1883. {
  1884. $tid .= " id = ".$value." or";
  1885. }
  1886. foreach ($warehouse as $value)
  1887. {
  1888. $wid .= " id = ".$value." or";
  1889. }
  1890. }
  1891. else
  1892. {
  1893. header('Location: /');exit;
  1894. }
  1895. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1896. $this->data['transfer'] = $transfer;
  1897. $this->_Template('whlabel_bh_ck',$this->data);
  1898. }
  1899. }