| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Reset extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_reset','fullreset');		$this->load->_model('Model_shop','shop');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'edit')        {             $this->_edit($arg_array);        }		else		{			$this->_index();		}    }		public function _index()	{		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $usersp = explode('|',trim($user['shop'],'|'));			foreach ($usersp as $value) 		    {				$fgshop .= " shop = ".$value." or";				$sid .= " id = ".$value." or";			}		}		$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);			$number = $this->input->post('number',true);			$where = "1=1 ";			if($shop)            {                $where  .= " and shop = '$shop'";            }			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($number)            {                $where  .= " and number = '$number'";            }            //数据排序            $order_str = "id desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->fullreset->find_all($where,'id,shop,orderinfo,number,warehouse,state,express,time',$order_str,$start,$perpage);			 //格式化数据            foreach ($info_list as $key=>$value) 		    {				$shop = $this->shop->read($value['shop']);				$info_list[$key]['shop'] = $shop['shopname'];				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);            }		    $total = $this->fullreset->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;		}		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;        $this->_Template('reset',$this->data);	}	public function _edit($arg_array)	{		$arg_array = $arg_array[0];$fpdata = array();		$reset = $this->fullreset->read($arg_array);		$shop = $this->shop->read($reset['shop']);		$reset['shop'] = $shop['shopname'];		$this->data['reset'] = $reset;		if(stripos($reset['fpdata'],';') !== false)		{		    $fpdata = explode(';',rtrim($reset['fpdata'],';'));		    foreach ($fpdata as $k=>$v) 		    {			    $fpdata[$k] = explode('|',$v);            }		}		$this->data['fpdata'] = $fpdata;		$this->_Template('reset_edit',$this->data);	}}
 |