load->library('session'); $this->load->_model('Model_whlabelbarcode','whlabelbarcode'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_excel','excel'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'add')//入库操作 { $this->_add(); } else if($arg == 'edit')//修改 { $this->_edit($arg_array); } else if($arg == 'del')//删除 { $this->_del(); } else if($arg == 'dc')//删除 { $this->_dc(); } else { $this->_index(); } } public function _del() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $this->whlabelbarcode->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } //管理 public function _index() { $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $sku = $this->input->post('sku',true); $title = $this->input->post('title',true); $warehouse = $this->input->post('warehouse',true); $purchase = $this->input->post('purchase',true); $orderinfo = $this->input->post('orderinfo',true); $waybill = $this->input->post('waybill',true); $category = $this->input->post('category',true); $size = $this->input->post('size',true); $grade = $this->input->post('grade',true); $color = $this->input->post('color',true); $lowe = $this->input->post('lowe',true); $state = $this->input->post('state',true); $label = $this->input->post('label',true); $timetk = $this->input->post('kktime',true); $timetj = $this->input->post('jjtime',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 "; if($timetk && $timetj) { $where .= " and time > '$timetk' and time < '$timetj'"; } if($sku) { $where .= " and sku = '$sku'"; } if($title) { $where .= " and title like '%$title%'"; } if($warehouse) { $where .= " and warehouse = '$warehouse'"; } if($purchase) { $where .= " and purchase = '$purchase'"; } if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($waybill) { $where .= " and waybill = '$waybill'"; } if($category) { $where .= " and features like '%-$category-%'"; } if($size) { $where .= " and features like '%-$size-%'"; } if($grade) { $where .= " and features like '%-$grade-%'"; } if($color) { $where .= " and features like '%-$color-%'"; } if($lowe) { $where .= " and features like '%-$lowe-%'"; } if($label) { $where .= " and label = '$label'"; } //数据排序 $order_str = "time desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->whlabelbarcode->find_all($where,'id,sku,title,label',$order_str,$start,$perpage); $total = $this->whlabelbarcode->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $this->_Template('whlabelbarcode',$this->data); } //入库操作 public function _add() { $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>''); //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外 $post = $this->input->post(NULL, TRUE); if(isset($post['category'])) { $list = array();$num = "";$title = "";$features = "";$state=0; $post['time'] = time(); $category = $this->input->post('category',true); $list['category'] = $category; $list['hairtype'] = $this->input->post('hairtype',true); $list['grade'] = $this->input->post('grade',true); $size = $this->input->post('size',true); $list['size'] = rtrim($size,','); $list['color'] = $this->input->post('color',true); $list['lowe'] = $this->input->post('lowe',true); $list['warehouse'] = $this->input->post('warehouse',true); if($category == 127) { $list['type'] = $this->input->post('type',true); $list['headroad'] = $this->input->post('headroad',true); $list['density'] = $this->input->post('density',true); if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = $this->input->post('lacesize',true); } $list['lacecolor'] = $this->input->post('lacecolor',true); } else if($category == 128) { $list['lacetype'] = $this->input->post('lacetype',true); $list['haircap'] = $this->input->post('haircap',true); $list['density'] = $this->input->post('density',true); $list['lacecolor'] = $this->input->post('lacecolor',true); } else if($category == 129) { $list['wide'] = $this->input->post('wide',true); } else if($category == 130) { $list['weight'] = $this->input->post('weight',true); } else if($category == 131) { $list['gift'] = $this->input->post('gift',true); } else if($category == 133) { $list['package'] = $this->input->post('package',true); $list['unitweight'] = $this->input->post('unitweight',true); } else if($category == 134) { $list['pieceweight'] = $this->input->post('pieceweight',true); } foreach($list as $k=>$v) { if($v != 0) { $num .=$v; $features .=$v.'-'; $post[$k] = $v; $typeclass = $this->typeclass->read($v); $title .= $typeclass['title']." "; $scsku[$typeclass['classid']] = $typeclass['bqsku']; } } $time = time(); $post['title'] = rtrim($title,' '); $post['number'] = $num; $post['features'] = '-'.$features; $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features); $featurespp = explode('-',trim($featurespp,'-')); if(isset($featurespp[5])) { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5]; } else { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4]; } $scsku = implode("-",$scsku); $scsku = str_replace('- ','-',trim($scsku,'-')); $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku); $bqsku = $scsku; $post['sku'] = $bqsku; $label = time().rand(0,9); $post['label'] = $label; $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']); if($whlabelbarcode) { echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit; } else { if($this->whlabelbarcode->insert($post)) { echo json_encode(array('msg'=>'添加成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试!','success'=>false));exit; } } } $this->_Template('whlabelbarcode_add',$this->data); } //修改产品 public function _edit($arg_array) { $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>''); //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外 $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库 $id = $this->input->post('id',true); $category = $this->input->post('category',true); $list['category'] = $category; $list['hairtype'] = $this->input->post('hairtype',true); $list['grade'] = $this->input->post('grade',true); $size = $this->input->post('size',true); $list['size'] = rtrim($size,','); $list['color'] = $this->input->post('color',true); $list['lowe'] = $this->input->post('lowe',true); $list['warehouse'] = $this->input->post('warehouse',true); if($category == 127) { $list['type'] = $this->input->post('type',true); $list['headroad'] = $this->input->post('headroad',true); $list['density'] = $this->input->post('density',true); if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = $this->input->post('lacesize',true); } $list['lacecolor'] = $this->input->post('lacecolor',true); } else if($category == 128) { $list['lacetype'] = $this->input->post('lacetype',true); $list['haircap'] = $this->input->post('haircap',true); $list['density'] = $this->input->post('density',true); $list['lacecolor'] = $this->input->post('lacecolor',true); } else if($category == 129) { $list['wide'] = $this->input->post('wide',true); } else if($category == 130) { $list['weight'] = $this->input->post('weight',true); } else if($category == 131) { $list['gift'] = $this->input->post('gift',true); } else if($category == 133) { $list['package'] = $this->input->post('package',true); $list['unitweight'] = $this->input->post('unitweight',true); } else if($category == 134) { $list['pieceweight'] = $this->input->post('pieceweight',true); } foreach($list as $k=>$v) { if($v != 0) { $num .=$v; $features .=$v.'-'; $post[$k] = $v; $typeclass = $this->typeclass->read($v); $title .= $typeclass['title']." "; $scsku[$typeclass['classid']] = $typeclass['bqsku']; } } $time = time(); $post['title'] = rtrim($title,' '); $post['number'] = $num; $post['features'] = '-'.$features; $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features); $featurespp = explode('-',trim($featurespp,'-')); if(isset($featurespp[5])) { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5]; } else { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4]; } $scsku = implode("-",$scsku); $scsku = str_replace('- ','-',trim($scsku,'-')); $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku); $bqsku = $scsku; $post['sku'] = $bqsku; $whlabelbarcode = $this->whlabelbarcode->get_number($post['number']); if($whlabelbarcode) { echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit; } else { if($this->whlabelbarcode->save($post,$id)) { echo json_encode(array('msg'=>'修改成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'修改失败,请重试!','success'=>false));exit; } } } $uid = $this->whlabelbarcode->read($arg_array[0]); $this->data['enter'] = $uid ; $this->_Template('whlabelbarcode_edit',$this->data); } public function _dc() { if(isset($_GET['excel'])) { $category = $this->input->get('category',true); $size = $this->input->get('size',true); $grade = $this->input->get('grade',true); $color = $this->input->get('color',true); $lowe = $this->input->get('lowe',true); $sku = $this->input->get('sku',true); $ktime = $this->input->get('ktime',true); $jtime = $this->input->get('jtime',true); $ktime = strtotime($kktime); $jtime = strtotime($jjtime); $where = "1=1";$gj = "";$ck = ""; if($category) { $where .= " and features like '%-$category-%'"; } if($size) { $where .= " and features like '%-$size-%'"; } if($grade) { $where .= " and features like '%-$grade-%'"; } if($color) { $where .= " and features like '%-$color-%'"; } if($lowe) { $where .= " and features like '%-$lowe-%'"; } if($sku) { $where .= " and sku like '%$sku%'"; } if($ktime && $jtime) { $where .= " and time > '$ktime' and time < '$jtime'"; } $order_str = "time desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $info_list = $this->whlabelbarcode->find_all($where,'label,sku,title',$order_str); $title = '导入标签-'.date('Y-m-d H-i-s',time()); $titlename = "
条码号 | SKU | 产品名称 | 打印数量 |