load->library('session'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_productprice','productprice'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'add')//在库标签 { $this->_add(); } else { $this->_index(); } } //管理 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); $warehouse = $this->input->post('warehouse',true); $supplier = $this->input->post('supplier',true); $label = $this->input->post('label',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); $type = $this->input->post('type',true); $productweight = $this->input->post('productweight',true); $where = "1=1 "; if($sku) { $where .= " and sku = '$sku'"; } if($warehouse) { $where .= " and warehouse = '$warehouse'"; } if($supplier) { $where .= " and supplier = '$supplier'"; } if($label) { $where .= " and label = '$label'"; } if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($waybill) { $where .= " and waybill = '$waybill'"; } if($category || $size || $grade || $color || $lowe || $productweight) { $where .= " and title like '%$category.$grade.$size.$color.$lowe.$productweight%'"; } if($type) { $where .= " and type = '$type'"; } //数据排序 $order_str = "id asc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->whenter->find_all($where,'id,supplier,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $warehouse = $this->warehouse->read($value['warehouse']); $info_list[$key]['warehouse'] = $warehouse['title']; $supplier = $this->productprice->read($value['supplier']); $info_list[$key]['supplier'] = $supplier['supplier']; if($value['enter'] != 0) { $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']); } else { $info_list[$key]['enter'] = ""; } if($value['outk'] != 0) { $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']); } else { $info_list[$key]['outk'] = ""; } if($value['printing'] != 0) { $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']); } else { $info_list[$key]['printing'] = ""; } if($value['orderinfo'] == 0) { $info_list[$key]['orderinfo'] = ""; } if($value['waybill'] == 0) { $info_list[$key]['waybill'] = ""; } } $total = $this->whenter->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; } $pr = $this->productprice->find_all(); $this->data['pr'] = $pr; $this->_Template('whenter',$this->data); } //在库标签 public function _add() { $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $warehouse = $this->input->post('warehouse',true); $label = $this->input->post('label',true); $productweight = $this->input->post('productweight',true); $where = "1=1 and type = 2"; if($warehouse) { $where .= " and warehouse = '$warehouse'"; } if($label) { $where .= " and label = '$label'"; } //数据排序 $order_str = "id asc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->whenter->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { if($value['enter'] != 0) { $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']); } else { $info_list[$key]['enter'] = ""; } if($value['printing'] != 0) { $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']); } else { $info_list[$key]['printing'] = ""; } } $total = $this->whenter->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('whenter_add',$this->data); } }