Whlabelbarcode.php 15 KB

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