Whlabelfz.php 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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' => $this->_getWarehouse($info['3']),
  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. $list['lacesize'] = empty($post['lacesize'])?'':$post['lacesize'];
  715. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  716. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  717. $list['lacetypestwo'] = empty($post['lacetypestwo'])?'':$post['lacetypestwo'];
  718. }
  719. if ($category == 128) {
  720. $list['lacetype'] =empty($post['lacetype'])?'':$post['lacetype'];
  721. $list['haircap'] = empty($post['haircap'])?'':$post['haircap'];
  722. $list['density'] = empty($post['density'])?'':$post['density'];
  723. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  724. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  725. $list['wigother'] = empty($post['wigother'])?'':$post['wigother'];
  726. $list['wigother1'] = empty($post['wigother1'])?'':$post['wigother1'];
  727. $list['wigother2'] = empty($post['wigother2'])?'':$post['wigother2'];
  728. }
  729. if ($category == 129) {
  730. $list['wide'] = empty($post['wide'])?'':$post['wide'];
  731. }
  732. if ($category == 131) {
  733. $list['gifttype'] = empty($post['gifttype'])?'':$post['gifttype'];
  734. $list['giftother'] = empty($post['giftother'])?'':$post['giftother'];
  735. }
  736. if ($category == 134) {
  737. $list['pieceweight'] = empty($post['pieceweight'])?'':$post['pieceweight'];
  738. }
  739. if ($category == 1297) {
  740. $list['synthetictype'] = empty($post['synthetictype'])?'':$post['synthetictype'];
  741. $list['sywigother'] = empty($post['sywigother'])?'':$post['sywigother'];
  742. }
  743. if ($category == 130 || $category == 133 || $category == 1702) {
  744. $list['items'] = empty($post['items'])?'':$post['items'];
  745. $list['weight'] = empty($post['weight'])?'':$post['weight'];
  746. }
  747. if ($category == 130 ) {
  748. $list['jfother'] = empty($post['jfother'])?'':$post['jfother'];
  749. }
  750. if ($category == 1702) {
  751. $list['syhairther'] = empty($post['syhairther'])?'':$post['syhairther'];
  752. }
  753. $pm = $scsku = $classid;
  754. $number = $features = $title = "";
  755. foreach ($list as $k => $v) {
  756. if ($v != 0) {
  757. $number .= $v;
  758. $features .= $v . '-';
  759. $typeclass = $this->typeclass->read($v);
  760. if (isset($pm[$typeclass['classid']])) {
  761. if (stripos($typeclass['zh'], '|') !== false) {
  762. $exzh = explode('|', $typeclass['zh']);
  763. if($k == 'hairtype'){
  764. if(!in_array($v,[163,164,165,166])){
  765. $pm[$typeclass['classid']] = $exzh[0];
  766. }
  767. }else{
  768. $pm[$typeclass['classid']] = $exzh[0];
  769. }
  770. } else {
  771. if($k == 'hairtype'){
  772. if(!in_array($v,[163,164,165,166])){
  773. $pm[$typeclass['classid']] = $typeclass['zh'];
  774. }
  775. }else{
  776. $pm[$typeclass['classid']] = $typeclass['zh'];
  777. }
  778. }
  779. }
  780. if($k == 'hairtype'){
  781. if(!in_array($v,[163,164,165,166])){
  782. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  783. }
  784. }else{
  785. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  786. }
  787. if ($k != 'size') {
  788. $title .= $typeclass['title'] . " ";
  789. }
  790. }
  791. }
  792. $typeclass = $this->typeclass->read($list['size']);
  793. $title .= $typeclass['title'];
  794. $time = time();
  795. $insert_arr['title'] = rtrim($title, ' ');
  796. $insert_arr['number'] = $number;
  797. $insert_arr['features'] = "-".trim($features, '-')."-";
  798. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  799. $featurespp = explode('-', trim($featurespp, '-'));
  800. if (isset($featurespp[5])) {
  801. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  802. } else {
  803. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  804. }
  805. $insert_arr['time'] = $time;
  806. $insert_arr['dynum'] = $info['1'];
  807. $scsku = implode("-", $scsku);
  808. $zh = implode(" ", $pm);
  809. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  810. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  811. $bqsku = $scsku;;
  812. $insert_arr['sku'] = $bqsku;
  813. $label = time() . $i;
  814. $insert_arr['label'] = $label;
  815. return [
  816. 'code'=>1,
  817. 'msg'=>"success",
  818. 'data'=>$insert_arr
  819. ];
  820. }
  821. private function _printing(){
  822. $post = $this->input->post(NULL, TRUE);
  823. if(isset($post['s'])){
  824. $v = $this->input->post('s');
  825. $va = explode(',',rtrim($v,','));
  826. $n = $this->input->post('n');
  827. $tf = $this->input->post('tf');
  828. $text = [];
  829. $text['data'] = [];
  830. $do_action_id = $va[$n];
  831. $info = $this->whlabellabelprint->read($do_action_id);
  832. if(empty($info)){
  833. echo json_encode(array('msg'=>'ID为'.$do_action_id.'的数据不存在,请联系技术','success'=>false));exit;
  834. }
  835. if($info['status'] == 1){
  836. echo json_encode(array('msg'=>$info['sku'].'的数据已打印,请勿重复打印','success'=>false));exit;
  837. }
  838. $list = [];
  839. $sku = $info['features'];
  840. if(!empty($sku)){
  841. $list[] = [
  842. 'sku2'=>$sku
  843. ];
  844. }
  845. $u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
  846. $zh = $u9_data[0]['zh'];
  847. $this->whlabellabelprint->save([
  848. 'status'=>1,
  849. 'print_time'=>time()
  850. ],$do_action_id);
  851. $cpid = $this->whlabellabel->find_count();
  852. $insert_arr = [
  853. 'shop'=>$info['shop'],
  854. 'purchase'=>$info['purchase'],
  855. 'sku'=>$info['sku'],
  856. 'number'=>$info['number'],
  857. 'features'=>$info['features'],
  858. 'featurespp'=>$info['featurespp'],
  859. 'title'=>$info['title'],
  860. 'label'=>$info['label'],
  861. 'warehouse'=>$info['warehouse'],
  862. 'time'=>time(),
  863. 'details'=>$info['details'],
  864. 'cpbz'=>$info['cpbz'],
  865. 'cpid'=>$cpid,
  866. 'jm'=>$u9_data[0]['jm'],
  867. ];
  868. $this->whlabellabel->insert($insert_arr);
  869. $text = [];
  870. $text['number'] = $info['sku'];
  871. $details = ($info['details'] != '') ? '位置:(' . $info['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  872. if(!empty($warehouse_name)){
  873. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  874. }
  875. $purchase = $this->purchase->read($info['purchase']);
  876. $text['title'] = $u9_data[0]['jm'];
  877. $text['num'] = $info['label'];
  878. $text['bqsku'] = $u9_data[0]['jm'];
  879. $text['xbqnum'] = $info['dynum'];
  880. $text['zh'] = str_replace('自然色 ', '', rtrim($zh, ' '));
  881. $text['details'] = $details;
  882. $text['purchase'] = $purchase['title'];
  883. $text['cpbz'] = $info['cpbz'];
  884. $text['usa'] = 0;
  885. // ob_clean();
  886. $rows = array('type'=>1,'n'=>$n-1,'data'=>$v,'text'=>$text);
  887. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  888. }
  889. }
  890. private function _bqplprint(){
  891. }
  892. private function _whlabelscan(){
  893. if($this->input->method() == 'post'){
  894. $page = $this->input->post('page',true);
  895. $perpage = $this->input->post('perpage',true);
  896. $title = $this->input->post('title',true);
  897. $sku = $this->input->post('sku',true);
  898. $type = $this->input->post('type',true);
  899. $timetk = $this->input->post('timetk',true);
  900. $timetj = $this->input->post('timetj',true);
  901. $timetk = strtotime($timetk);
  902. $timetj = strtotime($timetj);
  903. $where = "";
  904. if($timetk && $timetj)
  905. {
  906. $where .= " addtime > '$timetk' and addtime < '$timetj'";
  907. }
  908. if($type){
  909. $where .= " and type = '$type'";
  910. }
  911. if($title){
  912. $where .= " and title like '%$title%'";
  913. }
  914. if($sku){
  915. $where .= " and sku like '%$sku%'";
  916. }
  917. //数据排序
  918. $order_str = "id desc";
  919. if(empty($page))
  920. {
  921. $start = 0;
  922. $perpage = 1;
  923. }
  924. else
  925. {
  926. $start = ($page - 1)*$perpage;
  927. }
  928. // $purchase_list = $this->purchase->find_all("1 = 1","id,title");
  929. // $purchase_list = array_column($purchase_list,'title','id');
  930. //取得信息列表
  931. $info_list = $this->whlabelscanlog->find_all($where,'id,sku,title,warehouse,type,num,addtime',$order_str,$start,$perpage);
  932. foreach ($info_list as $key=>$value)
  933. {
  934. $info_list[$key]['warehouse'] = $this->_getWarehouseById($value['warehouse']);
  935. $info_list[$key]['type'] = $value['type'] == 1 ? '扫描入库' : '扫描出库';
  936. $info_list[$key]['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  937. }
  938. $total = $this->whlabelscanlog->find_count($where);
  939. $pagenum = ceil($total/$perpage);
  940. $over = $total-($start+$perpage);
  941. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  942. echo json_encode($rows);exit;
  943. }else{
  944. $type = $this->input->get('type');
  945. $this->data['type'] = $type;
  946. $this->_Template('whlabelfz_whlabelscan', $this->data);
  947. }
  948. }
  949. private function _whlabelscanlogexcel(){
  950. $title = $this->input->post('title',true);
  951. $sku = $this->input->post('sku',true);
  952. $type = $this->input->post('type',true);
  953. $timetk = $this->input->post('timetk',true);
  954. $timetj = $this->input->post('timetj',true);
  955. $timetk = strtotime($timetk);
  956. $timetj = strtotime($timetj);
  957. $where = "";
  958. if($timetk && $timetj)
  959. {
  960. $where .= " addtime > '$timetk' and addtime < '$timetj'";
  961. }
  962. if($type){
  963. $where .= " and type = '$type'";
  964. }
  965. if($title){
  966. $where .= " and title like '%$title%'";
  967. }
  968. if($sku){
  969. $where .= " and sku like '%$sku%'";
  970. }
  971. $info_list = $this->whlabelscanlog->find_all($where,'sku,title,warehouse,type,num,addtime');
  972. foreach ($info_list as $key=>$value)
  973. {
  974. $info_list[$key]['warehouse'] = $this->_getWarehouseById($value['warehouse']);
  975. $info_list[$key]['type'] = $value['type'] == 1 ? '扫描入库' : '扫描出库';
  976. $info_list[$key]['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  977. }
  978. if(empty($info_list)){
  979. echo json_encode(array('msg'=>'没有数据','success'=>false));exit;
  980. }
  981. $final_list = [];
  982. foreach ($info_list as $key => $value) {
  983. $final_list[] = [
  984. "SKU"=>$value['sku'],
  985. "商品名称"=>$value['title'],
  986. "仓库"=>$value['warehouse'],
  987. "类型"=>$value['type'],
  988. "数量"=>$value['num'],
  989. "扫描时间"=> $value['addtime']
  990. ];
  991. }
  992. $filename = "扫描日志_".date("Ymd")."_".rand(1000,9999).".xls";
  993. echo json_encode(array('msg'=>'获取数据成功','success'=>true,'data'=>$final_list,'filename'=>$filename));exit;
  994. }
  995. private function _eidtmcinfo(){
  996. if($this->input->method(TRUE) == 'POST'){
  997. $data = $this->input->post(NULL,TRUE);
  998. if(empty($data['sku'])){
  999. echo json_encode(array('msg'=>'请输入sku','success'=>false));exit;
  1000. }
  1001. // if(empty($data['sm'])){
  1002. // echo json_encode(array('msg'=>'请输入负责人','success'=>false));exit;
  1003. // }
  1004. if(empty($data['details'])){
  1005. echo json_encode(array('msg'=>'请输入位置','success'=>false));exit;
  1006. }
  1007. $info = $this->whlabel->find(" warehouse = 5 and sku = '".$data['sku']."'");
  1008. if(empty($info)){
  1009. echo json_encode(array('msg'=>'该sku未在美仓存储','success'=>false));exit;
  1010. }
  1011. $this->db->where('sku',$data['sku'])->where('warehouse',5)->update('whlabel',[
  1012. 'sm' => $data['sm'],
  1013. 'details' => $data['details'],
  1014. ]);
  1015. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  1016. }else{
  1017. $this->_Template('whlabelfz_eidtmcinfo', $this->data);
  1018. }
  1019. }
  1020. }