Whlabelfz.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. else {
  26. $this->_index();
  27. }
  28. }
  29. private function _index(){
  30. die('No direct script access allowed');
  31. }
  32. private function _bqck_excel(){
  33. if (isset($_GET['excel'])) {
  34. //统计时间
  35. $timetk = $this->input->get('timetk', true);
  36. $timetj = $this->input->get('timetj', true);
  37. $timetk = strtotime($timetk);
  38. $timetj = strtotime($timetj);
  39. $category = $this->input->get('category',true); //类目
  40. $size = $this->input->get('size',true);//长度
  41. $grade = $this->input->get('grade',true);//等级
  42. $color = $this->input->get('color',true);//颜色
  43. $lowe = $this->input->get('lowe',true);//曲度
  44. $sku = $this->input->get('sku',true);//sku
  45. $warehouse = $this->input->get('warehouse',true);//仓库
  46. $purchase = $this->input->get('purchase',true);//供应商
  47. $where = "state=1 ";
  48. if ($timetk && $timetj) {
  49. $where .= " and outk > '$timetk' and outk < '$timetj'";
  50. }
  51. if ($sku) {
  52. $where .= " and sku = '$sku'";
  53. }
  54. if ($warehouse) {
  55. $where .= " and warehouse = '$warehouse'";
  56. }
  57. if ($purchase) {
  58. $where .= " and purchase = '$purchase'";
  59. }
  60. if ($category) {
  61. $where .= " and features like '%-$category-%'";
  62. }
  63. if ($size) {
  64. $where .= " and features like '%-$size-%'";
  65. }
  66. if ($grade) {
  67. $where .= " and features like '%-$grade-%'";
  68. }
  69. if ($color) {
  70. $where .= " and features like '%-$color-%'";
  71. }
  72. if ($lowe) {
  73. $where .= " and features like '%-$lowe-%'";
  74. }
  75. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  76. $order_str = "outk desc";
  77. //取得信息列表
  78. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,outk,details', $order_str);
  79. $classid = $this->classid->sku();
  80. $tcall = $this->typeclass->find_all();
  81. foreach ($tcall as $v)
  82. {
  83. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  84. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  85. }
  86. foreach ($info_list as $key => $value) {
  87. $warehouse = $this->warehouse->read($value['warehouse']);
  88. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  89. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  90. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  91. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  92. if ($value['state'] == 0) {
  93. $info_list[$key]['state'] = "在库";
  94. } else if ($value['state'] == 1) {
  95. $info_list[$key]['state'] = "出库";
  96. } else if ($value['state'] == 2) {
  97. $info_list[$key]['state'] = "退库";
  98. } else if ($value['state'] == 3) {
  99. $info_list[$key]['state'] = "调拨中";
  100. } else if ($value['state'] == 4) {
  101. $info_list[$key]['state'] = "再加工";
  102. } else if ($value['state'] == 5) {
  103. $info_list[$key]['state'] = "维修中";
  104. } else if ($value['state'] == 6) {
  105. $info_list[$key]['state'] = "盘亏";
  106. } else if ($value['state'] == 7) {
  107. $info_list[$key]['state'] = "更换标签";
  108. } else if ($value['state'] == 8) {
  109. $info_list[$key]['state'] = "其它";
  110. } else if ($value['state'] == 9) {
  111. $info_list[$key]['state'] = "预设";
  112. } else if ($value['state'] == 10) {
  113. $info_list[$key]['state'] = "美店零售";
  114. }
  115. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  116. }
  117. //生成excel
  118. $filename = date("Y-m-d")."标签出库导出.xls";
  119. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  120. <head>
  121. <!--[if gte mso 9]><xml>
  122. <x:ExcelWorkbook>
  123. <x:ExcelWorksheets>
  124. <x:ExcelWorksheet>
  125. <x:Name>EXCEL</x:Name>
  126. <x:WorksheetOptions>
  127. <x:Print>
  128. <x:ValidPrinterInfo />
  129. </x:Print>
  130. </x:WorksheetOptions>
  131. </x:ExcelWorksheet>
  132. </x:ExcelWorksheets>
  133. </x:ExcelWorkbook>
  134. </xml>
  135. <![endif]-->
  136. </head><body>";
  137. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  138. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>出库时间</td><td>所在位置</td></tr>";
  139. foreach ($info_list as $key=>$value)
  140. {
  141. $str .= "<tr>";
  142. $str .= "<td>". $value['warehouse']. "</td>";
  143. $str .= "<td>". $value['purchase']. "</td>";
  144. $str .= "<td>". $value['sku']. "</td>";
  145. $str .= "<td>". $value['title']. "</td>";
  146. $str .= "<td>". $value['features']. "</td>";
  147. $str .= "<td>". $value['state']. "</td>";
  148. $str .= "<td>". $value['outk']. "</td>";
  149. $str .= "<td>". $value['details']. "</td>";
  150. $str .= "</tr>";
  151. }
  152. $str .= "</table></body></html>";
  153. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  154. header( "Content-type: application/octet-stream" );
  155. header( "Content-Disposition: attachment; filename=".$filename );
  156. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  157. header( "Pragma: no-cache" );
  158. header( "Expires: 0" );
  159. exit($str);
  160. }else{
  161. }
  162. }
  163. }