Whlabelfz.php 12 KB

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