Whlabelfz.php 35 KB

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