| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Systemtransfer extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_systemtransfer','systemtransfer');		$this->load->_model('Model_systemtransfer_del','systemtransfer_del');		$this->load->_model('Model_excel','excel');		$this->load->_model('Model_shop','shop');		$this->load->_model('Model_warehouse','warehouse');		$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_transfer','transfer');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'data')        {             $this->_data();        }		else if($arg == 'out')        {             $this->_out();        }		else if($arg == 'del')        {             $this->_del();        }		else if($arg == 'add')        {             $this->_add();        }		else if($arg == 'excel')        {             $this->_excel();        }		else if($arg == 'barcode')        {             $this->_barcode($arg_array);        }		else if($arg == 'hb')        {             $this->_hb();        }		else if($arg == 'xz')        {             $this->_xz();        }		else		{			 $this->_index();		}    }		public function _index()	{		$power = 0;		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(stripos($user['userid'],'hr') !== false)//老厂小单			    {				    $power = 37;			    }		}		$kx = '';$zjtab = '';		$usertransfer = explode('|',trim($user['transfer'],'|'));		$transfer = $this->transfer->get_list();;		foreach ($usertransfer as $v) 		{			if(isset($transfer[$v]))			{				$kx .= '<option value="'.$v.'">'.$transfer[$v].'</option>';			}		}		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->data['vip'] = $user['vip'];			$this->data['kx'] = $kx;			$this->data['zjtab'] = $zjtab;		}		if(stripos($user['userid'],'baozhuang') !== false)		{			$this->data['xz'] = 1;		}		else		{			$this->data['xz'] = 0;		}		$this->data['czwarehouse'] = $power;		$this->_Template('systemtransfer',$this->data);	}		public function _data()	{		$post = $this->input->post(NULL, TRUE);	    if(isset($post['page']))  		{			$api = $this->input->post('api',true);		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$number = $this->input->post('number',true);			$type = $this->input->post('type',true);			$color = $this->input->post('color',true);			$cz = $this->input->post('cz',true);			$zjtab = $this->input->post('zjtab',true);			$czwarehouse = $this->input->post('czwarehouse',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = "type != 0";			if(isset($_SESSION['api']))			{				if($type)            	{                	$where  .= " and type = '$type'";           		}				else				{					$uw = '';				    $u = $this->user->get_api($_SESSION['api']);				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));				    foreach ($u['warehouse'] as $v) 		            {					    $uw  .= " type = '$v' or";                    }				    $uw = rtrim($uw,'or');					$uw = " and (".ltrim($uw,' ').")";					$where  .= $uw;				}			}			if(!$cz)			{				$cxctime = "time";			}			else			{			    $cxctime = "ctime".$cz;			}			if($timetk)            {                $where  .= " and $cxctime > '$timetk' and $cxctime < '$timetj'";            }			if($number)            {                $where  .= " and number = '$number'";            }			if($cz)            {                $where  .= " and cz like '%|".$cz."|%'";            }			if($zjtab)            {                $where  .= " and cz like '%~".$zjtab."-%'";            }			if($color)            {                $where  .= " and fpdata like '%-".$color."-%'";            }			if($czwarehouse != '')            {				$where  .= " and czwarehouse = '$czwarehouse'";            }            //数据排序            $order_str = "id desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->systemtransfer->find_all($where,'id,number,shipremarks,printtime,time,quantity',$order_str,$start,$perpage);			$transfer = $this->transfer->find_all();			$t = array();			foreach ($transfer as $v)		    {				$t[$v['id']] = $v['title'];			}			 //格式化数据            foreach ($info_list as $key=>$value)		    {				$dd = $this->systemtransfer->read($value['id']);				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);				$cz = explode('|',trim($dd['cz'],'|'));				$cztime = explode('|',trim($dd['cztime'],'|'));				if($dd['cz'] != '' && count($cz) > 0)				{					$info_list[$key]['time'] = '';					for($i=0;$i<count($cz);$i++)		            {						$info_list[$key]['time'] .= $t[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).'<br>';					}				}				$info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');            }		    $total = $this->systemtransfer->find_count($where);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);			$exdata = 0;			$count = $this->systemtransfer->find_all($where);			foreach ($count as $v) 			{				$exdata += $v['quantity']; 			}		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'datacount'=>$exdata,'exdata'=>$exdata);		    echo json_encode($rows);exit;		}	}		public function _out()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['number']))		{			$time = time();			$number = $this->input->post('number',true);			$type = $this->input->post('type',true);			$ps = $this->input->post('ps',true);			$cz = $this->input->post('cz',true);			$lx = $this->input->post('lx',true);			$ly = $this->input->post('ly',true);			$czwarehouse = $this->input->post('czwarehouse',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			if(!$number)			{				echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;			}			if(!$type)			{				echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;			}			if(!$cz)			{				echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;			}			if(!$lx)			{				echo json_encode(array('msg'=>'请选择需要操作的类型!','success'=>false));exit;			}			if(!$ly)			{				$ly = 0;			}			$nu = $this->fullorder->get_number($number);			if(!$nu)			{				$nu = $this->fullordersmt->get_number($number);			}			if(!$nu)			{				echo json_encode(array('msg'=>'错误!未找到此编号的订单','success'=>false));exit;			}			if($nu['state'] == '214' || $nu['state'] == '217')			{				echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;			}			$systemtransfer = $this->systemtransfer->get_czwarehouse($number,$czwarehouse);			//$systemtransfer = $this->systemtransfer->get_number($number);			if(!$systemtransfer)			{				if($this->systemtransfer->insert(array('type'=>$type,'cz'=>'|'.$cz.'|','cztime'=>'|'.$time.'|','number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'gtime'=>date('YmdH',$time),'time'=>$time,'fpdata'=>$nu['fpdata'],'ctime'.$cz=>$time,'czwarehouse'=>$czwarehouse)))				 {				    echo json_encode(array('music'=>'1','success'=>true));exit;				 }				 else				 {				    echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;				 }			}			$czarray = explode('|',trim($systemtransfer['cz'],'|'));			$cztimearray = explode('|',trim($systemtransfer['cztime'],'|'));			$czarray = array_flip($czarray);			if(stripos($systemtransfer['cz'],'|'.$cz.'|') !== false && $cztimearray[$czarray[$cz]] > $time-1200)			{				echo json_encode(array('msg'=>'错误,系统20分钟内已录入过!','success'=>false));exit;			}			if($this->systemtransfer->save(array('cz'=>$systemtransfer['cz'].$cz.'|','cztime'=>$systemtransfer['cztime'].$time.'|','ctime'.$cz=>$time),$systemtransfer['id']))			{				if($nu['state'] == '216')				{				    echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;				}				else				{				    echo json_encode(array('music'=>'1','success'=>true));exit;				}			}			else			{				echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;			}					}	}		public function _barcode($arg_array)	{		$dir = 'data/img/'.date('Ymd',time()).'/';        if(!is_dir('./'.$dir))mkdir('./'.$dir,0777);        $imgUrl = $dir.$arg_array.'.png';		// 引用class文件夹对应的类		require_once('./data/barcodegen/class/BCGFontFile.php');		require_once('./data/barcodegen/class/BCGColor.php');		require_once('./data/barcodegen/class/BCGDrawing.php'); 		// 条形码的编码格式		require_once('./data/barcodegen/class/BCGcode128.barcode.php'); 		// 加载字体大小		$font = new \BCGFontFile('./data/barcodegen/Arial.ttf', 18);		//设置条形码颜色		$color_black = new \BCGColor(0, 0, 0);		$color_white = new \BCGColor(255, 255, 255); 		$drawException = null;		try 		{   		    $code = new \BCGcode128();    		$code->setScale(2);    		$code->setThickness(30); // 条形码的厚度    		$code->setForegroundColor($color_black); // 条形码颜色    		$code->setBackgroundColor($color_white); // 条形码间隙颜色    		$code->setFont($font); //设置引用字体 条形码下方的文字    		$code->parse($arg_array); // 条形码需要的数据内容		} 		catch(\Exception $exception)		{            $drawException = $exception;        }		$drawing = new \BCGDrawing($imgUrl, $color_white);		if($drawException) 		{            $drawing->drawException($drawException);        }		else 		{			$drawing->setBarcode($code);    		$drawing->draw();		}		// Header that says it is an image (remove it if you save the barcode to a file)        //header('Content-Type: image/png');        //header('Content-Disposition: inline; filename="barcode.png"');        // Draw (or save) the image into PNG format.        $drawing->finish(\BCGDrawing::IMG_FORMAT_PNG);				return 'http://'.$_SERVER['HTTP_HOST'].'/data/img/'.date('Ymd',time()).'/'.$arg_array.'.png';        //return "<img src='".$data."' />";	}	public function _excel()	{		if(isset($_GET['fexcel']))  		{			$timetk = $this->input->get('timetk',true);			$timetj = $this->input->get('timetj',true);			$type = $this->input->get('type',true);			$cz = $this->input->get('cz',true);			$number = $this->input->get('number',true);			$timetk = strtotime($timetk.':0:0');			$timetj = strtotime($timetj);			$gctime = "gctime".$cz;			$where = "type != 0 and $gctime like '%-".date('YmdH',$timetk)."'";			if(isset($_SESSION['api']))            {				if($type)            	{                	$where  .= " and type = '$type'";					$warehouse = $this->warehouse->read($type);					$titletype = "---".$warehouse['title'];           		}				else				{					$uw = '';				    $u = $this->user->get_api($_SESSION['api']);				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));				    foreach ($u['warehouse'] as $v) 		            {					    $uw  .= " type = '$v' or";                    }				    $uw = rtrim($uw,'or');					$uw = " and (".ltrim($uw,' ').")";					$where  .= $uw;					$titletype = "";				}            }			else			{				echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;			}			if($number)            {                $where  .= " and number = '$number'";            }			if($cz)            {                $where  .= " and cz like '%~".$cz."-%'";            }			$data = array();			$datafy = array();			$j = 0;			$info_list = $this->systemtransfer->find_all($where,'number,shipremarks,printtime,quantity');			foreach ($info_list as $key=>$value)		    {				$img = $this->_barcode($value['number']);				$info_list[$key]['number'] = ".<img width='260' src='".$img."' />";				$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);            }            $title = date('Y-m-d H-i',time()).'扫码统计表'.$titletype;            $titlename = "<table border=1 >            <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>            <tr>            <td>编号</td>            <td>仓库品名</td>            <td>打印时间</td>            <td>数量</td>            </tr></table><table><tr></tr>";             $filename = $title.".xls"; 			$tail = "\n"; 						$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">        	<head>        	</head><body>";			$str .= $titlename; 			foreach ($info_list as $key=>$value) 			{ 		    	$str .= "<tr style=' border-bottom:1 double #000;'>";		    	foreach ($value as $ke=>$va) 				{					$tj = '';					if($ke == 'number')				    {					    $str .= "<td style='padding-left:400px;'>".$va."</td>";//使用文本格式				    }					else					{				        $str .= "<td>".$va."</td>";//使用文本格式					}		        }			    $str .= "</tr><tr></tr><tr></tr>\n";		    }		    $str .= $tail;		    $str .= "</table></body></html>"; 			header( "Content-Type: application/vnd.ms-excel; name='excel'" ); 		    header( "Content-type: application/octet-stream" ); 		    header( "Content-Disposition: attachment; filename=".$filename ); 		    header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); 		    header( "Pragma: no-cache" ); 		    header( "Expires: 0" ); 		    exit($str);			//echo "<pre>";			//print_r($info_list);	    }	}			public function _xz()	{		if(isset($_GET['fexcel']))  		{			$tc = array();$zh = array();			$typeclass = $this->typeclass->find_all();			foreach ($typeclass as $v) 			{				$tc[$v['id']] = $v['title'];				$zh[$v['id']] = $v;			}						$timetk = $this->input->get('timetk',true);			$timetj = $this->input->get('timetj',true);			$cz = $this->input->get('cz',true);			if(!$cz)			{				$cz = 1;			}			$type = $this->input->get('type',true);			$czwarehouse = $this->input->get('czwarehouse',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = "type != '0'";			$cxctime = "ctime".$cz;			if($timetk)            {                $where  .= " and $cxctime > '$timetk' and $cxctime < '$timetj'";            }			if($cz)            {                $where  .= " and cz like '%|".$cz."|%'";            }			if($czwarehouse != '')            {				$where  .= " and czwarehouse = '$czwarehouse'";            }			$data = array();			$datafy = array();			$j = 0;			$info_list = $this->systemtransfer->find_all($where,'number,shipremarks,printtime');			foreach ($info_list as $key=>$value)		    {				$dd = $this->fullordersmt->get_number($value['number']);				if(!$dd)				{					$dd = $this->fullorder->get_number($value['number']);				}				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);				$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);				//$this->systemtransfer->save(array('xz'=>1),$value['id']);				$fpdata = array();				if(stripos($dd['fpdata'],';') !== false)				{		   		    $fpdata = explode(';',rtrim($dd['fpdata'],';'));		            foreach ($fpdata as $ke=>$va)		            {						$pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');						$title = '';			            $fg = explode('|',$va);						$fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);						$cp = explode('-',rtrim($fg[0],'-'));						if(isset($cp[2]))						{						    $dj = $tc[$cp[2]];						}						else						{							$dj = '';						}						if(isset($cp[3]))						{						    $ys = isset($tc[$cp[3]])?$tc[$cp[3]]:'0';						}						else						{							$ys = 0;						}						if(isset($cp[7]))						{						     $md = (isset($tc[$cp[7]]))?$tc[$cp[7]]:'';						}						else						{							$md = '';						}						foreach ($cp as $v)		                {							$v = rtrim($v,',');							if(isset($zh[$v]['classid']) && isset($pm[$zh[$v]['classid']]))							{								$pm[$zh[$v]['classid']] = $zh[$v]['zh'];							}						}						unset($cp[0],$cp[1],$cp[2],$cp[3],$cp[7]);						foreach ($cp as $v)		                {							$title .= (isset($tc[$v]))?$tc[$v].' ':' ';						}						$fpdata[$ke] = array(implode(" ",$pm),$fg[5],$dj,$ys,$title,$md,$fg[2]);//内容,尺寸,等级,颜色,数量,密度                    }				}				$info_list[$key]['fpdata'] = $fpdata;            }						$title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 完成仓统计表';             $titlename = "<table border=1>           <tr>            <td>编号</td>            <td>仓库品名</td>            <td>打印时间</td>			<td>			<table border=1>            <tr><td colspan='7' align='center'>订单产品信息</td></tr>            <tr>			<td>产品名称</td>			<td>尺寸</td>			<td>等级</td>			<td>颜色</td>			<td>花型</td>			<td>密度</td>			<td>数量</td>			<td>总数量</td>            </tr>            </table>			</td>            </tr>            </table>";             $filename = $title.".xls"; 			$tail = "\n";            $this->excel->get_fz($info_list,$titlename,$filename,$tail);	    }	}		public function _add()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['number']))		{			$where = "gtime = '".date('Ymd',time())."'";			$number = $this->input->post('number',true);			$id = $this->input->post('id',true);			$type = $this->input->post('type',true);			$time = $this->input->post('time',true);			$time = strtotime($time);			if($id)            {				if($type)            	{                	$where  .= " and type = '$type'";           		}				else				{					$uw = '';				    $u = $this->user->get_api($id);				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));				    foreach ($u['warehouse'] as $v) 		            {					    $uw  .= " type = '$v' or";                    }				    $uw = rtrim($uw,'or');					$uw = " and (".ltrim($uw,' ').")";					$where  .= $uw;				}            }			if(!$number)			{				echo json_encode(array('msg'=>'编号不能为空!','success'=>false));exit;			}			if(!$type)			{				echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;			}			$nu = $this->fullorder->get_number($number);			if(!$nu)			{				$nu = $this->fullordersmt->get_number($number);			}			if(!$nu)			{				echo json_encode(array('msg'=>'错误!未找到此编号的订单','success'=>false));exit;			}			if($nu['printtime'] == '0')			{				echo json_encode(array('msg'=>'错误,此单没有打印时间!请联系店员核实','success'=>false));exit;			}						$data = 0;			$count = $this->systemtransfer->find_all($where);			foreach ($count as $v) 			{				$data += $v['quantity']; 			}			$systemtransfer = $this->systemtransfer->get_number($number);			if($systemtransfer)			{				$this->systemtransfer->save(array('quantity'=>$systemtransfer['quantity']+1),$systemtransfer['id']);				echo json_encode(array('title'=>'添加成功','msg'=>$data+1,'music'=>'1','success'=>true));exit;			}			else			{				if($this->systemtransfer->insert(array('type'=>$type,'number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'gtime'=>date('YmdH',time()),'time'=>time())))				{					echo json_encode(array('title'=>'添加成功','msg'=>$data+1,'music'=>'1','success'=>true));exit;				}				else				{					echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;				}			}					}	}		public function _del()	{		/**		$post = $this->input->post(NULL, TRUE);		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);		}		if(stripos($user['userid'],'peihuo') !== false)		{			$kx = 1;		}		else if(stripos($user['userid'],'gaozhen') !== false)		{			$kx = 2;		}		else if(stripos($user['userid'],'wancheng') !== false)		{			$kx = 3;		}		else if(stripos($user['userid'],'qvfa') !== false)		{			$kx = 4;		}		else if(stripos($user['userid'],'qianchuli') !== false)		{			$kx = 5;		}		else if(stripos($user['userid'],'houchuli') !== false)		{			$kx = 6;		}		else if(stripos($user['userid'],'faxingshi') !== false)		{			$kx = 7;		}		else if(stripos($user['userid'],'baozhuang') !== false)		{			$kx = 8;		}		else if(stripos($user['userid'],'sheji') !== false)		{			$kx = 9;		}		else if(stripos($user['userid'],'piaokou') !== false)		{			$kx = 10;		}		if(isset($post['delarr']))  		{            $id_arr = $this->input->post('delarr');            $id_arr =  explode(',',rtrim($id_arr,','));            if(!$id_arr)            {                echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;            }			if(count($id_arr) > 1)            {                echo json_encode(array('msg'=>'每次只能删除一个!','success'=>false));exit;            }            //循环删除记录			$a=0;            foreach ($id_arr as $v) 		    {				$systemtransfer = $this->systemtransfer->read($v);				$czarray = explode('|',trim($systemtransfer['cz'],'|'));				$cztimearray = explode('|',trim($systemtransfer['cztime'],'|'));				if(count($czarray) == 1)				{					$this->systemtransfer->remove($v);					continue;				}				foreach ($czarray as $ka=>$va) 		        {					if($va == $kx)					{						unset($czarray[$ka]);						unset($cztimearray[$ka]);					}				}				$cz = "|".implode("|",$czarray)."|";				$cztime = "|".implode("|",$cztimearray)."|";				$this->systemtransfer->save(array('cz'=>$cz,'cztime'=>$cztime),$v);            }			echo json_encode(array('success'=>true));exit;		}		**/		$post = $this->input->post(NULL, TRUE);		if(isset($post['s']))  		{            $id_arr = $this->input->post('s');            $id_arr =  explode(',',trim($id_arr,','));            if(!$id_arr)            {                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;            }			if(count($id_arr) > 1)            {                echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;            }            //循环删除记录            foreach ($id_arr as $v) 		    {				$data = $this->systemtransfer->read($v);                $this->systemtransfer->remove($v);				$this->systemtransfer_del->insert($data);            }            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));		}	}		public function _hb()	{		$dataorder = array();		/*  订单加入键值-k  */		$fdata = $this->fullorder->find_all('dtime > "'.(time()-50*24*3600).'" and printtime > 0','number,orderinfo,fpdata,shipremarks');		foreach ($fdata as $v) 		{			$dataorder[$v['number']] = $v;		}		$sdata = $this->fullordersmt->find_all('dtime > "'.(time()-50*24*3600).'" and printtime > 0','number,orderinfo,fpdata,shipremarks');		foreach ($sdata as $v) 		{			$dataorder[$v['number']] = $v;		}		/*  匹配ID加入  */		$tc = array();$ztc = array();$tclass = array();		$typeclass = $this->typeclass->find_all();		foreach ($typeclass as $v) 		{			$ztc[$v['id']] = $v['zh'];			$tc[$v['id']] = $v['title'];			$tclass[$v['id']] = $v['classid'];		}				$dir = '/data/excel/'.date('Ymd',time()).'/';		$config['upload_path'] = '.'.$dir ;		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);        $config['allowed_types'] = 'xls|xlsx|csv';        $config['max_size'] = 10240;		$this->load->library('upload', $config);		$this->upload->initialize($config);        if ($this->upload->do_upload('userfile'))        {			$full_path = $dir.$this->upload->data('file_name');			$fileName = '.' . $full_path;            if (!file_exists($fileName)) 			{				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;            }			else			{				require_once "./data/excel/PHPExcel/IOFactory.php";				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件				$phpExcel->setActiveSheetIndex(0);// 设置为默认表				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数				++$column;//如果列数大于26行				$list = array();				for ($i = 2; $i <= $row; $i++) // 行数循环				{					$data = array();                    for ($c = 'A'; $c != $column; $c++)  // 列数循环	                {						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();                    }					$list[] = $data;                }			}			$ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';			$cmf_arr = array_column($list, '1');            array_multisort($cmf_arr, SORT_ASC, $list);		    foreach ($list as $key=>$value)		    {				$number = $value['1'];				$bbtime = $value['7'];				if(stripos($number,'QM') !== false)				{					continue;				}				if(isset($dataorder[$number])) 				{					$thisnumber = $dataorder[$number];$thisshipremarks = array();					if(stripos($thisnumber['fpdata'],';') !== false)					{		   		    	$fpdata = explode(';',rtrim($thisnumber['fpdata'],';'));		            	foreach ($fpdata as $ke=>$va)		            	{							$title = '';			            	$fg = explode('|',$va);							$fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);							$cp = explode('-',rtrim($fg[0],'-'));							if(isset($cp[5]))							{							   $tt = $ztc[$cp[5]];							}							else							{								$tt = '';							}							$md = '';							foreach ($cp as $v)		                	{								if(!isset($tclass[$v]))								{									continue;								}								if($tclass[$v] == '10')								{									$md = $tc[$v];								}							}							if(isset($cp[4]))							{							    $dchx = $tc[$cp[4]];							}							else							{								 $dchx = ' ';							}							$thisshipremarks[] = array($tt,$tc[$cp[3]],$md,$dchx,$fg[5],$fg[2]);//头套种类,颜色,密度,花型,尺寸,数量                    	}					}					$thisnumber['shipremarks'] = str_replace(array('<','>'),array('<','>'),$thisnumber['shipremarks']);					$dcdata[] = array('number'=>$thisnumber['number'],'time'=>$bbtime,'shipremarks'=>$thisnumber['shipremarks'],'fpdata'=>$thisshipremarks);				}				else				{					$ed[] = array($number.'-系统未找到此订单信息');					$i++;					continue;				}			}			if($i > 0)			{				$yc = $i.'条异常';			}			$title = date('Y-m-d H:i:s',time())." 产品详细信息";             $titlename = "<table border=1>            <tr><th colspan='29' align='left'><h3>".$title."<h3></th></tr>            <tr>            <td>订单编号</td>            <td>配货时间</td>            <td>仓库品名</td>            <td>            <table border=1>            <tr><td colspan='4' align='center'>订单产品信息</td></tr>            <tr>			<td>种类</td>			<td>颜色</td>			<td>密度</td>			<td>花型</td>			<td>尺寸</td>			<td>数量</td>            </tr>            </table>            </td>			<td>总条数</td>            </tr>            </table>";             $filename = $title.".xls"; 			$tail = "\n";             $downexcel = $this->get_fz($dcdata,$titlename,$filename,$tail);			$time = date('Ymd',time());				$dir = '/data/excel/'.$time.'/';				$file_name = $title;				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();				fwrite($myfile,$downexcel);				fclose($myfile);				$goexcel = $dir.$file_name.'.xls';				echo json_encode(array('msg'=>'操作成功 '.$yc,'goexcel'=>$goexcel,'success'=>true));exit;			        }		else		{			echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;		}    }		public function get_fz($info_list,$titlename,$filename,$tail)	{		$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">        <head>        <!--[if gte mso 9]><xml>        <x:ExcelWorkbook>        <x:ExcelWorksheets>        <x:ExcelWorksheet>        <x:Name>EXCEL</x:Name>        <x:WorksheetOptions>        <x:Print>        <x:ValidPrinterInfo />        </x:Print>        </x:WorksheetOptions>        </x:ExcelWorksheet>        </x:ExcelWorksheets>        </x:ExcelWorkbook>        </xml>        <![endif]-->        </head><body>";		$str .= $titlename; 		$str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>"; 		foreach ($info_list as $key=>$value) 		{ 		    if($value['fpdata'] == '')				{					continue;				}		    $str .= "<tr>";		    foreach ($value as $ke=>$va) 			{				if($ke == 'orderinfo' || $ke == 'waybill')				{					$str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$va."</td>";				}				else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle')				{		            $str .= "<td align='left'>".$va."</td>"; 				}		    }			$str .= "<td><table border=1>";			$a = 0;			foreach ($value['fpdata'] as $k=>$v) 		    {				$vd = '';				foreach ($v as $vv) 		        {					$vd .= "<td>".$vv."</td>";				}				$str .= "<tr>".$vd."</tr>";				$endv = is_numeric(end($v))?end($v):0;				$a = $a + $endv;			}			$str .= "</table></td>"; 			$str .= "<td>".$a."</td>";		    $str .= "</tr>\n"; 		}		$str .= $tail;		$str .= "</table></body></html>"; 		return $str; 		//return $str;	}}
 |