Whlabel_bh.php 84 KB

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