BUB-7 Automobili: Esportazione dei dettagli in PDF delle auto
This commit is contained in:
parent
bb783b9bf1
commit
2828ebcec9
@ -116,6 +116,11 @@ class AutoController extends Controller
|
||||
public function getOperazioni(Request $request)
|
||||
{
|
||||
$operazioni=Operazione::getOperazioni($request['id']);
|
||||
dd($operazioni);
|
||||
// dd($operazioni);
|
||||
}
|
||||
|
||||
public function exportPdfOperazioni(Request $id)
|
||||
{
|
||||
$pdf=Operazione::exportPdfOperazioni($id['id']);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
//use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Sfneal\ViewExport\Pdf\PdfExportService;
|
||||
|
||||
|
||||
class Operazione extends Model
|
||||
{
|
||||
@ -72,7 +75,12 @@ class Operazione extends Model
|
||||
$manutenzione[$dato->id]=Manutenzione::getElementsbyOperazione($dato->id);
|
||||
$revisione[$dato->id]=Revisione::getElementsbyOperazione($dato->id);
|
||||
$rifornimento[$dato->id]=Rifornimento::getElementsbyOperazione($dato->id);
|
||||
if(isset($dato->km)){$km=$dato->km;}else{$km=0;}
|
||||
if(isset($dato->km))
|
||||
{
|
||||
$km=$dato->km;
|
||||
}else{
|
||||
$km=0;
|
||||
}
|
||||
}
|
||||
// Debug
|
||||
/* dd($rifornimento);*/
|
||||
@ -87,4 +95,37 @@ class Operazione extends Model
|
||||
'rifornimento'=>$rifornimento,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function exportPdfOperazioni($autoId)
|
||||
{
|
||||
$automobile=Auto::getAutoById($autoId);
|
||||
$data=DB::table('operaziones')
|
||||
->where('fk_auto_id','=',$autoId)
|
||||
->orderBy('km')
|
||||
->get();
|
||||
foreach ($data as $dato)
|
||||
{
|
||||
$accessori[$dato->id]=Accessori::getElementsbyOperazione($dato->id);
|
||||
$manutenzione[$dato->id]=Manutenzione::getElementsbyOperazione($dato->id);
|
||||
$revisione[$dato->id]=Revisione::getElementsbyOperazione($dato->id);
|
||||
$rifornimento[$dato->id]=Rifornimento::getElementsbyOperazione($dato->id);
|
||||
if(isset($dato->km))
|
||||
{
|
||||
$km=$dato->km;
|
||||
}else{
|
||||
$km=0;
|
||||
}
|
||||
}
|
||||
$view= view('auto.detailpdf',[
|
||||
'dettagli'=>$automobile,
|
||||
'km'=>$km,
|
||||
|
||||
'operazione'=>$data,
|
||||
'accessori'=>$accessori,
|
||||
'manutenzione'=>$manutenzione,
|
||||
'revisione'=>$revisione,
|
||||
'rifornimento'=>$rifornimento,
|
||||
]);
|
||||
return $pdf=PdfExportService::fromView($view)->handle()->download();
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ $app->singleton(
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
// $app->register(\Barryvdh\DomPDF\ServiceProvider::class);
|
||||
// $app->configure('dompdf');
|
||||
//$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
|
||||
//$app->configure('dompdf');
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|
@ -9,7 +9,7 @@
|
||||
"license" : "MIT",
|
||||
"require" : {
|
||||
"php": "^7.3|^8.0",
|
||||
"barryvdh/laravel-dompdf": "^1.0",
|
||||
"barryvdh/laravel-dompdf": "^2.0",
|
||||
"directorytree/ldaprecord": "^2.9",
|
||||
"directorytree/ldaprecord-laravel": "^2.5",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
@ -22,6 +22,7 @@
|
||||
"laraveldaily/laravel-charts": "^0.1.29",
|
||||
"rap2hpoutre/fast-excel": "^3.2",
|
||||
"secondtruth/startmin": "^1.1",
|
||||
"sfneal/view-export": "^2.10",
|
||||
"snapappointments/bootstrap-select": "^1.13",
|
||||
"webklex/laravel-imap": "^2.4"
|
||||
},
|
||||
|
1741
composer.lock
generated
1741
composer.lock
generated
File diff suppressed because it is too large
Load Diff
175
config/view-export.php
Normal file
175
config/view-export.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'pdf' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Chroot
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| dompdf's "chroot".
|
||||
|
|
||||
| Prevents dompdf from accessing system files or other files on the webserver.
|
||||
| All local files opened by dompdf must be in a subdirectory of this directory
|
||||
| or array of directories.
|
||||
| DO NOT set it to '/' since this could allow an attacker to use dompdf to
|
||||
| read any files on the server. This should be an absolute path.
|
||||
|
|
||||
| ==== IMPORTANT ====
|
||||
| This setting may increase the risk of system exploit. Do not change
|
||||
| this settings without understanding the consequences. Additional
|
||||
| documentation is available on the dompdf wiki at:
|
||||
| https://github.com/dompdf/dompdf/wiki
|
||||
|
|
||||
*/
|
||||
'chroot' => base_path('vendor/dompdf/dompdf'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Font Cache
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| dompdf's font cache directory.
|
||||
|
|
||||
| The location of the DOMPDF font cache directory
|
||||
|
|
||||
| This directory contains the cached font metrics for the fonts used by DOMPDF.
|
||||
| This directory can be the same as $fontDir
|
||||
|
|
||||
| Note: This directory must exist and be writable by the webserver process.
|
||||
|
|
||||
| Default: leaving as 'null' will result in the 'chroot' being used as the
|
||||
| font cache directory.
|
||||
|
|
||||
*/
|
||||
'font_cache' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PHP enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enable embedded PHP.
|
||||
|
|
||||
| If this setting is set to true then DOMPDF will automatically evaluate
|
||||
| embedded PHP contained within <script type="text/php"> ... </script> tags.
|
||||
|
|
||||
| ==== IMPORTANT ====
|
||||
| Enabling this for documents you do not trust (e.g. arbitrary remote html
|
||||
| pages) is a security risk. Embedded scripts are run with the same level of
|
||||
| system access available to dompdf. Set this option to false (recommended)
|
||||
| if you wish to process untrusted documents.
|
||||
|
|
||||
| This setting may increase the risk of system exploit. Do not change
|
||||
| this settings without understanding the consequences. Additional
|
||||
| documentation is available on the dompdf wiki at:
|
||||
| https://github.com/dompdf/dompdf/wiki
|
||||
|
|
||||
*/
|
||||
'php_enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Javascript enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enable inline Javascript.
|
||||
|
|
||||
| If this setting is set to true then DOMPDF will automatically insert
|
||||
| JavaScript code contained within <script type="text/javascript"> ... </script> tags.
|
||||
|
|
||||
*/
|
||||
'javascript_enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTML 5 parsable enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Use the more-than-experimental HTML5 Lib parser.
|
||||
|
|
||||
*/
|
||||
'html5_parsable' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Remote enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enable remote file access.
|
||||
|
|
||||
| If this setting is set to true, DOMPDF will access remote sites for
|
||||
| images and CSS files as required.
|
||||
|
|
||||
| ==== IMPORTANT ====
|
||||
| This can be a security risk, in particular in combination with isPhpEnabled and
|
||||
| allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...);
|
||||
| This allows anonymous users to download legally doubtful internet content which on
|
||||
| tracing back appears to being downloaded by your server, or allows malicious php code
|
||||
| in remote html pages to be executed by your server with your account privileges.
|
||||
|
|
||||
| This setting may increase the risk of system exploit. Do not change
|
||||
| this settings without understanding the consequences. Additional
|
||||
| documentation is available on the dompdf wiki at:
|
||||
| https://github.com/dompdf/dompdf/wiki
|
||||
|
|
||||
*/
|
||||
'remote_enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Output
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The file that Dompdf logs should be written to.
|
||||
|
|
||||
*/
|
||||
'log_output' => storage_path('logs/dompdf.htm'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Metadata default
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| PDF metadata that should be used by default.
|
||||
|
|
||||
*/
|
||||
'metadata' => [
|
||||
'Title' => '',
|
||||
'Author' => '',
|
||||
'Subject' => '',
|
||||
'Keywords' => '',
|
||||
'Creator' => '',
|
||||
'Producer' => '',
|
||||
'CreationDate' => '',
|
||||
'ModDate' => '',
|
||||
'Trapped' => '',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Content Loader convention
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determine if PDF content should be loaded using the 'disk' to export a
|
||||
| static HTML file prior to loading into the PDF. Set the value to
|
||||
| 'memory' if you would like load HTML stored in memory directly to the PDF.
|
||||
|
|
||||
| Values: 'memory' or 'disk'
|
||||
|
|
||||
*/
|
||||
'content_loader' => 'disk',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cloud Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Many applications store files both locally and in the cloud. For this
|
||||
| reason, you may specify a default "cloud" driver here. This driver
|
||||
| will be bound as the Cloud disk implementation in the container.
|
||||
|
|
||||
*/
|
||||
'disk' => 'cloud',
|
||||
];
|
@ -9,6 +9,11 @@
|
||||
<!-- Content here -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<a class="btn btn-primary" href="operazioni/pdf?id={{ $dettagli->id; }}">Esporta PDF</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
|
249
resources/views/auto/detailpdf.blade.php
Normal file
249
resources/views/auto/detailpdf.blade.php
Normal file
@ -0,0 +1,249 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;600&display=swap" rel="stylesheet">
|
||||
<style lang="text/css">
|
||||
body{
|
||||
font-family: 'Titillium Web', sans-serif;
|
||||
}
|
||||
|
||||
th{
|
||||
text-align: left;
|
||||
}
|
||||
td{
|
||||
font-size: 11px;
|
||||
border:1px, solid, #000000;
|
||||
}
|
||||
|
||||
table{
|
||||
border:1px, solid, #000000;
|
||||
}
|
||||
#panel_heading{
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Content here -->
|
||||
|
||||
<span class="titolo"><h1>Scheda {{ $dettagli->marca; }} {{ $dettagli->modello; }} - {{ $dettagli->targa; }}</h1></span>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Dettaglio
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="intestazione_doc" id="">
|
||||
<tr>
|
||||
<th>Marca:</th><td>{{ $dettagli->marca; }}</td>
|
||||
<th>Modello:</th><td>{{ $dettagli->modello; }}</td>
|
||||
<th>Targa:</th> <td>{{ $dettagli->targa; }}</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Alimentazione:</th><td>{{ $dettagli->alimentazione; }}</td>
|
||||
<th>Cilindrata:</th><td>{{ $dettagli->cilindrata; }}</td>
|
||||
<th>Cavalli Fisc.:</th><td>{{ $dettagli->cvfiscali; }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Num.Telaio:</th><td>{{ $dettagli->ntelaio; }}</td>
|
||||
<th>Num. Motore:</th><td>{{ $dettagli->nmotore; }}</td>
|
||||
<th>Data acquisto:</th><td>{{ $dettagli->data_acquisto; }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Kilometraggio:</th><td>{{ $km ?? ''; }}</td>
|
||||
<th>Note:</th><td>{{ $dettagli->note; }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br><hr>
|
||||
<!-- Revisioni -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Revisioni
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="revisione">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Km</th>
|
||||
<th>Superata</th>
|
||||
<th>Centro Revisione</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Prossima revisione</th>
|
||||
<th>Importo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($operazione as $operazioni)
|
||||
@if ($operazioni->type =='revisione')
|
||||
<tr>
|
||||
<td>{{ $operazioni->data; }}</td>
|
||||
<td>{{ $operazioni->km; }}</td>
|
||||
<td>{{ $revisione[$operazioni->id][0]->superata; }}</td>
|
||||
<td>{{ $revisione[$operazioni->id][0]->centrorevisione; }}</td>
|
||||
<td>{{ $revisione[$operazioni->id][0]->descrizione; }}</td>
|
||||
<td>{{ $revisione[$operazioni->id][0]->dataproxrevisione; }}</td>
|
||||
<td>{{ $operazioni->importo; }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Fine Revisioni -->
|
||||
<br><hr>
|
||||
<!-- Manutenzioni -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Manutenzione
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="manutenzione">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Km</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Importo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($operazione as $operazioni)
|
||||
@if ($operazioni->type =='manutenzione')
|
||||
<tr>
|
||||
<td>{{ $operazioni->data; }}</td>
|
||||
<td>{{ $operazioni->km; }}</td>
|
||||
<td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td>
|
||||
<td>{{ $operazioni->importo; }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Fine Manutenzioni -->
|
||||
<br> <hr>
|
||||
<!-- Accessori -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Accessori/Ricambi
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="accessori">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Km</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Importo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($operazione as $operazioni)
|
||||
@if ($operazioni->type=='accessori')
|
||||
<tr>
|
||||
<td>{{ $operazioni->data; }}</td>
|
||||
<td>{{ $operazioni->km; }}</td>
|
||||
<td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td>
|
||||
<td>{{ $operazioni->importo; }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Fine Accessori -->
|
||||
<br> <hr>
|
||||
<!-- Rifornimenti -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Rifornimenti
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Km</th>
|
||||
<th>Distributore</th>
|
||||
<th>Euro al litro</th>
|
||||
<th>Litri</th>
|
||||
<th>Importo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($operazione as $operazioni)
|
||||
@if ($operazioni->type =='rifornimento')
|
||||
<tr>
|
||||
<td>{{ $operazioni->data; }}</td>
|
||||
<td>{{ $operazioni->km; }}</td>
|
||||
<td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td>
|
||||
<td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td>
|
||||
<td>{{ $rifornimento[$operazioni->id][0]->litri; }}</td>
|
||||
<td>{{ $operazioni->importo; }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Fine Rifornimenti -->
|
||||
<br> <hr>
|
||||
<!-- -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!-- /.col-lg-12 -->
|
||||
|
@ -2,7 +2,7 @@
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Letture Gas</h1>
|
||||
<h1 class="page-header">Letture Energia Elettrica</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -79,6 +79,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
Route::get('auto/accessori', [AutoController::class, 'accessoriAuto']);
|
||||
Route::post('auto/accessori', [AutoController::class, 'saveAccessori']);
|
||||
Route::get('auto/operazioni', [AutoController::class, 'getOperazioni']);
|
||||
Route::get('auto/operazioni/pdf', [AutoController::class, 'exportPdfOperazioni']);
|
||||
|
||||
/// TEST routes
|
||||
Route::get('fullcalender', [FullCalenderController::class, 'index']);
|
||||
|
Loading…
Reference in New Issue
Block a user