| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Whlabelbarcode extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_whlabelbarcode','whlabelbarcode');		$this->load->_model('Model_typeclass','typeclass');		$this->load->_model('Model_excel','excel');	}	//定义方法的调用规则 获取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 == 'dc')//删除        {             $this->_dc();        }		else		{			$this->_index();		}    }		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->whlabelbarcode->remove($v);            }            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));		}    }		//管理	public function _index()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['page']))  		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$sku = $this->input->post('sku',true);			$title = $this->input->post('title',true);			$warehouse = $this->input->post('warehouse',true);			$purchase = $this->input->post('purchase',true);			$orderinfo = $this->input->post('orderinfo',true);			$waybill = $this->input->post('waybill',true);			$category = $this->input->post('category',true);			$size = $this->input->post('size',true);			$grade = $this->input->post('grade',true);			$color = $this->input->post('color',true);			$lowe = $this->input->post('lowe',true);			$state = $this->input->post('state',true);			$label = $this->input->post('label',true);			$timetk = $this->input->post('kktime',true);			$timetj = $this->input->post('jjtime',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = "1=1 ";			if($timetk && $timetj)            {                $where .= " and time > '$timetk' and time < '$timetj'";            }			if($sku)            {                $where  .= " and sku = '$sku'";            }			if($title)            {                $where  .= " and title like '%$title%'";            }			if($warehouse)            {                $where  .= " and warehouse = '$warehouse'";            }			if($purchase)            {                $where  .= " and purchase = '$purchase'";            }			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($waybill)            {                $where  .= " and waybill = '$waybill'";            }			if($category)            {                $where  .= " and features like '%-$category-%'";            }			if($size)            {                $where  .= " and features like '%-$size-%'";            }			if($grade)            {                $where  .= " and features like '%-$grade-%'";            }			if($color)            {                $where  .= " and features like '%-$color-%'";            }			if($lowe)            {                $where  .= " and features like '%-$lowe-%'";            }			if($label)            {                $where  .= " and label = '$label'";            }            //数据排序            $order_str = "time desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->whlabelbarcode->find_all($where,'id,sku,title,label',$order_str,$start,$perpage);		    $total = $this->whlabelbarcode->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('whlabelbarcode',$this->data);	}		//入库操作	public function _add()	{		$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');		//等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外		$post = $this->input->post(NULL, TRUE);		if(isset($post['category']))		{			$list = array();$num = "";$title = "";$features = "";$state=0;			$post['time'] = time();			$category = $this->input->post('category',true);			$list['category'] = $category;			$list['hairtype'] = $this->input->post('hairtype',true);			$list['grade'] = $this->input->post('grade',true);			$size = $this->input->post('size',true);			$list['size'] = rtrim($size,',');			$list['color'] = $this->input->post('color',true);			$list['lowe'] = $this->input->post('lowe',true);			$list['warehouse'] = $this->input->post('warehouse',true);			if($category == 127)			{				$list['type'] = $this->input->post('type',true);				$list['headroad'] = $this->input->post('headroad',true);				$list['density'] = $this->input->post('density',true);				if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)				{					$list['lacesize'] = $this->input->post('lacesize',true);				}				$list['lacecolor'] = $this->input->post('lacecolor',true);			}			else if($category == 128)			{				$list['lacetype'] = $this->input->post('lacetype',true);				$list['haircap'] = $this->input->post('haircap',true);				$list['density'] = $this->input->post('density',true);				$list['lacecolor'] = $this->input->post('lacecolor',true);			}			else if($category == 129)			{				$list['wide'] = $this->input->post('wide',true);			}			else if($category == 130)			{				$list['weight'] = $this->input->post('weight',true);			}			else if($category == 131)			{				$list['gift'] = $this->input->post('gift',true);			}			else if($category == 133)			{				$list['package'] = $this->input->post('package',true);				$list['unitweight'] = $this->input->post('unitweight',true);			}			else if($category == 134)			{				$list['pieceweight'] = $this->input->post('pieceweight',true);			}			foreach($list as $k=>$v)			{				if($v != 0)				{					$num .=$v;					$features .=$v.'-';					$post[$k] = $v;					$typeclass = $this->typeclass->read($v);			        $title .= $typeclass['title']." ";					$scsku[$typeclass['classid']] = $typeclass['bqsku'];				}            }			$time = time();			$post['title'] = rtrim($title,' ');			$post['number'] = $num;			$post['features'] = '-'.$features;			$featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);			$featurespp = explode('-',trim($featurespp,'-'));			if(isset($featurespp[5]))			{				$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];			}			else			{				$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];			}			$scsku = implode("-",$scsku);			$scsku = str_replace('- ','-',trim($scsku,'-'));			$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);			$bqsku = $scsku;			$post['sku'] = $bqsku;			$label = time().rand(0,9);			$post['label'] = $label;			$whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);			if($whlabelbarcode)			{				echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;			}			else			{				if($this->whlabelbarcode->insert($post))				{				    echo json_encode(array('msg'=>'添加成功','success'=>true));exit;				}				else				{					echo json_encode(array('msg'=>'添加失败,请重试!','success'=>false));exit;				}			}		}		$this->_Template('whlabelbarcode_add',$this->data);	}	//修改产品	public function _edit($arg_array)	{		$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');		//等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套属性 100为头套额外		$post = $this->input->post(NULL, TRUE);		if(isset($post['id']))		{			$list = array();$num = "";$title = "";$features = "";$state=0;//正常入库			$id = $this->input->post('id',true);			$category = $this->input->post('category',true);			$list['category'] = $category;			$list['hairtype'] = $this->input->post('hairtype',true);			$list['grade'] = $this->input->post('grade',true);			$size = $this->input->post('size',true);			$list['size'] = rtrim($size,',');			$list['color'] = $this->input->post('color',true);			$list['lowe'] = $this->input->post('lowe',true);			$list['warehouse'] = $this->input->post('warehouse',true);			if($category == 127)			{				$list['type'] = $this->input->post('type',true);				$list['headroad'] = $this->input->post('headroad',true);				$list['density'] = $this->input->post('density',true);				if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)				{					$list['lacesize'] = $this->input->post('lacesize',true);				}				$list['lacecolor'] = $this->input->post('lacecolor',true);			}			else if($category == 128)			{				$list['lacetype'] = $this->input->post('lacetype',true);				$list['haircap'] = $this->input->post('haircap',true);				$list['density'] = $this->input->post('density',true);				$list['lacecolor'] = $this->input->post('lacecolor',true);			}			else if($category == 129)			{				$list['wide'] = $this->input->post('wide',true);			}			else if($category == 130)			{				$list['weight'] = $this->input->post('weight',true);			}			else if($category == 131)			{				$list['gift'] = $this->input->post('gift',true);			}			else if($category == 133)			{				$list['package'] = $this->input->post('package',true);				$list['unitweight'] = $this->input->post('unitweight',true);			}			else if($category == 134)			{				$list['pieceweight'] = $this->input->post('pieceweight',true);			}			foreach($list as $k=>$v)			{				if($v != 0)				{					$num .=$v;					$features .=$v.'-';					$post[$k] = $v;					$typeclass = $this->typeclass->read($v);			        $title .= $typeclass['title']." ";					$scsku[$typeclass['classid']] = $typeclass['bqsku'];				}            }			$time = time();			$post['title'] = rtrim($title,' ');			$post['number'] = $num;			$post['features'] = '-'.$features;			$featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);			$featurespp = explode('-',trim($featurespp,'-'));			if(isset($featurespp[5]))			{				$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];			}			else			{				$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];			}			$scsku = implode("-",$scsku);			$scsku = str_replace('- ','-',trim($scsku,'-'));			$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);			$bqsku = $scsku;			$post['sku'] = $bqsku;			$whlabelbarcode = $this->whlabelbarcode->get_number($post['number']);			if($whlabelbarcode)			{				echo json_encode(array('msg'=>'已有重复产品!','success'=>false));exit;			}			else			{				if($this->whlabelbarcode->save($post,$id))				{				    echo json_encode(array('msg'=>'修改成功','success'=>true));exit;				}				else				{					echo json_encode(array('msg'=>'修改失败,请重试!','success'=>false));exit;				}			}		}		$uid = $this->whlabelbarcode->read($arg_array[0]);		$this->data['enter'] = $uid ;		$this->_Template('whlabelbarcode_edit',$this->data);	}		public function _dc()	{		if(isset($_GET['excel']))  		{			$category = $this->input->get('category',true);			$size = $this->input->get('size',true);			$grade = $this->input->get('grade',true);			$color = $this->input->get('color',true);			$lowe = $this->input->get('lowe',true);			$sku = $this->input->get('sku',true);			$ktime = $this->input->get('ktime',true);			$jtime = $this->input->get('jtime',true);			$ktime = strtotime($kktime);			$jtime = strtotime($jjtime);			$where = "1=1";$gj = "";$ck = "";			if($category)            {                $where  .= " and features like '%-$category-%'";            }			if($size)            {                $where  .= " and features like '%-$size-%'";            }			if($grade)            {                $where  .= " and features like '%-$grade-%'";            }			if($color)            {                $where  .= " and features like '%-$color-%'";            }			if($lowe)            {                $where  .= " and features like '%-$lowe-%'";            }			if($sku)            {                $where  .= " and sku like '%$sku%'";            }			if($ktime && $jtime)            {                $where  .= " and time > '$ktime' and time < '$jtime'";            }            $order_str = "time desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }           				$info_list = $this->whlabelbarcode->find_all($where,'label,sku,title',$order_str);			   				$title = '导入标签-'.date('Y-m-d H-i-s',time());                 $titlename = "<table border=1>                <tr align='center'>				<td>条码号</td>			    <td>SKU</td>                <td>产品名称</td>			    <td>打印数量</td>                </tr>                </table>";                 $filename = $title.".xls";			    $tail = "";                $this->excel->get_fz2($info_list,$titlename,$filename,$tail);				    }	}}
 |