Whlabel_bh.php 71 KB

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