Whenter.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whenter extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_productprice','productprice');
  9. }
  10. //定义方法的调用规则 获取URI第二段值
  11. public function _remap($arg,$arg_array)
  12. {
  13. if($arg == 'add')//在库标签
  14. {
  15. $this->_add();
  16. }
  17. else
  18. {
  19. $this->_index();
  20. }
  21. }
  22. //管理
  23. public function _index()
  24. {
  25. $post = $this->input->post(NULL, TRUE);
  26. if(isset($post['page']))
  27. {
  28. $page = $this->input->post('page',true);
  29. $perpage = $this->input->post('perpage',true);
  30. $sku = $this->input->post('sku',true);
  31. $warehouse = $this->input->post('warehouse',true);
  32. $supplier = $this->input->post('supplier',true);
  33. $label = $this->input->post('label',true);
  34. $orderinfo = $this->input->post('orderinfo',true);
  35. $waybill = $this->input->post('waybill',true);
  36. $category = $this->input->post('category',true);
  37. $size = $this->input->post('size',true);
  38. $grade = $this->input->post('grade',true);
  39. $color = $this->input->post('color',true);
  40. $lowe = $this->input->post('lowe',true);
  41. $type = $this->input->post('type',true);
  42. $productweight = $this->input->post('productweight',true);
  43. $where = "1=1 ";
  44. if($sku)
  45. {
  46. $where .= " and sku = '$sku'";
  47. }
  48. if($warehouse)
  49. {
  50. $where .= " and warehouse = '$warehouse'";
  51. }
  52. if($supplier)
  53. {
  54. $where .= " and supplier = '$supplier'";
  55. }
  56. if($label)
  57. {
  58. $where .= " and label = '$label'";
  59. }
  60. if($orderinfo)
  61. {
  62. $where .= " and orderinfo = '$orderinfo'";
  63. }
  64. if($waybill)
  65. {
  66. $where .= " and waybill = '$waybill'";
  67. }
  68. if($category || $size || $grade || $color || $lowe || $productweight)
  69. {
  70. $where .= " and title like '%$category.$grade.$size.$color.$lowe.$productweight%'";
  71. }
  72. if($type)
  73. {
  74. $where .= " and type = '$type'";
  75. }
  76. //数据排序
  77. $order_str = "id asc";
  78. if(empty($page))
  79. {
  80. $start = 0;
  81. $perpage = 1;
  82. }
  83. else
  84. {
  85. $start = ($page - 1)*$perpage;
  86. }
  87. //取得信息列表
  88. $info_list = $this->whenter->find_all($where,'id,supplier,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill',$order_str,$start,$perpage);
  89. foreach ($info_list as $key=>$value)
  90. {
  91. $warehouse = $this->warehouse->read($value['warehouse']);
  92. $info_list[$key]['warehouse'] = $warehouse['title'];
  93. $supplier = $this->productprice->read($value['supplier']);
  94. $info_list[$key]['supplier'] = $supplier['supplier'];
  95. if($value['enter'] != 0)
  96. {
  97. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  98. }
  99. else
  100. {
  101. $info_list[$key]['enter'] = "";
  102. }
  103. if($value['outk'] != 0)
  104. {
  105. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  106. }
  107. else
  108. {
  109. $info_list[$key]['outk'] = "";
  110. }
  111. if($value['printing'] != 0)
  112. {
  113. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  114. }
  115. else
  116. {
  117. $info_list[$key]['printing'] = "";
  118. }
  119. if($value['orderinfo'] == 0)
  120. {
  121. $info_list[$key]['orderinfo'] = "";
  122. }
  123. if($value['waybill'] == 0)
  124. {
  125. $info_list[$key]['waybill'] = "";
  126. }
  127. }
  128. $total = $this->whenter->find_count($where);
  129. $pagenum = ceil($total/$perpage);
  130. $over = $total-($start+$perpage);
  131. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  132. echo json_encode($rows);exit;
  133. }
  134. $pr = $this->productprice->find_all();
  135. $this->data['pr'] = $pr;
  136. $this->_Template('whenter',$this->data);
  137. }
  138. //在库标签
  139. public function _add()
  140. {
  141. $post = $this->input->post(NULL, TRUE);
  142. if(isset($post['page']))
  143. {
  144. $page = $this->input->post('page',true);
  145. $perpage = $this->input->post('perpage',true);
  146. $warehouse = $this->input->post('warehouse',true);
  147. $label = $this->input->post('label',true);
  148. $productweight = $this->input->post('productweight',true);
  149. $where = "1=1 and type = 2";
  150. if($warehouse)
  151. {
  152. $where .= " and warehouse = '$warehouse'";
  153. }
  154. if($label)
  155. {
  156. $where .= " and label = '$label'";
  157. }
  158. //数据排序
  159. $order_str = "id asc";
  160. if(empty($page))
  161. {
  162. $start = 0;
  163. $perpage = 1;
  164. }
  165. else
  166. {
  167. $start = ($page - 1)*$perpage;
  168. }
  169. //取得信息列表
  170. $info_list = $this->whenter->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  171. foreach ($info_list as $key=>$value)
  172. {
  173. if($value['enter'] != 0)
  174. {
  175. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  176. }
  177. else
  178. {
  179. $info_list[$key]['enter'] = "";
  180. }
  181. if($value['printing'] != 0)
  182. {
  183. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  184. }
  185. else
  186. {
  187. $info_list[$key]['printing'] = "";
  188. }
  189. }
  190. $total = $this->whenter->find_count($where);
  191. $pagenum = ceil($total/$perpage);
  192. $over = $total-($start+$perpage);
  193. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  194. echo json_encode($rows);exit;
  195. }
  196. $this->_Template('whenter_add',$this->data);
  197. }
  198. }