Whlabel_bh.php 66 KB

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