Caiwusfh.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Caiwusfh extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_caiwusfh','caiwusfh');
  7. }
  8. //定义方法的调用规则 获取URI第二段值
  9. public function _remap($arg,$arg_array)
  10. {
  11. if($arg == 'add')//添加
  12. {
  13. $this->_add();
  14. }
  15. else if($arg == 'edit')
  16. {
  17. $this->_edit($arg_array);
  18. }
  19. else
  20. {
  21. $this->_index();
  22. }
  23. }
  24. public function _index()
  25. {
  26. $post = $this->input->post(NULL, TRUE);
  27. if(isset($post['page']))
  28. {
  29. $page = $this->input->post('page',true);
  30. $perpage = $this->input->post('perpage',true);
  31. $orderno = $this->input->post('orderno',true);
  32. $ht = $this->input->post('ht',true);
  33. $sfh = $this->input->post('sfh',true);
  34. $apptype = $this->input->post('apptype',true);
  35. $appstatus = $this->input->post('appstatus',true);
  36. $charge = $this->input->post('charge',true);
  37. $timetk = $this->input->post('timetk',true);
  38. $timetj = $this->input->post('timetj',true);
  39. $timetk = strtotime($timetk);
  40. $timetj = strtotime($timetj);
  41. $where = "1=1 ";
  42. if($timetk && $timetj)
  43. {
  44. $where .= " and createtime > '$timetk' and createtime < '$timetj'";
  45. }
  46. if($orderno)
  47. {
  48. $where .= " and orderno = '$orderno'";
  49. }
  50. if($ht)
  51. {
  52. $where .= " and ht = '$ht'";
  53. }
  54. if($sfh)
  55. {
  56. $where .= " and sfh = '$sfh'";
  57. }
  58. if($apptype)
  59. {
  60. $where .= " and apptype = '$apptype'";
  61. }
  62. if($appstatus)
  63. {
  64. $where .= " and appstatus = '$appstatus'";
  65. }
  66. if($charge)
  67. {
  68. $where .= " and charge = '$charge'";
  69. }
  70. //数据排序
  71. $order_str = "id asc";
  72. if(empty($page))
  73. {
  74. $start = 0;
  75. $perpage = 1;
  76. }
  77. else
  78. {
  79. $start = ($page - 1)*$perpage;
  80. }
  81. //取得信息列表
  82. $info_list = $this->caiwusfh->find_all($where,'id,orderno,ht,sfh,apptype,appstatus,charge,createtime',$order_str,$start,$perpage);
  83. foreach ($info_list as $key=>$value)
  84. {
  85. if($value['sfh'] == '1')
  86. {
  87. $info_list[$key]['sfh'] = '付汇';
  88. }
  89. else if($value['sfh'] == '2')
  90. {
  91. $info_list[$key]['sfh'] = '收汇';
  92. }
  93. if($value['apptype'] == '1')
  94. {
  95. $info_list[$key]['apptype'] = '新增';
  96. }
  97. else if($value['apptype'] == '2')
  98. {
  99. $info_list[$key]['apptype'] = '变更';
  100. }
  101. else if($value['apptype'] == '3')
  102. {
  103. $info_list[$key]['apptype'] = '删除';
  104. }
  105. if($value['appstatus'] == '1')
  106. {
  107. $info_list[$key]['appstatus'] = '暂存';
  108. }
  109. else if($value['appstatus'] == '2')
  110. {
  111. $info_list[$key]['appstatus'] = '申报';
  112. }
  113. $info_list[$key]['createtime'] = date('Y-m-d h:i:s',$value['createtime']);
  114. }
  115. $total = $this->caiwusfh->find_count($where);
  116. $pagenum = ceil($total/$perpage);
  117. $over = $total-($start+$perpage);
  118. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  119. echo json_encode($rows);exit;
  120. }
  121. $this->_Template('caiwusfh',$this->data);
  122. }
  123. //添加
  124. public function _add()
  125. {
  126. $post = $this->input->post(NULL, TRUE);
  127. if(isset($post['createtime']))
  128. {
  129. $createtime = $this->input->post('createtime',true);
  130. $post['createtime'] = strtotime($createtime);
  131. $accountingdate = $this->input->post('accountingdate',true);
  132. $post['accountingdate'] = strtotime($accountingdate);
  133. if($this->caiwusfh->insert($post))
  134. {
  135. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  136. }
  137. else
  138. {
  139. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  140. }
  141. }
  142. $this->_Template('caiwusfh_add',$this->data);
  143. }
  144. public function _edit($arg_array)
  145. {
  146. $post = $this->input->post(NULL, TRUE);
  147. if(isset($post['id']))
  148. {
  149. $id = $this->input->post('id',true);
  150. $createtime = $this->input->post('createtime',true);
  151. $post['createtime'] = strtotime($createtime);
  152. $accountingdate = $this->input->post('accountingdate',true);
  153. $post['accountingdate'] = strtotime($accountingdate);
  154. if($this->caiwusfh->save($post,$id))
  155. {
  156. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  157. }
  158. else
  159. {
  160. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  161. }
  162. }
  163. $arg_array = $arg_array[0];
  164. $caiwusfh = $this->caiwusfh->read($arg_array);
  165. $this->data['caiwusfh'] = $caiwusfh;
  166. $this->_Template('caiwusfh_edit',$this->data);
  167. }
  168. }