Reset.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Reset extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_reset','fullreset');
  7. $this->load->_model('Model_shop','shop');
  8. }
  9. //定义方法的调用规则 获取URI第二段值
  10. public function _remap($arg,$arg_array)
  11. {
  12. if($arg == 'edit')
  13. {
  14. $this->_edit($arg_array);
  15. }
  16. else
  17. {
  18. $this->_index();
  19. }
  20. }
  21. public function _index()
  22. {
  23. if(isset($_SESSION['api']))
  24. {
  25. $user = $this->user->get_api($_SESSION['api']);
  26. $usp = $user;
  27. $fgshop = "";$sid = "";
  28. $usersp = explode('|',trim($user['shop'],'|'));
  29. foreach ($usersp as $value)
  30. {
  31. $fgshop .= " shop = ".$value." or";
  32. $sid .= " id = ".$value." or";
  33. }
  34. }
  35. $post = $this->input->post(NULL, TRUE);
  36. if(isset($post['page']))
  37. {
  38. $page = $this->input->post('page',true);
  39. $perpage = $this->input->post('perpage',true);
  40. $shop = $this->input->post('shop',true);
  41. $orderinfo = $this->input->post('orderinfo',true);
  42. $number = $this->input->post('number',true);
  43. $where = "1=1 ";
  44. if($shop)
  45. {
  46. $where .= " and shop = '$shop'";
  47. }
  48. if($orderinfo)
  49. {
  50. $where .= " and orderinfo = '$orderinfo'";
  51. }
  52. if($number)
  53. {
  54. $where .= " and number = '$number'";
  55. }
  56. //数据排序
  57. $order_str = "id desc";
  58. if(empty($page))
  59. {
  60. $start = 0;
  61. $perpage = 1;
  62. }
  63. else
  64. {
  65. $start = ($page - 1)*$perpage;
  66. }
  67. //取得信息列表
  68. $info_list = $this->fullreset->find_all($where,'id,shop,orderinfo,number,warehouse,state,express,time',$order_str,$start,$perpage);
  69. //格式化数据
  70. foreach ($info_list as $key=>$value)
  71. {
  72. $shop = $this->shop->read($value['shop']);
  73. $info_list[$key]['shop'] = $shop['shopname'];
  74. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  75. }
  76. $total = $this->fullreset->find_count($where);
  77. $pagenum = ceil($total/$perpage);
  78. $over = $total-($start+$perpage);
  79. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  80. echo json_encode($rows);exit;
  81. }
  82. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  83. $this->data['wlshop'] = $wlshop;
  84. $this->_Template('reset',$this->data);
  85. }
  86. public function _edit($arg_array)
  87. {
  88. $arg_array = $arg_array[0];$fpdata = array();
  89. $reset = $this->fullreset->read($arg_array);
  90. $shop = $this->shop->read($reset['shop']);
  91. $reset['shop'] = $shop['shopname'];
  92. $this->data['reset'] = $reset;
  93. if(stripos($reset['fpdata'],';') !== false)
  94. {
  95. $fpdata = explode(';',rtrim($reset['fpdata'],';'));
  96. foreach ($fpdata as $k=>$v)
  97. {
  98. $fpdata[$k] = explode('|',$v);
  99. }
  100. }
  101. $this->data['fpdata'] = $fpdata;
  102. $this->_Template('reset_edit',$this->data);
  103. }
  104. }