Whlabelbarcode.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  177. {
  178. $list['lacesize'] = $this->input->post('lacesize',true);
  179. }
  180. $list['lacecolor'] = $this->input->post('lacecolor',true);
  181. }
  182. else if($category == 128)
  183. {
  184. $list['lacetype'] = $this->input->post('lacetype',true);
  185. $list['haircap'] = $this->input->post('haircap',true);
  186. $list['density'] = $this->input->post('density',true);
  187. $list['lacecolor'] = $this->input->post('lacecolor',true);
  188. }
  189. else if($category == 129)
  190. {
  191. $list['wide'] = $this->input->post('wide',true);
  192. }
  193. else if($category == 130)
  194. {
  195. $list['weight'] = $this->input->post('weight',true);
  196. }
  197. else if($category == 131)
  198. {
  199. $list['gift'] = $this->input->post('gift',true);
  200. }
  201. else if($category == 133)
  202. {
  203. $list['package'] = $this->input->post('package',true);
  204. $list['unitweight'] = $this->input->post('unitweight',true);
  205. //新增了 重量这选项 但是unitweight不知道是干啥的
  206. $list['weight'] = $this->input->post('weight',true);
  207. }
  208. else if($category == 134)
  209. {
  210. $list['pieceweight'] = $this->input->post('pieceweight',true);
  211. }
  212. foreach($list as $k=>$v)
  213. {
  214. if($v != 0)
  215. {
  216. $num .=$v;
  217. $features .=$v.'-';
  218. $post[$k] = $v;
  219. $typeclass = $this->typeclass->read($v);
  220. $title .= $typeclass['title']." ";
  221. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  222. }
  223. }
  224. $time = time();
  225. $post['title'] = rtrim($title,' ');
  226. $post['number'] = $num;
  227. $post['features'] = '-'.$features;
  228. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  229. $featurespp = explode('-',trim($featurespp,'-'));
  230. if(isset($featurespp[5]))
  231. {
  232. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  233. }
  234. else
  235. {
  236. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  237. }
  238. $scsku = implode("-",$scsku);
  239. $scsku = str_replace('- ','-',trim($scsku,'-'));
  240. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  241. $bqsku = $scsku;
  242. $post['sku'] = $bqsku;
  243. $label = time().rand(0,9);
  244. $post['label'] = $label;
  245. $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);
  246. if($whlabelbarcode)
  247. {
  248. echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;
  249. }
  250. else
  251. {
  252. if($this->whlabelbarcode->insert($post))
  253. {
  254. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  255. }
  256. else
  257. {
  258. echo json_encode(array('msg'=>'添加失败,请重试!','success'=>false));exit;
  259. }
  260. }
  261. }
  262. $this->_Template('whlabelbarcode_add',$this->data);
  263. }
  264. //修改产品
  265. public function _edit($arg_array)
  266. {
  267. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  268. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外
  269. $post = $this->input->post(NULL, TRUE);
  270. if(isset($post['id']))
  271. {
  272. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  273. $id = $this->input->post('id',true);
  274. $category = $this->input->post('category',true);
  275. $list['category'] = $category;
  276. $list['hairtype'] = $this->input->post('hairtype',true);
  277. $list['grade'] = $this->input->post('grade',true);
  278. $size = $this->input->post('size',true);
  279. $list['size'] = rtrim($size,',');
  280. $list['color'] = $this->input->post('color',true);
  281. $list['lowe'] = $this->input->post('lowe',true);
  282. $list['warehouse'] = $this->input->post('warehouse',true);
  283. if($category == 127)
  284. {
  285. $list['type'] = $this->input->post('type',true);
  286. $list['headroad'] = $this->input->post('headroad',true);
  287. $list['density'] = $this->input->post('density',true);
  288. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  289. {
  290. $list['lacesize'] = $this->input->post('lacesize',true);
  291. }
  292. $list['lacecolor'] = $this->input->post('lacecolor',true);
  293. }
  294. else if($category == 128)
  295. {
  296. $list['lacetype'] = $this->input->post('lacetype',true);
  297. $list['haircap'] = $this->input->post('haircap',true);
  298. $list['density'] = $this->input->post('density',true);
  299. $list['lacecolor'] = $this->input->post('lacecolor',true);
  300. }
  301. else if($category == 129)
  302. {
  303. $list['wide'] = $this->input->post('wide',true);
  304. }
  305. else if($category == 130)
  306. {
  307. $list['weight'] = $this->input->post('weight',true);
  308. }
  309. else if($category == 131)
  310. {
  311. $list['gift'] = $this->input->post('gift',true);
  312. }
  313. else if($category == 133)
  314. {
  315. $list['package'] = $this->input->post('package',true);
  316. $list['unitweight'] = $this->input->post('unitweight',true);
  317. //新增了 重量这选项 但是unitweight不知道是干啥的
  318. $list['weight'] = $this->input->post('weight',true);
  319. }
  320. else if($category == 134)
  321. {
  322. $list['pieceweight'] = $this->input->post('pieceweight',true);
  323. }
  324. foreach($list as $k=>$v)
  325. {
  326. if($v != 0)
  327. {
  328. $num .=$v;
  329. $features .=$v.'-';
  330. $post[$k] = $v;
  331. $typeclass = $this->typeclass->read($v);
  332. $title .= $typeclass['title']." ";
  333. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  334. }
  335. }
  336. $time = time();
  337. $post['title'] = rtrim($title,' ');
  338. $post['number'] = $num;
  339. $post['features'] = '-'.$features;
  340. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  341. $featurespp = explode('-',trim($featurespp,'-'));
  342. if(isset($featurespp[5]))
  343. {
  344. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  345. }
  346. else
  347. {
  348. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  349. }
  350. $scsku = implode("-",$scsku);
  351. $scsku = str_replace('- ','-',trim($scsku,'-'));
  352. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  353. $bqsku = $scsku;
  354. $post['sku'] = $bqsku;
  355. $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);
  356. if($whlabelbarcode)
  357. {
  358. echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;
  359. }
  360. else
  361. {
  362. if($this->whlabelbarcode->save($post,$id))
  363. {
  364. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  365. }
  366. else
  367. {
  368. echo json_encode(array('msg'=>'修改失败,请重试!','success'=>false));exit;
  369. }
  370. }
  371. }
  372. $uid = $this->whlabelbarcode->read($arg_array[0]);
  373. $this->data['enter'] = $uid ;
  374. $this->_Template('whlabelbarcode_edit',$this->data);
  375. }
  376. public function _dc()
  377. {
  378. if(isset($_GET['excel']))
  379. {
  380. $category = $this->input->get('category',true);
  381. $size = $this->input->get('size',true);
  382. $grade = $this->input->get('grade',true);
  383. $color = $this->input->get('color',true);
  384. $lowe = $this->input->get('lowe',true);
  385. $sku = $this->input->get('sku',true);
  386. $ktime = $this->input->get('ktime',true);
  387. $jtime = $this->input->get('jtime',true);
  388. $ktime = strtotime($kktime);
  389. $jtime = strtotime($jjtime);
  390. $where = "1=1";$gj = "";$ck = "";
  391. if($category)
  392. {
  393. $where .= " and features like '%-$category-%'";
  394. }
  395. if($size)
  396. {
  397. $where .= " and features like '%-$size-%'";
  398. }
  399. if($grade)
  400. {
  401. $where .= " and features like '%-$grade-%'";
  402. }
  403. if($color)
  404. {
  405. $where .= " and features like '%-$color-%'";
  406. }
  407. if($lowe)
  408. {
  409. $where .= " and features like '%-$lowe-%'";
  410. }
  411. if($sku)
  412. {
  413. $where .= " and sku like '%$sku%'";
  414. }
  415. if($ktime && $jtime)
  416. {
  417. $where .= " and time > '$ktime' and time < '$jtime'";
  418. }
  419. $order_str = "time desc";
  420. if(empty($page))
  421. {
  422. $start = 0;
  423. $perpage = 1;
  424. }
  425. else
  426. {
  427. $start = ($page - 1)*$perpage;
  428. }
  429. $info_list = $this->whlabelbarcode->find_all($where,'label,sku,title',$order_str);
  430. $title = '导入标签-'.date('Y-m-d H-i-s',time());
  431. $titlename = "<table border=1>
  432. <tr align='center'>
  433. <td>条码号</td>
  434. <td>SKU</td>
  435. <td>产品名称</td>
  436. <td>打印数量</td>
  437. </tr>
  438. </table>";
  439. $filename = $title.".xls";
  440. $tail = "";
  441. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  442. }
  443. }
  444. }