浏览代码

完成导出功能

lvhao 1 月之前
父节点
当前提交
476bd4f899
共有 2 个文件被更改,包括 139 次插入2 次删除
  1. 119 1
      core/CoreApp/controllers/Whlabelfz.php
  2. 20 1
      template/erp/whlabel_enter.html

+ 119 - 1
core/CoreApp/controllers/Whlabelfz.php

@@ -14,6 +14,7 @@ class Whlabelfz extends Start_Controller
         $this->load->_model('Model_classid','classid');
         $this->load->_model('Model_typeclass','typeclass');
         $this->load->_model('Model_purchase', 'purchase');
+		$this->load->_model("Model_shop", "shop");
     }
     //定义方法的调用规则 获取URI第二段值
 	public function _remap($arg, $arg_array)
@@ -275,7 +276,8 @@ class Whlabelfz extends Start_Controller
 				$info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
 
                 $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
-                $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];				if ($value['state'] == 0) {
+                $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];				
+				if ($value['state'] == 0) {
 					$info_list[$key]['state'] = "在库";
 				} else if ($value['state'] == 1) {
 					$info_list[$key]['state'] = "出库";
@@ -349,6 +351,122 @@ class Whlabelfz extends Start_Controller
     }
 
 	public function _whlabel_cprk_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);
+		$warehouse = $this->input->get('warehouse', true);
+		$purchase = $this->input->get('purchase', true);
+		$ktime = $this->input->get('ktime', true);
+		$jtime = $this->input->get('jtime', true);
+		$ktime = strtotime($ktime);
+		$jtime = strtotime($jtime);
+		$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 ($warehouse) {
+			$where  .= " and warehouse = '$warehouse'";
+		}
+		if ($purchase) {
+			$where  .= " and purchase = '$purchase'";
+		}
+		if ($sku) {
+			$where  .= " and sku like '%$sku%'";
+		}
+		if ($ktime && $jtime) {
+			$where .= " and enter > '$ktime' and enter < '$jtime'";
+		}
+		
+		//取得信息列表
+		$info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,enter,features');
+		if(!empty($info_list)){
+			$wh = array();
+			$w = $this->warehouse->find_all('1=1', 'id,title');
+			foreach ($w as $v) {
+				$wh[$v['id']] = $v['title'];
+			}
+			$classid = $this->classid->sku();
+			$tcall = $this->typeclass->find_all();
+			foreach ($tcall as $v)
+			{
+				//$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+				$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+			}
+			foreach ($info_list as $k => $v) {
+				$info_list[$k]['warehouse'] = $wh[$v['warehouse']];
+				
+				$info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
+				$g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
+				$info_list[$k]['g'] = $g;
+				$u9_info = $this->logic_u9tools->getOneU9bm($v['features'],$classid,$typeclass);
+                $info_list[$k]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];	
+			}
+		}
+
+
+		//生成excel
+		$filename = date("Y-m-d")."标签入库导出.xls";
+		$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
+		<head>
+		<!--[if gte mso 9]><xml>
+		<x:ExcelWorkbook>
+		<x:ExcelWorksheets>
+		<x:ExcelWorksheet>
+		<x:Name>EXCEL</x:Name>
+		<x:WorksheetOptions>
+		<x:Print>
+		<x:ValidPrinterInfo />
+		</x:Print>
+		</x:WorksheetOptions>
+		</x:ExcelWorksheet>
+		</x:ExcelWorksheets>
+		</x:ExcelWorkbook>
+		</xml>
+		<![endif]-->
+		</head><body>";
+		$str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>"; 
+		$str .= "<tr><td>仓库</td><td>SKU</td><td>产品名称</td><td>入库时间</td><td>数量</td><td>料号</td></tr>";
+		foreach ($info_list as $key=>$value) 
+		{ 
+			
+			$str .= "<tr>";
+			$str .= "<td>". $value['warehouse']. "</td>";	
+			$str .= "<td>". $value['sku']. "</td>";	
+			$str .= "<td>". $value['title']. "</td>";
+			$str .= "<td>". $value['enter']. "</td>";
+			$str .= "<td>". $value['g']. "</td>";
+			$str .= "<td>". $value['features']. "</td>";
+
+			$str .= "</tr>";
+		}
+		$str .= "</table></body></html>"; 
+		header( "Content-Type: application/vnd.ms-excel; name='excel'" ); 
+		header( "Content-type: application/octet-stream" ); 
+		header( "Content-Disposition: attachment; filename=".$filename ); 
+		header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); 
+		header( "Pragma: no-cache" ); 
+		header( "Expires: 0" ); 
+		exit($str); 
+		
+		
 		
 	}
 

+ 20 - 1
template/erp/whlabel_enter.html

@@ -41,6 +41,7 @@
 <div class="control">
 <a href="javascript:void(0);" class="window" data-h="/whlabel/enteradd/" data-t="库存配置 - 添加">添 加</a>
 <!-- <a href="javascript:void(0);" class="check">删 除</a> -->
+<a href="javascript:void(0);" class="export_excel">按筛选条件导出表格</a>
 </div>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
@@ -73,6 +74,24 @@ $(this).find('td:eq(3)').css("width","14%");
 $(this).find('td:eq(5)').css("width","14%");
 $(this).find('td:eq(6)').css("width","4%");
 $(this).find('td:eq(4)').css("width","45%");
-});}</script>
+});}
+$(".export_excel").on("click",function(){
+    let str = "";
+    $(".search select").each(function(){
+        if($(this).val()){
+            str += $(this).attr("name")  +"="+$(this).val() + "&";
+        }
+       
+    });
+    $(".search input").each(function(){
+        if($(this).val()){
+            str += $(this).attr("name")  +"="+$(this).val() + "&";
+        }
+    })
+    str = str.substring(0,str.length-1);
+    var url = "/whlabelfz/whlabel_cprk_excel?"+$("#searchform").serialize();
+    window.location.href = url;
+})
+</script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>
 {Template footer}