Przeglądaj źródła

提交打印导出数据

lvhao 6 miesięcy temu
rodzic
commit
0acca600ba

+ 201 - 0
core/CoreApp/controllers/Systemprint.php

@@ -55,6 +55,7 @@ class Systemprint extends Start_Controller {
 		$this->load->_model("Model_logic_order","logic_order");
 		$this->load->_model("Model_itsxb","itsxb");
 		$this->load->_model("Model_express_tt","express_tt");
+		$this->load->_model("Model_logic_u9tools","logic_u9tools");
 	}
 	//定义方法的调用规则 获取URI第二段值
     public function _remap($arg,$arg_array)
@@ -102,6 +103,9 @@ class Systemprint extends Start_Controller {
 		else if($arg == 'mcindex'){
 			$this->_mcindex();
 		}
+		else if($arg == 'ckpmcheck'){
+			$this->_ckpmcheck();
+		}
 		else
 		{
 			 $this->_index();
@@ -2910,4 +2914,201 @@ class Systemprint extends Start_Controller {
 		],JSON_UNESCAPED_UNICODE);
 		die;
 	}
+
+	public function  _ckpmcheck(){
+		$params = $this->input->get(NULL, TRUE);
+
+		$user = $this->user->get_api($_SESSION['api']);
+		$fgshop = "";$sid = "";$wid="";$wtype="";
+		$usersp = explode('|',trim($user['shop'],'|'));
+		$userwh = explode('|',trim($user['warehouse'],'|'));
+		foreach ($usersp as $value) 
+		{
+			$fgshop .= " shop = ".$value." or";
+			$sid .= " id = ".$value." or";
+		}
+		foreach ($userwh as $value) 
+		{
+			$wid .= " id = ".$value." or";
+			$wtype .= " type = ".$value." or";
+		}
+
+
+		if(isset($params['excel'])&& ($params['excel'] == 1)){
+			$timetk = $this->input->get('timetk',true);
+			$timetj = $this->input->get('timetj',true);
+			$shop = $this->input->get('shop',true);
+			$print = $this->input->get('print',true);
+			$express = $this->input->get('express',true);
+			$waybill = $this->input->get('waybill',true);
+			$printtype = $this->input->get('printtype',true);
+			$orderinfo = $this->input->get('orderinfo',true);
+			$number = $this->input->get('number',true);
+            $type = $this->input->get('type',true);
+			$lowe = $this->input->get('lowe',true);
+			$ji = $this->input->get('ji',true);
+			$so = $this->input->get('so',true);
+			$ckfl = $this->input->get('ckfl',true);
+			$sfxh = $this->input->get('sfxh',true);
+			$lowe = $this->input->get('lowe',true);
+			$color = $this->input->get('color',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
+			    if($print == 3)
+                {
+                    $where  .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
+                }
+			    else
+			    {
+				    $where  .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 and reviewtime > '".(time() - 30*24*3600)."'";
+			    }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($printtype)
+            {
+                $where  .= " and printtype = '$printtype'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($color)
+            {
+                $where  .= " and fpdata like '%-$color-%'";
+            }
+			if($lowe)
+            {
+                $where  .= " and fpdata like '%-$lowe-%'";
+            }
+			if($type)
+            {
+				$where  .= " and type = '$type'";
+			}
+			else
+			{
+				$where  .= " and type != '16'";
+			}
+			
+			if($ji)
+            {
+                $where  .= " and shipremarks like '%急%'";
+            }
+			if($so)
+            {
+                $where  .= " and shipremarks like '%$so%'";
+            }
+			if($ckfl)
+            {
+                $where  .= " and ckfl = '$ckfl'";
+            }
+			if($sfxh != '')
+            {
+                $where  .= " and sfxh = '$sfxh'";
+            }
+            //数据排序
+            $order_str = ($print != 3)?"id desc":"printtime desc";
+			$field = 'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks,is_jiaji,fpdata';
+
+			$dlz_ret = $this->indexData('fullorder',0,1000,$where,$field,$order_str);
+			$dlz_list = $dlz_ret['list'];
+			$smt_ret = $this->indexData('fullordersmt',0,1000,$where,$field,$order_str);
+			$smt_list = $smt_ret['list'];
+			$tt_ret = $this->indexData('fullordertt',0,1000,$where,$field,$order_str);
+			$tt_list = $tt_ret['list'];
+			$amz_ret = $this->indexData('fullorderamz',0,1000,$where,$field,$order_str);
+			$amz_list = $amz_ret['list'];
+			$list = array_merge($dlz_list,$smt_list,$tt_list,$amz_list);
+			$typeclass = [];
+
+			$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($list as $key=>$value){
+				$tmp = explode(';',trim($value['fpdata'],";"));
+				foreach($tmp as $k => $v){
+					$arr_tmp = explode('|',$v);
+					if(strpos($arr_tmp[0],',')!== false){
+						$sku  = "-".str_replace(',','-',$arr_tmp[0]);
+					}else{
+						$sku = $arr_tmp[0];
+					}
+
+					$r = $this->logic_u9tools->getOneU9bmHasGift($sku,$classid,$typeclass);
+					$list[$key]['u9_zh'][] = $r['zh'];
+					$list[$key]['u9_jm'][] = $r['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>订单号</td><td>编号</td><td>快递公司</td><td>运单号</td><td>状态</td><td>类型</td><td>次数</td><td>打印时间</td><td>仓库品名</td><td>中文品名</td><td>u9料号</td></tr>";
+			
+			 foreach ($list as $key=>$value) 
+			 { 
+				 $u9_zh = implode('<br/>',$value['u9_zh']);
+				 $u9_jm = implode('<br/>',$value['u9_jm']);
+				 
+				 $str .= "<tr>";
+				 $str .= "<td>". $value['shop']. "</td>";
+				 $str .= "<td>". $value['orderinfo']. "</td>";
+				 $str .= "<td>". $value['number']. "</td>";
+				 $str .= "<td>". $value['express']. "</td>";
+				 $str .= "<td>". $value['waybill']. "</td>";
+				 $str .= "<td>". $value['print']. "</td>";
+				 $str .= "<td>". $value['printtype']. "</td>";
+				 $str .= "<td>". $value['printnumber']. "</td>";
+				 $str .= "<td>". $value['printtime']. "</td>";
+				 $str .= "<td>". $value['shipremarks']. "</td>";
+				 $str .= "<td>".trim($u9_zh,"<br/>"). "</td>";
+				 $str .= "<td>".trim($u9_jm,"<br/>"). "</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 - 0
template/erp/systemprint.html

@@ -74,6 +74,7 @@
 </div>
 <a href="javascript:void(0);" class="printing">打 印</a>
 <a href="javascript:void(0);" class="exceldy">导出Excel</a>
+<a href="javascript:void(0);" class="ckpmcheck">导出Excel(料号多行)</a>
 </div>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
@@ -135,6 +136,25 @@ window.onload = function() {
     },1100)
 };
 
+$(".ckpmcheck").on("click",function(){
+    var f = "";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+    $("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+    var a = "";
+    $(".datatext input[name='check']:checked").each(function() {
+        a = a + $(this).val() + ",";
+    });
+    f = f + "excel=1&a=" + a ;
+    window.location.href = "/systemprint/ckpmcheck?fexcel=1&" + f;
+    $("select[name=fexcel] option:eq(0)").prop('selected', 'selected');
+})
 </script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>
 <script type="text/javascript" src="{$theme}js/print.js?v=202505301539"></script>