| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Warehouse extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_warehouse','warehouse');		$this->load->_model('Model_country','country');		$this->load->_model('Model_express','express');		$this->load->_model('Model_whlabel','whlabel');		$this->load->_model('Model_fullorder','fullorder');		$this->load->_model('Model_fullordertt','fullordertt');		$this->load->_model('Model_fullordersmt','fullordersmt');		$this->load->_model('Model_typeclass','typeclass');		$this->load->_model('Model_shop','shop');		$this->load->_model('Model_systemwigsout','systemwigsout');		$this->load->_model('Model_excel','excel');		$this->load->_model('Model_transfer','transfer');		$this->load->_model('Model_systemtransfer','systemtransfer');		$this->load->_model('Model_whlabeltransport', 'whlabeltransport');		$this->load->_model('Model_systemtransfer_cr', 'systemtransfer_cr');		$this->load->_model("Model_logic_order",'logic_order');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'add')//添加        {             $this->_add();        }		else if($arg == 'edit')        {             $this->_edit($arg_array);        }		else if($arg == 'del')        {             $this->_del();        }		else if($arg == 'rows')        {             $this->_rows();        }		else if($arg == 'list')        {             $this->_list();        }		else if($arg == 'kcpd')        {             $this->_kcpd();        }		else if($arg == 'orderlist')        {             $this->_orderlist();        }		else if($arg == 'orderlistck')//华荣厂查看        {             $this->_orderlistck();        }		else if($arg == 'orderlistexcel')        {             $this->_orderlistexcel();        }		else if($arg == 'ordersee')        {             $this->_ordersee($arg_array);        }		else		{			 $this->_index();		}    }	//管理	public function _index()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['page']))  		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$title = $this->input->post('title',true);			$where = "1=1 ";			if($title)            {                $where  .= " and title = '$title'";            }            //数据排序            $order_str = "id asc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->warehouse->find_all($where,'id,title,show,zd,zdms,fpzd,wz,fpsx,express,bdcountry,yybm',$order_str,$start,$perpage);			foreach ($info_list as $key=>$value) 		    {				if($value['show'] == 1)				{					$info_list[$key]['show'] = "是";				}				else				{					$info_list[$key]['show'] = "否";				}				if($value['zd'] == 1)				{					$info_list[$key]['zd'] = "启用";				}				else				{					$info_list[$key]['zd'] = "无";				}				if($value['zdms'] == 1)				{					$info_list[$key]['zdms'] = "单独占单";				}				else if(($value['zdms'] == 2))				{					$info_list[$key]['zdms'] = "全占";				}				else if(($value['zdms'] == 3))				{					$info_list[$key]['zdms'] = "混占";				}				else				{					$info_list[$key]['zdms'] = "无";				}				if($value['express'] == 0)				{					$info_list[$key]['express'] = "无";				}				else				{					$express = $this->express->read($value['express']);					$info_list[$key]['express'] = $express['servicename'];				}				if($value['fpzd'] == 1)				{					$info_list[$key]['fpzd'] = "自动";				}				else				{					$info_list[$key]['fpzd'] = "否";				}				if($value['wz'] == 1)				{					$info_list[$key]['wz'] = "开启";				}				else				{					$info_list[$key]['wz'] = "关闭";				}				if($value['bdcountry'] != 0)				{					$country = $this->country->read($value['bdcountry']);					$info_list[$key]['bdcountry'] = $country['name'];				}				else				{					$info_list[$key]['bdcountry'] = "";				}		    }		    $total = $this->warehouse->find_count($where);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));		    echo json_encode($rows);exit;		}		$this->_Template('warehouse',$this->data);	}	//添加	public function _add()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['title']))		{			$post['title'] = $this->input->post('title',true);			$post['company'] = $this->input->post('company',true);			$post['user'] = $this->input->post('user',true);			$post['show'] = $this->input->post('show',true);			//$post['function'] = $this->input->post('function',true);			//$post['functiontext'] = $this->input->post('functiontext',true);			$post['country'] = $this->input->post('country',true);			$post['name'] = $this->input->post('name',true);			$post['phone'] = $this->input->post('phone',true);			$post['province'] = $this->input->post('province',true);			$post['city'] = $this->input->post('city',true);			$post['zipcode'] = $this->input->post('zipcode',true);			$post['address'] = $this->input->post('address',true);			$post['address2'] = $this->input->post('address2',true);			$post['hz'] = $this->input->post('hz',true);			$post['zd'] = $this->input->post('zd',true);			$post['bdck'] = $this->input->post('bdck',true);			if($post['zd'] == 1 && $post['bdck'] == '')			{			    echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit;			}			if($post['zd'] == 1 && $post['hz'] == '')			{			    echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit;			}			if($post['zd'] == 1 && !ctype_alpha($post['hz']))			{			    echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit;			}			if($this->warehouse->insert($post))        	{				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;       	 	}       		else        	{           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;        	}		}		 $country = $this->country->find_all();		 $this->data['country'] = $country;		$this->_Template('warehouse_add',$this->data);	}	//修改	public function _edit($arg_array)	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['id']))		{			$id = $this->input->post('id',true);			$data = $this->warehouse->read($id);			$post['title'] = $this->input->post('title',true);			$post['company'] = $this->input->post('company',true);			$post['user'] = $this->input->post('user',true);			$post['show'] = $this->input->post('show',true);			/**			$post['out'] = $this->input->post('out',true);			if($post['out'] == 1)			{			    //$post['mode'] = $this->input->post('mode',true);				$post['mode'] = 0;			}			else			{				$post['mode'] = 0;			}			**/			//$post['function'] = $this->input->post('function',true);			//$post['functiontext'] = $this->input->post('functiontext',true);			$post['country'] = $this->input->post('country',true);			$post['name'] = $this->input->post('name',true);			$post['phone'] = $this->input->post('phone',true);			$post['province'] = $this->input->post('province',true);			$post['city'] = $this->input->post('city',true);			$post['zipcode'] = $this->input->post('zipcode',true);			$post['address'] = $this->input->post('address',true);			$post['address2'] = $this->input->post('address2',true);			$post['hz'] = $this->input->post('hz',true);			$post['zd'] = $this->input->post('zd',true);			$post['bdck'] = $this->input->post('bdck',true);			if($post['zd'] == 1 && $post['bdck'] == '' && $data['bdck'] == '')			{			    echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit;			}			if($post['zd'] == 1 && $post['hz'] == '' && $data['hz'] == '')			{			    echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit;			}			if($post['hz'] && !ctype_alpha($post['hz']))			{			    echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit;			}			if($data['bdck'] != '')			{				$post['bdck'] = $data['bdck'];			}			if($data['hz'] != '')			{				$post['hz'] = $data['hz'];			}			if($this->warehouse->save($post,$id))        	{         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;       	 	}       		else        	{           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;        	}		}		$arg_array = $arg_array[0];		$warehouse = $this->warehouse->read($arg_array);		$country = $this->country->find_all();		$this->data['country'] = $country;		$this->data['warehouse'] = $warehouse;		$this->_Template('warehouse_edit',$this->data);	}	//删除	public function _del()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['s']))		{            $id_arr = $this->input->post('s');            $id_arr =  explode(',',$id_arr);            if(!$id_arr)            {                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;            }            //循环删除记录            foreach ($id_arr as $v)		    {                $this->warehouse->remove($v);            }            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));		}    }	//获取数据	public function _rows()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['rows']))  		{			$rows = $this->input->post('rows',true);			$bn = array('0'=>array('id'=>'3','title'=>'销售出库'),'1'=>array('id'=>'4','title'=>'非更换SKU方式调拨出库'));			$cn = array('0'=>array('id'=>'5','title'=>'采购入库'),'1'=>array('id'=>'6','title'=>'单产品入库'),'2'=>array('id'=>'7','title'=>'非更换SKU方式调拨入库'));			$an = array('0'=>array('id'=>'1','title'=>'出库','bn'=>$bn),'1'=>array('id'=>'2','title'=>'入库','bn'=>$cn));			$warehouse = array();			if($rows != "null")			{			    $warehouse = $this->warehouse->read($rows);//找出次ID的权限内容				if($warehouse['function'])				{			        $warehouse = explode('|',trim($warehouse['function'],'|'));//数组化权限内容				}			}			echo json_encode(array('msg'=>($an),'power'=>($warehouse),'success'=>true));		}    }		public function _list()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['id']))  		{			$id = $this->input->post('id',true);			$warehouse = $this->warehouse->read($id);			if(isset($warehouse['zd']))			{				if(($warehouse['zd'] == '1' && $warehouse['ys'] == '1') || $warehouse['zd'] == '0')				{					$zd = '0';				}				else				{					$zd = '1';				}							     echo json_encode(array('msg'=>$zd,'success'=>true));exit;			}			else			{				echo json_encode(array('msg'=>'错误,请重试','success'=>false));			}		}	}			public function _kcpd()	{		header("Access-Control-Allow-Origin: *");		//echo json_encode(array('msg'=>'','success'=>true));exit;		//暂时不用		$post = $this->input->post(NULL, TRUE);		if(isset($post['warehouse']))  		{			$warehouse = $this->input->post('warehouse',true);			$warehouse = $this->warehouse->read($warehouse);			$whlabel = $this->input->post('whlabel',true);			$shop = $this->input->post('shop',true);			$data = $this->input->post('data',true);			$data = str_replace('--','-',$data);			$number = $this->input->post('number',true);			// 替换下面代码 换成logic_order的方法			// $y = $this->fullordersmt->get_number($number);			// if(!$y)			// {			// 	$y = $this->fullorder->get_number($number);			// }			// if(!$y)			// {			// 	$y = $this->fullordertt->get_number($number);			// }			$y = $this->logic_order->getInfo("number = '".$number.'"');						if(!preg_match('/[0-9]/',$whlabel))			{				echo json_encode(array('msg'=>"无",'success'=>true));exit;			}			$typeclass = array();			$tdata = $this->typeclass->find_all();			foreach ($tdata as $v) 			{				$typeclass[$v['id']] = $v['classid'];			}			$kxw = '';			if(1==1)//($warehouse['zd'] == '0' || ($warehouse['zd'] == '1' && stripos($whlabel,$warehouse['hz'].'|') === false))			{				$kxw = '可用现货仓:';$tdfh = '';$cs = array();				$warehousedata = $this->warehouse->find_all("zd = '1' and id != '8'");				$pp = explode('|',trim($whlabel,'|'));				$ccpp = explode('|',trim($data,'|'));				$mgc = 0;//美国仓计数				foreach ($warehousedata as $v) 		        {					if($y['country'] != '192' && $v['id'] == 5)					{						continue;					}			        $x = 0;$j = 0;$save = array();$tdxh = 0;$thqd = 0;$thqdzh = '';$tdwh = 0;$tdshopwh = 0;$htpd = 0;$wearToGo = 0;$hdtx = '';			        foreach ($pp as $va)			        {				        $num = explode('-',$va);						if($num[1] < 1)						{							continue;						}				        $wh = $this->whlabel->find_count("state = '0' and number = '$num[0]' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");				        $x++;				        if($wh < $num[1])				        {							$cp = $ccpp[$x-1];							$cp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$cp);				        	$save[] = $x-1;//提前先加X不然出错,所以要减1							$cc = explode(',',$cp);							if($v['id'] == '5')//美国仓提档检测是否有货							{							    $xcc = $this->typeclass->read($cc[0]+1);							    if($xcc['classid'] == '14')							    {								    $tdnum = $this->str_replace_limit($cc[0],$xcc['id'],$num[0]);								    $tdwh = $this->whlabel->find_count("state = '0' and number = '$tdnum' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");							    }							    if($tdwh < $num[1])				                {				        	        $tdxh += 1;//提前先加X不然出错,所以要减1							    }							}							//美国仓提档检测是否有货结束							//103 Body Wave     1647 LooseBody							if(stripos($cp,'-103-') !== false || stripos($cp,'-1647-') !== false)							{								$htpd += 1;								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									//曲度后边加了长度									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}									if(stripos($newcp,'-103-') !== false)									{										$gpp = str_replace('-103-','-1647-',$newcp);										$thqdzh = 'Loose Body';									}									else									{										$gpp = str_replace('-1647-','-103-',$newcp);										$thqdzh = 'Body';									}									$qdth_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($qdth_wh < $num[1])				                	{				        	        	$thqd += 1;//提前先加X不然出错,所以要减1							    	}															}							/**							if(stripos($cp,'-1181-') !== false)							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}									$gpp = str_replace('-1181-','-2071-',$newcp);									$wtgo_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($wtgo_wh >= $num[1])				                	{				        	        	$wearToGo += 1;							    	}															}							*/							/** /HKK							if(stripos($cp,'-2028-') !== false)							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}									$gpp = str_replace('-2028-','-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 非HKK有货;';							    	}															}							else if(stripos($cp,'-128-') !== false)							{								$cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套								$cc1 = explode('-',trim($cc[1],'-'));								$cptt[$typeclass[$cc[0]]] = $cc[0];								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									$cptt[$typeclass[$vv]] = $vv;            					}								if($cptt[44] != '')								{									continue;								}								else								{									$cptt[44] = '2028';									$cptt = array_filter($cptt);								}									$gpp =  '-'.implode("-",$cptt).'-';									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HKK有货;';							    	}							}							**/							//RTGWL   注释掉了							// if(stripos($cp,'-2076-') !== false)							// {							// 		$cc1 = explode('-',trim($cc[1],'-'));							// 		$newcp = '-';							// 		foreach ($cc1 as $kk=>$vv)							// 		{							// 			if($kk == 1)							// 			{							// 				$newcp .= $vv.'-'.$cc[0].'-';							// 			}							// 			else							// 			{							// 				$newcp .= $vv.'-';							// 			}							// 		}							// 		$gpp = str_replace('-2076-','-',$newcp);							// 		$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用							// 		if($ccxh >= $num[1])				            //     	{				        	//         	$hdtx .= $v['title'].' - 非RTGWL有货;';							//     	}															// }							// else if(stripos($cp,'-128-') !== false)							// {							// 		$cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套							// 		$cc1 = explode('-',trim($cc[1],'-'));							// 		$cptt[$typeclass[$cc[0]]] = $cc[0];							// 		$newcp = '-';							// 		foreach ($cc1 as $kk=>$vv)							// 		{							// 			$cptt[$typeclass[$vv]] = $vv;							// 		}							// 		if($cptt[44] != '')							// 		{							// 			continue;							// 		}							// 		else							// 		{							// 			$cptt[44] = '2076';							// 			$cptt = array_filter($cptt);							// 		}							// 		$gpp =  '-'.implode("-",$cptt).'-';							// 		$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用							// 		if($ccxh >= $num[1])				            //     	{				        	//         	$hdtx .= $v['title'].' - RTGWL有货;';							//     	}							// }														// 4*7没货的,5*7如果有货,给提醒							if(stripos($cp,'-1253-') !== false)							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								$gpp = str_replace('-1253-','-2062-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 5*7有货;';							    	}															}							// 5*5没货的,5*7、5*9如果有货,给提醒							if(stripos($cp,'-297-') !== false) //13*4  HD13*4							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								$gpp = str_replace('-297-','-2062-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 5*7有货;';							    	}																								$gpp2 = str_replace('-297-','-1254-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 5*9有货;';							    	}																							}														// 180%货的,200、250如果有货,给提醒							if(stripos($cp,'-72-') !== false) //13*4  HD13*4							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								$gpp = str_replace('-72-','-73-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 200%密度有货;';							    	}																								$gpp2 = str_replace('-72-','-74-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 250%密度有货;';							    	}																							}							if(stripos($cp,'-73-') !== false) //200%   250%							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}																								$gpp2 = str_replace('-73-','-74-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 250%密度有货;';							    	}																							}							//HD相互提醒							if(stripos($cp,'-146-') !== false || stripos($cp,'-331-') !== false) //13*4  HD13*4							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-146-') !== false)								{									$gpp = str_replace('-146-','-331-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HD13*4有货;';							    	}								}								else if(stripos($cp,'-331-') !== false)								{									$gpp = str_replace('-331-','-146-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 13*4有货;';							    	}								}															}														if(stripos($cp,'-322-') !== false || stripos($cp,'-341-') !== false)//13*6  HD13*6							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-322-') !== false)								{									$gpp = str_replace('-322-','-341-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HD13*6有货;';							    	}								}								else if(stripos($cp,'-341-') !== false)								{									$gpp = str_replace('-341-','-322-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 13*6有货;';							    	}								}															}																					if(stripos($cp,'-147-') !== false || stripos($cp,'-781-') !== false)//4*4  HD4*4							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-147-') !== false)								{									$gpp = str_replace('-147-','-781-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HD4*4有货;';							    	}								}								else if(stripos($cp,'-781-') !== false)								{									$gpp = str_replace('-781-','-147-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 4*4有货;';							    	}								}															}																					if(stripos($cp,'-297-') !== false || stripos($cp,'-540-') !== false)//5*5  HD5*5							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-297-') !== false)								{									$gpp = str_replace('-297-','-540-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HD5*5有货;';							    	}								}								else if(stripos($cp,'-540-') !== false)								{									$gpp = str_replace('-540-','-297-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 5*5有货;';							    	}								}															}																												if(stripos($cp,'-298-') !== false || stripos($cp,'-370-') !== false)//6*6  HD6*6							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-298-') !== false)								{									$gpp = str_replace('-298-','-370-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - HD6*6有货;';							    	}								}								else if(stripos($cp,'-370-') !== false)								{									$gpp = str_replace('-370-','-298-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - 6*6有货;';							    	}								}															}																					if(stripos($cp,'-935-') !== false || stripos($cp,'-854-') !== false)//#P4/27/613  #P4/613							{								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}								if(stripos($cp,'-935-') !== false)								{									$gpp = str_replace('-935-','-854-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - #P4/613;';							    	}								}								else if(stripos($cp,'-854-') !== false)								{									$gpp = str_replace('-854-','-935-',$newcp);									$ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用									if($ccxh >= $num[1])				                	{				        	        	$hdtx .= $v['title'].' - #P4/27/613;';							    	}								}															}							//HD相互提醒结束							$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}							//在途库存    							$transportlist = $this->whlabeltransport->find_all("features = '".$newcp."' and cz = 0 and warehouse = '".$v['id']."'");								$transportMsg = "";                                if(count($transportlist) > 0)								{									                                    $transportItem = $transportlist[0];                                    $transportMsg = "<br/>". $transportItem['sku'] . " 在途库存:  <b>" . $transportItem['num'] . "   </b>  预达时间: ".date("Y-m-d",$transportItem['stime']). "  <br/>  备注 :  " . $transportItem['text'];                                }				        }						else						{							if($v['id'] == '5')							{								$mgc++;							}							else							{							    $kxw .= $v['title'].';';							}						}			       }			       if(!isset($save[0]))//非预设仓库提醒                   {				       //$kxw .= $v['title'].';';                   }				   else				   {					   if($v['id'] == '5' && $tdxh == '0')					   {						   $kxw .= $v['title'].'(当前尺寸无货,提一档有货) ;';					   }					   if($thqd == 0 && $htpd > 0)					   {						   $kxw .= $v['title'].'(当前曲度无货,'.$thqdzh.'有货) ;';					   }					   if($wearToGo > 0)					   {						   $kxw .= $v['title'].'(ReadytoGo有货) ;';					   }					   if($hdtx != '')					   {						   $kxw .= $hdtx;					   }					   if (!empty($transportMsg)) {							$kxw .= $transportMsg;						}				   }				}			}			if(isset($pp) && $mgc ==  count($pp))			{				$kxw .= '美国店;';			}			if($kxw == '可用现货仓:')			{				echo json_encode(array('msg'=>$kxw.'无','cs'=>$cs,'success'=>true));exit;			}			else			{				echo json_encode(array('msg'=>rtrim($kxw,';'),'success'=>true));exit;			}		}	}		public function str_replace_limit($search, $replace, $subject) 	{        $pos = strpos($subject, $search);        if ($pos !== false) 		{            return substr_replace($subject, $replace, $pos, strlen($search));        }        return $subject;    }			public function _orderlist()	{		$post = $this->input->post(NULL, TRUE);		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(isset($post['page']))  		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$orderinfo = $this->input->post('orderinfo',true);			$number = $this->input->post('number',true);			$print = $this->input->post('print',true);			$shop = $this->input->post('shop',true);            $type = $this->input->post('type',true);			$ckfl = $this->input->post('ckfl',true);			$so = $this->input->post('so',true);			$sfxh = $this->input->post('sfxh',true);			$library = $this->input->post('library',true);			$libraryconfirm = $this->input->post('libraryconfirm',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($number)            {                $where  .= " and number = '$number'";            }			if($print)            {                $where  .= " and print = '$print'";				if($print == 3)				{					 $where  .= " and printtime > '$timetk' and printtime < '$timetj'";				}            }			if($shop)            {                $where  .= " and shop = '$shop'";            }			if($type)            {				$where  .= " and type = '$type'";			}			if($so)            {                $where  .= " and shipremarks like '%$so%'";            }			if($ckfl)            {                $where  .= " and ckfl = '$ckfl'";            }			if($library)            {                $where  .= " and library = '$library'";            }			if($type)            {                $where  .= " and type = '$type'";            }			if($libraryconfirm)            {                $where .= " and libraryconfirm = '$libraryconfirm'";            }            //数据排序            $order_str = ($print != 3)?"id desc":"printtime desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }			$t = array();			$transfer = $this->transfer->find_all();			foreach ($transfer as $v)		    {				$t[$v['id']] = $v['title'];				$ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;			}            //取得信息列表            $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);			$info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);			$info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);			$rows = array_merge($info_list,$info_listsmt,$info_listtt);			 //格式化数据            foreach ($rows as $key=>$value) 		    {				$rows[$key]['id'] = $value['id'].'-fullorder';				$shop = $this->shop->read($value['shop']);				$rows[$key]['shop'] = $shop['shopname'];				if($value['printtime'] > 0)				{					$rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);				}				else				{					$rows[$key]['printtime'] = '未打印';				}				if(isset($value['librarytime']) && $value['librarytime'] > 0)				{					$rows[$key]['librarytime'] = date('Y-m-d H:s',$value['librarytime']);				}				else				{					$rows[$key]['librarytime'] = '未出库';				}				$rows[$key]['orderinfo'] = "<h9 class='window' data-h='/warehouse/ordersee/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>";				$rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);				$out = '';				$tf = $this->systemtransfer->find_all("number = '".$value['number']."'");				if(!empty($tf)){					if($tf[0]['is_jiaji']){						$rows[$key]['number'] = "<a href='javascript:void(0)' style='color:red'>".$rows[$key]['number']."加急!!!</a>";					}				}				foreach ($tf as $k=>$v) 		        {					if(count($tf) > 1)					{						$out .= $k.'<br>';					}					$data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");				    $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';				    foreach ($data as $k=>$v)		            {					    $type = ($v['type']==1)?'入库':'出库';					    $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';				    }				}				$rows[$key]['outread'] = trim($out,'<br>');            }			$dlz = $this->fullorder->find_count($where);		    $smt = $this->fullordersmt->find_count($where);			$tt = $this->fullordertt->find_count($where);						//$total += $this->fullorder_smt->find_count($where);			$total = $dlz+$smt+$tt;						//$rows = array_slice($rows,$start,$perpage);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);			$tmp = array();			if($print == 3)			{			foreach ($rows as $key => $val)			{                $tmp[$key] = $val['printtime'];            }            array_multisort($tmp,SORT_DESC,$rows);			}		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)		    echo json_encode($rows);exit;		}		if(isset($_SESSION['api']))		{			$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));			$warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");		    $this->data['wlshop'] = $wlshop;		    $this->data['warehouse'] = $warehouse;		}		$this->_Template('warehouse_orderlist',$this->data);	}			public function _orderlistck()//华荣厂查看	{		$post = $this->input->post(NULL, TRUE);		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(isset($post['page']))  		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$number = $this->input->post('number',true);			$so = $this->input->post('so',true);			$where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";			if($number)            {                $where  .= " and number = '$number'";            }			if($so)            {                $where  .= " and shipremarks like '%$so%'";            }			if(!$so && !$number)			{				$where = "id < 0";			}            //数据排序            $order_str = "id desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }			$info_list = array();			$info_listsmt = array();			$dlz = 0; $smt = 0;            //取得信息列表            $info_list = $this->fullorder->find_all($where,'id,number,shipremarks',$order_str,$start,$perpage);			$info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);			$info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);			$rows = array_merge($info_list,$info_listsmt,$info_listtt);			 //格式化数据            foreach ($rows as $key=>$value) 		    {				$rows[$key]['id'] = $value['id'].'-fullorder';				$rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);				$systemwigsout = $this->systemwigsout->get_number($value['number']);		$wigsout = '';		if($systemwigsout)		{			$cz = explode('|',trim($systemwigsout['cz'],'|'));			$cztime = explode('|',trim($systemwigsout['cztime'],'|'));			$zw = array();			$t = $this->transfer->find_all("1=1");			foreach ($t as $v)		    {				$zw[$v['id']] = $v['title'];			}			if($systemwigsout['cz'] != '' && count($cz) > 0)			{				for($i=0;$i<count($cz);$i++)		        {					if(!isset($cztime[$i]))					{						$wigsout .= $zw[$cz[$i]];					}					else					{					    $wigsout .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).',';					}				}			}		}		$rows[$key]['systemwigsout'] = rtrim($wigsout,',');            }			    $dlz = $this->fullorder->find_count($where);			    $smt = $this->fullordersmt->find_count($where);				$tt = $this->fullordersmt->find_count($where);						//$total += $this->fullorder_smt->find_count($where);			$total = $dlz+$smt+$tt;						//$rows = array_slice($rows,$start,$perpage);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);			$tmp = array();		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)		    echo json_encode($rows);exit;		}		if(isset($_SESSION['api']))		{			$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));			$warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");		    $this->data['wlshop'] = $wlshop;		    $this->data['warehouse'] = $warehouse;		}		$this->_Template('warehouse_orderlistck',$this->data);	}		public function _ordersee($arg_array)	{		$arg_array = $arg_array[0];		$fullorder = 'fullorder';		$data = $this->fullorder->read($arg_array);		if(!$data)		{			$fullorder = 'fullordersmt';			$data = $this->fullordersmt->read($arg_array);		}		if(!$data)		{			$fullorder = 'fullordertt';			$data = $this->fullordertt->read($arg_array);		}		$fpdata = array();		$fullorder = $this->$fullorder->read($arg_array);		if(stripos($fullorder['fpdata'],';') !== false)		{		    $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));		    foreach ($fpdata as $k=>$v) 		    {			    $fpdata[$k] = explode('|',$v);            }		}		$systemwigsout = $this->systemwigsout->get_number($fullorder['number']);		$wigsout = array();		if($systemwigsout)		{			$cz = explode('|',trim($systemwigsout['cz'],'|'));			$cztime = explode('|',trim($systemwigsout['cztime'],'|'));			$zw = array();			$t = $this->transfer->find_all("1=1");			foreach ($t as $v)		    {				$zw[$v['id']] = $v['title'];			}			if($systemwigsout['cz'] != '' && count($cz) > 0)			{				for($i=0;$i<count($cz);$i++)		        {					if(!isset($cztime[$i]))					{						$wigsout[] = $zw[$cz[$i]];					}					else					{					    $wigsout[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]);					}				}			}		}		$this->data['systemwigsout'] = $wigsout;		$this->data['fpdata'] = $fpdata;		$this->data['data'] = $data;		$this->_Template('warehouse_ordersee',$this->data);	}			public function _orderlistexcel()	{		$post = $this->input->post(NULL, TRUE);		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(isset($_GET['excel']))  		{			$a = $this->input->get('a',true);			$id_is = '';$id_smt = '';			if($a)			{                $a =  explode(',',rtrim($a,','));			    foreach ($a as $value) 		        {				    $v = explode('-',$value);				    if($v[1] == 'fullorder')				    {				        $id_is .= "id = ".$v[0]." or ";				    }				    else				    {				    	$id_smt .= "id = ".$v[0]." or ";				    }			    }				if($id_is)				{				    $id_is = " and (".rtrim($id_is,'or ').")";				}				if($id_smt)				{				    $id_smt = " and (".rtrim($id_smt,'or ').")";				}			}			$timetk = $this->input->get('timetk',true);			$timetj = $this->input->get('timetj',true);			$orderinfo = $this->input->get('orderinfo',true);			$number = $this->input->get('number',true);			$print = $this->input->get('print',true);			$shop = $this->input->get('shop',true);            $type = $this->input->get('type',true);			$ckfl = $this->input->get('ckfl',true);			$so = $this->input->get('so',true);			$sfxh = $this->input->get('sfxh',true);			$library = $this->input->get('library',true);			$libraryconfirm = $this->input->get('libraryconfirm',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($number)            {                $where  .= " and number = '$number'";            }			if($print)            {                $where  .= " and print = '$print'";				if($print == 3)				{					 $where  .= " and printtime > '$timetk' and printtime < '$timetj'";				}            }			if($shop)            {                $where  .= " and shop = '$shop'";            }			if($type)            {				$where  .= " and type = '$type'";			}			if($so)            {                $where  .= " and shipremarks like '%$so%'";            }			if($ckfl)            {                $where  .= " and ckfl = '$ckfl'";            }			if($library)            {                $where  .= " and library = '$library'";            }			if($libraryconfirm)            {                $where .= " and libraryconfirm = '$libraryconfirm'";            }			$t = array();			$transfer = $this->transfer->find_all();			foreach ($transfer as $v)		    {				$t[$v['id']] = $v['title'];				$ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;			}            $order_str = ($print != 3)?"id desc":"printtime desc";			$info_list = $this->fullorder->find_all($where.$id_is,'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);			$info_listsmt = $this->fullordersmt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);			$info_listtt = $this->fullordertt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);			$rows = array_merge($info_list,$info_listsmt,$info_listtt);            foreach ($rows as $key=>$value) 		    {				if($value['printtime'] > 0)				{					$rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);				}				else				{					$rows[$key]['printtime'] = '未打印';				}				if($value['library'] == 1)				{					$rows[$key]['library'] = "未出库";				}				else if($value['library'] == 2)				{					$rows[$key]['library'] = "已出库";				}				else if($value['library'] == 3)				{					$rows[$key]['printtime'] = '已退库';				}				if($value['libraryconfirm'] == 1)				{					$rows[$key]['libraryconfirm'] = '不允许出库';				}				else				{					$rows[$key]['libraryconfirm'] = '允许出库';				}				$rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);				$out = '';				$tf = $this->systemtransfer->find_all("number = '".$value['number']."'");				foreach ($tf as $k=>$v) 		        {					if(count($tf) > 1)					{						$out .= $k.'<br>';					}					$data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");				    $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';				    foreach ($data as $k=>$v)		            {					    $type = ($v['type']==1)?'入库':'出库';					    $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';				    }				}				$rows[$key]['systemwigsout'] = trim($out,'<br>');            }			            	$title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'进销存详情';             	$titlename = "<table border=1>            	<tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>            	<tr align='center'>				<td>编号</td>				<td>仓库品名</td>			    <td>条数</td>				<td>打印时间</td>            	<td>出库状态</td>				<td>出库确认</td>				<td>禁止出库原因</td>            	<td>追踪</td>            	</tr>            	</table>";             	$filename = $title.".xls";				$tail = "";            	$this->excel->get_fz2($rows,$titlename,$filename,$tail);	    }	}}
 |