| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Orderurl extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_typeclass','typeclass');		$this->load->_model('Model_orderurl','orderurl');		$this->load->_model('Model_express','express');		$this->load->_model('Model_warehouse','warehouse');		$this->load->_model('Model_shop','shop');		$this->load->_model('Model_fullorderexcel','fullorderexcel');		$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 == 'order')//修改        {             $this->_order();        }		else		{			 $this->_index();		}    }		public function _index()	{		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user 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);			$url = $this->input->post('url',true);			$title = $this->input->post('title',true);			$where = "(".rtrim($fgshop,'or').")";            //数据排序            $order_str = "id asc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }			if($shop)			{				$where .= " and shop = '$shop'";			}			if($title)			{				$where .= " and title like '%$title%'";			}			if($url)			{				$where .= " and url like '%$url%'";			}            //取得信息列表            $info_list = $this->orderurl->find_all($where,'id,title,url',$order_str,$start,$perpage);		    $total = $this->orderurl->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('orderurl',$this->data);	}				public function _order()	{		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user as $value) 		    {				$sid .= " id = ".$value." or";			}		}		else		{			echo "请重新登录";		}		$post = $this->input->post(NULL, TRUE);		if(isset($post['page']))  		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$warehouse = $this->input->post('warehouse',true);			$xztime = $this->input->post('xztime',true);			$timetk = $this->input->post('timetkk',true);			$timetj = $this->input->post('timetjj',true);			$shop = $this->input->post('shop',true);			$source = $this->input->post('source',true);			$orderinfo = $this->input->post('orderinfo',true);			$number = $this->input->post('number',true);			$sfxh = $this->input->post('sfxh',true);			$express = $this->input->post('express',true);			$waybill = $this->input->post('waybill',true);			$library = $this->input->post('library',true);			$country = $this->input->post('country',true);			$so = $this->input->post('so',true);			$libraryconfirm = $this->input->post('libraryconfirm',true);			$print = $this->input->post('print',true);			$state = $this->input->post('state',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			/**			$sj = $this->input->post('sj',true);			if($sj)			{				$sj = $this->input->post('sj',true);			}			else			{				$sj = "fullorder";			}			**/			$sj = "fullorder";			$where = "mergeid = 0";			if($warehouse)            {                $where  .= " and type = '$warehouse'";            }			if($timetk && $timetj)            {                $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";            }			if($orderinfo)            {                $where  .= " and orderinfo = '$orderinfo'";            }			if($number)            {                $where  .= " and number = '$number'";            }			if($express)            {                $where  .= " and express = '$express'";            }			if($waybill)            {                $where  .= " and waybill = '$waybill'";            }			if($library)            {                $where  .= " and library = '$library'";            }			if($print)            {                $where  .= " and print = '$print'";            }			if($libraryconfirm)            {                $where .= " and libraryconfirm = '$libraryconfirm'";            }			if($state)            {                $where .= " and state = '$state'";            }			if($shop)            {                $where .= " and shop = '$shop'";            }			if($country)            {                $where .= " and country = '$country'";            }			if($sfxh != '')            {                $where .= " and sfxh = '$sfxh'";            }			if($so)            {                $where  .= " and shipremarks like '%$so%'";            }			if($source)            {				if($source == '2d')				{					$where  .= " and source >= '2'";				}				else				{                    $where  .= " and source = '$source'";				}            }			if(isset($_SESSION['api']))		        {			        foreach ($user as $value) 		            {			        	$fgshop .= " shop = ".$value." or";			        }					$where .= " and (".rtrim($fgshop,'or').")";		        }            //数据排序            $order_str = "librarytime desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);			 //格式化数据            foreach ($info_list as $key=>$value) 		    {				$shop = $this->shop->read($value['shop']);				$info_list[$key]['shop'] = $shop['shopname'];				$express = $this->express->read($value['express']);				$info_list[$key]['express'] = $express['servicename'];				$warehouse = $this->warehouse->read($value['type']);				$info_list[$key]['type'] = $warehouse['title'];				if($value['librarytime'] == '0')				{					$info_list[$key]['librarytime'] = '<em class="t"></em>';				}				else				{					$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';				}            }		    $total = $this->$sj->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->data['express'] = $this->express->find_all();		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;		$this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板		$this->_Template('orderurl_order',$this->data);	}		//添加	public function _add()	{		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user as $value) 		    {				$sid .= " id = ".$value." or";			}		}		$post = $this->input->post(NULL, TRUE);		if(isset($post['url']))		{			$d = $this->orderurl->get_url($post['url']);			if($d)			{				echo json_encode(array('msg'=>'已有此链接','success'=>false));exit;			}			if($this->orderurl->insert($post))        	{         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;       	 	}       		else        	{           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;        	}		}		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;		$this->_Template('orderurl_add',$this->data);	}	//修改	public function _edit($arg_array)	{		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user as $value) 		    {				$sid .= " id = ".$value." or";			}		}		$post = $this->input->post(NULL, TRUE);		if(isset($post['id']))		{			$id = $this->input->post('id',true);			if($this->orderurl->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];		$orderurl = $this->orderurl->read($arg_array);		$this->data['orderurl'] = $orderurl;		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;		$this->_Template('orderurl_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->orderurl->remove($v);            }            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));		}    }}
 |