| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687 | <?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');		$this->load->_model("Model_logic_ding","logic_ding");	}	//定义方法的调用规则 获取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(empty($y['country'])){						continue;					}					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')//美国仓提档检测是否有货							{								$tmp_cc = (int)$cc[0];								//之所以这样写 是为了避免 没有尺寸的代码 造成的字符串加1 这种不可以  如果没有长度 就不会提档 tdxh如果为0 会提示加一档有现货								if($tmp_cc > 0){									$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有货;';							    	}															}							// 1255  HD 4*7 Closure Wig  HD 5*7 Closure Wig 如果有货,给提醒							if(stripos($cp,'-1255-') !== 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('-1255-','-2147-',$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有货;';							    	}															}							// 1323  4*7 Bob Wig  5*7 Bob Wig 如果有货,给提醒							if(stripos($cp,'-1323-') !== 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('-1323-','-2167-',$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有货;';							    	}															}							// 1257  HD 4*7 Bob Wig  HD 5*7 Bob Wig 如果有货,给提醒							if(stripos($cp,'-1257-') !== 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('-1257-','-2434-',$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							{								if(isset($cc[1])){									$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相互提醒结束							if(isset($cc[1])){								$cc1 = explode('-',trim($cc[1],'-'));								$newcp = '-';								foreach ($cc1 as $kk=>$vv)		   					    {									if($kk == 1)									{                					    $newcp .= $vv.'-'.$cc[0].'-';									}									else									{										$newcp .= $vv.'-';									}            					}							}else{								//$this->logic_ding->sendToDing("仓库kcpd提醒cc".json_encode($cc).'cp'.json_encode($cp)."ccpp".json_encode($ccpp)."number:".$number);								$newcp = $cc[0]; 															}														//在途库存    							$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);	    }	}}
 |