Whlabelfz.php 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. /**
  3. * 由于whlabel类下的代码太长了,决定以后非必要代码都放在whlabelfz类中,以便于管理。
  4. */
  5. class Whlabelfz extends Start_Controller
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->load->_model('Model_whlabel', 'whlabel');
  11. $this->load->_model('Model_warehouse', 'warehouse');
  12. $this->load->_model('Model_specialstock', 'specialstock');
  13. $this->load->_model('Model_logic_u9tools','logic_u9tools');
  14. $this->load->_model('Model_classid','classid');
  15. $this->load->_model('Model_typeclass','typeclass');
  16. $this->load->_model('Model_purchase', 'purchase');
  17. $this->load->_model("Model_shop", "shop");
  18. $this->load->_model("Model_whlabellabel","whlabellabel");
  19. $this->load->_model("Model_logic_zhlp",'logic_zhlp');
  20. $this->load->_model("Model_whlabellabelprint","whlabellabelprint");
  21. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  22. }
  23. //定义方法的调用规则 获取URI第二段值
  24. public function _remap($arg, $arg_array)
  25. {
  26. if ($arg == 'bqckexcel') //
  27. {
  28. //获取标签出库的按条件导出的excel
  29. $this->_bqck_excel();
  30. }
  31. elseif ($arg == 'bqrkexcel') //
  32. {
  33. //获取标签出库的按条件导出的excel
  34. $this->_bqrk_excel();
  35. }
  36. elseif ($arg == 'whlabel_cprk_excel') //
  37. {
  38. $this->_whlabel_cprk_excel();
  39. }
  40. elseif($arg == 'bqplindex'){
  41. $this->_bqplindex();
  42. }elseif($arg == 'bqplprint'){
  43. $this->_bqplprint();
  44. }elseif($arg == 'bqpladd'){
  45. $this->_bqpladd();
  46. }elseif($arg == 'printing'){
  47. $this->_printing();
  48. }elseif($arg == 'whlabelscan'){
  49. $this->_whlabelscan();
  50. }elseif($arg == 'whlabelscanlogexcel'){
  51. $this->_whlabelscanlogexcel();
  52. }elseif($arg =='eidtmcinfo'){
  53. $this->_eidtmcinfo();
  54. }
  55. else {
  56. $this->_index();
  57. }
  58. }
  59. private function _index(){
  60. die('No direct script access allowed');
  61. }
  62. private function _bqck_excel(){
  63. if (isset($_GET['excel'])) {
  64. //统计时间
  65. $timetk = $this->input->get('timetk', true);
  66. $timetj = $this->input->get('timetj', true);
  67. $timetk = strtotime($timetk);
  68. $timetj = strtotime($timetj);
  69. $category = $this->input->get('category',true); //类目
  70. $size = $this->input->get('size',true);//长度
  71. $grade = $this->input->get('grade',true);//等级
  72. $color = $this->input->get('color',true);//颜色
  73. $lowe = $this->input->get('lowe',true);//曲度
  74. $sku = $this->input->get('sku',true);//sku
  75. $warehouse = $this->input->get('warehouse',true);//仓库
  76. $purchase = $this->input->get('purchase',true);//供应商
  77. $where = "state=1 ";
  78. if ($timetk && $timetj) {
  79. $where .= " and outk > '$timetk' and outk < '$timetj'";
  80. }
  81. if ($sku) {
  82. $where .= " and sku = '$sku'";
  83. }
  84. if ($warehouse) {
  85. $where .= " and warehouse = '$warehouse'";
  86. }
  87. if ($purchase) {
  88. $where .= " and purchase = '$purchase'";
  89. }
  90. if ($category) {
  91. $where .= " and features like '%-$category-%'";
  92. }
  93. if ($size) {
  94. $where .= " and features like '%-$size-%'";
  95. }
  96. if ($grade) {
  97. $where .= " and features like '%-$grade-%'";
  98. }
  99. if ($color) {
  100. $where .= " and features like '%-$color-%'";
  101. }
  102. if ($lowe) {
  103. $where .= " and features like '%-$lowe-%'";
  104. }
  105. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  106. $order_str = "outk desc";
  107. //取得信息列表
  108. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,outk,details', $order_str);
  109. $classid = $this->classid->sku();
  110. $tcall = $this->typeclass->find_all();
  111. $typeclass = array();
  112. foreach ($tcall as $v)
  113. {
  114. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  115. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  116. }
  117. $prc = array();
  118. $purchase = $this->purchase->find_all();
  119. foreach ($purchase as $k => $v) {
  120. $prc[$v['id']] = $v['title'];
  121. }
  122. foreach ($info_list as $key => $value) {
  123. $warehouse = $this->warehouse->read($value['warehouse']);
  124. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  125. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  126. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  127. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  128. if ($value['state'] == 0) {
  129. $info_list[$key]['state'] = "在库";
  130. } else if ($value['state'] == 1) {
  131. $info_list[$key]['state'] = "出库";
  132. } else if ($value['state'] == 2) {
  133. $info_list[$key]['state'] = "退库";
  134. } else if ($value['state'] == 3) {
  135. $info_list[$key]['state'] = "调拨中";
  136. } else if ($value['state'] == 4) {
  137. $info_list[$key]['state'] = "再加工";
  138. } else if ($value['state'] == 5) {
  139. $info_list[$key]['state'] = "维修中";
  140. } else if ($value['state'] == 6) {
  141. $info_list[$key]['state'] = "盘亏";
  142. } else if ($value['state'] == 7) {
  143. $info_list[$key]['state'] = "更换标签";
  144. } else if ($value['state'] == 8) {
  145. $info_list[$key]['state'] = "其它";
  146. } else if ($value['state'] == 9) {
  147. $info_list[$key]['state'] = "预设";
  148. } else if ($value['state'] == 10) {
  149. $info_list[$key]['state'] = "美店零售";
  150. }
  151. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  152. }
  153. //生成excel
  154. $filename = date("Y-m-d")."标签出库导出.xls";
  155. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  156. <head>
  157. <!--[if gte mso 9]><xml>
  158. <x:ExcelWorkbook>
  159. <x:ExcelWorksheets>
  160. <x:ExcelWorksheet>
  161. <x:Name>EXCEL</x:Name>
  162. <x:WorksheetOptions>
  163. <x:Print>
  164. <x:ValidPrinterInfo />
  165. </x:Print>
  166. </x:WorksheetOptions>
  167. </x:ExcelWorksheet>
  168. </x:ExcelWorksheets>
  169. </x:ExcelWorkbook>
  170. </xml>
  171. <![endif]-->
  172. </head><body>";
  173. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  174. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>出库时间</td><td>所在位置</td></tr>";
  175. foreach ($info_list as $key=>$value)
  176. {
  177. $str .= "<tr>";
  178. $str .= "<td>". $value['warehouse']. "</td>";
  179. $str .= "<td>". $value['purchase']. "</td>";
  180. $str .= "<td>". $value['sku']. "</td>";
  181. $str .= "<td>". $value['title']. "</td>";
  182. $str .= "<td>". $value['features']. "</td>";
  183. $str .= "<td>". $value['state']. "</td>";
  184. $str .= "<td>". $value['outk']. "</td>";
  185. $str .= "<td>". $value['details']. "</td>";
  186. $str .= "</tr>";
  187. }
  188. $str .= "</table></body></html>";
  189. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  190. header( "Content-type: application/octet-stream" );
  191. header( "Content-Disposition: attachment; filename=".$filename );
  192. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  193. header( "Pragma: no-cache" );
  194. header( "Expires: 0" );
  195. exit($str);
  196. }else{
  197. }
  198. }
  199. public function _bqrk_excel(){
  200. if (isset($_GET['excel'])) {
  201. $sku = $this->input->get('sku', true);
  202. $bs = $this->input->get('bs', true);
  203. $number = $this->input->get('number', true);
  204. $warehouse = $this->input->get('warehouse', true);
  205. $purchase = $this->input->get('purchase', true);
  206. $orderinfo = $this->input->get('orderinfo', true);
  207. $waybill = $this->input->get('waybill', true);
  208. $category = $this->input->get('category', true);
  209. $size = $this->input->get('size', true);
  210. $grade = $this->input->get('grade', true);
  211. $color = $this->input->get('color', true);
  212. $lowe = $this->input->get('lowe', true);
  213. $state = $this->input->get('state', true);
  214. $label = $this->input->get('label', true);
  215. $timetk = $this->input->get('ktime', true);
  216. $timetj = $this->input->get('jtime', true);
  217. $timetk = strtotime($timetk);
  218. $timetj = strtotime($timetj);
  219. $where = "1=1 ";
  220. if ($timetk && $timetj) {
  221. $where .= " and enter > '$timetk' and enter < '$timetj'";
  222. }
  223. if ($sku) {
  224. $where .= " and sku = '$sku'";
  225. }
  226. if ($bs != '') {
  227. $where .= " and bs = '$bs'";
  228. }
  229. if ($number) {
  230. $where .= " and number = '$number'";
  231. }
  232. if ($warehouse) {
  233. $where .= " and warehouse = '$warehouse'";
  234. }
  235. if ($purchase) {
  236. $where .= " and purchase = '$purchase'";
  237. }
  238. if ($orderinfo) {
  239. $where .= " and orderinfo = '$orderinfo'";
  240. }
  241. if ($waybill) {
  242. $where .= " and waybill = '$waybill'";
  243. }
  244. if ($category) {
  245. $where .= " and features like '%-$category-%'";
  246. }
  247. if ($size) {
  248. $where .= " and features like '%-$size-%'";
  249. }
  250. if ($grade) {
  251. $where .= " and features like '%-$grade-%'";
  252. }
  253. if ($color) {
  254. $where .= " and features like '%-$color-%'";
  255. }
  256. if ($lowe) {
  257. $where .= " and features like '%-$lowe-%'";
  258. }
  259. if ($label) {
  260. $where .= " and label = '$label'";
  261. }
  262. if ($state || $state == 0) {
  263. $where .= " and state = '$state'";
  264. }
  265. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  266. //数据排序
  267. $order_str = "enter desc";
  268. //取得信息列表
  269. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,enter,details', $order_str);
  270. $prc = array();
  271. $purchase = $this->purchase->find_all();
  272. foreach ($purchase as $k => $v) {
  273. $prc[$v['id']] = $v['title'];
  274. }
  275. $classid = $this->classid->sku();
  276. $tcall = $this->typeclass->find_all();
  277. foreach ($tcall as $v)
  278. {
  279. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  280. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  281. }
  282. foreach ($info_list as $key => $value) {
  283. $warehouse = $this->warehouse->read($value['warehouse']);
  284. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  286. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  287. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  288. if ($value['state'] == 0) {
  289. $info_list[$key]['state'] = "在库";
  290. } else if ($value['state'] == 1) {
  291. $info_list[$key]['state'] = "出库";
  292. } else if ($value['state'] == 2) {
  293. $info_list[$key]['state'] = "退库";
  294. } else if ($value['state'] == 3) {
  295. $info_list[$key]['state'] = "调拨中";
  296. } else if ($value['state'] == 4) {
  297. $info_list[$key]['state'] = "再加工";
  298. } else if ($value['state'] == 5) {
  299. $info_list[$key]['state'] = "维修中";
  300. } else if ($value['state'] == 6) {
  301. $info_list[$key]['state'] = "盘亏";
  302. } else if ($value['state'] == 7) {
  303. $info_list[$key]['state'] = "更换标签";
  304. } else if ($value['state'] == 8) {
  305. $info_list[$key]['state'] = "其它";
  306. } else if ($value['state'] == 9) {
  307. $info_list[$key]['state'] = "预设";
  308. } else if ($value['state'] == 10) {
  309. $info_list[$key]['state'] = "美店零售";
  310. }
  311. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  312. }
  313. //生成excel
  314. $filename = date("Y-m-d")."标签入库导出.xls";
  315. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  316. <head>
  317. <!--[if gte mso 9]><xml>
  318. <x:ExcelWorkbook>
  319. <x:ExcelWorksheets>
  320. <x:ExcelWorksheet>
  321. <x:Name>EXCEL</x:Name>
  322. <x:WorksheetOptions>
  323. <x:Print>
  324. <x:ValidPrinterInfo />
  325. </x:Print>
  326. </x:WorksheetOptions>
  327. </x:ExcelWorksheet>
  328. </x:ExcelWorksheets>
  329. </x:ExcelWorkbook>
  330. </xml>
  331. <![endif]-->
  332. </head><body>";
  333. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  334. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>入库时间</td><td>所在位置</td></tr>";
  335. foreach ($info_list as $key=>$value)
  336. {
  337. $str .= "<tr>";
  338. $str .= "<td>". $value['warehouse']. "</td>";
  339. $str .= "<td>". $value['purchase']. "</td>";
  340. $str .= "<td>". $value['sku']. "</td>";
  341. $str .= "<td>". $value['title']. "</td>";
  342. $str .= "<td>". $value['features']. "</td>";
  343. $str .= "<td>". $value['state']. "</td>";
  344. $str .= "<td>". $value['enter']. "</td>";
  345. $str .= "<td>". $value['details']. "</td>";
  346. $str .= "</tr>";
  347. }
  348. $str .= "</table></body></html>";
  349. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  350. header( "Content-type: application/octet-stream" );
  351. header( "Content-Disposition: attachment; filename=".$filename );
  352. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  353. header( "Pragma: no-cache" );
  354. header( "Expires: 0" );
  355. exit($str);
  356. }
  357. }
  358. public function _whlabel_cprk_excel(){
  359. if (empty($_SESSION['api'])) {
  360. exit('No direct script access allowed');
  361. }
  362. // $user = $this->user->get_api($_SESSION['api']);
  363. // $warehouses = $user['warehouse'];
  364. // if(empty($warehouses)){
  365. // exit('没有仓库权限!!!');
  366. // }
  367. // $warehouses = explode('|',trim($warehouses,'|'));
  368. // $ware_list = [];
  369. // foreach ($warehouses as $v) {
  370. // if(!empty($v)){
  371. // $ware_list[] = $v;
  372. // }
  373. // }
  374. $category = $this->input->get('category', true);
  375. $size = $this->input->get('size', true);
  376. $grade = $this->input->get('grade', true);
  377. $color = $this->input->get('color', true);
  378. $lowe = $this->input->get('lowe', true);
  379. $sku = $this->input->get('sku', true);
  380. $warehouse = $this->input->get('warehouse', true);
  381. $purchase = $this->input->get('purchase', true);
  382. $ktime = $this->input->get('ktime', true);
  383. $jtime = $this->input->get('jtime', true);
  384. $ktime = strtotime($ktime);
  385. $jtime = strtotime($jtime);
  386. $where = " ";
  387. // if ($warehouse) {
  388. // if(in_array($warehouse,$ware_list)){
  389. // $where .= " warehouse = '$warehouse' ";
  390. // }else{
  391. // $where .= " warehouse = 0 ";
  392. // }
  393. // }else{
  394. // $where .= " warehouse in (".implode(',',$ware_list).")";
  395. // }
  396. if($warehouse){
  397. $where .= " warehouse = '$warehouse' ";
  398. }else{
  399. $where .=" 1 = 1 ";
  400. }
  401. if ($category) {
  402. $where .= " and features like '%-$category-%'";
  403. }
  404. if ($size) {
  405. $where .= " and features like '%-$size-%'";
  406. }
  407. if ($grade) {
  408. $where .= " and features like '%-$grade-%'";
  409. }
  410. if ($color) {
  411. $where .= " and features like '%-$color-%'";
  412. }
  413. if ($lowe) {
  414. $where .= " and features like '%-$lowe-%'";
  415. }
  416. if ($purchase) {
  417. $where .= " and purchase = '$purchase'";
  418. }
  419. if ($sku) {
  420. $where .= " and sku like '%$sku%'";
  421. }
  422. if ($ktime && $jtime) {
  423. $where .= " and enter > '$ktime' and enter < '$jtime'";
  424. }
  425. //取得信息列表
  426. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter,features');
  427. if(!empty($info_list)){
  428. $wh = array();
  429. $w = $this->warehouse->find_all('1=1', 'id,title');
  430. foreach ($w as $v) {
  431. $wh[$v['id']] = $v['title'];
  432. }
  433. $classid = $this->classid->sku();
  434. $tcall = $this->typeclass->find_all();
  435. foreach ($tcall as $v)
  436. {
  437. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  438. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  439. }
  440. foreach ($info_list as $k => $v) {
  441. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  442. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  443. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  444. $info_list[$k]['g'] = $g;
  445. if(!empty($v['features'])){
  446. $u9_info = $this->logic_u9tools->getOneU9bm($v['features'],$classid,$typeclass);
  447. $info_list[$k]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  448. }
  449. }
  450. }
  451. //生成excel
  452. $filename = date("Y-m-d")."产品入库导出.xls";
  453. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  454. <head>
  455. <!--[if gte mso 9]><xml>
  456. <x:ExcelWorkbook>
  457. <x:ExcelWorksheets>
  458. <x:ExcelWorksheet>
  459. <x:Name>EXCEL</x:Name>
  460. <x:WorksheetOptions>
  461. <x:Print>
  462. <x:ValidPrinterInfo />
  463. </x:Print>
  464. </x:WorksheetOptions>
  465. </x:ExcelWorksheet>
  466. </x:ExcelWorksheets>
  467. </x:ExcelWorkbook>
  468. </xml>
  469. <![endif]-->
  470. </head><body>";
  471. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  472. $str .= "<tr><td>仓库</td><td>SKU</td><td>产品名称</td><td>入库时间</td><td>数量</td><td>料号</td></tr>";
  473. foreach ($info_list as $key=>$value)
  474. {
  475. $str .= "<tr>";
  476. $str .= "<td>". $value['warehouse']. "</td>";
  477. $str .= "<td>". $value['sku']. "</td>";
  478. $str .= "<td>". $value['title']. "</td>";
  479. $str .= "<td>". $value['enter']. "</td>";
  480. $str .= "<td>". $value['g']. "</td>";
  481. $str .= "<td>". $value['features']. "</td>";
  482. $str .= "</tr>";
  483. }
  484. $str .= "</table></body></html>";
  485. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  486. header( "Content-type: application/octet-stream" );
  487. header( "Content-Disposition: attachment; filename=".$filename );
  488. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  489. header( "Pragma: no-cache" );
  490. header( "Expires: 0" );
  491. exit($str);
  492. }
  493. private function _bqplindex(){
  494. if($this->input->method() == 'post'){
  495. $page = $this->input->post('page',true);
  496. $perpage = $this->input->post('perpage',true);
  497. $title = $this->input->post('title',true);
  498. $sku = $this->input->post('sku',true);
  499. $timetk = $this->input->post('timetk',true);
  500. $timetj = $this->input->post('timetj',true);
  501. $timetk = strtotime($timetk);
  502. $timetj = strtotime($timetj);
  503. $status = $this->input->post('status',true);
  504. if($timetk && $timetj)
  505. {
  506. $where = " time > '$timetk' and time < '$timetj'";
  507. }
  508. if($title){
  509. $where .= " and title like '%$title%'";
  510. }
  511. if($sku){
  512. $where .= " and sku like '%$sku%'";
  513. }
  514. if($status > -1){
  515. $where .= " and status = '$status'";
  516. }
  517. //数据排序
  518. $order_str = "id desc";
  519. if(empty($page))
  520. {
  521. $start = 0;
  522. $perpage = 1;
  523. }
  524. else
  525. {
  526. $start = ($page - 1)*$perpage;
  527. }
  528. $purchase_list = $this->purchase->find_all("1 = 1","id,title");
  529. $purchase_list = array_column($purchase_list,'title','id');
  530. //取得信息列表
  531. $info_list = $this->whlabellabelprint->find_all($where,'id,purchase,sku,title,warehouse,details,dynum,status,time,print_time',$order_str,$start,$perpage);
  532. foreach ($info_list as $key=>$value)
  533. {
  534. $info_list[$key]['purchase'] = isset($purchase_list[$value['purchase']])?$purchase_list[$value['purchase']]:'';
  535. $info_list[$key]['warehouse'] = $this->_getWarehouseById($value['warehouse']);
  536. $info_list[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  537. $info_list[$key]['status'] = empty($value['status'])?'未打印':'已打印';
  538. $info_list[$key]['print_time'] = empty($value['print_time'])? '': date('Y-m-d H:i:s', $value['print_time']);
  539. }
  540. $total = $this->whlabellabelprint->find_count($where);
  541. $pagenum = ceil($total/$perpage);
  542. $over = $total-($start+$perpage);
  543. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  544. echo json_encode($rows);exit;
  545. }
  546. $this->_Template('whlabelfz_bqpl', $this->data);
  547. }
  548. private function _getShop($str){
  549. $str = trim($str);
  550. if($str == '无'){
  551. return '';
  552. }else{
  553. $str = strtolower($str);
  554. if($str =='alipearl'){
  555. return 1;
  556. }elseif($str == 'supernova'){
  557. return 2;
  558. }elseif($str == 'asteriahair'){
  559. return 3;
  560. }elseif($str == 'westkiss'){
  561. return 4;
  562. }elseif($str == 'yolissahair'){
  563. return 5;
  564. }elseif($str == 'wiggins'){
  565. return 6;
  566. }
  567. }
  568. }
  569. private function _getWarehouse($str){
  570. if($str == '特殊库存仓'){
  571. return 12;
  572. }elseif($str == '美国店'){
  573. return 5;
  574. }elseif($str == '定制头套仓'){
  575. return 16;
  576. }elseif($str == 'TikTok仓'){
  577. return 34;
  578. }else{
  579. return 13;
  580. }
  581. }
  582. private function _getWarehouseById($str){
  583. if($str == 12){
  584. return '特殊库存仓';
  585. }elseif($str == 5){
  586. return '美国店';
  587. }elseif($str == 16){
  588. return '定制头套仓';
  589. }elseif($str == 34){
  590. return 'TikTok仓';
  591. }else{
  592. return '许昌仓';
  593. }
  594. }
  595. private function _bqpladd(){
  596. $params = $this->input->post('data',true);
  597. $params = json_decode($params,true);
  598. $list = [];
  599. $error_list= [];
  600. // $warehouse_list = $this->warehouse->find_all("1 = 1","id,title");
  601. // $warehouse_list = array_column($warehouse_list,'id','title');
  602. $warehouse_list = [];
  603. $purchase_list = $this->purchase->find_all("1 = 1","id,title");
  604. $purchase_list = array_column($purchase_list,'id','title');
  605. $classid = $this->classid->sku();
  606. foreach($params as $k => $v){
  607. if(empty($v['0'])){
  608. $error_list[] = [
  609. 'sku'=>$v['0'],
  610. 'msg'=>"第".($k+1)."行的数据为空"
  611. ];
  612. continue;
  613. }
  614. $r = $this->_transferForm($v['0'],$v,$warehouse_list,$purchase_list,$classid,$k);
  615. if($r['code'] != 1){
  616. $error_list[] = [
  617. 'sku'=>$v['0'],
  618. 'msg'=>$r['msg']
  619. ];
  620. }else{
  621. $tmp_data = $r['data'];
  622. $tmp_data['details'] = $v['4'];
  623. if(isset($tmp_data['id'])){
  624. unset($tmp_data['id']);
  625. }
  626. $tmp_data['label'] = substr($tmp_data['label'],1);
  627. $tmp_list = $this->whlabellabelprint->find_all("label = '".$tmp_data['label']."'");
  628. if(!empty($tmp_list)){
  629. $tmp_data['label'] = $tmp_data['label'].rand(0,9);
  630. }
  631. $this->whlabellabelprint->insert($tmp_data);
  632. //$list[] = $tmp_data['data'];
  633. }
  634. }
  635. if(empty($error_list)){
  636. echo json_encode(['code'=>1,'msg'=>'操作成功','data'=>[],'error'=>[]]);exit;
  637. }else{
  638. echo json_encode(['code'=>-1,'msg'=>'导入数据异常,是否下载错误信息?','data'=>[],'error'=>$error_list]);exit;
  639. }
  640. }
  641. /**
  642. * 将数据转化为 批量打印标签需要data格式
  643. */
  644. private function _transferForm($tmsku,$info,$warehouse_list,$purchase_list,$classid,$i){
  645. if (is_numeric($tmsku)) {
  646. $yyh = $this->whlabellabel->get_label($tmsku);
  647. } else {
  648. $yyh = $this->whlabellabel->get_sku($tmsku);
  649. }
  650. if(!empty($yyh)){
  651. return ['code'=>1,'msg'=>"获取标签",'data'=>[
  652. 'sku_shop_id' => 0,
  653. 'sku_master_id' => 0,
  654. 'status' => 0,
  655. 'shop' =>0,
  656. 'purchase' => $yyh['purchase'],
  657. 'warehouse' => $yyh['warehouse'],
  658. 'cpbz' => $yyh['cpbz'],
  659. 'title' => $yyh['title'],
  660. 'number' => $yyh['number'],
  661. 'features' => $yyh['features'],
  662. 'featurespp' => $yyh['featurespp'],
  663. 'time' => time(),
  664. 'dynum' => $info['1'],
  665. 'sku' => $yyh['sku'],
  666. 'label' => time().$i
  667. ]];
  668. }
  669. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  670. if($r['code'] == -1 ){
  671. return ['code'=>-1,'msg'=>"未找到对应的料品"];
  672. }
  673. $str = $r['data'];
  674. $arr = explode("-",trim($str,"-"));
  675. $data = $this->logic_zhlp->transferSku($arr);
  676. $res = $this->logic_zhlp->sortByColume($data);
  677. if($res['code'] == -1){
  678. return $res;
  679. }
  680. $insert_arr = [];
  681. $insert_arr['sku_master_id']= $insert_arr['sku_shop_id'] =0;
  682. $insert_arr['status'] = 0;
  683. $insert_arr['shop'] = '';
  684. $purchase = isset($purchase_list[$info['2']])?$purchase_list[$info['2']]:1;
  685. $insert_arr['purchase'] = $purchase;
  686. $insert_arr['warehouse'] = $this->_getWarehouse($info['3']);
  687. $insert_arr['cpbz'] = '';
  688. $post = $res['data'];
  689. $list = [];
  690. $category = $post['category'];
  691. $list['category'] = $category;
  692. $list['hairtype'] = empty($post['hairtype'])?'':$post['hairtype'];
  693. $list['grade'] = empty($post['grade'])?'':$post['grade'];
  694. $list['size'] = empty($post['size'])?'':$post['size'];
  695. $list['hairnumber'] = empty($post['hairnumber'])?'':$post['hairnumber'];
  696. $list['extension'] = empty($post['extension'])?'':$post['extension'];
  697. if ($category == 1297) {
  698. $list['sywignumber'] = empty($post['sywignumber'])?'':$post['sywignumber'];
  699. }
  700. if ($category == 1702) {
  701. $list['syhairnumber'] = empty($post['syhairnumber'])?'':$post['syhairnumber'];
  702. $list['syother'] = empty($post['syother'])?'':$post['syother'];
  703. }
  704. if ($category == 133) {
  705. $list['fittype'] = empty($post['fittype'])?'':$post['fittype'];
  706. $list['acother'] = empty($post['acother'])?'':$post['acother'];
  707. }
  708. $list['color'] = empty($post['color'])?'':$post['color'];
  709. $list['lowe'] = empty($post['lowe'])?'':$post['lowe'];
  710. if ($category == 127) {
  711. $list['type'] = empty($post['type'])?'':$post['type'];
  712. $list['headroad'] = empty($post['headroad'])?'':$post['headroad'];
  713. $list['density'] =empty($post['density'])?'':$post['density'];
  714. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  715. $list['lacesize'] = empty($post['lacesize'])?'':$post['lacesize'];
  716. }
  717. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  718. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  719. }
  720. if ($category == 128) {
  721. $list['lacetype'] =empty($post['lacetype'])?'':$post['lacetype'];
  722. $list['haircap'] = empty($post['haircap'])?'':$post['haircap'];
  723. $list['density'] = empty($post['density'])?'':$post['density'];
  724. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  725. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  726. $list['wigother'] = empty($post['wigother'])?'':$post['wigother'];
  727. $list['wigother1'] = empty($post['wigother1'])?'':$post['wigother1'];
  728. $list['wigother2'] = empty($post['wigother2'])?'':$post['wigother2'];
  729. }
  730. if ($category == 129) {
  731. $list['wide'] = empty($post['wide'])?'':$post['wide'];
  732. }
  733. if ($category == 131) {
  734. $list['gifttype'] = empty($post['gifttype'])?'':$post['gifttype'];
  735. $list['giftother'] = empty($post['giftother'])?'':$post['giftother'];
  736. }
  737. if ($category == 134) {
  738. $list['pieceweight'] = empty($post['pieceweight'])?'':$post['pieceweight'];
  739. }
  740. if ($category == 1297) {
  741. $list['synthetictype'] = empty($post['synthetictype'])?'':$post['synthetictype'];
  742. $list['sywigother'] = empty($post['sywigother'])?'':$post['sywigother'];
  743. }
  744. if ($category == 130 || $category == 133 || $category == 1702) {
  745. $list['items'] = empty($post['items'])?'':$post['items'];
  746. $list['weight'] = empty($post['weight'])?'':$post['weight'];
  747. }
  748. if ($category == 130 ) {
  749. $list['jfother'] = empty($post['jfother'])?'':$post['jfother'];
  750. }
  751. if ($category == 1702) {
  752. $list['syhairther'] = empty($post['syhairther'])?'':$post['syhairther'];
  753. }
  754. $pm = $scsku = $classid;
  755. $number = $features = $title = "";
  756. foreach ($list as $k => $v) {
  757. if ($v != 0) {
  758. $number .= $v;
  759. $features .= $v . '-';
  760. $typeclass = $this->typeclass->read($v);
  761. if (isset($pm[$typeclass['classid']])) {
  762. if (stripos($typeclass['zh'], '|') !== false) {
  763. $exzh = explode('|', $typeclass['zh']);
  764. $pm[$typeclass['classid']] = $exzh[0];
  765. } else {
  766. $pm[$typeclass['classid']] = $typeclass['zh'];
  767. }
  768. }
  769. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  770. if ($k != 'size') {
  771. $title .= $typeclass['title'] . " ";
  772. }
  773. }
  774. }
  775. $typeclass = $this->typeclass->read($list['size']);
  776. $title .= $typeclass['title'];
  777. $time = time();
  778. $insert_arr['title'] = rtrim($title, ' ');
  779. $insert_arr['number'] = $number;
  780. $insert_arr['features'] = "-".trim($features, '-')."-";
  781. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  782. $featurespp = explode('-', trim($featurespp, '-'));
  783. if (isset($featurespp[5])) {
  784. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  785. } else {
  786. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  787. }
  788. $insert_arr['time'] = $time;
  789. $insert_arr['dynum'] = $info['1'];
  790. $scsku = implode("-", $scsku);
  791. $zh = implode(" ", $pm);
  792. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  793. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  794. $bqsku = $scsku;;
  795. $insert_arr['sku'] = $bqsku;
  796. $label = time() . $i;
  797. $insert_arr['label'] = $label;
  798. return [
  799. 'code'=>1,
  800. 'msg'=>"success",
  801. 'data'=>$insert_arr
  802. ];
  803. }
  804. private function _printing(){
  805. $post = $this->input->post(NULL, TRUE);
  806. if(isset($post['s'])){
  807. $v = $this->input->post('s');
  808. $va = explode(',',rtrim($v,','));
  809. $n = $this->input->post('n');
  810. $tf = $this->input->post('tf');
  811. $text = [];
  812. $text['data'] = [];
  813. $do_action_id = $va[$n];
  814. $info = $this->whlabellabelprint->read($do_action_id);
  815. if(empty($info)){
  816. echo json_encode(array('msg'=>'ID为'.$do_action_id.'的数据不存在,请联系技术','success'=>false));exit;
  817. }
  818. if($info['status'] == 1){
  819. echo json_encode(array('msg'=>$info['sku'].'的数据已打印,请勿重复打印','success'=>false));exit;
  820. }
  821. $list = [];
  822. $sku = $info['features'];
  823. if(!empty($sku)){
  824. $list[] = [
  825. 'sku2'=>$sku
  826. ];
  827. }
  828. $u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
  829. $zh = $u9_data[0]['zh'];
  830. $this->whlabellabelprint->save([
  831. 'status'=>1,
  832. 'print_time'=>time()
  833. ],$do_action_id);
  834. $cpid = $this->whlabellabel->find_count();
  835. $insert_arr = [
  836. 'shop'=>$info['shop'],
  837. 'purchase'=>$info['purchase'],
  838. 'sku'=>$info['sku'],
  839. 'number'=>$info['number'],
  840. 'features'=>$info['features'],
  841. 'featurespp'=>$info['featurespp'],
  842. 'title'=>$info['title'],
  843. 'label'=>$info['label'],
  844. 'warehouse'=>$info['warehouse'],
  845. 'time'=>time(),
  846. 'details'=>$info['details'],
  847. 'cpbz'=>$info['cpbz'],
  848. 'cpid'=>$cpid,
  849. 'jm'=>$u9_data[0]['jm'],
  850. ];
  851. $this->whlabellabel->insert($insert_arr);
  852. $text = [];
  853. $text['number'] = $info['sku'];
  854. $details = ($info['details'] != '') ? '位置:(' . $info['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  855. if(!empty($warehouse_name)){
  856. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  857. }
  858. $purchase = $this->purchase->read($info['purchase']);
  859. $text['title'] = $u9_data[0]['jm'];
  860. $text['num'] = $info['label'];
  861. $text['bqsku'] = $u9_data[0]['jm'];
  862. $text['xbqnum'] = $info['dynum'];
  863. $text['zh'] = str_replace('自然色 ', '', rtrim($zh, ' '));
  864. $text['details'] = $details;
  865. $text['purchase'] = $purchase['title'];
  866. $text['cpbz'] = $info['cpbz'];
  867. $text['usa'] = 0;
  868. // ob_clean();
  869. $rows = array('type'=>1,'n'=>$n-1,'data'=>$v,'text'=>$text);
  870. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  871. }
  872. }
  873. private function _bqplprint(){
  874. }
  875. private function _whlabelscan(){
  876. if($this->input->method() == 'post'){
  877. $page = $this->input->post('page',true);
  878. $perpage = $this->input->post('perpage',true);
  879. $title = $this->input->post('title',true);
  880. $sku = $this->input->post('sku',true);
  881. $type = $this->input->post('type',true);
  882. $timetk = $this->input->post('timetk',true);
  883. $timetj = $this->input->post('timetj',true);
  884. $timetk = strtotime($timetk);
  885. $timetj = strtotime($timetj);
  886. $where = "";
  887. if($timetk && $timetj)
  888. {
  889. $where .= " addtime > '$timetk' and addtime < '$timetj'";
  890. }
  891. if($type){
  892. $where .= " and type = '$type'";
  893. }
  894. if($title){
  895. $where .= " and title like '%$title%'";
  896. }
  897. if($sku){
  898. $where .= " and sku like '%$sku%'";
  899. }
  900. //数据排序
  901. $order_str = "id desc";
  902. if(empty($page))
  903. {
  904. $start = 0;
  905. $perpage = 1;
  906. }
  907. else
  908. {
  909. $start = ($page - 1)*$perpage;
  910. }
  911. // $purchase_list = $this->purchase->find_all("1 = 1","id,title");
  912. // $purchase_list = array_column($purchase_list,'title','id');
  913. //取得信息列表
  914. $info_list = $this->whlabelscanlog->find_all($where,'id,sku,title,warehouse,type,num,addtime',$order_str,$start,$perpage);
  915. foreach ($info_list as $key=>$value)
  916. {
  917. $info_list[$key]['warehouse'] = $this->_getWarehouseById($value['warehouse']);
  918. $info_list[$key]['type'] = $value['type'] == 1 ? '扫描入库' : '扫描出库';
  919. $info_list[$key]['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  920. }
  921. $total = $this->whlabelscanlog->find_count($where);
  922. $pagenum = ceil($total/$perpage);
  923. $over = $total-($start+$perpage);
  924. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  925. echo json_encode($rows);exit;
  926. }else{
  927. $type = $this->input->get('type');
  928. $this->data['type'] = $type;
  929. $this->_Template('whlabelfz_whlabelscan', $this->data);
  930. }
  931. }
  932. private function _whlabelscanlogexcel(){
  933. $title = $this->input->post('title',true);
  934. $sku = $this->input->post('sku',true);
  935. $type = $this->input->post('type',true);
  936. $timetk = $this->input->post('timetk',true);
  937. $timetj = $this->input->post('timetj',true);
  938. $timetk = strtotime($timetk);
  939. $timetj = strtotime($timetj);
  940. $where = "";
  941. if($timetk && $timetj)
  942. {
  943. $where .= " addtime > '$timetk' and addtime < '$timetj'";
  944. }
  945. if($type){
  946. $where .= " and type = '$type'";
  947. }
  948. if($title){
  949. $where .= " and title like '%$title%'";
  950. }
  951. if($sku){
  952. $where .= " and sku like '%$sku%'";
  953. }
  954. $info_list = $this->whlabelscanlog->find_all($where,'sku,title,warehouse,type,num,addtime');
  955. foreach ($info_list as $key=>$value)
  956. {
  957. $info_list[$key]['warehouse'] = $this->_getWarehouseById($value['warehouse']);
  958. $info_list[$key]['type'] = $value['type'] == 1 ? '扫描入库' : '扫描出库';
  959. $info_list[$key]['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  960. }
  961. if(empty($info_list)){
  962. echo json_encode(array('msg'=>'没有数据','success'=>false));exit;
  963. }
  964. $final_list = [];
  965. foreach ($info_list as $key => $value) {
  966. $final_list[] = [
  967. "SKU"=>$value['sku'],
  968. "商品名称"=>$value['title'],
  969. "仓库"=>$value['warehouse'],
  970. "类型"=>$value['type'],
  971. "数量"=>$value['num'],
  972. "扫描时间"=> $value['addtime']
  973. ];
  974. }
  975. $filename = "扫描日志_".date("Ymd")."_".rand(1000,9999).".xls";
  976. echo json_encode(array('msg'=>'获取数据成功','success'=>true,'data'=>$final_list,'filename'=>$filename));exit;
  977. }
  978. private function _eidtmcinfo(){
  979. if($this->input->method(TRUE) == 'POST'){
  980. $data = $this->input->post(NULL,TRUE);
  981. if(empty($data['sku'])){
  982. echo json_encode(array('msg'=>'请输入sku','success'=>false));exit;
  983. }
  984. if(empty($data['sm'])){
  985. echo json_encode(array('msg'=>'请输入负责人','success'=>false));exit;
  986. }
  987. if(empty($data['details'])){
  988. echo json_encode(array('msg'=>'请输入位置','success'=>false));exit;
  989. }
  990. $info = $this->whlabel->find(" warehouse = 5 and sku = '".$data['sku']."'");
  991. if(empty($info)){
  992. echo json_encode(array('msg'=>'该sku未在美仓存储','success'=>false));exit;
  993. }
  994. $this->db->where('sku',$data['sku'])->where('warehouse',5)->update('whlabel',[
  995. 'sm' => $data['sm'],
  996. 'details' => $data['details'],
  997. ]);
  998. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  999. }else{
  1000. $this->_Template('whlabelfz_eidtmcinfo', $this->data);
  1001. }
  1002. }
  1003. }