| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Distribution extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_user','user');
 
- 		$this->load->_model('Model_distribution','distribution');
 
- 		$this->load->_model('Model_typeclass','typeclass');
 
- 		$this->load->_model('Model_warehouse','warehouse');
 
- 		$this->load->_model('Model_productprice','productprice');
 
- 		$this->load->_model('Model_excel','excel');
 
- 		$this->load->_model('Model_fullorder','fullorder');
 
- 		$this->load->_model('Model_fullordertt','fullordertt');
 
- 		$this->load->_model('Model_fullordersmt','fullordersmt');
 
- 	}
 
- 	//定义方法的调用规则 获取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 == 'drmb')//修改
 
-         {
 
-              $this->_drmb();
 
-         }
 
- 		else if($arg == 'dr')
 
-         {
 
-              $this->_dr();
 
-         }
 
- 		else if($arg == 'db')
 
-         {
 
-              $this->_db();
 
-         }
 
- 		else
 
- 		{
 
- 			 $this->_index();
 
- 		}
 
-     }
 
- 	//管理
 
- 	public function _index()
 
- 	{
 
- 		$t = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v)
 
- 		{
 
- 			$t[$v['id']] = $v['title'];
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['page']))  
 
- 		{
 
- 		    $page = $this->input->post('page',true);
 
- 		    $perpage = $this->input->post('perpage',true);
 
- 			$category = $this->input->post('category',true);
 
- 			$where = "1=1 ";
 
-             //数据排序
 
-             $order_str = "id asc";
 
- 			if($category)
 
- 			{
 
- 				$where .= "and category = '$category'";
 
- 			}
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
-             //取得信息列表
 
-             $info_list = $this->distribution->find_all($where,'id,category,lace,density,size,weight,pb',$order_str,$start,$perpage);
 
- 			 //格式化数据
 
-             foreach ($info_list as $key=>$value) 
 
- 		    {
 
- 				if(isset($t[$value['category']]))
 
- 				{
 
- 					$info_list[$key]['category'] = $t[$value['category']];
 
- 				}
 
- 				if(isset($t[$value['lace']]))
 
- 				{
 
- 					$info_list[$key]['lace'] = $t[$value['lace']];
 
- 				}
 
- 				if(isset($t[$value['density']]))
 
- 				{
 
- 					$info_list[$key]['density'] = $t[$value['density']];
 
- 				}
 
- 				if(isset($t[$value['size']]))
 
- 				{
 
- 					$info_list[$key]['size'] = $t[$value['size']];
 
- 				}
 
- 				if($value['pb'] != '')
 
- 				{
 
- 					$info_list[$key]['pb'] = '';
 
- 					$pb = explode('/',trim($value['pb'],'/'));
 
- 					foreach ($pb as $vv) 
 
- 		            {
 
- 						$vv = explode('*',trim($vv,'*'));
 
- 						foreach ($vv as $v) 
 
- 		                {
 
- 							$info_list[$key]['pb'] .= '<p>'.trim($v,' ').'</p>';
 
- 						}
 
- 					}
 
- 				}
 
-             }
 
- 		    $total = $this->distribution->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('distribution',$this->data);
 
- 	}
 
- 	//添加
 
- 	public function _add()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['category']))
 
- 		{
 
- 			$category = $this->input->post('category',true);
 
- 			$lace = $this->input->post('lace',true);
 
- 			$density = $this->input->post('density',true);
 
- 			$size = $this->input->post('size',true);
 
- 			$size = trim($size,',');
 
- 			$pb = $this->input->post('pb',true);
 
- 			$post['category'] = (isset($t[$category]))?$t[$category]:'';
 
- 			$post['lace'] = (isset($t[$lace]))?$t[$lace]:'';
 
- 			$post['density'] = (isset($t[$density]))?$t[$density]:'';
 
- 			$post['size'] = (isset($t[$size]))?$t[$size]:'';
 
- 			$post['pb'] = $pb;
 
- 			if($post['category'] == '' || $post['size'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'提交信息有误,请检查','success'=>false));exit;
 
- 			}
 
- 			$gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
 
- 			if($pb != '')
 
- 			{
 
- 				if($post['category'] == 128)
 
- 				{
 
- 					$pb = explode('/',trim($pb,'/'));
 
- 					$ftpb = $this->ft($pb);
 
- 					if($ftpb['cw'] > 0)
 
- 					{
 
- 						$cw++;
 
- 					}
 
- 					else
 
- 					{
 
- 						$xq .= $ftpb['pb'];
 
- 					}
 
- 					if(isset($pb[1]))//有蕾丝头套
 
- 					{
 
- 						$xq .= $pb['1'].'+';//发块
 
- 					}
 
- 					$hf = $this->js($xq);
 
- 				}
 
- 				else
 
- 				{
 
- 					if(stripos($pb,'/') !== false)
 
- 					{
 
- 						$cw++;
 
- 					}
 
- 					$xq .= $pb;
 
- 					$pb = explode('+',trim($pb,'+'));
 
- 					$hf = $this->js($pb);
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('msg'=>'请填写配比信息!','success'=>false));exit;
 
- 			}
 
- 			if($cw > 0)
 
- 			{
 
- 				echo json_encode(array('msg'=>'配比信息错误,请检查!','success'=>false));exit;
 
- 			}
 
- 			$post['gl'] = $hf['gl'];
 
- 			$post['weight'] = $hf['zzl'];
 
- 			$post['zh'] = $hf['zh'];
 
- 			$post['time'] = time();
 
- 			$pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
 
- 			$post['pid'] = str_replace(array('---','--'),'-',$pid);
 
- 			$post['pbxq'] = trim($xq,'+');
 
- 			if($this->distribution->insert($post))
 
-         	{
 
-          		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$this->_Template('distribution_add',$this->data);
 
- 	}
 
- 	//修改
 
- 	public function _edit($arg_array)
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['id']))
 
- 		{
 
- 			$id = $this->input->post('id',true);
 
- 			$category = $this->input->post('category',true);
 
- 			$lace = $this->input->post('lace',true);
 
- 			$density = $this->input->post('density',true);
 
- 			$size = $this->input->post('size',true);
 
- 			$size = trim($size,',');
 
- 			$pb = $this->input->post('pb',true);
 
- 			$post['category'] = (isset($t[$category]))?$t[$category]:'';
 
- 			$post['lace'] = (isset($t[$lace]))?$t[$lace]:'';
 
- 			$post['density'] = (isset($t[$density]))?$t[$density]:'';
 
- 			$post['size'] = (isset($t[$size]))?$t[$size]:'';
 
- 			$post['pb'] = $pb;
 
- 			if($post['category'] == '' || $post['size'] == '')
 
- 			{
 
- 				echo json_encode(array('msg'=>'提交信息有误,请检查','success'=>false));exit;
 
- 			}
 
- 			$gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
 
- 			if($pb != '')
 
- 			{
 
- 				if($post['category'] == 128)
 
- 				{
 
- 					$pb = explode('/',trim($pb,'/'));
 
- 					$ftpb = $this->ft($pb);
 
- 					if($ftpb['cw'] > 0)
 
- 					{
 
- 						$cw++;
 
- 					}
 
- 					else
 
- 					{
 
- 						$xq .= $ftpb['pb'];
 
- 					}
 
- 					if(isset($pb[1]))//有蕾丝头套
 
- 					{
 
- 						$xq .= $pb['1'].'+';//发块
 
- 					}
 
- 					$hf = $this->js($xq);
 
- 				}
 
- 				else
 
- 				{
 
- 					if(stripos($pb,'/') !== false)
 
- 					{
 
- 						$cw++;
 
- 					}
 
- 					$xq .= $pb;
 
- 					$pb = explode('+',trim($pb,'+'));
 
- 					$hf = $this->js($pb);
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('msg'=>'请填写配比信息!','success'=>false));exit;
 
- 			}
 
- 			if($cw > 0)
 
- 			{
 
- 				echo json_encode(array('msg'=>'配比信息错误,请检查!','success'=>false));exit;
 
- 			}
 
- 			$post['gl'] = $hf['gl'];
 
- 			$post['weight'] = $hf['zzl'];
 
- 			$post['zh'] = $hf['zh'];
 
- 			$post['time'] = time();
 
- 			$pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
 
- 			$post['pid'] = str_replace(array('---','--'),'-',$pid);
 
- 			$post['pbxq'] = trim($xq,'+');
 
- 			if($this->distribution->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];
 
- 		$distribution = $this->distribution->read($arg_array);
 
- 		$this->data['distribution'] = $distribution;
 
- 		$this->_Template('distribution_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->distribution->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
-     }
 
- 	
 
- 	public function _drmb()
 
- 	{
 
- 				$title = '导入模板'; 
 
-                 $titlename = "<table border=1>
 
-                 <tr align='center'>
 
- 				<td>类目</td>
 
- 				<td>蕾丝类型</td>
 
- 				<td>密度</td>
 
- 				<td>尺寸</td>
 
- 				<td style='width:300px'>配比 (按照右侧格式填写)</td>
 
- 				<td>发条 :原材料尺寸-克数+原材料尺寸-克数  具体示例: 6-0.2+8-0.2+10-0.3+12-0.3<br>
 
- 				发块: 原材料尺寸-克数+原材料尺寸-克数  具体示例: 8-0.1+10-0.1+12-0.25+14-0.25+16-0.3<br>
 
- 				不含蕾丝头套:填写所需发条的尺寸(发条尺寸-克数+发条尺寸-克数+发条尺寸-克数) 具体示例: 14-20+16-10+18-8<br>
 
- 				有发块的蕾丝头套(/后填发块原材料配比):发条尺寸-克数+发条尺寸-克数+发条尺寸-克数/发块原材料配比 具体示例: 14-20+16-10+18-8/18<br>
 
- 				无发块的蕾丝头套(/后填蕾丝配比):发条尺寸-克数+发条尺寸-克数+发条尺寸-克数/蕾丝原材料配比 具体示例: 14-20+16-10+18-8/6-0.2+8-0.2+10-0.1<br>
 
- 				全蕾丝头套:原材料尺寸-克数+原材料尺寸-克数  具体示例: 6-0.2+8-0.2+10-0.3+12-0.3<br></td>
 
-                 </tr></table>";
 
- 				$lm = array('发条','发块前头','头套');
 
- 				$md = $this->typeclass->find_all("classid = '10'");
 
- 				$ttls = $this->typeclass->find_all("classid = '18'");
 
- 				$fkls = $this->typeclass->find_all("classid = '25' or classid = '26'");
 
- 				$cc = $this->typeclass->find_all("classid = '14'");
 
- 				$rowsdq = array();
 
- 				foreach ($lm as $vvv) 
 
- 		        {
 
- 					
 
- 					if($vvv == '头套')
 
- 					{
 
- 						foreach ($ttls as $vv) 
 
- 		                {
 
- 							foreach ($md as $v) 
 
- 		                    {
 
- 								foreach ($cc as $val) 
 
- 		                        {
 
- 									if(stripos($v['zh'],'|') !== false)
 
- 									{
 
- 										$vzh =  explode('|',$v['zh']);
 
- 										$v['zh'] = $vzh[0];
 
- 									}
 
- 									if($val['spare'] == 'Short Hair')
 
- 									{
 
- 										$val['spare'] = '短款';
 
- 									}
 
- 					                $rowsdq[] = array($vvv,$vv['zh'],$v['title'],$val['spare'],'');
 
- 								}
 
- 							}
 
- 						}
 
- 					}
 
- 					else if($vvv == '发块前头')
 
- 					{
 
- 						foreach ($fkls as $vv) 
 
- 		                {
 
- 							foreach ($md as $v) 
 
- 		                    {
 
- 					            foreach ($cc as $val) 
 
- 		                        {
 
- 									if(stripos($v['zh'],'|') !== false)
 
- 									{
 
- 										$vzh =  explode('|',$v['zh']);
 
- 										$v['zh'] = $vzh[0];
 
- 									}
 
- 									if($val['spare'] == 'Short Hair')
 
- 									{
 
- 										$val['spare'] = '短款';
 
- 									}
 
- 					               $rowsdq[] = array($vvv,$vv['zh'],$v['title'],$val['spare'],'');
 
- 								}
 
- 							}
 
- 						}
 
- 					}
 
- 					else
 
- 					{
 
- 						foreach ($cc as $val) 
 
- 		                {
 
- 							if($val['spare'] == 'Short Hair')
 
- 							{
 
- 								$val['spare'] = '短款';
 
- 							}
 
- 							$rowsdq[] = array($vvv,'','',$val['spare'],'');
 
- 						}
 
- 					}
 
- 				}
 
- 	    $filename = $title.".xls";
 
- 			        $tail = "\n";
 
-                     $this->excel->get_fz2($rowsdq,$titlename,$filename,$tail);
 
- 	}
 
- 	
 
- 	public function _dr()
 
- 	{
 
- 		$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
 
- 			{
 
- 				libxml_use_internal_errors(true);
 
- 				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;
 
-                 }
 
- 			}
 
- 			$tz = array();$bs = array();
 
- 			$typeclassa = $this->typeclass->find_all("zh != ''");
 
- 			foreach ($typeclassa as $v)
 
- 			{
 
- 				$tz[$v['zh']] = $v['id'];
 
- 			}
 
- 			$typeclassb = $this->typeclass->find_all("bqsku != ''");
 
- 			foreach ($typeclassb as $v)
 
- 			{
 
- 				$bs[$v['bqsku']] = $v['id'];
 
- 			}
 
- 			$i = 0;$j = 0;$ed = array();$x=0;$cs = array();
 
- 		    foreach ($list as $k=>$v)
 
- 		    {
 
- 				$hs = $k+2;
 
- 				$post['category']= (isset($tz[$v[0]]))?$tz[$v[0]]:'';
 
- 				$post['lace'] = (isset($tz[$v[1]]))?$tz[$v[1]]:'';
 
- 			    $post['density'] = (isset($bs[$v[2]]))?$bs[$v[2]]:'';
 
- 			    $post['size'] = (isset($bs[$v[3]]))?$bs[$v[3]]:'';
 
- 				$post['pb'] = $v[4];
 
- 				$pb = $v[4];
 
- 			    $gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
 
- 			    if($pb != null)
 
- 			    {
 
- 				    if($post['category'] == 128)
 
- 				    {
 
- 					    $pb = explode('/',trim($pb,'/'));
 
- 						$ftpb = $this->ft($pb);
 
- 						if($ftpb['cw'] > 0)
 
- 						{
 
- 							$j++;
 
- 							$ed[] = array('第'.$hs.'行导入失败,发条的配比信息有误!');
 
- 							continue;
 
- 						}
 
- 						else
 
- 						{
 
- 							$xq .= $ftpb['pb'];
 
- 						}
 
- 						if(isset($pb[1]))//有蕾丝头套
 
- 						{
 
- 							$xq .= $pb['1'].'+';//发块
 
- 						}
 
- 					    $hf = $this->js($xq);
 
- 				    }
 
- 				    else
 
- 				    {
 
- 					    if(stripos($pb,'/') !== false)
 
- 					    {
 
- 						    $j++;
 
- 							$ed[] = array('第'.$hs.'行导入失败,请检查配比内容1');
 
- 							continue;
 
- 					    }
 
- 						$xq .= $v[4];
 
- 					    $hf = $this->js($pb);
 
- 				    }
 
- 			    
 
- 				if($hf['cw'] > 0)
 
- 				{
 
- 					$j++;
 
- 					$ed[] = array($hf['cw'].' - '.json_encode($hf['nr']).' - 第'.$hs.'行导入失败,请检查配比内容2');
 
- 					continue;
 
- 				}
 
- 			    $post['gl'] = $hf['gl'];
 
- 			    $post['weight'] = $hf['zzl'];
 
- 				$post['zh'] = $hf['zh'];
 
- 			    $pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
 
- 			    $post['pid'] = str_replace(array('---','--'),'-',$pid);
 
- 			    $post['pbxq'] = trim($xq,'+');
 
- 				$x = $this->distribution->get_pid($post['pid']);
 
- 				if($x)
 
- 				{
 
- 					if(!$this->distribution->save($post,$x['id']))
 
- 					{
 
- 						$j++;
 
- 						$ed[] = array('第'.$hs.'行导入失败,请重试1');
 
- 					}
 
- 				}
 
- 				else
 
- 				{
 
- 					$post['time'] = time();
 
- 					if(!$this->distribution->insert($post))
 
- 					{
 
- 						$j++;
 
- 						$ed[] = array('第'.$hs.'行导入失败,请重试2');
 
- 					}
 
- 				}
 
- 				}
 
- 			}
 
- 			if($j > 0)
 
- 			{
 
- 				$time = date('Ymd',time());
 
- 				$tt = date('Ymd',time());
 
- 				$title = '导入错误信息-'.$tt;
 
-         		$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
 
- 				$tail = "\n";
 
-         		$filename = $title.".xls";
 
-         		$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
 
- 				$dir = '/data/excel/'.$time.'/';
 
- 				$file_name = 'error_'.$time.rand(1000,9999);
 
- 				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
 
- 				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
 
- 				fwrite($myfile,$ecl);
 
- 				fclose($myfile);
 
- 				$error = $dir.$file_name.'.xls';
 
- 				echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('msg'=>'导入成功!','error'=>$cs,'success'=>true));exit;
 
- 			}
 
- 		}
 
- 	}
 
- 	
 
- 	public function ft($pb)
 
- 	{
 
- 		$t = array();$bs = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v)
 
- 		{
 
- 			$t[$v['id']] = $v['id'];
 
- 			$bs[$v['bqsku']] = $v['id'];
 
- 		}
 
- 		$xq = '';$j = 0;
 
- 		$pb[0] = explode('+',trim($pb[0],'+'));
 
- 		foreach ($pb[0] as $val) //发条
 
- 		{
 
- 			$sz = explode('-',$val);
 
- 			if(!isset($sz[1]) || !isset($bs[$sz[0]]))
 
- 			{
 
- 				$j++;
 
- 				break;
 
- 			}
 
- 			$sizedata = $this->distribution->ge_size(126,$bs[$sz[0]]);
 
- 			if(!$sizedata)
 
- 			{
 
- 				 $j++;
 
- 				 break;
 
- 			}
 
- 			$bl = $sz[1]/$sizedata['weight'];
 
- 			$ftpb = explode('+',$sizedata['pb']);
 
- 			foreach ($ftpb as $v) 
 
- 		    {
 
- 				$xxzl = explode('-',$v);
 
- 				$xq .= $xxzl[0].'-'.sprintf("%01.2f",$xxzl[1]*$bl).'+';
 
- 			}
 
- 		}
 
- 		if($j > 0)
 
- 		{
 
- 			return array('cw'=>1);
 
- 		}
 
- 		else
 
- 		{
 
- 			return array('cw'=>0,'pb'=>$xq);
 
- 		}
 
- 	}
 
- 	public function js($data)
 
- 	{
 
- 		$zzl = 0;$gl = '';$fl=array();$cw=0;$nr = array();$zh = '';
 
- 		$pb = explode('+',trim($data,'+'));
 
- 		if(isset($pb))
 
- 		{
 
- 		    foreach ($pb as $k=>$v) 
 
- 		    {
 
- 			    $v = explode('-',trim($v,'-'));
 
- 				if(!isset($v[1]))
 
- 				{
 
- 					$cw = 1;
 
- 					$nr[] = array($pb,$pb[$k]);
 
- 					break;
 
- 				}
 
- 			    if(!is_numeric($v[0]) || !is_numeric($v[1]))
 
- 			    {
 
- 			    	$cw = 2;
 
- 					$nr[] = array($pb,$pb[$k]);
 
- 					break;
 
- 			    }
 
- 			    $zzl += $v[1];
 
- 			    if(isset($fl[$v[0]]))
 
- 			    {
 
- 			    	$fl[$v[0]] += $v[1];
 
- 			    }
 
- 			    else
 
- 			    {
 
- 			    	$fl[$v[0]] = $v[1];
 
- 			    }
 
- 		    }
 
- 		    foreach ($fl as $k=>$v) 
 
- 		    {
 
- 				$zh .= $k.'inch:'.$v.'g<br>'; 
 
- 		    	$gl .= $k.'-'.$v.'+';
 
- 		    }
 
- 		}
 
- 		else
 
- 		{
 
- 			$cw = 3;
 
- 		}
 
- 		if($cw < 1)
 
- 		{
 
- 			return array('cw'=>0,'gl'=>trim($gl,'+'),'zzl'=>$zzl,'zh'=>trim($zh,'<br>'));
 
- 		}
 
- 		else
 
- 		{
 
- 			return array('cw'=>$cw,'nr'=>$nr);
 
- 		}
 
- 	}
 
- 	
 
- 	public function _db()
 
- 	{
 
- 		$t = array();$y = array();$w = array();$cc = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v)
 
- 		{
 
- 			if($v['classid'] == 14)
 
- 			{
 
- 				$cc[$v['bqsku']] = 0;
 
- 			}
 
- 			$t[$v['id']] = $v['bqsku'];
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($_GET['dktime']))  
 
- 		{
 
- 		    $ktime = $this->input->get('dktime',true);
 
- 			$jtime = $this->input->get('djtime',true);
 
- 			$ktime = strtotime($ktime);
 
- 			$jtime = strtotime($jtime);
 
- 		$pb = array();$zz = '';
 
- 		$distribution = $this->distribution->find_all();
 
- 		foreach ($distribution as $val) 
 
- 		{
 
- 			$pb[$val['pid']] = array('weight'=>$val['weight'],'gl'=>$val['gl'],'zh'=>$val['zh']);
 
- 		}
 
- 		$where = "shop != '9' and shop != '26' and type != '3' and type != '5' and type != '7' and type != '8' and type != '9' and type != '10' and type != '12' and library = '2' and librarytime > '".$ktime."' and librarytime < '".$jtime."'";
 
- 		$dlz = $this->fullorder->find_all($where,'id,fpdata,number,orderinfo','id desc',0,5);
 
- 		$smt = $this->fullordersmt->find_all($where,'id,fpdata,number,orderinfo','id desc',0,5);
 
- 		$data = array_merge($dlz,$smt);
 
- 		$product = array();
 
- 		foreach ($data as $val) 
 
- 		{
 
- 			$sy = array();
 
- 			$cp = explode(';',trim($val['fpdata'],';'));
 
- 			foreach ($cp as $v) 
 
- 		    {
 
- 				$a = 0;
 
- 				$v = explode('|',trim($v,'|'));
 
- 				$qb = explode(',',$v[0]);
 
- 				$szid = $qb[0];//尺寸ID
 
- 				if(!isset($qb[1]))
 
- 				{
 
- 					$w[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'产品参数错误',$v);
 
- 					continue;
 
- 				}
 
- 				$qb = explode('-',trim($qb[1],'-'));//尺寸外其它参数
 
- 				if($qb[0] == '126')
 
- 				{
 
- 					if(isset($pb[$qb[0].'-'.$szid]))
 
- 					{
 
- 						$a = 1;
 
- 						$zz .= $pb[$qb[0].'-'.$szid]['gl'].'+';
 
- 						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$szid]['zh']);
 
- 					}
 
- 				}
 
- 				else if($qb[0] == '127')
 
- 				{
 
- 					if(isset($pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]))
 
- 					{
 
- 						$a = 1;
 
- 						$zz .= $pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['gl'].'+';
 
- 						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['zh']);
 
- 					}
 
- 				}
 
- 				else if($qb[0] == '128')
 
- 				{
 
- 					if(isset($pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]))
 
- 					{
 
- 						$a = 1;
 
- 						$zz .= $pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['gl'].'+';
 
- 						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['zh']);
 
- 					}
 
- 				}
 
- 				if($a == 0)
 
- 				{
 
- 					$w[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'','');
 
- 				}
 
- 			}
 
- 		}
 
- 		    $zz = explode('+',trim($zz,'+'));
 
- 		    foreach ($zz as $v) 
 
- 		    {
 
- 				$cd = explode('-',trim($v,'-'));
 
- 				if(isset($cc[$cd[0]]))
 
- 				{
 
- 					$cc[$cd[0]] += $cd[1];
 
- 				}
 
- 			}
 
- 			$zzcx = '';
 
- 			foreach ($cc as $k=>$v) 
 
- 		    {
 
- 				$zzcx .= $k.'inch:'.$v.'g'.'<br>';
 
- 			}
 
- 		    $title = date('Y-m-d',$ktime).' 至 '.date('Y-m-d',$jtime).'订单原材料配比'; 
 
-             $titlename = "<table border=1>
 
-                 <tr align='center'>
 
- 				<td>编号</td>
 
- 				<td>订单号</td>
 
- 				<td>产品名称</td>
 
- 				<td>总重量</td>
 
- 				<td>配比详情</td>
 
-                 </tr></table>";
 
- 		    $filename = $title.".xls";
 
- 		    $tail = "<tr align='center'><td></td><td></td><td></td><td>所有尺寸合并数据:</td><td>".trim($zzcx,'<br>')."</td></tr>";
 
-             $this->excel->get_fz2($y,$titlename,$filename,$tail);
 
- 		}
 
- 	}
 
- }
 
 
  |