Whlabelfz.php 13 KB

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