| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Purchasedetailed extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_purchasedetailed','purchasedetailed');		$this->load->_model('Model_typeclass','typeclass');		$this->load->_model('Model_pricedeploy','pricedeploy');		$this->load->_model('Model_asd','asd');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'add')//添加        {             $this->_add($arg_array);        }		else if($arg == 'edit')//修改        {             $this->_edit($arg_array);        }		else if($arg == 'del')//修改        {             $this->_del();        }		else if($arg == 'rows')//修改        {             $this->_rows();        }		else		{			 $this->_index($arg_array);		}    }	//管理	public function _index($arg_array)	{		$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);			$size = $this->input->post('size',true);			$grade = $this->input->post('grade',true);			$density = $this->input->post('density',true);			$lacetype = $this->input->post('lacetype',true);			$arg_array = $this->input->post('arg_array',true);			$where = "1=1 ";			if($category)            {                $where  .= " and category = '$category	'";            }			if($size)            {                $where  .= " and size = '$size'";            }			if($grade)            {                $where  .= " and grade = '$grade'";            }			if($density)            {                $where  .= " and density = '$density'";            }			if($lacetype)            {                $where  .= " and lacetype = '$lacetype'";            }			if($arg_array || $arg_array != 0)            {                $where  .= " and classid = '$arg_array'";            }            //数据排序            $order_str = "id asc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->purchasedetailed->find_all($where,'id,category,size,grade,density,lacetype,lowe,color,haircap,money,classid',$order_str,$start,$perpage);			foreach ($info_list as $key=>$value) 		    {				$category = $this->typeclass->read($value['category']);				$info_list[$key]['category'] = $category['title'];				$size = $this->typeclass->read($value['size']);				$info_list[$key]['size'] = $size['title'];				$grade = $this->typeclass->read($value['grade']);				$info_list[$key]['grade'] = $grade['title'];				if($value['density'] == 0)				{					$info_list[$key]['density'] = "未选择";				}				else				{				    $density = $this->typeclass->read($value['density']);				    $info_list[$key]['density'] = $density['title'];				}				if($value['lacetype'] == 0)				{					$info_list[$key]['lacetype'] = "未选择";				}				else				{				    $lacetype = $this->typeclass->read($value['lacetype']);				    $info_list[$key]['lacetype'] = $lacetype['title'];				}								$lowe = explode('|',trim($value['lowe'],'|'));				$lowex = "";				foreach ($lowe as $k=>$v) 		        {					$lower = $this->typeclass->read($v);					$lowex = $lowex.$lower['title'].",";				}				$info_list[$key]['lowe'] = $lowex;				$color = explode('|',trim($value['color'],'|'));				$colorx = "";				foreach ($color as $k=>$v) 		        {					$colorr = $this->typeclass->read($v);					$colorx = $colorx.$colorr['title'].",";				}				$info_list[$key]['color'] = $colorx;				if($value['haircap'])				{				    $haircap = explode('|',trim($value['haircap'],'|'));				    $haircapx = "";				    foreach ($haircap as $k=>$v) 		            {				    	$haircapr = $this->typeclass->read($v);				    	$haircapx = $haircapx.$haircapr['title'].",";				    }				    $info_list[$key]['haircap'] = $haircapx;			    }				$money = $this->pricedeploy->read($value['classid']);				if($money['money'] == 1)				{					$money = "CNY";				}				else				{					$money = "USD";				}				$info_list[$key]['money'] = $value['money']."(".$money.")";				            }		    $total = $this->purchasedetailed->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;		}		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();		$typeclass = $this->typeclass->find_all();		foreach ($typeclass as $key=>$value) 		{			if($value['classid'] == 16)			{				$category[] = $value;			}			if($value['classid'] == 14)			{				$size[] = $value;			}			if($value['classid'] == 13)			{				$grade[] = $value;			}			if($value['classid'] == 10)			{				$density[] = $value;			}			if($value['classid'] == 19)			{				$lacetype[] = $value;			}			if($value['classid'] == 15)			{				$lowe[] = $value;			}			if($value['classid'] == 8)			{				$color[] = $value;			}			if($value['classid'] == 6)			{				$haircap[] = $value;			}		}		$this->data['category'] = $category;		$this->data['size'] = $size;		$this->data['grade'] = $grade;		$this->data['density'] = $density;		$this->data['lacetype'] = $lacetype;		$this->data['lowe'] = $lowe;		$this->data['color'] = $color;		$this->data['haircap'] = $haircap;		if(isset($arg_array[0]))		{		    $arg_array = $arg_array[0];		}		else		{			$arg_array = "";		}		$this->data['arg_array'] = $arg_array;		$this->_Template('purchasedetailed',$this->data);	}	//添加	public function _add($arg_array)	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['category']))		{			$post['classid'] = $this->input->post('class',true);			$post['category'] = $this->input->post('category',true);			$post['size'] = $this->input->post('size',true);			$post['grade'] = $this->input->post('grade',true);			$post['density'] = $this->input->post('density',true);			$post['lacetype'] = $this->input->post('lacetype',true);			$post['money'] = $this->input->post('money',true);			$lowedata = $this->input->post('lowe',true);			$colordata = $this->input->post('color',true);			$haircapdata = $this->input->post('haircap',true);			$post['lowe'] = "|".str_replace(',','|',$lowedata);			$post['color'] = "|".str_replace(',','|',$colordata);			$post['haircap'] = "|".str_replace(',','|',$haircapdata);			if($this->purchasedetailed->insert($post))			{				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;			}       		else        	{           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;        	}		}		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();		$typeclass = $this->typeclass->find_all();		foreach ($typeclass as $key=>$value) 		{			if($value['classid'] == 16)			{				$category[] = $value;			}			if($value['classid'] == 14)			{				$size[] = $value;			}			if($value['classid'] == 13)			{				$grade[] = $value;			}			if($value['classid'] == 10)			{				$density[] = $value;			}			if($value['classid'] == 19)			{				$lacetype[] = $value;			}			if($value['classid'] == 15)			{				$lowe[] = $value;			}			if($value['classid'] == 8)			{				$color[] = $value;			}			if($value['classid'] == 6)			{				$haircap[] = $value;			}		}		$this->data['category'] = $category;		$this->data['size'] = $size;		$this->data['grade'] = $grade;		$this->data['density'] = $density;		$this->data['lacetype'] = $lacetype;		$this->data['lowe'] = $lowe;		$this->data['color'] = $color;		$this->data['haircap'] = $haircap;		$this->data['class'] = $arg_array[0];		$this->_Template('purchasedetailed_add',$this->data);	}	//修改	public function _edit($arg_array)	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['id']))		{			$id = $this->input->post('id',true);			$post['category'] = $this->input->post('category',true);			$post['size'] = $this->input->post('size',true);			$post['grade'] = $this->input->post('grade',true);			$post['density'] = $this->input->post('density',true);			$post['lacetype'] = $this->input->post('lacetype',true);			$post['money'] = $this->input->post('money',true);			$lowedata = $this->input->post('lowe',true);			$colordata = $this->input->post('color',true);			$haircap = $this->input->post('haircap',true);			$post['lowe'] = "|".str_replace(',','|',$lowedata);			$post['color'] = "|".str_replace(',','|',$colordata);			$post['haircap'] = "|".str_replace(',','|',$haircap);			if($this->purchasedetailed->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];		$purchasedetailed = $this->purchasedetailed->read($arg_array);		$this->data['purchasedetailed'] = $purchasedetailed;		$this->data['xlowe'] = $purchasedetailed['lowe'];		$this->data['xcolor'] = $purchasedetailed['color'];		$this->data['xhaircap'] = $purchasedetailed['haircap'];		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();		$typeclass = $this->typeclass->find_all();		foreach ($typeclass as $key=>$value) 		{			if($value['classid'] == 16)			{				$category[] = $value;			}			if($value['classid'] == 14)			{				$size[] = $value;			}			if($value['classid'] == 13)			{				$grade[] = $value;			}			if($value['classid'] == 10)			{				$density[] = $value;			}			if($value['classid'] == 19)			{				$lacetype[] = $value;			}			if($value['classid'] == 15)			{				$lowe[] = $value;			}			if($value['classid'] == 8)			{				$color[] = $value;			}			if($value['classid'] == 6)			{				$haircap[] = $value;			}		}		$this->data['category'] = $category;		$this->data['size'] = $size;		$this->data['grade'] = $grade;		$this->data['density'] = $density;		$this->data['lacetype'] = $lacetype;		$this->data['lowe'] = $lowe;		$this->data['color'] = $color;		$this->data['haircap'] = $haircap;		$this->_Template('purchasedetailed_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->purchasedetailed->remove($v);            }            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));		}    }	//rows	public function _rows()	{		$info_list = $this->purchasedetailed->find_all();		foreach ($info_list as $key=>$value) 		{					}    }}
 |