lvhao 2 روز پیش
والد
کامیت
efa16de32e
2فایلهای تغییر یافته به همراه91 افزوده شده و 149 حذف شده
  1. 78 146
      core/CoreApp/controllers/Whlabelfz1.php
  2. 13 3
      template/erp/whlabelfz1_typedy.html

+ 78 - 146
core/CoreApp/controllers/Whlabelfz1.php

@@ -12,6 +12,9 @@ class Whlabelfz1 extends Start_Controller
 		$this->load->_model("Model_logic_u9tools","logic_u9tools");
 		$this->load->_model("Model_whlabellabel","whlabellabel");
 		$this->load->_model('Model_purchase', 'purchase');
+		$this->load->_model('Model_whlabel_type', 'whlabel_type');
+		$this->load->_model("Model_shop","shop");
+		$this->load->_model("Model_warehouse","warehouse");
     }
     //定义方法的调用规则 获取URI第二段值
 	public function _remap($arg, $arg_array)
@@ -212,185 +215,114 @@ class Whlabelfz1 extends Start_Controller
 			$page = $this->input->post('page', true);
 			$perpage = $this->input->post('perpage', 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);
-			$sku = $this->input->post('sku');
-			$title = $this->input->post('title');
 			$warehouse = $this->input->post('warehouse', true);
-			$usa = $this->input->post('usa', true);
-			$purchase = $this->input->post('purchase', true);
-			$lacetype = $this->input->post('lacetype', true);
-			$haircap = $this->input->post('haircap', true);
-			$density = $this->input->post('density', true);
-			$details = $this->input->post('details', true);
-			$state = $this->input->post('state', true);
-			$lacecolor = $this->input->post('lacecolor', true);
-			$hairnumber = $this->input->post('hairnumber', true);
-			$cklx = $this->input->post('cklx', true);
-			$ktime = $this->input->post('ktime', true);
-			$jtime = $this->input->post('jtime', true);
-			$sm = $this->input->post('sm', true);
-			$cpbz = $this->input->post('cpbz', true);
-			$type = $this->input->post('type', true);
-			$ktime = strtotime($ktime);
-			$jtime = strtotime($jtime);
-			$where = "1=1";
-			
-			if ($usa) {
-				if (!$warehouse) {
-					$where  .= " and (warehouse = '5' or warehouse = '8')";
-				}
-			}
-			if ($warehouse) {
-				$where  .= " and warehouse = '$warehouse'";
-			}
-			if ($details) {
-				$where  .= " and details = '$details'";
-			}
-			if ($purchase) {
-				$where  .= " and purchase = '$purchase'";
+		
+			//这里的仓库是隐藏传递的所以不需要判断
+			$where_sql = " state = 0  and  warehouse and ".$warehouse." ";
+			if(!empty($post['purchase'])){
+				$where_sql .= " and purchase = ".$post['purchase']." ";
 			}
-			if (isset($state)) {
-				if($state >-1){
-					$where  .= " and state = '$state'";
-				}
-				
+			if(!empty($post['type'])){
+				$where_sql .= " and type = ".$post['type']." ";
 			}
-
-			if ($lacetype) {
-				$where  .= " and features like '%-$lacetype-%'";
+			if(!empty($post['category'])){//类目
+				$where_sql .= " and features like '%-".$post['category']."-%' ";
 			}
-			if ($category) {
-				$where  .= " and features like '%-$category-%'";
+			if(!empty($post['grade'])){//等级
+				$where_sql .= " and grade like '%-".$post['grade']."-%' ";
 			}
-			if ($size) {
-				$where  .= " and features like '%-$size-%'";
+			if(!empty($post['color'])){//颜色
+				$where_sql .= " and color like '%-".$post['color']."-%' ";
 			}
-			if ($grade) {
-				$where  .= " and features like '%-$grade-%'";
+			if(!empty($post['lowe'])){//曲度
+				$where_sql .= " and lowe  like '%-".$post['lowe']."-%' ";
 			}
-			if ($color) {
-				$where  .= " and features like '%-$color-%'";
+			if(!empty($post['lacetype'])){//头套种类
+				$where_sql .= " and lacetype like '%-".$post['lacetype']."-%' ";
 			}
-			if ($lowe) {
-				$where  .= " and features like '%-$lowe-%'";
+			if(!empty($post['lacecolor'])){//头套颜色
+				$where_sql .= " and lacecolor like '%-".$post['lacecolor']."-%' ";
 			}
-			if ($haircap) {
-				$where  .= " and features like '%-$haircap-%'";
+			if(!empty($post['size'])){//尺寸
+				$where_sql .= " and size like '%-".$post['size']."-%' ";
 			}
-			if ($density) {
-				$where  .= " and features like '%-$density-%'";
+			if(!empty($post['density'])){//密度
+				$where_sql .= " and density like '%-".$post['density']."-%' ";
 			}
-			if ($lacecolor) {
-				$where  .= " and features like '%-$lacecolor-%'";
+			if(!empty($post['haircap'])){
+				$where_sql .= " and haircap like '%-".$post['haircap']."-%' ";
 			}
-			if($sm){
-				$where .= " and  sm like '%".$sm."%'";
+			if(!empty($post['hairnumber'])){
+				$where_sql .= " and hairnumber like '%-".$post['hairnumber']."-%' ";
 			}
-			if($cpbz){
-				$where .= " and  cpbz like '%".$cpbz."%'";
+			if(!empty($post['cklx'])){
+				$shop_info = $this->shop->read($post['cklx']);
+				if(!empty($shop_info)){
+					$where_sql .= " and zd like '%-".$shop_info['shortname']."-%' ";
+				}
 			}
-			if($type){
-				$where .= " and  type = ".$type."";
+			if(!empty($post['sku'])){
+				$sku = trim($post['sku'], ' ');
+				$sku = trim($sku, '	');
+				$where_sql .= " and sku like '%-".$sku."-%' ";
 			}
-			if (!empty($hairnumber)) {
-				$where  .= " and  features like '%-128-%' ";
-				if ($hairnumber < 0) {
-					$class_list = $this->typeclass->find_all('classid = 43');
-					foreach ($class_list as $v) {
-						$where .= " and  features not like '%-" . $v['id'] . "-%'";
-					}
-				} else {
-					$where  .= " and features like '%-$hairnumber-%'";
-				}
+			if(!empty($post['title'])){
+				$title = trim($post['title']);
+				$where_sql .= " and title like '%". $title ."%' ";
 			}
 
-			$where_add = '';
-			if ($cklx) {
-				$shop = $this->shop->read($cklx);
-				$where_add  .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
+			if(!empty($post['cpbz'])){
+				$cpbz = trim($post['cpbz']);
+				$where_sql .= " and cpbz like '%". $cpbz ."%' ";
+			}
+			if(!empty($post['sm'])){
+				$sm = trim($post['sm']);
+				$where_sql .= " and sm like '%". $sm ."%' ";
 			}
 			
-			//数据排序
-			$order_str = "id desc";
 			if (empty($page)) {
 				$start = 0;
 				$perpage = 1;
 			} else {
 				$start = ($page - 1) * $perpage;
 			}
-			//这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
-			if ($sku) {
-				$sku = trim($sku, ' ');
-				$sku = trim($sku, '	');
-				$where  .= " and sku like '%$sku%'";
-				$info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
-			} else if ($title) {
-				$title = trim($title, ' ');
-				$title = trim($title, '	');
-				$where  .= " and title like '%$title%'";
-				$info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
-			} else {
-				//$where  .= " and time > '$ktime' and time < '$jtime'";
-				$info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
-			}
-			//$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
-
-			$info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
-			foreach ($info_list as $k => $v) {
-				$info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
-				unset($info_list[$k]['pm']);
-				unset($info_list[$k]['jm']);
-				unset($info_list[$k]['bm']);
-			}
-
-			//取得信息列表
+			
 
-			$rows = array();
-			$list = array();
-			foreach ($info_list as $key => $value) {
-				$warehouse = $this->warehouse->read($value['warehouse']);
-				$info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
-				$c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
-				$z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
-				$info_list[$key]['cpbz'] = $value['cpbz'] ; 
-				$info_list[$key]['label'] = $value['sm'];
-				$number = $value['number'];
-				$ftime = time() - 15 * 24 * 3600;
-				$info_list[$key]['warehouse'] = $warehouse['title'];
-				$info_list[$key]['features'] = count($c);
-				$z = count($z); //查看订单号
-				$zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
-				$ztdata = '';
-				if (count($zt) > 0) {
-					foreach ($zt as $vv) {
-						$ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
-					}
-				}
-				$info_list[$key]['number'] = $ztdata;
-				$info_list[$key]['sm'] = $z;
-				$details = array();
-				$cpid = array();
-				foreach ($c as $k => $v) {
-					$details[$v['details']] = $v['details'];
-					if ($v['cpid'] != 0) {
-						$cpid[$v['cpid']] = $v['cpid'];
-					}
+			$get_model = $this->db->from("whlabel")->where($where_sql)->select("id,number,purchase,sku,warehouse,title,details,cpid,COUNT(id) AS total_num")->group_by('number');
+			if(!empty($post['dopx'])){
+				if($post['dopx'] == 1){
+					$get_model = $get_model->order_by("total_num",'ASC');
 				}
-				$info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
-				if ($value['shop'] != '') {
-					$shop = explode(',', trim($value['shop'], ','));
-					$shop = $this->shop->read($shop[0]);
-					$info_list[$key]['shop'] = $shop['shopname'];
+				if($post['dopx'] == 2){
+					$get_model = $get_model->order_by("total_num",'DESC');
 				}
 			}
+			
+			$list = $get_model->limit($perpage,$start)->get()->result_array();
+			$warehouse_info = $this->warehouse->read($warehouse);
+			$final_list = [];
+			foreach($list as $k => $v){
+				$final_list[$k]['id'] = $v['id'];
+				$final_list[$k]['warehous'] = $warehouse_info['title'];
+				$final_list[$k]['purchase'] = $prc[$v['purchase']];
+				$final_list[$k]['sku'] = $v['sku'];
+				$final_list[$k]['title'] = $v['title'];
+				$final_list[$k]['details'] = $v['details']."<br/>".$v['cpid'];
+				$final_list[$k]['total_num'] = $v['total_num'];
+				$final_list[$k]['zt'] = "";
+				$final_list[$k]['zd'] = "";
+			}
+
+		
 
-			$total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
+			
+			$total = $this->db->from("whlabel")->where($where_sql)->select("id,number,sku,warehouse,title,details,cpid,COUNT(id) AS total_num")->group_by('number')->count_all_results();
 			$pagenum = ceil($total / $perpage);
 			$over = $total - ($start + $perpage);
+	
+			
 			$rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
+			
 			echo json_encode($rows);
 			exit;
 		}

+ 13 - 3
template/erp/whlabelfz1_typedy.html

@@ -46,7 +46,7 @@
 </li>
 <li>状态:<select name="state" class="select">
 <option value="0">在库</option>
-<option value="-1">全部</option>
+<!-- <option value="-1">全部</option> -->
 <!--
 <option value="">请选择</option>
 <option value="1">正常出库</option>
@@ -84,6 +84,16 @@
 <li>备注:<input value="" name="cpbz" type="text" style="width:120px"></li>
 <li>说明:<input value="" name="sm" type="text" style="width:120px"></li>
 
+<li>
+    浏览排序  :<select name="dopx" class="select">
+        <option value="">请选择</option>
+        <option value="1">由小到大</option>
+        <option value="2">由大到小</option>
+       
+        </select>
+</li>
+
+
 <li><span>确 定</span></li>
 <input value="{$warehouse}" name="warehouse" type="hidden" >
 </ul>
@@ -95,9 +105,9 @@
 <td>SKU</td>
 <td>商品名称</td>
 <td>位置及编码</td>
-<td>品牌</td>
+<!-- <td>品牌</td>
 <td>备注</td>
-<td>说明</td>
+<td>说明</td> -->
 <td>库存</td>
 <td>在途</td>
 <td>占单</td>