| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 | <?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');        $this->load->_model('Model_purchase', 'purchase');		$this->load->_model("Model_shop", "shop");    }    //定义方法的调用规则 获取URI第二段值	public function _remap($arg, $arg_array)	{		if ($arg == 'bqckexcel') //		{            //获取标签出库的按条件导出的excel			$this->_bqck_excel();		}         elseif ($arg == 'bqrkexcel') //		{            //获取标签出库的按条件导出的excel			$this->_bqrk_excel();		} 		elseif ($arg == 'whlabel_cprk_excel') //		{			$this->_whlabel_cprk_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();			$typeclass = array();            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']);            }            $prc = array();            $purchase = $this->purchase->find_all();            foreach ($purchase as $k => $v) {                $prc[$v['id']] = $v['title'];            }			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{        }    }    public function _bqrk_excel(){        if (isset($_GET['excel'])) {			$sku = $this->input->get('sku', true);			$bs = $this->input->get('bs', true);			$number = $this->input->get('number', true);			$warehouse = $this->input->get('warehouse', true);			$purchase = $this->input->get('purchase', true);			$orderinfo = $this->input->get('orderinfo', true);			$waybill = $this->input->get('waybill', true);			$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);			$state = $this->input->get('state', true);			$label = $this->input->get('label', true);			$timetk = $this->input->get('ktime', true);			$timetj = $this->input->get('jtime', true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = "1=1 ";			if ($timetk && $timetj) {				$where .= " and enter > '$timetk' and enter < '$timetj'";			}			if ($sku) {				$where  .= " and sku = '$sku'";			}			if ($bs != '') {				$where  .= " and bs = '$bs'";			}			if ($number) {				$where  .= " and number = '$number'";			}			if ($warehouse) {				$where  .= " and warehouse = '$warehouse'";			}			if ($purchase) {				$where  .= " and purchase = '$purchase'";			}			if ($orderinfo) {				$where  .= " and orderinfo = '$orderinfo'";			}			if ($waybill) {				$where  .= " and waybill = '$waybill'";			}			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 ($label) {				$where  .= " and label = '$label'";			}			if ($state || $state == 0) {				$where  .= " and state = '$state'";			}			$ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';			//数据排序			$order_str = "enter desc";						//取得信息列表			$info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,enter,details', $order_str);            $prc = array();            $purchase = $this->purchase->find_all();            foreach ($purchase as $k => $v) {                $prc[$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 $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]['enter'] = date('Y-m-d H:i:s', $value['enter']);			}			//生成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['enter']. "</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); 					}    }	public function _whlabel_cprk_excel(){		if (empty($_SESSION['api'])) {			exit('No direct script access allowed');		}		// $user = $this->user->get_api($_SESSION['api']);		// $warehouses = $user['warehouse'];		// if(empty($warehouses)){		// 	exit('没有仓库权限!!!');		// }		// $warehouses = explode('|',trim($warehouses,'|'));		// $ware_list = [];		// foreach ($warehouses as $v) {		// 	if(!empty($v)){		// 		$ware_list[] = $v;		// 	}		// }				$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 = " ";		// if ($warehouse) {		// 	if(in_array($warehouse,$ware_list)){		// 		$where  .= "  warehouse = '$warehouse'  ";		// 	}else{		// 		$where  .= "  warehouse = 0 ";		// 	}					// }else{		// 	$where  .= "  warehouse in (".implode(',',$ware_list).")";		// }		if($warehouse){			$where  .= "  warehouse = '$warehouse'  ";		}else{			$where .="  1 = 1  ";		}		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 ($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,shop,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;				if(!empty($v['features'])){					$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); 							}}
 |