lvhao 1 месяц назад
Родитель
Сommit
166bd23623
2 измененных файлов с 117 добавлено и 2 удалено
  1. 96 1
      core/CoreApp/controllers/Whlabel.php
  2. 21 1
      template/erp/whlabel_typejs.html

+ 96 - 1
core/CoreApp/controllers/Whlabel.php

@@ -193,7 +193,10 @@ class Whlabel extends Start_Controller
 		}else if ($arg == 'exceljxcjs') //进销存信息导出
 		{
 			$this->_exceljxcjs();
-		} else if($arg == "w_t_cs"){
+		} else if ($arg == 'summaryjs') //汇总导出
+		{
+			$this->_summaryjs($arg_array);
+		}else if($arg == "w_t_cs"){
 			$this->_w_t_cs(); //首页
 		}else {
 			$this->_index();
@@ -8432,4 +8435,96 @@ class Whlabel extends Start_Controller
 	
 	}
 
+
+	public function _summaryjs($arg_array)
+	{
+		$prc = array();
+		$purchase = $this->purchase->find_all();
+		foreach ($purchase as $k => $v) {
+			$prc[$v['id']] = $v['title'];
+		}
+		if (isset($_GET['excel'])) {
+			$ktime = $this->input->get('ktime', true);
+			$jtime = $this->input->get('jtime', true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+			$where = "1=1";
+			if ($ktime && $jtime) {
+				$where  .= " and outk > '$ktime' and outk < '$jtime'";
+			}
+			//数据排序
+			$order_str = "time desc";
+			if (empty($page)) {
+				$start = 0;
+				$perpage = 1;
+			} else {
+				$start = ($page - 1) * $perpage;
+			}
+			//取得信息列表
+			$info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
+			foreach ($info_list as $key => $value) {
+				$info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = $warehouse['title'];
+				$x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
+				$details = array();
+				$cpid = array();
+				foreach ($x as $k => $v) {
+					if ($v['details'] != '') {
+						$details[$v['details']] = $v['details'];
+					}
+					if ($v['cpid'] != 0) {
+						$cpid[$v['cpid']] = $v['cpid'];
+					}
+				}
+				$info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
+				$info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
+				$s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
+				$info_list[$key]['s'] = $s;
+				$info_list[$key]['x'] = count($x);
+			}
+			if(empty($info_list)){
+				exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
+			}
+			$title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
+
+
+
+			$first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
+			$merges = [
+				[
+					"s"=>["r"=>0,"c"=>0],
+					"e"=>["r"=>0,"c"=>7]
+				]
+			];
+			$cols = [
+				["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
+			];
+			$final_list = [];
+			foreach($info_list as $k => $v){
+				$final_list[] = array_values($v);
+
+			}
+
+
+
+			exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
+			$titlename = "<table border=1>
+            <tr align='center'>
+			<td>仓库</td>
+			<td>供应商</td>
+			<td>出库位置</td>
+			<td>出库编码</td>
+			<td>SKU</td>
+            <td>产品名</td>
+            <td>总剩余库存</td>
+            <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
+            </tr>
+            </table>";
+			$filename = $title . ".xls";
+			$tail = "";
+			$this->excel->get_fz2($info_list, $titlename, $filename, $tail);
+		}
+	}
+
 }

+ 21 - 1
template/erp/whlabel_typejs.html

@@ -203,7 +203,7 @@
 </select>
 <a href="javascript:void(0);" data-url="exceljxc" data-id="1" class="whlabelexceljs">导出进销存</a>
 <a href="javascript:void(0);" data-url="excelct" data-id="3" class="whlabelexceljs">导出条件检索</a>
-<a href="javascript:void(0);" class="summary">出库汇总</a>
+<a href="javascript:void(0);" class="summaryjs">出库汇总</a>
 
 <a href="javascript:void(0);" data-url="presetout" data-id="3" class="whlabelexceljs">导出库存模板</a>
 <a href="javascript:void(0);" class="whlabeldr">导入库存</a>
@@ -430,6 +430,26 @@ $(".whlabelexceljs").click(function() {
         }
     },'json')
 });
+//出库汇总
+$(".summaryjs").click(function() {
+    var f = "";
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	let url  = excel+"summaryjs/"+"?excel=1&"+f;
+    $.get(url,{},function(res){
+        layx.destroy('loadId');
+        if(res.code == 1){
+            importDataNoCol(res.data)
+        }else{
+            layx.alert('错误',res.msg,function(id,button){
+            },{dialogIcon:'error'});
+        }
+    },'json')
+});
 //导出第一行不含合并单元格的
 function importDataNoCol(data){
     console.log(data.merges)