浏览代码

提交数据

lvhao 2 月之前
父节点
当前提交
158c726dd2
共有 2 个文件被更改,包括 212 次插入0 次删除
  1. 171 0
      core/CoreApp/controllers/Whlabelfz.php
  2. 41 0
      template/erp/whlabel_printck.html

+ 171 - 0
core/CoreApp/controllers/Whlabelfz.php

@@ -0,0 +1,171 @@
+<?php defined('BASEPATH') or exit('No direct script access allowed');
+/**
+ * 由于whlabel类下的代码太长了,决定以后非必要代码都放在whlabelfz类中,以便于管理。
+ */
+class Whlabelfz extends Start_Controller
+{
+	public function __construct()
+	{
+        parent::__construct();
+        $this->load->_model('Model_whlabel', 'whlabel');
+		$this->load->_model('Model_warehouse', 'warehouse');
+        $this->load->_model('Model_specialstock', 'specialstock');
+        $this->load->_model('Model_logic_u9tools','logic_u9tools');
+        $this->load->_model('Model_classid','classid');
+        $this->load->_model('Model_typeclass','typeclass');
+    }
+    //定义方法的调用规则 获取URI第二段值
+	public function _remap($arg, $arg_array)
+	{
+		if ($arg == 'bqckexcel') //
+		{
+            //获取标签出库的按条件导出的excel
+			$this->_bqck_excel();
+		} 
+	    else {
+			$this->_index();
+		}
+	}
+
+    private function _index(){
+        die('No direct script access allowed');
+    }
+
+    private function _bqck_excel(){
+        if (isset($_GET['excel'])) {
+            //统计时间
+            $timetk = $this->input->get('timetk', true);
+			$timetj = $this->input->get('timetj', true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+
+            $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);//sku
+            $warehouse = $this->input->get('warehouse',true);//仓库
+            $purchase = $this->input->get('purchase',true);//供应商
+			$where = "state=1 ";
+			if ($timetk && $timetj) {
+				$where .= " and outk > '$timetk' and outk < '$timetj'";
+			}
+			if ($sku) {
+				$where  .= " and sku = '$sku'";
+			}
+			if ($warehouse) {
+				$where  .= " and warehouse = '$warehouse'";
+			}
+			if ($purchase) {
+				$where  .= " and purchase = '$purchase'";
+			}
+			
+			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-%'";
+			}
+			
+			$ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
+            $order_str = "outk desc";
+            //取得信息列表
+			$info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,outk,details', $order_str);
+            $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 $key => $value) {
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
+				$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]['state'] = "在库";
+				} else if ($value['state'] == 1) {
+					$info_list[$key]['state'] = "出库";
+				} else if ($value['state'] == 2) {
+					$info_list[$key]['state'] = "退库";
+				} else if ($value['state'] == 3) {
+					$info_list[$key]['state'] = "调拨中";
+				} else if ($value['state'] == 4) {
+					$info_list[$key]['state'] = "再加工";
+				} else if ($value['state'] == 5) {
+					$info_list[$key]['state'] = "维修中";
+				} else if ($value['state'] == 6) {
+					$info_list[$key]['state'] = "盘亏";
+				} else if ($value['state'] == 7) {
+					$info_list[$key]['state'] = "更换标签";
+				} else if ($value['state'] == 8) {
+					$info_list[$key]['state'] = "其它";
+				} else if ($value['state'] == 9) {
+					$info_list[$key]['state'] = "预设";
+				} else if ($value['state'] == 10) {
+					$info_list[$key]['state'] = "美店零售";
+				}
+				$info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
+			}
+            //生成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>供应商</td><td>SKU</td><td>名称</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['purchase']. "</td>";	
+                $str .= "<td>". $value['sku']. "</td>";	
+                $str .= "<td>". $value['title']. "</td>";
+                $str .= "<td>". $value['features']. "</td>";
+                $str .= "<td>". $value['state']. "</td>";
+                $str .= "<td>". $value['outk']. "</td>";
+                $str .= "<td>". $value['details']. "</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); 
+        }else{
+
+        }
+    }
+}

+ 41 - 0
template/erp/whlabel_printck.html

@@ -41,6 +41,9 @@
 {/loop}
 </select></li>
 <li><span>确 定</span></li>
+<li>
+    <font class="cona export_data">按条件导出</font>
+ </li>
 </ul>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
@@ -143,6 +146,44 @@ $(".systemwindow").on('click', ".wcoutbound", function() {
     $("#tmsku").focus();
     $(".systemwindow").hide();
 });
+$(".export_data").off('click').on('click',function(){
+    let str = "excel=1";
+    let timetk = $("#ktime").val();
+    let timetj = $("#jtime").val();
+    if(timetk){
+        str += "&timetk=" + timetk;
+    }
+    if(timetj){
+        str += "&timetj=" + timetj;
+    }
+    if($("select[name='category']").val()){
+        str += "&category=" + $("select[name='category']").val();
+    }
+    if($("select[name='size']").val()){
+        str += "&size=" + $("select[name='size']").val();
+    }
+    if($("select[name='grade']").val()){
+        str += "&grade=" + $("select[name='grade']").val();
+    }
+    if($("select[name='color']").val()){
+        str += "&color=" + $("select[name='color']").val();
+    }
+    if($("select[name='lowe']").val()){
+        str += "&lowe=" + $("select[name='lowe']").val();
+    }
+    if($("input[name='sku']").val()){
+        str += "&sku=" + $("input[name='sku']").val();
+    }
+    if($("select[name='warehouse']").val()){
+        str += "&warehouse=" + $("select[name='warehouse']").val();
+    }
+    if($("select[name='purchase']").val()){
+        str += "&purchase=" + $("select[name='purchase']").val();
+    }
+    window.location.href ="/whlabelfz/bqckexcel?" + str;
+})
+   
+
 </script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>
 {Template footer}