| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Evaluate extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_evaluate','evaluate');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'add')//添加        {             $this->_add();        }		else		{			 $this->_index();		}    }	//管理	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);			$shop = $this->input->post('shop',true);			$orderinfo = $this->input->post('orderinfo',true);			$name = $this->input->post('name',true);			$grade = $this->input->post('grade',true);			$where = "1=1";			if($shop)            {                $where  .= " and shop = '$shop'";            }			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($name)            {                $where  .= " and name = '$name'";            }			if($grade != "")            {                $where  .= " and grade = '$grade'";            }            //数据排序            $order_str = "id desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->evaluate->find_all($where,'id,shopname,shopid,orderinfo,name,grade,content,time',$order_str,$start,$perpage);			//格式化数据            foreach ($info_list as $key=>$value) 		    {				if($value['grade'] == 0)				{					$info_list[$key]['grade'] = "未评价";				}				else				{					$info_list[$key]['grade'] = $value['grade']."星";				}				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);            }		    $total = $this->evaluate->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('evaluate',$this->data);	}	//添加	public function _add()	{		$post = $this->input->post(NULL, TRUE);		if(isset($post['grade']))		{			$post['grade'] = $this->input->post('grade',true);			$post['content'] = $this->input->post('content',true);			/** 接口提交			if($this->evaluate->insert($post))        	{         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;       	 	}       		else        	{           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;        	}			**/		}		$this->_Template('evaluate_add',$this->data);	}}
 |