Whlabelfz.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. /**
  3. * 由于whlabel类下的代码太长了,决定以后非必要代码都放在whlabelfz类中,以便于管理。
  4. */
  5. class Whlabelfz extends Start_Controller
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->load->_model('Model_whlabel', 'whlabel');
  11. $this->load->_model('Model_warehouse', 'warehouse');
  12. $this->load->_model('Model_specialstock', 'specialstock');
  13. $this->load->_model('Model_logic_u9tools','logic_u9tools');
  14. $this->load->_model('Model_classid','classid');
  15. $this->load->_model('Model_typeclass','typeclass');
  16. $this->load->_model('Model_purchase', 'purchase');
  17. }
  18. //定义方法的调用规则 获取URI第二段值
  19. public function _remap($arg, $arg_array)
  20. {
  21. if ($arg == 'bqckexcel') //
  22. {
  23. //获取标签出库的按条件导出的excel
  24. $this->_bqck_excel();
  25. }
  26. if ($arg == 'bqrkexcel') //
  27. {
  28. //获取标签出库的按条件导出的excel
  29. $this->_bqrk_excel();
  30. }
  31. else {
  32. $this->_index();
  33. }
  34. }
  35. private function _index(){
  36. die('No direct script access allowed');
  37. }
  38. private function _bqck_excel(){
  39. if (isset($_GET['excel'])) {
  40. //统计时间
  41. $timetk = $this->input->get('timetk', true);
  42. $timetj = $this->input->get('timetj', true);
  43. $timetk = strtotime($timetk);
  44. $timetj = strtotime($timetj);
  45. $category = $this->input->get('category',true); //类目
  46. $size = $this->input->get('size',true);//长度
  47. $grade = $this->input->get('grade',true);//等级
  48. $color = $this->input->get('color',true);//颜色
  49. $lowe = $this->input->get('lowe',true);//曲度
  50. $sku = $this->input->get('sku',true);//sku
  51. $warehouse = $this->input->get('warehouse',true);//仓库
  52. $purchase = $this->input->get('purchase',true);//供应商
  53. $where = "state=1 ";
  54. if ($timetk && $timetj) {
  55. $where .= " and outk > '$timetk' and outk < '$timetj'";
  56. }
  57. if ($sku) {
  58. $where .= " and sku = '$sku'";
  59. }
  60. if ($warehouse) {
  61. $where .= " and warehouse = '$warehouse'";
  62. }
  63. if ($purchase) {
  64. $where .= " and purchase = '$purchase'";
  65. }
  66. if ($category) {
  67. $where .= " and features like '%-$category-%'";
  68. }
  69. if ($size) {
  70. $where .= " and features like '%-$size-%'";
  71. }
  72. if ($grade) {
  73. $where .= " and features like '%-$grade-%'";
  74. }
  75. if ($color) {
  76. $where .= " and features like '%-$color-%'";
  77. }
  78. if ($lowe) {
  79. $where .= " and features like '%-$lowe-%'";
  80. }
  81. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  82. $order_str = "outk desc";
  83. //取得信息列表
  84. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,outk,details', $order_str);
  85. $classid = $this->classid->sku();
  86. $tcall = $this->typeclass->find_all();
  87. foreach ($tcall as $v)
  88. {
  89. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  90. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  91. }
  92. $prc = array();
  93. $purchase = $this->purchase->find_all();
  94. foreach ($purchase as $k => $v) {
  95. $prc[$v['id']] = $v['title'];
  96. }
  97. foreach ($info_list as $key => $value) {
  98. $warehouse = $this->warehouse->read($value['warehouse']);
  99. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  100. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  101. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  102. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  103. if ($value['state'] == 0) {
  104. $info_list[$key]['state'] = "在库";
  105. } else if ($value['state'] == 1) {
  106. $info_list[$key]['state'] = "出库";
  107. } else if ($value['state'] == 2) {
  108. $info_list[$key]['state'] = "退库";
  109. } else if ($value['state'] == 3) {
  110. $info_list[$key]['state'] = "调拨中";
  111. } else if ($value['state'] == 4) {
  112. $info_list[$key]['state'] = "再加工";
  113. } else if ($value['state'] == 5) {
  114. $info_list[$key]['state'] = "维修中";
  115. } else if ($value['state'] == 6) {
  116. $info_list[$key]['state'] = "盘亏";
  117. } else if ($value['state'] == 7) {
  118. $info_list[$key]['state'] = "更换标签";
  119. } else if ($value['state'] == 8) {
  120. $info_list[$key]['state'] = "其它";
  121. } else if ($value['state'] == 9) {
  122. $info_list[$key]['state'] = "预设";
  123. } else if ($value['state'] == 10) {
  124. $info_list[$key]['state'] = "美店零售";
  125. }
  126. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  127. }
  128. //生成excel
  129. $filename = date("Y-m-d")."标签出库导出.xls";
  130. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  131. <head>
  132. <!--[if gte mso 9]><xml>
  133. <x:ExcelWorkbook>
  134. <x:ExcelWorksheets>
  135. <x:ExcelWorksheet>
  136. <x:Name>EXCEL</x:Name>
  137. <x:WorksheetOptions>
  138. <x:Print>
  139. <x:ValidPrinterInfo />
  140. </x:Print>
  141. </x:WorksheetOptions>
  142. </x:ExcelWorksheet>
  143. </x:ExcelWorksheets>
  144. </x:ExcelWorkbook>
  145. </xml>
  146. <![endif]-->
  147. </head><body>";
  148. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  149. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>出库时间</td><td>所在位置</td></tr>";
  150. foreach ($info_list as $key=>$value)
  151. {
  152. $str .= "<tr>";
  153. $str .= "<td>". $value['warehouse']. "</td>";
  154. $str .= "<td>". $value['purchase']. "</td>";
  155. $str .= "<td>". $value['sku']. "</td>";
  156. $str .= "<td>". $value['title']. "</td>";
  157. $str .= "<td>". $value['features']. "</td>";
  158. $str .= "<td>". $value['state']. "</td>";
  159. $str .= "<td>". $value['outk']. "</td>";
  160. $str .= "<td>". $value['details']. "</td>";
  161. $str .= "</tr>";
  162. }
  163. $str .= "</table></body></html>";
  164. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  165. header( "Content-type: application/octet-stream" );
  166. header( "Content-Disposition: attachment; filename=".$filename );
  167. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  168. header( "Pragma: no-cache" );
  169. header( "Expires: 0" );
  170. exit($str);
  171. }else{
  172. }
  173. }
  174. public function _bqrk_excel(){
  175. if (isset($_GET['excel'])) {
  176. $sku = $this->input->get('sku', true);
  177. $bs = $this->input->get('bs', true);
  178. $number = $this->input->get('number', true);
  179. $warehouse = $this->input->get('warehouse', true);
  180. $purchase = $this->input->get('purchase', true);
  181. $orderinfo = $this->input->get('orderinfo', true);
  182. $waybill = $this->input->get('waybill', true);
  183. $category = $this->input->get('category', true);
  184. $size = $this->input->get('size', true);
  185. $grade = $this->input->get('grade', true);
  186. $color = $this->input->get('color', true);
  187. $lowe = $this->input->get('lowe', true);
  188. $state = $this->input->get('state', true);
  189. $label = $this->input->get('label', true);
  190. $timetk = $this->input->get('ktime', true);
  191. $timetj = $this->input->get('jtime', true);
  192. $timetk = strtotime($timetk);
  193. $timetj = strtotime($timetj);
  194. $where = "1=1 ";
  195. if ($timetk && $timetj) {
  196. $where .= " and enter > '$timetk' and enter < '$timetj'";
  197. }
  198. if ($sku) {
  199. $where .= " and sku = '$sku'";
  200. }
  201. if ($bs != '') {
  202. $where .= " and bs = '$bs'";
  203. }
  204. if ($number) {
  205. $where .= " and number = '$number'";
  206. }
  207. if ($warehouse) {
  208. $where .= " and warehouse = '$warehouse'";
  209. }
  210. if ($purchase) {
  211. $where .= " and purchase = '$purchase'";
  212. }
  213. if ($orderinfo) {
  214. $where .= " and orderinfo = '$orderinfo'";
  215. }
  216. if ($waybill) {
  217. $where .= " and waybill = '$waybill'";
  218. }
  219. if ($category) {
  220. $where .= " and features like '%-$category-%'";
  221. }
  222. if ($size) {
  223. $where .= " and features like '%-$size-%'";
  224. }
  225. if ($grade) {
  226. $where .= " and features like '%-$grade-%'";
  227. }
  228. if ($color) {
  229. $where .= " and features like '%-$color-%'";
  230. }
  231. if ($lowe) {
  232. $where .= " and features like '%-$lowe-%'";
  233. }
  234. if ($label) {
  235. $where .= " and label = '$label'";
  236. }
  237. if ($state || $state == 0) {
  238. $where .= " and state = '$state'";
  239. }
  240. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  241. //数据排序
  242. $order_str = "enter desc";
  243. //取得信息列表
  244. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,enter,details', $order_str);
  245. $prc = array();
  246. $purchase = $this->purchase->find_all();
  247. foreach ($purchase as $k => $v) {
  248. $prc[$v['id']] = $v['title'];
  249. }
  250. $classid = $this->classid->sku();
  251. $tcall = $this->typeclass->find_all();
  252. foreach ($tcall as $v)
  253. {
  254. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  255. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  256. }
  257. foreach ($info_list as $key => $value) {
  258. $warehouse = $this->warehouse->read($value['warehouse']);
  259. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  260. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  261. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  262. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm']; if ($value['state'] == 0) {
  263. $info_list[$key]['state'] = "在库";
  264. } else if ($value['state'] == 1) {
  265. $info_list[$key]['state'] = "出库";
  266. } else if ($value['state'] == 2) {
  267. $info_list[$key]['state'] = "退库";
  268. } else if ($value['state'] == 3) {
  269. $info_list[$key]['state'] = "调拨中";
  270. } else if ($value['state'] == 4) {
  271. $info_list[$key]['state'] = "再加工";
  272. } else if ($value['state'] == 5) {
  273. $info_list[$key]['state'] = "维修中";
  274. } else if ($value['state'] == 6) {
  275. $info_list[$key]['state'] = "盘亏";
  276. } else if ($value['state'] == 7) {
  277. $info_list[$key]['state'] = "更换标签";
  278. } else if ($value['state'] == 8) {
  279. $info_list[$key]['state'] = "其它";
  280. } else if ($value['state'] == 9) {
  281. $info_list[$key]['state'] = "预设";
  282. } else if ($value['state'] == 10) {
  283. $info_list[$key]['state'] = "美店零售";
  284. }
  285. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  286. }
  287. //生成excel
  288. $filename = date("Y-m-d")."标签入库导出.xls";
  289. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  290. <head>
  291. <!--[if gte mso 9]><xml>
  292. <x:ExcelWorkbook>
  293. <x:ExcelWorksheets>
  294. <x:ExcelWorksheet>
  295. <x:Name>EXCEL</x:Name>
  296. <x:WorksheetOptions>
  297. <x:Print>
  298. <x:ValidPrinterInfo />
  299. </x:Print>
  300. </x:WorksheetOptions>
  301. </x:ExcelWorksheet>
  302. </x:ExcelWorksheets>
  303. </x:ExcelWorkbook>
  304. </xml>
  305. <![endif]-->
  306. </head><body>";
  307. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  308. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>入库时间</td><td>所在位置</td></tr>";
  309. foreach ($info_list as $key=>$value)
  310. {
  311. $str .= "<tr>";
  312. $str .= "<td>". $value['warehouse']. "</td>";
  313. $str .= "<td>". $value['purchase']. "</td>";
  314. $str .= "<td>". $value['sku']. "</td>";
  315. $str .= "<td>". $value['title']. "</td>";
  316. $str .= "<td>". $value['features']. "</td>";
  317. $str .= "<td>". $value['state']. "</td>";
  318. $str .= "<td>". $value['enter']. "</td>";
  319. $str .= "<td>". $value['details']. "</td>";
  320. $str .= "</tr>";
  321. }
  322. $str .= "</table></body></html>";
  323. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  324. header( "Content-type: application/octet-stream" );
  325. header( "Content-Disposition: attachment; filename=".$filename );
  326. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  327. header( "Pragma: no-cache" );
  328. header( "Expires: 0" );
  329. exit($str);
  330. }
  331. }
  332. }