浏览代码

添加一件导出惠城的数据

lvhao 3 月之前
父节点
当前提交
12be725c90
共有 1 个文件被更改,包括 102 次插入0 次删除
  1. 102 0
      core/CoreApp/controllers/Systembound.php

+ 102 - 0
core/CoreApp/controllers/Systembound.php

@@ -37,6 +37,11 @@ class Systembound extends Start_Controller {
 		else if($arg == 'excel')
         {
              $this->_excel();
+        }
+		else if($arg == 'excelhc')
+        {
+			//一件导出惠城和GES的全部快递
+             $this->_excelhc();
         }
 		else
 		{
@@ -654,6 +659,103 @@ class Systembound extends Start_Controller {
 	    }
 	}
 	
+	//一件导出惠城的全部快递
+	public function _excelhc()
+	{
+		if(isset($_GET['fexcel']))  
+		{
+			$timetk = $this->input->get('timetk',true);
+			$timetj = $this->input->get('timetj',true);
+			$library = $this->input->get('library',true);
+			$type = $this->input->get('type',true);
+			$number = $this->input->get('number',true);
+			$waybill = $this->input->get('waybill',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+
+			$cx_arr = [7,50,51,52,69,73];//需要的查询数据
+
+			$ex_list = $this->express->find_all("id in (".implode(',',$cx_arr).")","id,servicename");
+			//GES  7     惠城联邦  50 惠城GES  51  惠城安迈世  51  惠城DHL 69 惠城usps  73
+			$where = "type != 0 and express in (".implode(',',$cx_arr).")";
+			
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			if(isset($_SESSION['api']))
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($_SESSION['api']);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			else
+			{
+				echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
+			}
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			
+			$data = array();
+			$datafy = array();
+			$j = 0;
+			$info_list = $this->outbound->find_all($where,'number,waybill,express','time asc');
+
+			$final_list= [
+
+			];
+			foreach($cx_arr as $v){
+				$final_list[$v] = [];
+			}
+			foreach ($info_list as $key=>$value)
+		    {
+				if(isset($final_list[$value['express']])){
+					$final_list[$value['express']][] = [
+						$value['number'],
+						$value['waybill'],
+					];
+				}
+				
+			}
+			$data[] = $datafy;
+			 //格式化数据
+			$i = 0;$cpexcel = array();
+            $title = date('Ymd',time())."发货统计信息"; $td = '';
+			$td = "";
+			foreach($ex_list as $v){
+				$td .= "<td>".$v['servicename']."</td><td></td>";
+			}
+            $titlename = "<table border=1>
+            <tr>
+            ".$td."
+            </tr>
+            </table>"; 
+            $filename = $title.".xls";
+            $this->excel->get_fz6($final_list,$titlename,$filename);
+	    }
+	}
+
+
 	public function _add()
 	{
 		$post = $this->input->post(NULL, TRUE);