added report download
This commit is contained in:
parent
254fc65859
commit
b63606a48c
@ -43,6 +43,7 @@
|
|||||||
"phpmailer/phpmailer": "^6.9",
|
"phpmailer/phpmailer": "^6.9",
|
||||||
"proengsoft/laravel-jsvalidation": "^4.0.0",
|
"proengsoft/laravel-jsvalidation": "^4.0.0",
|
||||||
"spatie/laravel-query-builder": "^5.0",
|
"spatie/laravel-query-builder": "^5.0",
|
||||||
|
"tecnickcom/tcpdf": "^6.8",
|
||||||
"vanguardapp/activity-log": "^5.0",
|
"vanguardapp/activity-log": "^5.0",
|
||||||
"vanguardapp/announcements": "^5.0",
|
"vanguardapp/announcements": "^5.0",
|
||||||
"vanguardapp/plugins": "^5.0",
|
"vanguardapp/plugins": "^5.0",
|
||||||
|
|||||||
75
composer.lock
generated
75
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "4aa12c72336d4694139400139378d75f",
|
"content-hash": "36e0265c4d1a5422d60fbaef9b95eb98",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "akaunting/laravel-setting",
|
"name": "akaunting/laravel-setting",
|
||||||
@ -6189,6 +6189,79 @@
|
|||||||
],
|
],
|
||||||
"time": "2023-02-24T10:42:00+00:00"
|
"time": "2023-02-24T10:42:00+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "tecnickcom/tcpdf",
|
||||||
|
"version": "6.8.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/tecnickcom/TCPDF.git",
|
||||||
|
"reference": "f7a781073e1645062f163e058139e2f89355d420"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/f7a781073e1645062f163e058139e2f89355d420",
|
||||||
|
"reference": "f7a781073e1645062f163e058139e2f89355d420",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"php": ">=7.1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"config",
|
||||||
|
"include",
|
||||||
|
"tcpdf.php",
|
||||||
|
"tcpdf_parser.php",
|
||||||
|
"tcpdf_import.php",
|
||||||
|
"tcpdf_barcodes_1d.php",
|
||||||
|
"tcpdf_barcodes_2d.php",
|
||||||
|
"include/tcpdf_colors.php",
|
||||||
|
"include/tcpdf_filters.php",
|
||||||
|
"include/tcpdf_font_data.php",
|
||||||
|
"include/tcpdf_fonts.php",
|
||||||
|
"include/tcpdf_images.php",
|
||||||
|
"include/tcpdf_static.php",
|
||||||
|
"include/barcodes/datamatrix.php",
|
||||||
|
"include/barcodes/pdf417.php",
|
||||||
|
"include/barcodes/qrcode.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicola Asuni",
|
||||||
|
"email": "info@tecnick.com",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
|
||||||
|
"homepage": "http://www.tcpdf.org/",
|
||||||
|
"keywords": [
|
||||||
|
"PDFD32000-2008",
|
||||||
|
"TCPDF",
|
||||||
|
"barcodes",
|
||||||
|
"datamatrix",
|
||||||
|
"pdf",
|
||||||
|
"pdf417",
|
||||||
|
"qrcode"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/tecnickcom/TCPDF/issues",
|
||||||
|
"source": "https://github.com/tecnickcom/TCPDF/tree/6.8.2"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20tcpdf%20project",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-01-26T14:03:12+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "tijsverkoyen/css-to-inline-styles",
|
"name": "tijsverkoyen/css-to-inline-styles",
|
||||||
"version": "2.2.6",
|
"version": "2.2.6",
|
||||||
|
|||||||
@ -166,6 +166,21 @@ while ($row = $queryPages->fetch_assoc()) {
|
|||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-warning {
|
||||||
|
background-color: #ffca2c;
|
||||||
|
/* Un giallo più brillante */
|
||||||
|
border-color: #ffca2c;
|
||||||
|
color: #212529;
|
||||||
|
/* Testo scuro per contrasto */
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-warning:hover {
|
||||||
|
background-color: #e0b026;
|
||||||
|
/* Giallo più scuro al passaggio del mouse */
|
||||||
|
border-color: #e0b026;
|
||||||
|
color: #212529;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -188,6 +203,9 @@ while ($row = $queryPages->fetch_assoc()) {
|
|||||||
<button onclick="history.back()" class="btn btn-dark">
|
<button onclick="history.back()" class="btn btn-dark">
|
||||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||||
</button>
|
</button>
|
||||||
|
<a href="download-shared-documents.php?idhome=<?php echo $idhome; ?>" class="btn btn-warning" id="downloadZipBtn">
|
||||||
|
<i class="fas fa-file-archive"></i> Scarica Zip
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
195
public/userportal/download-report.php
Normal file
195
public/userportal/download-report.php
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include('include/headscript.php');
|
||||||
|
require_once '../../vendor/autoload.php';
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
$iduserlogin = $_SESSION['iduserlogin'];
|
||||||
|
$emailuser = $_SESSION['emailuser'];
|
||||||
|
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||||
|
|
||||||
|
// Verifica accesso
|
||||||
|
$querySharing = $conn->prepare("
|
||||||
|
SELECT sharing_type, shared_sections, iduser
|
||||||
|
FROM home_sharing
|
||||||
|
WHERE idhome = ? AND (idshareduser = ? OR shared_email = ?) AND status = 'accepted'
|
||||||
|
");
|
||||||
|
$querySharing->bind_param('iis', $idhome, $iduserlogin, $emailuser);
|
||||||
|
$querySharing->execute();
|
||||||
|
$sharingData = $querySharing->get_result()->fetch_assoc();
|
||||||
|
|
||||||
|
$queryOwner = $conn->prepare("SELECT iduser FROM home WHERE idhome = ?");
|
||||||
|
$queryOwner->bind_param("i", $idhome);
|
||||||
|
$queryOwner->execute();
|
||||||
|
$ownerData = $queryOwner->get_result()->fetch_assoc();
|
||||||
|
|
||||||
|
if (!$sharingData && $ownerData['iduser'] != $iduserlogin) {
|
||||||
|
die("Accesso negato.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera i dati della casa
|
||||||
|
$queryHome = $conn->prepare("SELECT * FROM home WHERE idhome = ?");
|
||||||
|
$queryHome->bind_param('i', $idhome);
|
||||||
|
$queryHome->execute();
|
||||||
|
$homeData = $queryHome->get_result()->fetch_assoc();
|
||||||
|
|
||||||
|
// Classe personalizzata per il PDF
|
||||||
|
class MYPDF extends TCPDF
|
||||||
|
{
|
||||||
|
protected $homeName; // Proprietà per il nome dell'immobile
|
||||||
|
|
||||||
|
public function __construct($homeName, $orientation, $unit, $format)
|
||||||
|
{
|
||||||
|
parent::__construct($orientation, $unit, $format);
|
||||||
|
$this->homeName = $homeName; // Imposta il nome dell'immobile
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Header()
|
||||||
|
{
|
||||||
|
$this->SetFont('helvetica', 'B', 16);
|
||||||
|
$this->SetTextColor(0, 63, 127);
|
||||||
|
$this->Cell(80, 10, 'Report Immobile', 0, 0, 'L');
|
||||||
|
$this->SetFont('helvetica', 'B', 14);
|
||||||
|
$this->Cell(0, 10, htmlspecialchars($this->homeName), 0, 1, 'R');
|
||||||
|
$this->SetFont('helvetica', '', 10);
|
||||||
|
$this->SetTextColor(100, 100, 100);
|
||||||
|
$this->Cell(0, 5, 'Generato il ' . date('d/m/Y H:i'), 0, 1, 'C');
|
||||||
|
$this->Ln(5);
|
||||||
|
$this->SetLineStyle(array('width' => 0.5, 'color' => array(0, 63, 127)));
|
||||||
|
$this->Line(15, $this->GetY(), $this->getPageWidth() - 15, $this->GetY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Footer()
|
||||||
|
{
|
||||||
|
$this->SetY(-15);
|
||||||
|
$this->SetFont('helvetica', 'I', 8);
|
||||||
|
$this->SetTextColor(100, 100, 100);
|
||||||
|
$this->Cell(0, 10, 'CasaDoc - Pagina ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, 0, 'C');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea il PDF passando il nome dell'immobile
|
||||||
|
$pdf = new MYPDF($homeData['name'], PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||||
|
$pdf->SetCreator(PDF_CREATOR);
|
||||||
|
$pdf->SetAuthor('CasaDoc');
|
||||||
|
$pdf->SetTitle($homeData['name']);
|
||||||
|
$pdf->SetMargins(15, 35, 15);
|
||||||
|
$pdf->SetHeaderMargin(10);
|
||||||
|
$pdf->SetFooterMargin(10);
|
||||||
|
$pdf->SetAutoPageBreak(true, 25);
|
||||||
|
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
||||||
|
$pdf->AddPage();
|
||||||
|
|
||||||
|
// Stile generale
|
||||||
|
$pdf->SetFont('helvetica', '', 11);
|
||||||
|
$pdf->SetTextColor(0, 0, 0);
|
||||||
|
|
||||||
|
// Sezione Informazioni Generali
|
||||||
|
$pdf->SetFillColor(240, 248, 255);
|
||||||
|
$pdf->SetDrawColor(0, 63, 127);
|
||||||
|
$pdf->SetLineWidth(0.2);
|
||||||
|
$pdf->Cell(0, 8, 'Informazioni Generali', 'B', 1, 'L', 1);
|
||||||
|
$pdf->Ln(2);
|
||||||
|
|
||||||
|
$html = '
|
||||||
|
<table cellpadding="4">
|
||||||
|
<tr>
|
||||||
|
<td width="30%"><strong>Indirizzo:</strong></td>
|
||||||
|
<td width="70%">' . htmlspecialchars($homeData['fulladdress']) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Città:</strong></td>
|
||||||
|
<td>' . htmlspecialchars($homeData['city']) . ', ' . htmlspecialchars($homeData['country']) . ' ' . htmlspecialchars($homeData['zip']) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Note:</strong></td>
|
||||||
|
<td>' . (empty($homeData['comment']) ? 'Nessuna nota' : htmlspecialchars($homeData['comment'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>';
|
||||||
|
$pdf->writeHTML($html, true, false, true, false, '');
|
||||||
|
|
||||||
|
// Immagine
|
||||||
|
$imageFile = !empty($homeData['mainphoto']) ? 'mainphoto/' . $homeData['mainphoto'] : 'assets/images/no-image.jpg';
|
||||||
|
if (file_exists($imageFile)) {
|
||||||
|
$pdf->Ln(5);
|
||||||
|
list($width, $height) = getimagesize($imageFile);
|
||||||
|
$maxWidth = $pdf->getPageWidth() - 100;
|
||||||
|
$scale = $maxWidth / $width;
|
||||||
|
$newHeight = $height * $scale;
|
||||||
|
$pdf->Image($imageFile, 15, $pdf->GetY(), $maxWidth, $newHeight, '', '', 'T', false, 300, '', false, false, 1);
|
||||||
|
$pdf->Ln($newHeight + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mappa Google Static Maps
|
||||||
|
$latitude = $homeData['latitude'] ?: 41.9028;
|
||||||
|
$longitude = $homeData['longitude'] ?: 12.4964;
|
||||||
|
$googleMapsApiKey = 'AIzaSyADtQRKgCpJNnQCP8QvBeKDcm0TrTPpsGY'; // Sostituisci con la tua chiave API
|
||||||
|
$mapUrl = "https://maps.googleapis.com/maps/api/staticmap?center={$latitude},{$longitude}&zoom=14&size=800x500&markers=color:red|{$latitude},{$longitude}&key={$googleMapsApiKey}";
|
||||||
|
$mapFile = sys_get_temp_dir() . '/map_' . $idhome . '.png';
|
||||||
|
|
||||||
|
file_put_contents($mapFile, file_get_contents($mapUrl));
|
||||||
|
if (file_exists($mapFile)) {
|
||||||
|
$pdf->SetFillColor(240, 248, 255);
|
||||||
|
$pdf->Cell(0, 8, 'Posizione Geografica', 'B', 1, 'L', 1);
|
||||||
|
$pdf->Ln(2);
|
||||||
|
$pdf->Image($mapFile, 15, $pdf->GetY(), 100, 50, '', '', 'T', false, 300, '', false, false, 1);
|
||||||
|
$pdf->Ln(55);
|
||||||
|
unlink($mapFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sezione Dati Catastali
|
||||||
|
$pdf->SetFillColor(240, 248, 255);
|
||||||
|
$pdf->Cell(0, 8, 'Dati Catastali', 'B', 1, 'L', 1);
|
||||||
|
$pdf->Ln(2);
|
||||||
|
|
||||||
|
$html = '
|
||||||
|
<table border="1" cellpadding="5" style="border-color: #003f7f;">
|
||||||
|
<tr style="background-color: #e6f0fa;">
|
||||||
|
<th width="40%"><strong>Campo</strong></th>
|
||||||
|
<th width="60%"><strong>Valore</strong></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Comune Catastale</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_municipality']) ? '-' : htmlspecialchars($homeData['cadastral_municipality'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Sezione</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_section']) ? '-' : htmlspecialchars($homeData['cadastral_section'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Foglio</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_sheet']) ? '-' : htmlspecialchars($homeData['cadastral_sheet'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Particella</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_particle']) ? '-' : htmlspecialchars($homeData['cadastral_particle'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Subalterno</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_sub']) ? '-' : htmlspecialchars($homeData['cadastral_sub'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Categoria</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_category']) ? '-' : htmlspecialchars($homeData['cadastral_category'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Classe</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_class']) ? '-' : htmlspecialchars($homeData['cadastral_class'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Superficie</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_surface']) ? '-' : htmlspecialchars($homeData['cadastral_surface']) . ' mq') . '</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Rendita</td>
|
||||||
|
<td>' . (empty($homeData['cadastral_rendita']) ? '-' : '€' . htmlspecialchars($homeData['cadastral_rendita'])) . '</td>
|
||||||
|
</tr>
|
||||||
|
</table>';
|
||||||
|
$pdf->writeHTML($html, true, false, true, false, '');
|
||||||
|
|
||||||
|
// Nome del file e output
|
||||||
|
$homeNameSafe = preg_replace('/[^A-Za-z0-9\-]/', '_', $homeData['name']);
|
||||||
|
$pdfFileName = "Report_Immobile_{$homeNameSafe}_" . date('Ymd_His') . ".pdf";
|
||||||
|
$pdf->Output($pdfFileName, 'D');
|
||||||
|
exit;
|
||||||
162
public/userportal/download-shared-documents.php
Normal file
162
public/userportal/download-shared-documents.php
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include('include/headscript.php');
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
$iduserlogin = $_SESSION['iduserlogin'];
|
||||||
|
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||||
|
|
||||||
|
// Verifica accesso
|
||||||
|
$querySharing = $conn->prepare("
|
||||||
|
SELECT sharing_type, shared_sections, iduser
|
||||||
|
FROM home_sharing
|
||||||
|
WHERE idhome = ? AND idshareduser = ? AND status = 'accepted'
|
||||||
|
");
|
||||||
|
$querySharing->bind_param('ii', $idhome, $iduserlogin);
|
||||||
|
$querySharing->execute();
|
||||||
|
$sharingData = $querySharing->get_result()->fetch_assoc();
|
||||||
|
|
||||||
|
if (!$sharingData) {
|
||||||
|
die("Accesso negato o condivisione non trovata.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$sharedSections = json_decode($sharingData['shared_sections'], true);
|
||||||
|
$sharingIdUser = $sharingData['iduser'];
|
||||||
|
|
||||||
|
// Recupera i dettagli della casa
|
||||||
|
$queryHome = $conn->prepare("SELECT * FROM home WHERE idhome = ?");
|
||||||
|
$queryHome->bind_param('i', $idhome);
|
||||||
|
$queryHome->execute();
|
||||||
|
$homeData = $queryHome->get_result()->fetch_assoc();
|
||||||
|
$homeName = preg_replace('/[^A-Za-z0-9\-]/', '_', $homeData['name']);
|
||||||
|
|
||||||
|
// Recupera i documenti caricati
|
||||||
|
$queryLoaded = $conn->prepare("
|
||||||
|
SELECT ds.filename, ds.document_id, d.document_name, s.section_name
|
||||||
|
FROM doc_storage ds
|
||||||
|
LEFT JOIN documents d ON ds.document_id = d.document_id
|
||||||
|
LEFT JOIN sections s ON d.idsections = s.idsections
|
||||||
|
LEFT JOIN home_sharing hs ON hs.idhome = ds.idhome
|
||||||
|
WHERE ds.idhome = ? AND hs.idshareduser = ? AND hs.status = 'accepted'
|
||||||
|
AND d.idsections IN (" . implode(',', array_map('intval', $sharedSections)) . ")
|
||||||
|
");
|
||||||
|
$queryLoaded->bind_param('ii', $idhome, $iduserlogin);
|
||||||
|
$queryLoaded->execute();
|
||||||
|
$resultLoaded = $queryLoaded->get_result();
|
||||||
|
|
||||||
|
$files = [];
|
||||||
|
while ($row = $resultLoaded->fetch_assoc()) {
|
||||||
|
$files[] = [
|
||||||
|
'filename' => $row['filename'],
|
||||||
|
'document_name' => $row['document_name'],
|
||||||
|
'section_name' => $row['section_name']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea il PDF del report
|
||||||
|
// ... (codice precedente fino alla creazione del PDF) ...
|
||||||
|
|
||||||
|
class MYPDF extends TCPDF
|
||||||
|
{
|
||||||
|
protected $homeName;
|
||||||
|
|
||||||
|
public function __construct($homeName, $orientation, $unit, $format)
|
||||||
|
{
|
||||||
|
parent::__construct($orientation, $unit, $format);
|
||||||
|
$this->homeName = $homeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Header()
|
||||||
|
{
|
||||||
|
$this->SetFont('helvetica', 'B', 16);
|
||||||
|
$this->SetTextColor(0, 63, 127);
|
||||||
|
$this->Cell(80, 10, 'Report Immobile', 0, 0, 'L');
|
||||||
|
$this->SetFont('helvetica', 'B', 14);
|
||||||
|
$this->Cell(0, 10, htmlspecialchars($this->homeName), 0, 1, 'R');
|
||||||
|
$this->SetFont('helvetica', '', 10);
|
||||||
|
$this->SetTextColor(100, 100, 100);
|
||||||
|
$this->Cell(0, 5, 'Generato il ' . date('d/m/Y H:i'), 0, 1, 'C');
|
||||||
|
$this->Ln(5);
|
||||||
|
$this->SetLineStyle(array('width' => 0.5, 'color' => array(0, 63, 127)));
|
||||||
|
$this->Line(15, $this->GetY(), $this->getPageWidth() - 15, $this->GetY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Footer()
|
||||||
|
{
|
||||||
|
$this->SetY(-15);
|
||||||
|
$this->SetFont('helvetica', 'I', 8);
|
||||||
|
$this->SetTextColor(100, 100, 100);
|
||||||
|
$this->Cell(0, 10, 'CasaDoc - Pagina ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, 0, 'C');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf = new MYPDF($homeData['name'], PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||||
|
$pdf->SetMargins(15, 35, 15);
|
||||||
|
$pdf->SetHeaderMargin(10);
|
||||||
|
$pdf->SetFooterMargin(10);
|
||||||
|
$pdf->SetAutoPageBreak(true, 25);
|
||||||
|
$pdf->AddPage();
|
||||||
|
|
||||||
|
// ... (resto del codice per il PDF e lo ZIP invariato) ...
|
||||||
|
|
||||||
|
$html = '<h2>' . htmlspecialchars($homeData['name']) . '</h2>';
|
||||||
|
$html .= '<p><strong>Indirizzo:</strong> ' . htmlspecialchars($homeData['fulladdress']) . '</p>';
|
||||||
|
$html .= '<p><strong>Città:</strong> ' . htmlspecialchars($homeData['city']) . ', ' . htmlspecialchars($homeData['country']) . ' ' . htmlspecialchars($homeData['zip']) . '</p>';
|
||||||
|
$html .= '<p><strong>Note:</strong> ' . htmlspecialchars($homeData['comment']) . '</p>';
|
||||||
|
$html .= '<h3>Dati Catastali</h3>';
|
||||||
|
$html .= '<p><strong>Comune Catastale:</strong> ' . htmlspecialchars($homeData['cadastral_municipality']) . '</p>';
|
||||||
|
$html .= '<p><strong>Sezione:</strong> ' . htmlspecialchars($homeData['cadastral_section']) . '</p>';
|
||||||
|
$html .= '<p><strong>Foglio:</strong> ' . htmlspecialchars($homeData['cadastral_sheet']) . '</p>';
|
||||||
|
$html .= '<p><strong>Particella:</strong> ' . htmlspecialchars($homeData['cadastral_particle']) . '</p>';
|
||||||
|
$html .= '<p><strong>Subalterno:</strong> ' . htmlspecialchars($homeData['cadastral_sub']) . '</p>';
|
||||||
|
$html .= '<p><strong>Categoria:</strong> ' . htmlspecialchars($homeData['cadastral_category']) . '</p>';
|
||||||
|
$html .= '<p><strong>Classe:</strong> ' . htmlspecialchars($homeData['cadastral_class']) . '</p>';
|
||||||
|
$html .= '<p><strong>Superficie:</strong> ' . htmlspecialchars($homeData['cadastral_surface']) . ' mq</p>';
|
||||||
|
$html .= '<p><strong>Rendita:</strong> €' . htmlspecialchars($homeData['cadastral_rendita']) . '</p>';
|
||||||
|
|
||||||
|
$pdf->writeHTML($html, true, false, true, false, '');
|
||||||
|
|
||||||
|
$imageFile = !empty($homeData['mainphoto']) ? 'mainphoto/' . $homeData['mainphoto'] : 'assets/images/no-image.jpg';
|
||||||
|
if (file_exists($imageFile)) {
|
||||||
|
$pdf->Image($imageFile, 15, $pdf->GetY() + 10, 100, 0, '', '', '', false, 300, '', false, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$reportFilePath = sys_get_temp_dir() . "/Report_Immobile_{$homeName}_" . date('Ymd_His') . ".pdf";
|
||||||
|
$pdf->Output($reportFilePath, 'F'); // Salva il PDF temporaneamente
|
||||||
|
|
||||||
|
// Crea lo ZIP
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$zipFileName = "Documenti_Condivisi_{$homeName}_" . date('Ymd_His') . ".zip";
|
||||||
|
$zipFilePath = sys_get_temp_dir() . '/' . $zipFileName;
|
||||||
|
|
||||||
|
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
|
||||||
|
die("Errore nella creazione del file ZIP.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiungi i documenti allo ZIP
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$filePath = "homedocuments/{$file['filename']}";
|
||||||
|
if (file_exists($filePath)) {
|
||||||
|
$zip->addFile($filePath, "{$file['section_name']}/{$file['document_name']}_{$file['filename']}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiungi il PDF del report
|
||||||
|
if (file_exists($reportFilePath)) {
|
||||||
|
$zip->addFile($reportFilePath, "Report_Immobile_{$homeName}.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
// Download dello ZIP
|
||||||
|
header('Content-Type: application/zip');
|
||||||
|
header('Content-Disposition: attachment; filename="' . $zipFileName . '"');
|
||||||
|
header('Content-Length: ' . filesize($zipFilePath));
|
||||||
|
readfile($zipFilePath);
|
||||||
|
|
||||||
|
// Pulizia
|
||||||
|
unlink($zipFilePath);
|
||||||
|
unlink($reportFilePath);
|
||||||
|
exit;
|
||||||
@ -268,6 +268,19 @@ $result = $stmt->get_result();
|
|||||||
right: 0;
|
right: 0;
|
||||||
left: auto;
|
left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-item.bg-warning {
|
||||||
|
background-color: #ffca2c;
|
||||||
|
/* Giallo brillante */
|
||||||
|
color: #212529;
|
||||||
|
/* Testo scuro per contrasto */
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item.bg-warning:hover {
|
||||||
|
background-color: #e0b026;
|
||||||
|
/* Giallo più scuro al passaggio del mouse */
|
||||||
|
color: #212529;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -380,7 +393,7 @@ $result = $stmt->get_result();
|
|||||||
<li><a class="dropdown-item" href="documents-home-shared.php?idhome=<?php echo $row['idhome']; ?>">
|
<li><a class="dropdown-item" href="documents-home-shared.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
<i class="fas fa-folder-open"></i> Documenti
|
<i class="fas fa-folder-open"></i> Documenti
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a class="dropdown-item" href="download-zip.php?idhome=<?php echo $row['idhome']; ?>">
|
<li><a class="dropdown-item text-dark bg-warning" href="download-shared-documents.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
<i class="fas fa-file-archive"></i> Scarica ZIP
|
<i class="fas fa-file-archive"></i> Scarica ZIP
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a class="dropdown-item" href="download-report.php?idhome=<?php echo $row['idhome']; ?>">
|
<li><a class="dropdown-item" href="download-report.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
@ -425,7 +438,7 @@ $result = $stmt->get_result();
|
|||||||
<i class="fas fa-user"></i> <?php echo htmlspecialchars($row['owner_count']); ?>
|
<i class="fas fa-user"></i> <?php echo htmlspecialchars($row['owner_count']); ?>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown action-menu">
|
<div class="dropdown action-menu">
|
||||||
<button class="btn btn-light btn-sm action-toggle" data-toggle="dropdown">
|
<button class="btn btn-light btn-sm action-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="fas fa-ellipsis-v"></i>
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
@ -435,7 +448,7 @@ $result = $stmt->get_result();
|
|||||||
<a class="dropdown-item" href="documents-home-shared.php?idhome=<?php echo $row['idhome']; ?>">
|
<a class="dropdown-item" href="documents-home-shared.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
<i class="fas fa-folder-open"></i> Documenti
|
<i class="fas fa-folder-open"></i> Documenti
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item" href="download-zip.php?idhome=<?php echo $row['idhome']; ?>">
|
<a class="dropdown-item text-dark bg-warning" href="download-shared-documents.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
<i class="fas fa-file-archive"></i> Scarica ZIP
|
<i class="fas fa-file-archive"></i> Scarica ZIP
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item" href="download-report.php?idhome=<?php echo $row['idhome']; ?>">
|
<a class="dropdown-item" href="download-report.php?idhome=<?php echo $row['idhome']; ?>">
|
||||||
@ -552,6 +565,31 @@ $result = $stmt->get_result();
|
|||||||
$(this).closest('.dropdown-menu').removeClass('show');
|
$(this).closest('.dropdown-menu').removeClass('show');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Controllo se ci sono documenti allegati
|
||||||
|
function checkDocuments() {
|
||||||
|
let documents = document.getElementById("fileInput").files; // Supponendo un input file
|
||||||
|
if (documents.length === 0) {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Nessun documento presente',
|
||||||
|
text: 'Carica almeno un file per procedere.',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Procedi con il caricamento
|
||||||
|
console.log("Documenti trovati:", documents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Esempio di HTML per l'input file
|
||||||
|
document.write('<input type="file" id="fileInput" multiple>');
|
||||||
|
document.write('<button onclick="checkDocuments()">Verifica</button>');
|
||||||
|
|
||||||
|
// Importa la libreria se non l'hai già inclusa
|
||||||
|
document.write('<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11">
|
||||||
|
</script>');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<!-- Modal per visualizzazione dell'immagine -->
|
<!-- Modal per visualizzazione dell'immagine -->
|
||||||
<div class="modal fade" id="photoModal" tabindex="-1" role="dialog" aria-labelledby="photoModalLabel" aria-hidden="true">
|
<div class="modal fade" id="photoModal" tabindex="-1" role="dialog" aria-labelledby="photoModalLabel" aria-hidden="true">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user