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); } }