Whlabelbarcode.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabelbarcode extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  7. $this->load->_model('Model_typeclass','typeclass');
  8. $this->load->_model('Model_excel','excel');
  9. }
  10. //定义方法的调用规则 获取URI第二段值
  11. public function _remap($arg,$arg_array)
  12. {
  13. if($arg == 'add')//入库操作
  14. {
  15. $this->_add();
  16. }
  17. else if($arg == 'edit')//修改
  18. {
  19. $this->_edit($arg_array);
  20. }
  21. else if($arg == 'del')//删除
  22. {
  23. $this->_del();
  24. }
  25. else if($arg == 'dc')//删除
  26. {
  27. $this->_dc();
  28. }
  29. else
  30. {
  31. $this->_index();
  32. }
  33. }
  34. public function _del()
  35. {
  36. $post = $this->input->post(NULL, TRUE);
  37. if(isset($post['s']))
  38. {
  39. $id_arr = $this->input->post('s');
  40. $id_arr = explode(',',$id_arr);
  41. if(!$id_arr)
  42. {
  43. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  44. }
  45. //循环删除记录
  46. foreach ($id_arr as $v)
  47. {
  48. $this->whlabelbarcode->remove($v);
  49. }
  50. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  51. }
  52. }
  53. //管理
  54. public function _index()
  55. {
  56. $post = $this->input->post(NULL, TRUE);
  57. if(isset($post['page']))
  58. {
  59. $page = $this->input->post('page',true);
  60. $perpage = $this->input->post('perpage',true);
  61. $sku = $this->input->post('sku',true);
  62. $title = $this->input->post('title',true);
  63. $warehouse = $this->input->post('warehouse',true);
  64. $purchase = $this->input->post('purchase',true);
  65. $orderinfo = $this->input->post('orderinfo',true);
  66. $waybill = $this->input->post('waybill',true);
  67. $category = $this->input->post('category',true);
  68. $size = $this->input->post('size',true);
  69. $grade = $this->input->post('grade',true);
  70. $color = $this->input->post('color',true);
  71. $lowe = $this->input->post('lowe',true);
  72. $state = $this->input->post('state',true);
  73. $label = $this->input->post('label',true);
  74. $timetk = $this->input->post('kktime',true);
  75. $timetj = $this->input->post('jjtime',true);
  76. $timetk = strtotime($timetk);
  77. $timetj = strtotime($timetj);
  78. $where = "1=1 ";
  79. if($timetk && $timetj)
  80. {
  81. $where .= " and time > '$timetk' and time < '$timetj'";
  82. }
  83. if($sku)
  84. {
  85. $where .= " and sku = '$sku'";
  86. }
  87. if($title)
  88. {
  89. $where .= " and title like '%$title%'";
  90. }
  91. if($warehouse)
  92. {
  93. $where .= " and warehouse = '$warehouse'";
  94. }
  95. if($purchase)
  96. {
  97. $where .= " and purchase = '$purchase'";
  98. }
  99. if($orderinfo)
  100. {
  101. $where .= " and orderinfo = '$orderinfo'";
  102. }
  103. if($waybill)
  104. {
  105. $where .= " and waybill = '$waybill'";
  106. }
  107. if($category)
  108. {
  109. $where .= " and features like '%-$category-%'";
  110. }
  111. if($size)
  112. {
  113. $where .= " and features like '%-$size-%'";
  114. }
  115. if($grade)
  116. {
  117. $where .= " and features like '%-$grade-%'";
  118. }
  119. if($color)
  120. {
  121. $where .= " and features like '%-$color-%'";
  122. }
  123. if($lowe)
  124. {
  125. $where .= " and features like '%-$lowe-%'";
  126. }
  127. if($label)
  128. {
  129. $where .= " and label = '$label'";
  130. }
  131. //数据排序
  132. $order_str = "time desc";
  133. if(empty($page))
  134. {
  135. $start = 0;
  136. $perpage = 1;
  137. }
  138. else
  139. {
  140. $start = ($page - 1)*$perpage;
  141. }
  142. //取得信息列表
  143. $info_list = $this->whlabelbarcode->find_all($where,'id,sku,title,label',$order_str,$start,$perpage);
  144. $total = $this->whlabelbarcode->find_count($where);
  145. $pagenum = ceil($total/$perpage);
  146. $over = $total-($start+$perpage);
  147. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  148. echo json_encode($rows);exit;
  149. }
  150. $this->_Template('whlabelbarcode',$this->data);
  151. }
  152. //入库操作
  153. public function _add()
  154. {
  155. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  156. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外
  157. $post = $this->input->post(NULL, TRUE);
  158. if(isset($post['category']))
  159. {
  160. $list = array();$num = "";$title = "";$features = "";$state=0;
  161. $post['time'] = time();
  162. $category = $this->input->post('category',true);
  163. $list['category'] = $category;
  164. $list['hairtype'] = $this->input->post('hairtype',true);
  165. $list['grade'] = $this->input->post('grade',true);
  166. $size = $this->input->post('size',true);
  167. $list['size'] = rtrim($size,',');
  168. $list['color'] = $this->input->post('color',true);
  169. $list['lowe'] = $this->input->post('lowe',true);
  170. $list['warehouse'] = $this->input->post('warehouse',true);
  171. if($category == 127)
  172. {
  173. $list['type'] = $this->input->post('type',true);
  174. $list['headroad'] = $this->input->post('headroad',true);
  175. $list['density'] = $this->input->post('density',true);
  176. $list['lacesize'] = $this->input->post('lacesize',true);
  177. $list['lacecolor'] = $this->input->post('lacecolor',true);
  178. $list['lacetypes'] = $this->input->post('lacetypes',true);
  179. $list['lacetypestwo'] = $this->input->post('lacetypestwo',true);
  180. }
  181. else if($category == 128)
  182. {
  183. $list['lacetype'] = $this->input->post('lacetype',true);
  184. $list['haircap'] = $this->input->post('haircap',true);
  185. $list['density'] = $this->input->post('density',true);
  186. $list['lacecolor'] = $this->input->post('lacecolor',true);
  187. }
  188. else if($category == 129)
  189. {
  190. $list['wide'] = $this->input->post('wide',true);
  191. }
  192. else if($category == 130)
  193. {
  194. $list['weight'] = $this->input->post('weight',true);
  195. }
  196. else if($category == 131)
  197. {
  198. $list['gift'] = $this->input->post('gift',true);
  199. }
  200. else if($category == 133)
  201. {
  202. $list['package'] = $this->input->post('package',true);
  203. $list['unitweight'] = $this->input->post('unitweight',true);
  204. //新增了 重量这选项 但是unitweight不知道是干啥的
  205. $list['weight'] = $this->input->post('weight',true);
  206. }
  207. else if($category == 134)
  208. {
  209. $list['pieceweight'] = $this->input->post('pieceweight',true);
  210. }
  211. if($category == 130){
  212. $list['jfother'] = $this->input->post('jfother', true);
  213. }
  214. foreach($list as $k=>$v)
  215. {
  216. if($v != 0)
  217. {
  218. $num .=$v;
  219. $features .=$v.'-';
  220. $post[$k] = $v;
  221. $typeclass = $this->typeclass->read($v);
  222. $title .= $typeclass['title']." ";
  223. if($k == 'hairtype'){
  224. if(!in_array($v,[163,164,165,166])){
  225. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  226. }
  227. }else{
  228. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  229. }
  230. }
  231. }
  232. $time = time();
  233. $post['title'] = rtrim($title,' ');
  234. $post['number'] = $num;
  235. $post['features'] = '-'.$features;
  236. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  237. $featurespp = explode('-',trim($featurespp,'-'));
  238. if(isset($featurespp[5]))
  239. {
  240. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  241. }
  242. else
  243. {
  244. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  245. }
  246. $scsku = implode("-",$scsku);
  247. $scsku = str_replace('- ','-',trim($scsku,'-'));
  248. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  249. $bqsku = $scsku;
  250. $post['sku'] = $bqsku;
  251. $label = time().rand(0,9);
  252. $post['label'] = $label;
  253. $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);
  254. if($whlabelbarcode)
  255. {
  256. echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;
  257. }
  258. else
  259. {
  260. if($this->whlabelbarcode->insert($post))
  261. {
  262. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  263. }
  264. else
  265. {
  266. echo json_encode(array('msg'=>'添加失败,请重试!','success'=>false));exit;
  267. }
  268. }
  269. }
  270. $this->_Template('whlabelbarcode_add',$this->data);
  271. }
  272. //修改产品
  273. public function _edit($arg_array)
  274. {
  275. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  276. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外
  277. $post = $this->input->post(NULL, TRUE);
  278. if(isset($post['id']))
  279. {
  280. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  281. $id = $this->input->post('id',true);
  282. $category = $this->input->post('category',true);
  283. $list['category'] = $category;
  284. $list['hairtype'] = $this->input->post('hairtype',true);
  285. $list['grade'] = $this->input->post('grade',true);
  286. $size = $this->input->post('size',true);
  287. $list['size'] = rtrim($size,',');
  288. $list['color'] = $this->input->post('color',true);
  289. $list['lowe'] = $this->input->post('lowe',true);
  290. $list['warehouse'] = $this->input->post('warehouse',true);
  291. if($category == 127)
  292. {
  293. $list['type'] = $this->input->post('type',true);
  294. $list['headroad'] = $this->input->post('headroad',true);
  295. $list['density'] = $this->input->post('density',true);
  296. $list['lacesize'] = $this->input->post('lacesize',true);
  297. $list['lacecolor'] = $this->input->post('lacecolor',true);
  298. $list['lacetypes'] = $this->input->post('lacetypes',true);
  299. $list['lacetypestwo'] = $this->input->post('lacetypestwo',true);
  300. }
  301. else if($category == 128)
  302. {
  303. $list['lacetype'] = $this->input->post('lacetype',true);
  304. $list['haircap'] = $this->input->post('haircap',true);
  305. $list['density'] = $this->input->post('density',true);
  306. $list['lacecolor'] = $this->input->post('lacecolor',true);
  307. }
  308. else if($category == 129)
  309. {
  310. $list['wide'] = $this->input->post('wide',true);
  311. }
  312. else if($category == 130)
  313. {
  314. $list['weight'] = $this->input->post('weight',true);
  315. }
  316. else if($category == 131)
  317. {
  318. $list['gift'] = $this->input->post('gift',true);
  319. }
  320. else if($category == 133)
  321. {
  322. $list['package'] = $this->input->post('package',true);
  323. $list['unitweight'] = $this->input->post('unitweight',true);
  324. //新增了 重量这选项 但是unitweight不知道是干啥的
  325. $list['weight'] = $this->input->post('weight',true);
  326. }
  327. else if($category == 134)
  328. {
  329. $list['pieceweight'] = $this->input->post('pieceweight',true);
  330. }
  331. foreach($list as $k=>$v)
  332. {
  333. if($v != 0)
  334. {
  335. $num .=$v;
  336. $features .=$v.'-';
  337. $post[$k] = $v;
  338. $typeclass = $this->typeclass->read($v);
  339. $title .= $typeclass['title']." ";
  340. if($k == 'hairtype'){
  341. if(!in_array($v,[163,164,165,166])){
  342. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  343. }
  344. }else{
  345. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  346. }
  347. }
  348. }
  349. $time = time();
  350. $post['title'] = rtrim($title,' ');
  351. $post['number'] = $num;
  352. $post['features'] = '-'.$features;
  353. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  354. $featurespp = explode('-',trim($featurespp,'-'));
  355. if(isset($featurespp[5]))
  356. {
  357. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  358. }
  359. else
  360. {
  361. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  362. }
  363. $scsku = implode("-",$scsku);
  364. $scsku = str_replace('- ','-',trim($scsku,'-'));
  365. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  366. $bqsku = $scsku;
  367. $post['sku'] = $bqsku;
  368. $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);
  369. if($whlabelbarcode)
  370. {
  371. echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;
  372. }
  373. else
  374. {
  375. if($this->whlabelbarcode->save($post,$id))
  376. {
  377. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  378. }
  379. else
  380. {
  381. echo json_encode(array('msg'=>'修改失败,请重试!','success'=>false));exit;
  382. }
  383. }
  384. }
  385. $uid = $this->whlabelbarcode->read($arg_array[0]);
  386. $this->data['enter'] = $uid ;
  387. $this->_Template('whlabelbarcode_edit',$this->data);
  388. }
  389. public function _dc()
  390. {
  391. if(isset($_GET['excel']))
  392. {
  393. $category = $this->input->get('category',true);
  394. $size = $this->input->get('size',true);
  395. $grade = $this->input->get('grade',true);
  396. $color = $this->input->get('color',true);
  397. $lowe = $this->input->get('lowe',true);
  398. $sku = $this->input->get('sku',true);
  399. $ktime = $this->input->get('ktime',true);
  400. $jtime = $this->input->get('jtime',true);
  401. $ktime = strtotime($kktime);
  402. $jtime = strtotime($jjtime);
  403. $where = "1=1";$gj = "";$ck = "";
  404. if($category)
  405. {
  406. $where .= " and features like '%-$category-%'";
  407. }
  408. if($size)
  409. {
  410. $where .= " and features like '%-$size-%'";
  411. }
  412. if($grade)
  413. {
  414. $where .= " and features like '%-$grade-%'";
  415. }
  416. if($color)
  417. {
  418. $where .= " and features like '%-$color-%'";
  419. }
  420. if($lowe)
  421. {
  422. $where .= " and features like '%-$lowe-%'";
  423. }
  424. if($sku)
  425. {
  426. $where .= " and sku like '%$sku%'";
  427. }
  428. if($ktime && $jtime)
  429. {
  430. $where .= " and time > '$ktime' and time < '$jtime'";
  431. }
  432. $order_str = "time desc";
  433. if(empty($page))
  434. {
  435. $start = 0;
  436. $perpage = 1;
  437. }
  438. else
  439. {
  440. $start = ($page - 1)*$perpage;
  441. }
  442. $info_list = $this->whlabelbarcode->find_all($where,'label,sku,title',$order_str);
  443. $title = '导入标签-'.date('Y-m-d H-i-s',time());
  444. $titlename = "<table border=1>
  445. <tr align='center'>
  446. <td>条码号</td>
  447. <td>SKU</td>
  448. <td>产品名称</td>
  449. <td>打印数量</td>
  450. </tr>
  451. </table>";
  452. $filename = $title.".xls";
  453. $tail = "";
  454. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  455. }
  456. }
  457. }