Whlabelfz.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. $typeclass = array();
  88. foreach ($tcall as $v)
  89. {
  90. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  91. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  92. }
  93. $prc = array();
  94. $purchase = $this->purchase->find_all();
  95. foreach ($purchase as $k => $v) {
  96. $prc[$v['id']] = $v['title'];
  97. }
  98. foreach ($info_list as $key => $value) {
  99. $warehouse = $this->warehouse->read($value['warehouse']);
  100. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  101. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  102. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  103. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  104. if ($value['state'] == 0) {
  105. $info_list[$key]['state'] = "在库";
  106. } else if ($value['state'] == 1) {
  107. $info_list[$key]['state'] = "出库";
  108. } else if ($value['state'] == 2) {
  109. $info_list[$key]['state'] = "退库";
  110. } else if ($value['state'] == 3) {
  111. $info_list[$key]['state'] = "调拨中";
  112. } else if ($value['state'] == 4) {
  113. $info_list[$key]['state'] = "再加工";
  114. } else if ($value['state'] == 5) {
  115. $info_list[$key]['state'] = "维修中";
  116. } else if ($value['state'] == 6) {
  117. $info_list[$key]['state'] = "盘亏";
  118. } else if ($value['state'] == 7) {
  119. $info_list[$key]['state'] = "更换标签";
  120. } else if ($value['state'] == 8) {
  121. $info_list[$key]['state'] = "其它";
  122. } else if ($value['state'] == 9) {
  123. $info_list[$key]['state'] = "预设";
  124. } else if ($value['state'] == 10) {
  125. $info_list[$key]['state'] = "美店零售";
  126. }
  127. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  128. }
  129. //生成excel
  130. $filename = date("Y-m-d")."标签出库导出.xls";
  131. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  132. <head>
  133. <!--[if gte mso 9]><xml>
  134. <x:ExcelWorkbook>
  135. <x:ExcelWorksheets>
  136. <x:ExcelWorksheet>
  137. <x:Name>EXCEL</x:Name>
  138. <x:WorksheetOptions>
  139. <x:Print>
  140. <x:ValidPrinterInfo />
  141. </x:Print>
  142. </x:WorksheetOptions>
  143. </x:ExcelWorksheet>
  144. </x:ExcelWorksheets>
  145. </x:ExcelWorkbook>
  146. </xml>
  147. <![endif]-->
  148. </head><body>";
  149. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  150. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>出库时间</td><td>所在位置</td></tr>";
  151. foreach ($info_list as $key=>$value)
  152. {
  153. $str .= "<tr>";
  154. $str .= "<td>". $value['warehouse']. "</td>";
  155. $str .= "<td>". $value['purchase']. "</td>";
  156. $str .= "<td>". $value['sku']. "</td>";
  157. $str .= "<td>". $value['title']. "</td>";
  158. $str .= "<td>". $value['features']. "</td>";
  159. $str .= "<td>". $value['state']. "</td>";
  160. $str .= "<td>". $value['outk']. "</td>";
  161. $str .= "<td>". $value['details']. "</td>";
  162. $str .= "</tr>";
  163. }
  164. $str .= "</table></body></html>";
  165. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  166. header( "Content-type: application/octet-stream" );
  167. header( "Content-Disposition: attachment; filename=".$filename );
  168. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  169. header( "Pragma: no-cache" );
  170. header( "Expires: 0" );
  171. exit($str);
  172. }else{
  173. }
  174. }
  175. public function _bqrk_excel(){
  176. if (isset($_GET['excel'])) {
  177. $sku = $this->input->get('sku', true);
  178. $bs = $this->input->get('bs', true);
  179. $number = $this->input->get('number', true);
  180. $warehouse = $this->input->get('warehouse', true);
  181. $purchase = $this->input->get('purchase', true);
  182. $orderinfo = $this->input->get('orderinfo', true);
  183. $waybill = $this->input->get('waybill', true);
  184. $category = $this->input->get('category', true);
  185. $size = $this->input->get('size', true);
  186. $grade = $this->input->get('grade', true);
  187. $color = $this->input->get('color', true);
  188. $lowe = $this->input->get('lowe', true);
  189. $state = $this->input->get('state', true);
  190. $label = $this->input->get('label', true);
  191. $timetk = $this->input->get('ktime', true);
  192. $timetj = $this->input->get('jtime', true);
  193. $timetk = strtotime($timetk);
  194. $timetj = strtotime($timetj);
  195. $where = "1=1 ";
  196. if ($timetk && $timetj) {
  197. $where .= " and enter > '$timetk' and enter < '$timetj'";
  198. }
  199. if ($sku) {
  200. $where .= " and sku = '$sku'";
  201. }
  202. if ($bs != '') {
  203. $where .= " and bs = '$bs'";
  204. }
  205. if ($number) {
  206. $where .= " and number = '$number'";
  207. }
  208. if ($warehouse) {
  209. $where .= " and warehouse = '$warehouse'";
  210. }
  211. if ($purchase) {
  212. $where .= " and purchase = '$purchase'";
  213. }
  214. if ($orderinfo) {
  215. $where .= " and orderinfo = '$orderinfo'";
  216. }
  217. if ($waybill) {
  218. $where .= " and waybill = '$waybill'";
  219. }
  220. if ($category) {
  221. $where .= " and features like '%-$category-%'";
  222. }
  223. if ($size) {
  224. $where .= " and features like '%-$size-%'";
  225. }
  226. if ($grade) {
  227. $where .= " and features like '%-$grade-%'";
  228. }
  229. if ($color) {
  230. $where .= " and features like '%-$color-%'";
  231. }
  232. if ($lowe) {
  233. $where .= " and features like '%-$lowe-%'";
  234. }
  235. if ($label) {
  236. $where .= " and label = '$label'";
  237. }
  238. if ($state || $state == 0) {
  239. $where .= " and state = '$state'";
  240. }
  241. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  242. //数据排序
  243. $order_str = "enter desc";
  244. //取得信息列表
  245. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,enter,details', $order_str);
  246. $prc = array();
  247. $purchase = $this->purchase->find_all();
  248. foreach ($purchase as $k => $v) {
  249. $prc[$v['id']] = $v['title'];
  250. }
  251. $classid = $this->classid->sku();
  252. $tcall = $this->typeclass->find_all();
  253. foreach ($tcall as $v)
  254. {
  255. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  256. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  257. }
  258. foreach ($info_list as $key => $value) {
  259. $warehouse = $this->warehouse->read($value['warehouse']);
  260. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  261. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  262. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  263. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm']; if ($value['state'] == 0) {
  264. $info_list[$key]['state'] = "在库";
  265. } else if ($value['state'] == 1) {
  266. $info_list[$key]['state'] = "出库";
  267. } else if ($value['state'] == 2) {
  268. $info_list[$key]['state'] = "退库";
  269. } else if ($value['state'] == 3) {
  270. $info_list[$key]['state'] = "调拨中";
  271. } else if ($value['state'] == 4) {
  272. $info_list[$key]['state'] = "再加工";
  273. } else if ($value['state'] == 5) {
  274. $info_list[$key]['state'] = "维修中";
  275. } else if ($value['state'] == 6) {
  276. $info_list[$key]['state'] = "盘亏";
  277. } else if ($value['state'] == 7) {
  278. $info_list[$key]['state'] = "更换标签";
  279. } else if ($value['state'] == 8) {
  280. $info_list[$key]['state'] = "其它";
  281. } else if ($value['state'] == 9) {
  282. $info_list[$key]['state'] = "预设";
  283. } else if ($value['state'] == 10) {
  284. $info_list[$key]['state'] = "美店零售";
  285. }
  286. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  287. }
  288. //生成excel
  289. $filename = date("Y-m-d")."标签入库导出.xls";
  290. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  291. <head>
  292. <!--[if gte mso 9]><xml>
  293. <x:ExcelWorkbook>
  294. <x:ExcelWorksheets>
  295. <x:ExcelWorksheet>
  296. <x:Name>EXCEL</x:Name>
  297. <x:WorksheetOptions>
  298. <x:Print>
  299. <x:ValidPrinterInfo />
  300. </x:Print>
  301. </x:WorksheetOptions>
  302. </x:ExcelWorksheet>
  303. </x:ExcelWorksheets>
  304. </x:ExcelWorkbook>
  305. </xml>
  306. <![endif]-->
  307. </head><body>";
  308. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  309. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>入库时间</td><td>所在位置</td></tr>";
  310. foreach ($info_list as $key=>$value)
  311. {
  312. $str .= "<tr>";
  313. $str .= "<td>". $value['warehouse']. "</td>";
  314. $str .= "<td>". $value['purchase']. "</td>";
  315. $str .= "<td>". $value['sku']. "</td>";
  316. $str .= "<td>". $value['title']. "</td>";
  317. $str .= "<td>". $value['features']. "</td>";
  318. $str .= "<td>". $value['state']. "</td>";
  319. $str .= "<td>". $value['enter']. "</td>";
  320. $str .= "<td>". $value['details']. "</td>";
  321. $str .= "</tr>";
  322. }
  323. $str .= "</table></body></html>";
  324. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  325. header( "Content-type: application/octet-stream" );
  326. header( "Content-Disposition: attachment; filename=".$filename );
  327. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  328. header( "Pragma: no-cache" );
  329. header( "Expires: 0" );
  330. exit($str);
  331. }
  332. }
  333. }