| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- header("Access-Control-Allow-Origin: *");
 
- class Systemfoutfz extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_whlabel','whlabel');
 
- 		$this->load->_model('Model_warehouse','warehouse');
 
- 		$this->load->_model('Model_productprice','productprice');
 
- 		$this->load->_model('Model_excel','excel');
 
- 		$this->load->_model('Model_fullorder','fullorder');
 
- 		$this->load->_model('Model_fullordertt','fullordertt');
 
- 		$this->load->_model('Model_fullorderamz','fullorderamz');
 
- 		$this->load->_model('Model_fullordersmt','fullordersmt');
 
- 		$this->load->_model('Model_outbound','outbound');
 
- 		$this->load->_model('Model_express','express');
 
- 		$this->load->_model('Model_shop','shop');
 
- 		$this->load->_model('Model_typeclass','typeclass');
 
- 		$this->load->_model('Model_country','country');
 
- 		$this->load->_model('Model_kdniao','kdniao');
 
- 		$this->load->_model('Model_notice','notice');
 
- 		$this->load->_model('Model_dhl','dhl');
 
- 		$this->load->_model('Model_dhlhz','dhlhz');
 
- 		$this->load->_model('Model_usps','usps');
 
- 		$this->load->_model('Model_fedex','fedex');
 
- 		$this->load->_model('Model_fedex_cby','fedex_cby');
 
- 		$this->load->_model('Model_ups','ups');
 
- 		$this->load->_model('Model_ali','ali');
 
- 		$this->load->_model('Model_dpd','dpd');
 
- 		$this->load->_model('Model_shop','shop');
 
- 		$this->load->_model('Model_user','user');
 
- 		$this->load->_model('Model_whlabel','whlabel');
 
- 		$this->load->_model('Model_specialstock','specialstock');
 
- 		$this->load->_model('Model_ck','ck');
 
- 		$this->load->_model('Model_whlabellabel','whlabellabel');
 
- 		$this->load->_model('Model_apiyy','apiyy');
 
- 		$this->load->helper('url');
 
- 		$this->load->_model('Model_whlabel_fc','whlabel_fc');
 
- 		$this->load->_model('Model_systemtransfer','systemtransfer');
 
- 		$this->load->_model('Model_classid','classid');
 
- 		$this->load->_model('Model_allocation','allocation');
 
- 		$this->load->_model('Model_fullorderxw','fullorderxw');
 
- 		$this->load->_model('Model_fullorderpaypal','fullorderpaypal');
 
- 		$this->load->_model("Model_logic_ding","logic_ding");
 
- 		$this->load->_model("Model_fedexv1",'fedexv1');
 
- 		$this->load->_model("Model_zzquque_u9","zzquque_u9");
 
- 		$this->load->_model("Model_customsdeclaration","customsdeclaration");
 
- 	}
 
- 	//定义方法的调用规则 获取URI第二段值
 
-     public function _remap($arg,$arg_array)
 
-     {
 
- 		if($arg == 'exceltwo')
 
-         {
 
-              $this->_exceltwo($arg_array);
 
-         }
 
- 		else
 
- 		{
 
- 			 $this->_index();
 
- 		}
 
-     }
 
- 	public function _exceltwo($arg_array)
 
-     {
 
- 		if(isset($_SESSION['api']))
 
- 		{
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 		    $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($user['userid'] == 'xw')
 
- 			{
 
- 				$xw = 1;
 
- 			}
 
- 		}
 
- 		if(isset($_GET['fexcel']))  
 
- 		{
 
- 			$dowid = $this->input->get('a');
 
- 			$wid = "";
 
- 			if($dowid != "")
 
- 			{
 
- 				$id_arr =  explode(',',rtrim($dowid,','));
 
- 				foreach ($id_arr as $v) 
 
- 		        {
 
-                     $wid  .= " id = '$v' or";
 
-                 }
 
- 				$wid = " and".rtrim($wid,'or');
 
- 			}
 
- 		    $t = $this->input->get('t',true);
 
- 			$timetk = $this->input->get('timetk',true);
 
- 			$timetj = $this->input->get('timetj',true);
 
- 			$shop = $this->input->get('shop',true);
 
- 			$source = $this->input->get('source',true);
 
- 			$orderinfo = $this->input->get('orderinfo',true);
 
- 			$number = $this->input->get('number',true);
 
- 			$library = $this->input->get('library',true);
 
- 			$waybill = $this->input->get('waybill',true);
 
- 			$express = $this->input->get('express',true);
 
- 			$type = $this->input->get('type',true);
 
- 			$so = $this->input->get('so',true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			$where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
 
- 			if($timetk && $timetj && $library == 1)
 
-             {
 
- 				//$cxtime = 'reviewtime';
 
-                 $where  .= "  and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
 
- 				$where  .= " and state != 217";
 
- 				
 
-             }
 
- 			else if($timetk && $timetj && $library == 2)
 
-             {
 
- 				$cxtime = 'librarytime';
 
-                 $where  .= " and librarytime > '$timetk' and librarytime < '$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($shop)
 
-             {
 
-                 $where  .= " and shop = '$shop'";
 
-             }
 
- 			if($number)
 
-             {
 
-                 $where  .= " and number = '$number'";
 
-             }
 
- 			if($library)
 
-             {
 
-                 $where  .= " and library = '$library'";
 
-             }
 
- 			if($waybill)
 
-             {
 
-                 $where  .= " and waybill = '$waybill'";
 
-             }
 
- 			if($express)
 
-             {
 
- 				$where  .= " and express = '$express'";
 
-             }
 
- 			if($orderinfo)
 
-             {
 
-                 $where  .= " and orderinfo = '$orderinfo'";
 
-             }
 
- 			if($so)
 
-             {
 
-                 $where  .= " and shipremarks like '%$so%'";
 
-             }
 
-             //数据排序
 
- 			//$order_str = ($print != 3)?"id desc":"librarytime desc";
 
- 			$order_str = "librarytime desc";
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
- 			$typeclass = array();
 
- 			$tclass = $this->typeclass->find_all();
 
- 			foreach ($tclass as $v) 
 
- 			{
 
- 				$typeclass[$v['id']] = $v;
 
- 			}
 
- 			$classid = $classid = $this->classid->sku();
 
- 			$shop_list = $this->shop->find_all();
 
- 			$shop_list = array_column($shop_list,'shopname','id');
 
- 			$express_list = $this->express->find_all();
 
- 			$express_list = array_column($express_list,'servicename','id');
 
- 			$warehouse_list = $this->warehouse->find_all();
 
- 			$warehouse_list = array_column($warehouse_list,'title','id');
 
- 			$info_list = $this->_getAndTransfer('fullorder',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass);
 
- 			$info_listsmt = $this->_getAndTransfer('fullordersmt',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass);
 
- 			$info_listtt = $this->_getAndTransfer('fullordertt',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass);
 
- 			$info_listamz = $this->_getAndTransfer('fullorderamz',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass);
 
- 			$info_listxw = $this->_getAndTransfer('fullorderxw',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass);
 
- 			
 
- 			
 
- 			
 
- 			$list = [];
 
- 			$list = array_merge($info_list,$info_listsmt,$info_listtt,$info_listamz,$info_listxw);
 
- 			// $final_list = [];
 
- 			// foreach(){
 
- 			// }
 
- 			
 
- 			//生成excel
 
-             $filename = '订单出库-'.date('Ymd',time()).".xlsx";
 
-             $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></tr>";
 
-             foreach ($list as $key=>$value) 
 
-             { 
 
- 				foreach($value['trans_list'] as $k=>$v){
 
- 					$str .= "<tr>";
 
- 					$str .= "<td>". $value['number']. "</td>";
 
- 					$str .= "<td>". $value['librarytime']. "</td>";	
 
- 					$str .= "<td>". $value['shipremarks']. "</td>";	
 
- 					$str .= "<td>". $value['ts']. "</td>";	
 
- 					$str .= "<td>". $v['pm']. "</td>";
 
- 					$str .= "<td>". $v['jm']. "</td>";
 
- 					$str .= "<td>". $v['ts']. "</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); 
 
- 		
 
- 		}
 
- 	}
 
- 	
 
- 	
 
- 	/**
 
- 	 * 对多个平台的数据进行循环处理
 
- 	 */
 
- 	private function _getAndTransfer($table,$where,$order_str,$shop_list,$express_list,$warehouse_list,$classid,$typeclass){
 
- 		 //取得信息列表
 
- 		 $info_list = $this->$table->find_all($where,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
 
- 		 //格式化数据
 
- 		foreach ($info_list as $key=>$value) 
 
- 		{
 
- 			$info_list[$key]['shop'] = isset($shop_list[$value['shop']])?$shop_list[$value['shop']]: "";
 
- 			if($value['waybill'] == '0')
 
- 			{
 
- 				$info_list[$key]['waybill'] = "";
 
- 			}
 
- 			$info_list[$key]['express'] = isset($express_list[$value['express']])?$express_list[$value['express']]:"";
 
- 		
 
- 			$info_list[$key]['type'] = isset($warehouse_list[$value['type']])?$warehouse_list[$value['type']]: "";
 
- 			if($value['print'] == 1)
 
- 			{
 
- 				$info_list[$key]['print'] = '不可打印';
 
- 			}
 
- 			else if($value['print'] == 2)
 
- 			{
 
- 				$info_list[$key]['print'] = '未打印';
 
- 			}
 
- 			else if($value['print'] == 3)
 
- 			{
 
- 				$info_list[$key]['print'] = '已打印';
 
- 			}
 
- 			if($value['library'] == 1)
 
- 			{
 
- 				$info_list[$key]['library'] = '<em class="c">未出库</em>';
 
- 			}
 
- 			else if($value['library'] == 2)
 
- 			{
 
- 				$info_list[$key]['library'] = '<em class="c">已出库</em>';
 
- 			}
 
- 			else if($value['library'] == 3)
 
- 			{
 
- 				$info_list[$key]['library'] = '<em class="c">已退库</em>';
 
- 			}
 
- 			if($value['librarytime'] == '0')
 
- 			{
 
- 				$info_list[$key]['librarytime'] = '<em class="t"></em>';
 
- 			}
 
- 			else
 
- 			{
 
- 				$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
 
- 			}
 
- 			$dbapi = explode(';',trim($value['fpdata'],';'));
 
- 			$trans_list = [];
 
- 			foreach ($dbapi as $va) 
 
- 			{
 
- 				$pm = $classid;
 
- 				$jm = $classid;
 
- 				$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
 
- 				$features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
 
- 				$ts = explode('|',trim($features,'|'));
 
- 				if(stripos($ts[0],',') !== false)
 
- 				{
 
- 					$ft = explode(',',$ts[0]);
 
- 					$features = explode('-',trim($ft[1],'-'));
 
- 					$features[] = $ft[0];
 
- 				}
 
- 				else
 
- 				{
 
- 					$features = explode('-',trim($ts[0],'-'));
 
- 				}
 
- 				foreach($features as $k=>$v)
 
- 				{
 
- 					if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
 
- 					{
 
- 						if($typeclass[$v]['bm'] != '')
 
- 						{
 
- 							$bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
 
- 						}
 
- 					}
 
- 					if($v != 0 && isset($typeclass[$v]))
 
- 					{
 
- 						if($typeclass[$v]['classid'] == 13)
 
- 						{
 
- 							$dj = $typeclass[$v]['title'];
 
- 						}
 
- 						if($typeclass[$v]['classid'] == 8)
 
- 						{
 
- 							$ys = $typeclass[$v]['title'];
 
- 						}
 
- 						if($typeclass[$v]['classid'] == 15)
 
- 						{
 
- 							$hx = $typeclass[$v]['title'];
 
- 						}
 
- 						if(isset($pm[$typeclass[$v]['classid']]))
 
- 						{
 
- 							if($typeclass[$v]['title'] == '9A')
 
- 							{
 
- 								$pm[$typeclass[$v]['classid']] = '9A';
 
- 							}
 
- 							else if($typeclass[$v]['title'] == '10A')
 
- 							{
 
- 								$pm[$typeclass[$v]['classid']] = '10A';
 
- 							}
 
- 							else
 
- 							{
 
- 								$clzh = $typeclass[$v]['zh'];
 
- 								if(stripos($typeclass[$v]['zh'],'|') !== false)
 
- 								{
 
- 									$clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
 
- 									$clzh = $clzh[0];
 
- 								}
 
- 								$pm[$typeclass[$v]['classid']] = $clzh;
 
- 							}
 
- 						}
 
- 						if(isset($jm[$typeclass[$v]['classid']]))
 
- 						{
 
- 							if($typeclass[$v]['jm'])
 
- 							{
 
- 								$jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
 
- 							}
 
- 						}
 
- 					}
 
- 				}
 
- 				$jm = array_filter($jm);//去除空值
 
- 				$jm = implode("-",$jm);
 
- 				$pm = array_filter($pm);//去除空值
 
- 				$zh = implode(" ",$pm);
 
- 				$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
 
- 				$trans_list[] = [
 
- 					'jm'=>$jm ,
 
- 					'pm'=>$zh,
 
- 					'ts'=>isset($ts[2])?$ts[2]:json_encode($ts),
 
- 				];
 
- 			}
 
- 			$info_list[$key]['trans_list'] = $trans_list;
 
- 		
 
- 		}
 
- 		return $info_list;
 
- 	}
 
- }
 
 
  |