Whlabelfz.php 31 KB

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