Initial commit
This commit is contained in:
56
render_service_report.php
Normal file
56
render_service_report.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// PDF creator +++++++++++++++++++++++++++++++++++++++
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
// include autoloader
|
||||
require_once './assets/dompdf/autoload.inc.php';
|
||||
|
||||
// reference the Dompdf namespace
|
||||
use Dompdf\Dompdf;
|
||||
|
||||
// instantiate and use the dompdf class
|
||||
use Dompdf\Options;
|
||||
|
||||
if ($_GET['historyID']){
|
||||
|
||||
//GET Details from URL
|
||||
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
||||
//CALL TO API FOR History
|
||||
$api_url = '/v1/history/'.$GET_VALUES;
|
||||
$history = ioServer($api_url,'');
|
||||
|
||||
//Decode Payload
|
||||
if (!empty($history)){$history = decode_payload($history);}else{$history = null;}
|
||||
|
||||
$historyID = $_GET['historyID'] ?? '';
|
||||
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Create ServiceReport
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$servicereport_data = serviceReport($history[0], '');
|
||||
$servicereport_name = 'Service report - '.$historyID;
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++
|
||||
//dompdf libary +++++++++++++++++++++++++++
|
||||
//+++++++++++++++++++++++++++++++++++++++++++
|
||||
$options = new Options();
|
||||
$options->set('isRemoteEnabled', true);
|
||||
$dompdf = new Dompdf($options);
|
||||
$dompdf->loadHtml($servicereport_data);
|
||||
|
||||
// (Optional) Setup the paper size and orientation
|
||||
$dompdf->setPaper('A4', 'portrait');
|
||||
|
||||
// Render the HTML as PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Output the generated PDF to Browser
|
||||
$dompdf->stream($servicereport_name, array("Attachment" => 1)); // Change false to 1 for download
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user