| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Express extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_express','express');
 
- 		$this->load->_model('Model_service','service');
 
- 		$this->load->_model('Model_typeclass','typeclass');
 
- 		$this->load->_model('Model_describecode','describecode');
 
- 	}
 
- 	//定义方法的调用规则 获取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 == 'rows')//获取数据
 
-         {
 
-              $this->_rows();
 
-         }
 
- 		else if($arg == 'describecode')//修改describecode数据
 
-         {
 
-              $this->_describecode();
 
-         }
 
- 		else if($arg == 'packing')//修改packing数据
 
-         {
 
-              $this->_packing();
 
-         }
 
- 		else if($arg == 'read')
 
-         {
 
-              $this->_read();
 
-         }
 
- 		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);
 
- 			$servicename = $this->input->post('servicename',true);
 
- 			$off = $this->input->post('off',true);
 
- 			$where = "1=1 ";
 
- 			if($servicename)
 
-             {
 
-                 $where  .= " and servicename like '%$servicename%'";
 
-             }
 
- 			if($off != '')
 
-             {
 
-                 $where  .= " and off = '$off'";
 
-             }
 
-             //数据排序
 
-             $order_str = "idsort desc";
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
-             //取得信息列表
 
-             $info_list = $this->express->find_all($where,'id,servicename,title,url,iscode,aecode,printcode,cxcode,type,out,addresssize,yjtime,off,idsort',$order_str,$start,$perpage);
 
- 			foreach ($info_list as $k=>$v) 
 
- 		    {
 
- 				if($v['type'] == '1')
 
- 				{
 
- 					$info_list[$k]['type'] = '运单';
 
- 				}
 
- 				else if($v['type'] == '2')
 
- 				{
 
- 					$info_list[$k]['type'] = '发货单';
 
- 				}
 
- 				else if($v['type'] == '3')
 
- 				{
 
- 					$info_list[$k]['type'] = '不打印单据';
 
- 				}
 
- 				if($v['out'] == '1')
 
- 				{
 
- 					$info_list[$k]['out'] = '运单';
 
- 				}
 
- 				else if($v['out'] == '2')
 
- 				{
 
- 					$info_list[$k]['out'] = '发货单';
 
- 				}
 
- 				else if($v['out'] == '3')
 
- 				{
 
- 					$info_list[$k]['out'] = '运单+发货单';
 
- 				}
 
- 				if($v['off'] == '0')
 
- 				{
 
- 					$info_list[$k]['off'] = '显示';
 
- 				}
 
- 				else if($v['off'] == '1')
 
- 				{
 
- 					$info_list[$k]['off'] = '隐藏';
 
- 				}
 
- 			}
 
- 			//格式化数据
 
- 		    $total = $this->express->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;
 
- 		}
 
- 		$class = $this->service->find_all();
 
- 		$this->data['class'] = $class;
 
- 		$this->_Template('express',$this->data);
 
- 	}
 
- 	//添加
 
- 	public function _add()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['title']))
 
- 		{
 
- 			$post['title'] = $this->input->post('title',true);
 
- 			$post['service'] = $this->input->post('service',true);
 
- 			$post['servicecode'] = $this->input->post('servicecode',true);
 
- 			$post['servicetitle'] = $this->input->post('servicetitle',true);
 
- 			$post['servicename'] = $this->input->post('servicename',true);
 
- 			//$post['account'] = $this->input->post('account',true);
 
- 			//$post['billweight'] = $this->input->post('billweight',true);
 
- 			//$post['often'] = $this->input->post('often',true);
 
- 			$post['url'] = $this->input->post('url',true);
 
- 			$post['type'] = $this->input->post('type',true);
 
- 			$post['ioss'] = $this->input->post('ioss',true);
 
- 			//$post['freight'] = $this->input->post('freight',true);
 
- 			//$post['ordername'] = $this->input->post('ordername',true);
 
- 			//$post['slip'] = $this->input->post('slip',true);
 
- 			//$post['deliver'] = $this->input->post('deliver',true);
 
- 			$packing = $this->input->post('packing',true);
 
- 			$describecode = $this->input->post('describecode',true);
 
- 			if($packing != NULL)
 
- 			{
 
- 				$pnum = array();
 
- 				$packingdata = explode('|',rtrim($packing,'|'));
 
-                 foreach ($packingdata as $k=>$v) 
 
- 		        {
 
- 				    $rows = explode(',',rtrim($v,','));
 
- 					$packingpost['classid'] = 1;
 
- 					$packingpost['model'] = $rows[0];
 
- 			        $packingpost['weightend'] = $rows[1];
 
- 			        $packingpost['weight'] = $rows[2];
 
- 					$packingpost['time'] = time().rand(1000,9999);
 
- 					if($this->packing->insert($packingpost))
 
- 					{
 
- 						$pnum[] = $packingpost['time'];
 
- 					}
 
- 					
 
-                 }
 
- 			    $post['packing'] = "|";
 
- 				foreach ($pnum as $k=>$v) 
 
- 		        {
 
- 				    $pdata = $this->packing->get_time($v);
 
- 				    $post['packing'] = $post['packing'].$pdata['id']."|";
 
- 			    }
 
- 			}
 
- 			if($describecode != NULL)
 
- 			{
 
- 				$dnum = array();
 
- 				$describecodedata = explode('|',rtrim($describecode,'|'));
 
-                 foreach ($describecodedata as $k=>$v) 
 
- 		        {
 
- 				    $rows = explode(',',rtrim($v,','));
 
- 					$describecodepost['product'] = $rows[0];
 
- 			        $describecodepost['expresscode'] = $rows[1];
 
- 					$describecodepost['time'] = time().rand(1000,9999);
 
- 					if($this->describecode->insert($describecodepost))
 
- 					{
 
- 						$dnum[] = $describecodepost['time'];
 
- 					}
 
-                 }
 
- 				$post['describecode'] = "|";
 
- 				foreach ($dnum as $k=>$v) 
 
- 		        {
 
- 				    $ddata = $this->describecode->get_time($v);
 
- 				    $post['describecode'] = $post['describecode'].$ddata['id']."|";
 
- 			    }
 
- 			}
 
- 			if($post['sbjz_min']*1 > $post['sbjz']*1){
 
- 				echo json_encode(array('msg'=>'最低申报价不能大于最高申报价!!!','success'=>false));exit;
 
- 			}
 
- 			if($post['shouldmoney_min']*1 > $post['shouldmoney']*1){
 
- 				echo json_encode(array('msg'=>'最低订单金额不能大于最高订单金额!!!','success'=>false));exit;
 
- 			}
 
- 			if($post['weight_limit_min']*1 > $post['weight_limit']*1){
 
- 				echo json_encode(array('msg'=>'最低快递限重不能大于最高快递限重!!!','success'=>false));exit;
 
- 			}
 
- 			if($this->express->insert($post))
 
-         	{
 
-          		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$class = $this->service->find_all("1=1",'*','title asc');
 
- 		$this->data['class'] = $class;
 
- 		$this->_Template('express_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['title'] = $this->input->post('title',true);
 
- 			$post['service'] = $this->input->post('service',true);
 
- 			$post['servicecode'] = $this->input->post('servicecode',true);
 
- 			$post['servicetitle'] = $this->input->post('servicetitle',true);
 
- 			$post['servicename'] = $this->input->post('servicename',true);
 
- 			//$post['account'] = $this->input->post('account',true);
 
- 			$post['billweight'] = $this->input->post('billweight',true);
 
- 			$post['often'] = $this->input->post('often',true);
 
- 			$post['url'] = $this->input->post('url',true);
 
- 			$post['type'] = $this->input->post('type',true);
 
- 			$post['freight'] = $this->input->post('freight',true);
 
- 			$post['ordername'] = $this->input->post('ordername',true);
 
- 			$post['slip'] = $this->input->post('slip',true);
 
- 			$post['deliver'] = $this->input->post('deliver',true);
 
- 			$post['ioss'] = $this->input->post('ioss',true);
 
- 			$packingsun = $this->input->post('packing',true);
 
- 			$describecodesun = $this->input->post('describecode',true);
 
- 			$express = $this->express->read($id);
 
- 			$packingmoon="";$describecodemoon="";
 
- 			if($packingsun != NULL)
 
- 			{
 
- 				$pnum = array();
 
- 				$packingdata = explode('|',rtrim($packingsun,'|'));
 
-                 foreach ($packingdata as $k=>$v) 
 
- 		        {
 
- 				    $rows = explode(',',rtrim($v,','));
 
- 					$packingpost['classid'] = 1;
 
- 					$packingpost['model'] = $rows[0];
 
- 			        $packingpost['weightend'] = $rows[1];
 
- 			        $packingpost['weight'] = $rows[2];
 
- 					$packingpost['time'] = time().rand(1000,9999);
 
- 					if($this->packing->insert($packingpost))
 
- 					{
 
- 						$pnum[] = $packingpost['time'];
 
- 					}
 
- 					
 
-                 }
 
- 				foreach ($pnum as $k=>$v) 
 
- 		        {
 
- 				    $pdata = $this->packing->get_time($v);
 
- 				    $packingmoon = $packingmoon.$pdata['id']."|";
 
- 			    }
 
- 			}
 
- 			if($describecodesun != NULL)
 
- 			{
 
- 				$dnum = array();
 
- 				$describecodedata = explode('|',rtrim($describecodesun,'|'));
 
-                 foreach ($describecodedata as $k=>$v) 
 
- 		        {
 
- 				    $rows = explode(',',rtrim($v,','));
 
- 					$describecodepost['product'] = $rows[0];
 
- 			        $describecodepost['expresscode'] = $rows[1];
 
- 					$describecodepost['time'] = time().rand(1000,9999);
 
- 					if($this->describecode->insert($describecodepost))
 
- 					{
 
- 						$dnum[] = $describecodepost['time'];
 
- 					}
 
-                 }
 
- 				foreach ($dnum as $k=>$v) 
 
- 		        {
 
- 				    $ddata = $this->describecode->get_time($v);
 
- 				    $describecodemoon = $describecodemoon.$ddata['id']."|";
 
- 			    }
 
- 			}
 
- 			if($post['sbjz_min']*1 > $post['sbjz']*1){
 
- 				echo json_encode(array('msg'=>'最低申报价不能大于最高申报价!!!','success'=>false));exit;
 
- 			}
 
- 			if($post['shouldmoney_min']*1 > $post['shouldmoney']*1){
 
- 				echo json_encode(array('msg'=>'最低订单金额不能大于最高订单金额!!!','success'=>false));exit;
 
- 			}
 
- 			if($post['weight_limit_min']*1 > $post['weight_limit']*1){
 
- 				echo json_encode(array('msg'=>'最低快递限重不能大于最高快递限重!!!','success'=>false));exit;
 
- 			}
 
- 			$post['packing'] = $express['packing'].$packingmoon;
 
- 			$post['describecode'] = $express['describecode'].$describecodemoon;
 
- 			if($this->express->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];
 
- 		$express = $this->express->read($arg_array);
 
- 		$class = $this->service->find_all("1=1",'*','title asc');
 
- 		$this->data['class'] = $class;
 
- 		$this->data['express'] = $express;
 
- 		$pdata = array();$ddata = array();
 
- 		if($express['packing'])
 
- 		{
 
- 		    $packing = $express['packing'];
 
- 		    $packing = explode('|',trim($packing,'|'));
 
- 		    foreach ($packing as $k=>$v) 
 
- 		    {
 
- 		    	$pdata[] = $this->packing->read($v);
 
-             }
 
- 		}
 
- 		if($express['describecode'])
 
- 		{
 
- 		    $describecode = $express['describecode'];
 
- 		    $describecode = explode('|',trim($describecode,'|'));
 
- 		    foreach ($describecode as $k=>$v) 
 
- 		    {
 
- 			    $ddata[] = $this->describecode->read($v);
 
-             }
 
- 			foreach ($ddata as $k=>$v) 
 
- 		    {
 
- 			    $sdata = $this->typeclass->read($v['product']);
 
- 			    $ddata[$k]['producttitle'] = $sdata['title'];
 
-             }
 
- 		}
 
- 		$this->data['pdata'] = $pdata;
 
- 		$this->data['ddata'] = $ddata;
 
- 		$this->_Template('express_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->express->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
-     }
 
- 	//修改数据
 
- 	public function _describecode()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['s']))  
 
- 		{
 
-             $s = $this->input->post('s');
 
- 			$id= $this->input->post('id');
 
- 			$express = $this->express->read($id);
 
-             $describecode = str_replace('|'.$s.'|','|',$express['describecode']);
 
- 			if($describecode == "|")
 
- 			{
 
- 				$describecode = "";
 
- 			}
 
-             if($this->express->save(array('describecode'=>$describecode),$id))//写入删除后的数据
 
- 			{
 
- 				 echo json_encode(array('success'=>true));exit;
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
 
- 			}
 
- 		}
 
-     }
 
- 	//修改数据
 
- 	public function _packing()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['s']))  
 
- 		{
 
-             $s = $this->input->post('s');
 
- 			$id= $this->input->post('id');
 
- 			$express = $this->express->read($id);
 
-             $packing = str_replace('|'.$s.'|','|',$express['packing']);
 
- 			if($packing == "|")
 
- 			{
 
- 				$packing = "";
 
- 			}
 
-             if($this->express->save(array('packing'=>$packing),$id))//写入删除后的数据
 
- 			{
 
- 				 echo json_encode(array('success'=>true));exit;
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
 
- 			}
 
- 		}
 
-     }
 
- 	
 
- 	public function _read()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['id']))  
 
- 		{
 
- 			$id = $this->input->post('id');
 
- 			$data = $this->express->read($id);
 
- 			if(isset($data['id']) && $data['xxts'] != '')
 
- 			{
 
- 				echo json_encode(array('msg'=>$data['xxts'],'success'=>true));exit;
 
- 			}
 
- 			else
 
- 			{
 
- 				echo json_encode(array('success'=>false));exit;
 
- 			}
 
- 		}
 
- 	}
 
- }
 
 
  |