lvhao 1 päivä sitten
vanhempi
commit
459b12fdf5
1 muutettua tiedostoa jossa 100 lisäystä ja 1 poistoa
  1. 100 1
      core/CoreApp/controllers/Beihuogl.php

+ 100 - 1
core/CoreApp/controllers/Beihuogl.php

@@ -89,6 +89,8 @@ class Beihuogl extends Start_Controller {
             $this->_dcdjzrk();
         }elseif($arg == 'dyapplyyjsh'){
             $this->_dyapplyyjsh();
+        }elseif($arg == 'ccwlbhdownload'){
+            $this->_ccwlbhdownload();
         }
 		else
 		{
@@ -548,7 +550,7 @@ class Beihuogl extends Start_Controller {
                 $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"无";
                 $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
                 if($v['erp_check'] == 1){
-                      $list[$k]['sku'] = "<i style='color:red'>".$v['sku']."</i>  <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
+                      $list[$k]['sku'] = "<a style='color:red' href='javascript:void(0)' onclick='addnewgoods'>".$v['sku']."</a>  <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
                 }else{
                     $list[$k]['sku'] = $v['sku']."  <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
                 }
@@ -631,6 +633,103 @@ class Beihuogl extends Start_Controller {
             exit;
         }
     }
+    private function _ccwlbhdownload(){
+        if($this->input->method() === 'get'){
+            $query = $this->input->get(null,true);
+            if(empty($query['excel'])){
+                exit("不符合下载要求");
+            }
+            if($query['excel'] != 'erp'){
+                exit("不符合下载要求");
+            }
+            $ids = $this->input->get('ids',true);
+            if(empty($ids)){
+                exit("请选择要下载的备货单");
+            }
+            $arr_id = [];
+            if(stripos($ids,'|') !== false){
+                $arr_id = explode('|', $ids);   
+            }else{
+                $arr_id[] = $ids;
+            }
+            if(empty($arr_id)){
+                exit("请选择要下载的备货单-1");
+            }
+            $list = $this->bhccwl->find_all('id in ('.implode(',',$arr_id).')');
+            $batch_nos = array_column($list,'bh_no');
+            $batch_no_str = '';
+            foreach($batch_nos as $k=>$v){
+                $batch_no_str .= "'".$v."',";
+            }
+            $batch_no_str = trim($batch_no_str,',');
+            $bh_list = $this->bhsq->find_all("bh_no in (".$batch_no_str.")");
+            if(empty($bh_list)){
+                exit("备货单料品信息为空");
+            }
+            $shop_list = $this->shop->find_all("1=1","id,shopname");
+            $plat_list = $this->typeclass->find_all("classid = 32","id,title");
+            $final_list= [];
+            foreach($bh_list as $k=>$v){
+                $final_list[] = [
+                    'bh_no'=>$v['bh_no'],
+                    'shop'=>isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无",
+                    'plat'=>isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"无",
+                    'zh'=>$v['title'],
+                    'jm'=>$v['jm'],
+                    'sqr'=>$v['sqr'],
+                    'sq_num'=>$v['sq_num'],
+                    'public_time'=>date("Y-m-d",$v['public_time']),
+                    'remark'=>$v['remark'],
+                ];
+            }
+
+            $filename = "备货生产单.xls";
+            $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
+            <head>
+            <!--[if gte mso 9]><xml>
+            <x:ExcelWorkbook>
+            <x:ExcelWorksheets>
+            <x:ExcelWorksheet>
+            <x:Name>EXCEL</x:Name>
+            <x:WorksheetOptions>
+            <x:Print>
+            <x:ValidPrinterInfo />
+            </x:Print>
+            </x:WorksheetOptions>
+            </x:ExcelWorksheet>
+            </x:ExcelWorksheets>
+            </x:ExcelWorkbook>
+            </xml>
+            <![endif]-->
+            </head><body>";
+            $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>"; 
+            $str .= "<tr><td>备货单号</td><td>店铺</td><td>平台</td><td>中文名称</td><td>u9料号</td><td>申请人</td><td>申请数量<td>申请时间</td><td>备注</td></tr>";
+            foreach ($final_list as $key=>$value) 
+            { 
+                
+                $str .= "<tr>";
+                $str .= "<td>". $value['bh_no']. "</td>";	
+                $str .= "<td>". $value['shop']. "</td>";
+                $str .= "<td>". $value['plat']. "</td>";	
+                $str .= "<td>". $value['zh']. "</td>";	
+                $str .= "<td>". $value['jm']. "</td>";
+                $str .= "<td>". $value['sqr']. "</td>";
+                $str .= "<td>". $value['sq_num']. "</td>";
+                $str .= "<td>". $value['public_time']. "</td>";
+                $str .= "<td>". $value['remark']. "</td>";
+                $str .= "</tr>";
+            }
+            $str .= "</table></body></html>"; 
+            header( "Content-Type: application/vnd.ms-excel; name='excel'" ); 
+            header( "Content-type: application/octet-stream" ); 
+            header( "Content-Disposition: attachment; filename=".$filename ); 
+            header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); 
+            header( "Pragma: no-cache" ); 
+            header( "Expires: 0" ); 
+            exit($str); 
+            
+        }
+    }
     //仓储物流合成备货单
     private function _ccwlbhmake(){
         if($this->input->method() === 'post'){