| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Systemwigsout extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_systemwigsout','systemwigsout');
 
- 		$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');
 
- 	}
 
- 	//定义方法的调用规则 获取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
 
- 		{
 
- 			 $this->_index();
 
- 		}
 
-     }
 
- 	
 
- 	public function _index()
 
- 	{
 
- 		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";
 
- 			}
 
- 		}
 
- 		$kx = '';$zjtab = '';
 
- 		if($user['userid'] == 'toutao')
 
- 		{
 
- 			$kx = '<option value="1">头套</option>';
 
- 		}
 
- 		else if($user['userid'] == 'ranse')
 
- 		{
 
- 			$kx = '<option value="2">染色</option>';
 
- 		}
 
- 		else if($user['userid'] == 'qvfa')
 
- 		{
 
- 			$kx = '<option value="3">曲发</option>';
 
- 			$zjtab = 'qf';
 
- 		}
 
- 		else if($user['userid'] == 'body')
 
- 		{
 
- 			$kx = '<option value="4">BODY</option>';
 
- 		}
 
- 		else if($user['userid'] == 'faxingshi')
 
- 		{
 
- 			$kx = '<option value="5">发型师染色</option>';
 
- 		}
 
- 		else if($user['userid'] == 'houchuli')
 
- 		{
 
- 			$kx = '<option value="6">后处理</option>';
 
- 			$zjtab = 'hcl';
 
- 		}
 
- 		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['warehouse'] = $warehouse;
 
- 			$this->data['vip'] = $user['vip'];
 
- 			$this->data['kx'] = $kx;
 
- 			$this->data['zjtab'] = $zjtab;
 
- 		}
 
- 		$this->_Template('systemwigsout',$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);
 
- 			$cz = $this->input->post('cz',true);
 
- 			$zjtab = $this->input->post('zjtab',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;
 
- 				}
 
- 			}
 
- 			$gctime = "gctime".$cz;
 
- 			if($timetk)
 
-             {
 
-                 $where  .= " and $gctime like '%".date('Ymd',$timetk)."%'";
 
-             }
 
- 			if($number)
 
-             {
 
-                 $where  .= " and number = '$number'";
 
-             }
 
- 			if($cz)
 
-             {
 
-                 $where  .= " and cz like '%~".$cz."-%'";
 
-             }
 
- 			if($zjtab)
 
-             {
 
-                 $where  .= " and cz like '%~".$zjtab."-%'";
 
-             }
 
-             //数据排序
 
-             $order_str = "id desc";
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
-             //取得信息列表
 
-             $info_list = $this->systemwigsout->find_all($where,'id,number,shipremarks,printtime,time,quantity',$order_str,$start,$perpage);
 
- 			 //格式化数据
 
-             foreach ($info_list as $key=>$value)
 
- 		    {
 
- 				$dd = $this->systemwigsout->read($value['id']);
 
- 				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
 
- 				if($dd['ly'] == '1')
 
- 				{
 
- 					 $info_list[$key]['time'] = '小单<br>';
 
- 				}
 
- 				else
 
- 				{
 
- 				    $info_list[$key]['time'] = '';
 
- 				}
 
- 				$cz = explode('|',trim($dd['cz'],'|'));
 
- 				$zw = array(1=>'头套',2=>'染色',3=>'曲发',4=>'body',5=>'发型师染色',6=>'后处理');
 
- 				$lxzw = array(1=>'入库',2=>'出库');
 
- 				if($dd['cz'] != '' && count($cz) > 0)
 
- 				{
 
- 					for($i=0;$i<count($cz);$i++)
 
- 		            {
 
- 						$czfl = explode('-',trim($cz[$i],'~'));
 
- 						$ctime = 'ctime'.$czfl[0];
 
- 						$ct = explode('-',trim($dd[$ctime],'-'));
 
- 						$info_list[$key]['time'] .= $zw[$czfl[0]].'-'.$lxzw[$czfl[1]].':'.date('Y-m-d H:i:s',trim($ct[$czfl[1]-1],'-')).'<br>';
 
- 					}
 
- 				}
 
- 				$info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
 
-             }
 
- 		    $total = $this->systemwigsout->find_count($where);
 
- 		    $pagenum = ceil($total/$perpage);
 
- 		    $over = $total-($start+$perpage);
 
- 			$exdata = 0;
 
- 			$count = $this->systemwigsout->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);
 
- 			$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['printtime'] == '0')
 
- 			{
 
- 				echo json_encode(array('msg'=>'错误,此单没有打印时间!请联系店员核实','success'=>false));exit;
 
- 			}
 
- 			$systemwigsout = $this->systemwigsout->get_num($number);
 
- 			if($cz == '1')
 
- 			{
 
- 			    if($systemwigsout)
 
- 			    {
 
- 					if($systemwigsout['ly'] != '0')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,此订单已于小单方式录入系统!','success'=>false));exit;
 
- 					}
 
- 					if(stripos($systemwigsout['cz'],'~'.$cz.'-'.$lx) !== false && stripos($systemwigsout['cz'],'~'.$cz.'-1') === false)
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,系统中已有此类型记录!','success'=>false));exit;
 
- 					}
 
- 					if(stripos($systemwigsout['cz'],'~1-2') !== false && $lx == '2')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,此订单已有出库记录!','success'=>false));exit;
 
- 					}
 
- 					if(stripos($systemwigsout['cz'],'~6-2') === false && $lx == '1')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,此订单已进入后续流程,还未结束!','success'=>false));exit;
 
- 					}
 
- 					$cz1 = explode('-',$systemwigsout['ctime1']);$gcz1 = explode('-',$systemwigsout['gctime1']);
 
- 			    	if($this->systemwigsout->save(array('cz'=>$systemwigsout['cz'].'|~'.$cz.'-'.$lx,'ctime1'=>$time.'-'.$cz1[0],'gctime1'=>date('YmdH',$time).'-'.$gcz1[0]),$systemwigsout['id']))
 
- 				   	{
 
- 				    	echo json_encode(array('music'=>'1','success'=>true));exit;
 
- 				    }
 
- 				    else
 
- 				    {
 
- 				    	echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
 
- 				    }
 
- 			    }
 
- 			    else
 
- 			    {
 
- 					if($lx == '1')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,此订单没有出库记录','success'=>false));exit;
 
- 					}
 
- 			    	if($this->systemwigsout->insert(array('type'=>$type,'cz'=>'~'.$cz.'-'.$lx,'number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'gtime'=>date('YmdH',$time),'time'=>$time,'ctime1'=>$time.'-'.$time,'gctime1'=>date('YmdH',$time).'-'.date('YmdH',$time))))
 
- 				    {
 
- 				    	echo json_encode(array('music'=>'1','success'=>true));exit;
 
- 				    }
 
- 				    else
 
- 				    {
 
- 				    	echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
 
- 				    }
 
- 			    }
 
- 			}
 
- 			else
 
- 			{
 
- 			    if($systemwigsout)
 
- 			    {
 
- 					if(stripos($systemwigsout['cz'],'~'.$cz.'-'.$lx) !== false)
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,系统中已有此类型记录!','success'=>false));exit;
 
- 					}
 
- 					if(stripos($systemwigsout['cz'],'~'.$cz.'-1') === false && $lx == '2')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,请先进行入库操作!','success'=>false));exit;
 
- 					}
 
- 					else if(stripos($systemwigsout['cz'],'~2-') === false && stripos($systemwigsout['cz'],'~3-') === false && stripos($systemwigsout['cz'],'~4-') === false && stripos($systemwigsout['cz'],'~5-') === false && $cz == '6')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,没有前置流程不可进入后处理!','success'=>false));exit;
 
- 					}
 
- 					else if(stripos($systemwigsout['cz'],'~2-2') === false && stripos($systemwigsout['cz'],'~3-2') === false && stripos($systemwigsout['cz'],'~4-2') === false && stripos($systemwigsout['cz'],'~5-2') === false && $cz == '6')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,前置流程未出库!','success'=>false));exit;
 
- 					}
 
- 					else if((stripos($systemwigsout['cz'],'~2-') !== false || stripos($systemwigsout['cz'],'~3-') !== false || stripos($systemwigsout['cz'],'~4-') !== false || stripos($systemwigsout['cz'],'~5-') !== false) && stripos($systemwigsout['cz'],'~'.$cz.'-') === false && $cz != '6')
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,系统中已有同类型记录!','success'=>false));exit;
 
- 					}
 
- 					else if(stripos($systemwigsout['cz'],'~1-1') !== false)
 
- 					{
 
- 						echo json_encode(array('msg'=>'错误,此订单流程已结束!','success'=>false));exit;
 
- 					}
 
- 					else
 
- 					{
 
- 						$ctime = array('ctime1'=>$systemwigsout['ctime1'],'ctime2'=>$systemwigsout['ctime2'],'ctime3'=>$systemwigsout['ctime3'],'ctime4'=>$systemwigsout['ctime4'],'ctime5'=>$systemwigsout['ctime5'],'ctime6'=>$systemwigsout['ctime6'],'gctime1'=>$systemwigsout['gctime1'],'gctime2'=>$systemwigsout['gctime2'],'gctime3'=>$systemwigsout['gctime3'],'gctime4'=>$systemwigsout['gctime4'],'gctime5'=>$systemwigsout['gctime5'],'gctime6'=>$systemwigsout['gctime6']);
 
- 					    if($cz == '2' || $cz == '3' || $cz == '4' || $cz == '5' || $cz == '6')
 
- 					    {
 
- 							if($lx == '1')
 
- 							{
 
- 					    	    $ctime['ctime'.$cz] = $time;
 
- 								$ctime['gctime'.$cz] = date('YmdH',$time);
 
- 							}
 
- 							else
 
- 							{
 
- 								$ctime['ctime'.$cz] = $systemwigsout['ctime'.$cz].'-'.$time;
 
- 								$ctime['gctime'.$cz] = $systemwigsout['gctime'.$cz].'-'.date('YmdH',$time);
 
- 							}
 
- 					    }
 
- 			    	    $this->systemwigsout->save(array('cz'=>$systemwigsout['cz'].'|~'.$cz.'-'.$lx,'ctime2'=>$ctime['ctime2'],'ctime3'=>$ctime['ctime3'],'ctime4'=>$ctime['ctime4'],'ctime5'=>$ctime['ctime5'],'ctime6'=>$ctime['ctime6'],'gctime2'=>$ctime['gctime2'],'gctime3'=>$ctime['gctime3'],'gctime4'=>$ctime['gctime4'],'gctime5'=>$ctime['gctime5'],'gctime6'=>$ctime['gctime6']),$systemwigsout['id']);
 
- 			    	    echo json_encode(array('music'=>$cz.'-'.$lx,'success'=>true));exit;
 
- 					}
 
- 			    }
 
- 				else if($cz == '3' && $lx == '1' && $ly == '1')
 
- 				{
 
- 					if($this->systemwigsout->insert(array('type'=>$type,'cz'=>'~'.$cz.'-'.$lx,'number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'ly'=>$ly,'gtime'=>date('YmdH',$time),'time'=>$time,'ctime3'=>$time,'gctime3'=>date('YmdH',$time))))
 
- 				    {
 
- 				    	echo json_encode(array('music'=>'1','success'=>true));exit;
 
- 				    }
 
- 				    else
 
- 				    {
 
- 				    	echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
 
- 				    }
 
- 				}
 
- 				else if($cz == '4' && $lx == '1')
 
- 				{
 
- 					if($this->systemwigsout->insert(array('type'=>$type,'cz'=>'~1-2|~'.$cz.'-'.$lx.'|~'.$cz.'-2','number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'gtime'=>date('YmdH',$time),'time'=>$time,'ctime1'=>$time.'-'.$time,'gctime1'=>date('YmdH',$time).'-'.date('YmdH',$time),'ctime4'=>$time.'-'.$time,'gctime4'=>date('YmdH',$time).'-'.date('YmdH',$time))))
 
- 				    {
 
- 				    	echo json_encode(array('music'=>'1','success'=>true));exit;
 
- 				    }
 
- 				    else
 
- 				    {
 
- 				    	echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
 
- 				    }
 
- 				}
 
- 				else if($cz == '5' && $lx == '1')
 
- 				{
 
- 					if($this->systemwigsout->insert(array('type'=>$type,'cz'=>'~1-2|~'.$cz.'-'.$lx,'number'=>$number,'shipremarks'=>$nu['shipremarks'],'printtime'=>$nu['printtime'],'quantity'=>1,'gtime'=>date('YmdH',$time),'time'=>$time,'ctime1'=>$time.'-'.$time,'gctime1'=>date('YmdH',$time).'-'.date('YmdH',$time),'ctime5'=>$time,'gctime5'=>date('YmdH',$time))))
 
- 				    {
 
- 				    	echo json_encode(array('music'=>'1','success'=>true));exit;
 
- 				    }
 
- 				    else
 
- 				    {
 
- 				    	echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
 
- 				    }
 
- 				}
 
- 				else if($cz == '3' && $lx != '1' && $ly == '1')
 
- 				{
 
- 					echo json_encode(array('msg'=>'错误,请先进行入库!','success'=>false));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->systemwigsout->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'] = $value['shipremarks'];
 
- 				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
 
- 				$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);
 
-             }
 
-             $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 _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->systemwigsout->find_all($where);
 
- 			foreach ($count as $v) 
 
- 			{
 
- 				$data += $v['quantity']; 
 
- 			}
 
- 			$systemwigsout = $this->systemwigsout->get_number($number);
 
- 			if($systemwigsout)
 
- 			{
 
- 				$this->systemwigsout->save(array('quantity'=>$systemwigsout['quantity']+1),$systemwigsout['id']);
 
- 				echo json_encode(array('title'=>'添加成功','msg'=>$data+1,'music'=>'1','success'=>true));exit;
 
- 			}
 
- 			else
 
- 			{
 
- 				if($this->systemwigsout->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($post['delarr']))  
 
- 		{
 
- 			$number = $this->input->post('number',true);
 
- 			$type = $this->input->post('type',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($timetk && $timetj)
 
-             {
 
-                 $where  .= " and time > '$timetk' and time < '$timetj'";
 
-             }
 
- 			if($number)
 
-             {
 
-                 $where  .= " and number = '$number'";
 
-             }
 
-             $id_arr = $this->input->post('delarr');
 
-             $id_arr =  explode(',',rtrim($id_arr,','));
 
-             if(!$id_arr)
 
-             {
 
-                 echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;
 
-             }
 
-             //循环删除记录
 
- 			$a=0;
 
-             foreach ($id_arr as $v) 
 
- 		    {
 
- 				if($this->systemwigsout->remove($v))
 
- 				{
 
- 					$a++;
 
- 				}
 
- 				
 
-             }
 
- 			if($a == count($id_arr))
 
- 			{
 
- 				$data = 0;
 
- 				$count = $this->systemwigsout->find_all($where);
 
- 				foreach ($count as $v) 
 
- 				{
 
- 					$data += $v['quantity']; 
 
- 				}
 
-                 echo json_encode(array('del'=>$id_arr,'data'=>$data-$a,'msg'=>'删除成功!','success'=>true));
 
- 			}
 
- 			else
 
- 			{
 
- 				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;
 
- 	}
 
- }
 
 
  |