123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Caiwusfh extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_caiwusfh','caiwusfh');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'add')//添加
- {
- $this->_add();
- }
- else if($arg == 'edit')
- {
- $this->_edit($arg_array);
- }
- 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);
- $orderno = $this->input->post('orderno',true);
- $ht = $this->input->post('ht',true);
- $sfh = $this->input->post('sfh',true);
- $apptype = $this->input->post('apptype',true);
- $appstatus = $this->input->post('appstatus',true);
- $charge = $this->input->post('charge',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and createtime > '$timetk' and createtime < '$timetj'";
- }
- if($orderno)
- {
- $where .= " and orderno = '$orderno'";
- }
- if($ht)
- {
- $where .= " and ht = '$ht'";
- }
- if($sfh)
- {
- $where .= " and sfh = '$sfh'";
- }
- if($apptype)
- {
- $where .= " and apptype = '$apptype'";
- }
- if($appstatus)
- {
- $where .= " and appstatus = '$appstatus'";
- }
- if($charge)
- {
- $where .= " and charge = '$charge'";
- }
- //数据排序
- $order_str = "id asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->caiwusfh->find_all($where,'id,orderno,ht,sfh,apptype,appstatus,charge,createtime',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- if($value['sfh'] == '1')
- {
- $info_list[$key]['sfh'] = '付汇';
- }
- else if($value['sfh'] == '2')
- {
- $info_list[$key]['sfh'] = '收汇';
- }
- if($value['apptype'] == '1')
- {
- $info_list[$key]['apptype'] = '新增';
- }
- else if($value['apptype'] == '2')
- {
- $info_list[$key]['apptype'] = '变更';
- }
- else if($value['apptype'] == '3')
- {
- $info_list[$key]['apptype'] = '删除';
- }
- if($value['appstatus'] == '1')
- {
- $info_list[$key]['appstatus'] = '暂存';
- }
- else if($value['appstatus'] == '2')
- {
- $info_list[$key]['appstatus'] = '申报';
- }
- $info_list[$key]['createtime'] = date('Y-m-d h:i:s',$value['createtime']);
- }
- $total = $this->caiwusfh->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('caiwusfh',$this->data);
- }
- //添加
- public function _add()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['createtime']))
- {
- $createtime = $this->input->post('createtime',true);
- $post['createtime'] = strtotime($createtime);
-
- $accountingdate = $this->input->post('accountingdate',true);
- $post['accountingdate'] = strtotime($accountingdate);
- if($this->caiwusfh->insert($post))
- {
- echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
- }
- }
- $this->_Template('caiwusfh_add',$this->data);
- }
-
- public function _edit($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $createtime = $this->input->post('createtime',true);
- $post['createtime'] = strtotime($createtime);
- $accountingdate = $this->input->post('accountingdate',true);
- $post['accountingdate'] = strtotime($accountingdate);
- if($this->caiwusfh->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];
- $caiwusfh = $this->caiwusfh->read($arg_array);
- $this->data['caiwusfh'] = $caiwusfh;
- $this->_Template('caiwusfh_edit',$this->data);
- }
- }
|