Commit c5798571 by hcy001

1

parent 859be2f3
......@@ -120,10 +120,11 @@ class ApiController extends Controller
if ($data[0] > 0){
Export($data);
}
print_r($data);
$InquiryItemsReportModel->createSalePdf($data[2]["report_sn"]);
$report_sn = $data[2]["report_sn"];
# $report_sn = "R2021030605803";
$InquiryItemsReportModel->createSalePdf($report_sn);
}
//删除询价列表
private function ApiDeleteInquiryItems($input, $id){
Export((new InquiryItemsModel())->DeleteInquiryItems($input));
......
......@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Model\InquiryItemsModel;
use App\Model\InquiryItemsReportModel;
use App\Model\InquiryModel;
use App\Model\LoginModel;
use Illuminate\Http\Request;
......@@ -39,6 +40,30 @@ class ServerController extends Controller
return ExportLayuiReturn($res);
}
//下载pdf文件
private function DownPdf($input, $id){
$filename = base_path()."/public/pdf/".$input["file_name"];
if (false == file_exists($filename)) {
exit("不存在此文件:".$filename);
}
// http headers
header('Content-Type: application-x/force-download');
header('Content-Disposition: attachment; filename="' . basename($filename) .'"');
header('Content-length: ' . filesize($filename));
// for IE6
if (false === strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6')) {
header('Cache-Control: no-cache, must-revalidate');
}
header('Pragma: no-cache');
return readfile($filename);;
}
//调试pdf
private function pdfdebug($input, $id){
$InquiryItemsReportModel = new InquiryItemsReportModel();
$report_sn = "R2021030605803";
return $InquiryItemsReportModel->createSalePdf($report_sn);
}
......
......@@ -31,7 +31,6 @@ class InquiryItemsReportModel extends Model
$inquiry_id = $input["inquiry_id"];
$currency = $input["currency"]; #币种
$money = 0; //总计报价
$insertArr = []; //批量插入数组
foreach ($input["items"] as $k=>$inquiry_items_id){
$temp = [
......@@ -57,14 +56,8 @@ class InquiryItemsReportModel extends Model
}else{
$temp["price_origin"] =@$input["quote_price"][$k] ? $input["quote_price"][$k] : 0;
}
array_push($insertArr,$temp);
if ($temp["quote_price"] > 0){
$money = $money + $temp["quote_price_count"];
}
}
print_r($insertArr);
die();
$this->insert($insertArr); //批量插入
......@@ -86,18 +79,26 @@ class InquiryItemsReportModel extends Model
$v["quote_account"] = $v["price_rmb"] > 0 ? $v["price_rmb"]*$v["inquiry_number"] : $v["price_origin"]*$v["inquiry_number"];
$quote_price_count = $quote_price_count+$v["quote_account"];
}
$data["itemsArr"] = $itemsArr;
$data["quote_price_count"] = $quote_price_count;
$html = view('pdf.sale', compact($itemsArr, $quote_price_count))->render();
$html = view('pdf.sale', $data)->render();
if (@$_REQUEST["flag"] == 100){
return $html;
print_r($html);
die();
}
$path = 'pdf/sale_report_'.time().'.pdf';
$name = 'sale_report_'.time().'.pdf';
PDF::loadHTML($html)
->setPaper('a4', 'landscape') //横列
->setWarnings(false)
->save($path);
Export([0,"成功",$path]);
->save('pdf/'.$name);
if (@$_REQUEST["flag"] == 101){
header("Location: http://frq_api.liexin.com/server/DownPdf?file_name=".$name);
die();
}
Export([0,"成功","/server/DownPdf?file_name=".$name]);
}
......
......@@ -17,4 +17,6 @@
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
......@@ -35,7 +35,7 @@
<table>
<tr>
<td colspan="2"></td>
<td colspan="2">Date:2020-7-14</td>
<td colspan="2">Date: <?= date("Y-m-d"); ?></td>
</tr>
<tr>
......@@ -99,7 +99,7 @@
</table>
</div>
<div class="footer" style="padding-top: 20px;">
<img src="./contract.png" width='150' height='150'>
<img src="http://api.ichunt.com/public/img/contract.png" width='150' height='150'>
<b style="font-size: 18px;font-weight: bold;color:#000;"> 条款和说明:<br>
Terms and conditions:</b>
<br>1.> <span class="pr30">付款方式:月结30天</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment