big update casadoc
This commit is contained in:
parent
d0698f2a6a
commit
af8f3511eb
@ -37,15 +37,16 @@
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/sanctum": "^3.2",
|
||||
"laravel/socialite": "^5.0",
|
||||
"laravel/tinker": "^2.7",
|
||||
"laravel/ui": "^4.0",
|
||||
"laravelcollective/html": "^6.3",
|
||||
"phpmailer/phpmailer": "^6.9",
|
||||
"proengsoft/laravel-jsvalidation": "^4.0.0",
|
||||
"spatie/laravel-query-builder": "^5.0",
|
||||
"vanguardapp/activity-log": "^5.0",
|
||||
"vanguardapp/announcements": "^5.0",
|
||||
"vanguardapp/plugins": "^5.0",
|
||||
"webpatser/laravel-countries": "dev-master",
|
||||
"laravel/tinker": "^2.7"
|
||||
"webpatser/laravel-countries": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.5",
|
||||
|
||||
85
composer.lock
generated
85
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1446e19ccb5a35288b8f09136f42c7f1",
|
||||
"content-hash": "4aa12c72336d4694139400139378d75f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/laravel-setting",
|
||||
@ -2956,6 +2956,87 @@
|
||||
],
|
||||
"time": "2023-02-08T01:06:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/2f5c94fe7493efc213f643c23b1b1c249d40f47e",
|
||||
"reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"ext-filter": "*",
|
||||
"ext-hash": "*",
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
||||
"doctrine/annotations": "^1.2.6 || ^1.13.3",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3.2",
|
||||
"phpcompatibility/php-compatibility": "^9.3.5",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"squizlabs/php_codesniffer": "^3.7.2",
|
||||
"yoast/phpunit-polyfills": "^1.0.4"
|
||||
},
|
||||
"suggest": {
|
||||
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
|
||||
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
|
||||
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
|
||||
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
|
||||
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
|
||||
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
|
||||
"psr/log": "For optional PSR-3 debug logging",
|
||||
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
|
||||
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHPMailer\\PHPMailer\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marcus Bointon",
|
||||
"email": "phpmailer@synchromedia.co.uk"
|
||||
},
|
||||
{
|
||||
"name": "Jim Jagielski",
|
||||
"email": "jimjag@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Andy Prevost",
|
||||
"email": "codeworxtech@users.sourceforge.net"
|
||||
},
|
||||
{
|
||||
"name": "Brent R. Matzelle"
|
||||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Synchro",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-24T18:04:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.9.1",
|
||||
@ -10110,5 +10191,5 @@
|
||||
"ext-json": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
||||
59
public/userportal/add-document.php
Normal file
59
public/userportal/add-document.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Verifica se la richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$document_name = $conn->real_escape_string($_POST['document_name']);
|
||||
$page_id = isset($_POST['page_id']) ? (int)$_POST['page_id'] : null;
|
||||
$idsections = isset($_POST['idsections']) ? (int)$_POST['idsections'] : null;
|
||||
$max_documents = isset($_POST['max_documents']) ? (int)$_POST['max_documents'] : 0;
|
||||
$is_required = isset($_POST['is_required']) ? (int)$_POST['is_required'] : 0;
|
||||
$notes = !empty($_POST['notes']) ? $conn->real_escape_string($_POST['notes']) : null;
|
||||
|
||||
// Prepara la query di inserimento
|
||||
$query = "
|
||||
INSERT INTO documents (document_name, page_id, idsections, max_documents, is_required, notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param('siiiss', $document_name, $page_id, $idsections, $max_documents, $is_required, $notes);
|
||||
|
||||
// Esegue la query e controlla il risultato
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza con messaggio di successo
|
||||
header("Location: documents-settings.php?success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza con messaggio di errore
|
||||
header("Location: documents-settings.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
25
public/userportal/add-page.php
Normal file
25
public/userportal/add-page.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera i dati dal form
|
||||
$namepages = $_POST['namepages'];
|
||||
$slug = $_POST['slug'];
|
||||
$descriptionpages = $_POST['descriptionpages'];
|
||||
|
||||
// Inserisce la nuova pagina nel database
|
||||
$query = $conn->prepare("INSERT INTO pages (namepages, slug, descriptionpages) VALUES (?, ?, ?)");
|
||||
$query->bind_param('sss', $namepages, $slug, $descriptionpages);
|
||||
|
||||
if ($query->execute()) {
|
||||
header("Location: page-settings.php?success=1");
|
||||
} else {
|
||||
header("Location: page-settings.php?error=1");
|
||||
}
|
||||
|
||||
$query->close();
|
||||
$conn->close();
|
||||
39
public/userportal/add-role.php
Normal file
39
public/userportal/add-role.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
|
||||
// Abilita debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla il metodo della richiesta
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$role_name = trim($_POST['role_name']);
|
||||
$description = trim($_POST['description']);
|
||||
$permissions = trim($_POST['permissions']);
|
||||
|
||||
|
||||
|
||||
// Prepara e esegue la query
|
||||
$stmt = $conn->prepare("INSERT INTO sharing_roles (`role_name`, `description`, `permissions`) VALUES (?, ?, ?)");
|
||||
if ($stmt) {
|
||||
$stmt->bind_param('sss', $role_name, $description, $permissions);
|
||||
if ($stmt->execute()) {
|
||||
header("Location: sharing-roles.php?success=1");
|
||||
exit;
|
||||
} else {
|
||||
die("Errore di esecuzione: " . $stmt->error);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
}
|
||||
$conn->close();
|
||||
52
public/userportal/add-section.php
Normal file
52
public/userportal/add-section.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se il metodo della richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$section_name = $conn->real_escape_string($_POST['section_name']);
|
||||
$description = $conn->real_escape_string($_POST['description']);
|
||||
|
||||
// Prepara la query per l'inserimento
|
||||
$query = "INSERT INTO sections (section_name, description) VALUES (?, ?)";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param('ss', $section_name, $description);
|
||||
|
||||
// Esegue la query
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di successo
|
||||
header("Location: sections.php?success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di errore
|
||||
header("Location: sections.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
187
public/userportal/add-sharing.php
Normal file
187
public/userportal/add-sharing.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera idhome
|
||||
$idhome = isset($_GET['idhome']) ? (int)$_GET['idhome'] : 0;
|
||||
|
||||
// Recupera le sezioni dalla tabella 'sections'
|
||||
$querySections = "SELECT idsections, section_name FROM sections ORDER BY section_name ASC";
|
||||
$resultSections = $conn->query($querySections);
|
||||
$sections = [];
|
||||
if ($resultSections->num_rows > 0) {
|
||||
while ($row = $resultSections->fetch_assoc()) {
|
||||
$sections[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// Recupera tutti i ruoli per la dropdown
|
||||
$queryRoles = "SELECT idrole, role_name FROM sharing_roles";
|
||||
$resultRoles = $conn->query($queryRoles);
|
||||
$roles = [];
|
||||
if ($resultRoles->num_rows > 0) {
|
||||
while ($row = $resultRoles->fetch_assoc()) {
|
||||
$roles[] = $row;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Aggiungi Condivisione</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.form-check-label {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #0056b3;
|
||||
border-color: #004085;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #6c757d;
|
||||
border-color: #6c757d;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: #5a6268;
|
||||
border-color: #545b62;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header bg-warning text-white">
|
||||
<h4 class="mb-0">
|
||||
<i class="fas fa-share-alt"></i> Aggiungi Condivisione
|
||||
</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="save-sharing.php" method="POST">
|
||||
<input type="hidden" name="idhome" value="<?php echo $idhome; ?>">
|
||||
|
||||
<!-- Email destinatario -->
|
||||
<div class="form-group">
|
||||
<label for="shared_email" class="form-label">
|
||||
<i class="fas fa-envelope"></i> Email destinatario
|
||||
</label>
|
||||
<input type="email" class="form-control" id="shared_email" name="shared_email" placeholder="Inserisci email del destinatario" required>
|
||||
</div>
|
||||
|
||||
<!-- Ruolo destinatario -->
|
||||
<div class="form-group">
|
||||
<label for="role_id" class="form-label">
|
||||
<i class="fas fa-user-tag"></i> Tipologia destinatario
|
||||
</label>
|
||||
<select class="form-control" id="role_id" name="role_id" required>
|
||||
<option value="">Seleziona un ruolo</option>
|
||||
<?php foreach ($roles as $role) { ?>
|
||||
<option value="<?php echo $role['idrole']; ?>"><?php echo htmlspecialchars($role['role_name']); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Tipo di condivisione -->
|
||||
<div class="form-group">
|
||||
<label for="sharing_type" class="form-label">
|
||||
<i class="fas fa-lock"></i> Tipo di condivisione
|
||||
</label>
|
||||
<select class="form-control" id="sharing_type" name="sharing_type" required>
|
||||
<option value="read-only">Solo lettura</option>
|
||||
<option value="add-documents">Aggiunta documenti</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Sezioni condivise -->
|
||||
<div class="form-group">
|
||||
<label class="form-label">
|
||||
<i class="fas fa-folder"></i> Sezioni condivise
|
||||
</label>
|
||||
<div>
|
||||
<?php foreach ($sections as $section) { ?>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="section_<?php echo $section['idsections']; ?>" name="shared_sections[]" value="<?php echo $section['idsections']; ?>">
|
||||
<label class="form-check-label" for="section_<?php echo $section['idsections']; ?>">
|
||||
<?php echo htmlspecialchars($section['section_name']); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Data di scadenza -->
|
||||
<div class="form-group">
|
||||
<label for="expiration_date" class="form-label">
|
||||
<i class="fas fa-calendar-alt"></i> Data di scadenza
|
||||
</label>
|
||||
<input type="date" class="form-control" id="expiration_date" name="expiration_date">
|
||||
</div>
|
||||
|
||||
<!-- Pulsanti -->
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="btn btn-primary btn-lg">
|
||||
<i class="fas fa-save"></i> Salva Condivisione
|
||||
</button>
|
||||
<a href="share-home.php?idhome=<?php echo $idhome; ?>" class="btn btn-secondary btn-lg">
|
||||
<i class="fas fa-arrow-left"></i> Annulla
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Page content Wrapper -->
|
||||
</div> <!-- content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
291
public/userportal/admin.php
Normal file
291
public/userportal/admin.php
Normal file
@ -0,0 +1,291 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database e avvio sessione
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'id utente loggato
|
||||
$iduserlogin = $_SESSION['iduserlogin'];
|
||||
|
||||
// Calcolo del numero di immobili
|
||||
$queryHomes = $conn->prepare("SELECT COUNT(*) AS total_homes FROM home");
|
||||
$queryHomes->execute();
|
||||
$resultHomes = $queryHomes->get_result();
|
||||
$totalHomes = $resultHomes->fetch_assoc()['total_homes'];
|
||||
|
||||
// Calcolo del numero di persone
|
||||
$queryOwners = $conn->prepare("SELECT COUNT(*) AS total_owners FROM property_owners");
|
||||
$queryOwners->execute();
|
||||
$resultOwners = $queryOwners->get_result();
|
||||
$totalOwners = $resultOwners->fetch_assoc()['total_owners'];
|
||||
|
||||
// Numero di documenti (placeholder per ora)
|
||||
// Calcolo del numero di documenti
|
||||
$queryDocuments = $conn->prepare("
|
||||
SELECT COUNT(*) AS total_documents
|
||||
FROM doc_storage
|
||||
LEFT JOIN home ON doc_storage.idhome = home.idhome
|
||||
WHERE home.iduser = ?
|
||||
");
|
||||
$queryDocuments->bind_param('i', $iduserlogin);
|
||||
$queryDocuments->execute();
|
||||
$resultDocuments = $queryDocuments->get_result();
|
||||
$totalDocuments = $resultDocuments->fetch_assoc()['total_documents'];
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<?php include('include/seo.php'); ?>
|
||||
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<style>
|
||||
/* Visualizza il pulsante mobile anche su desktop */
|
||||
.button-menu-mobile {
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
/* Nascondi il quadrato rosso con la X su desktop */
|
||||
@media (min-width: 992px) {
|
||||
.button-menu-mobile {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.button-menu-mobile i.ion-close {
|
||||
display: none;
|
||||
/* Nasconde la X rossa */
|
||||
}
|
||||
|
||||
.button-menu-mobile i.mdi-menu {
|
||||
display: inline-block;
|
||||
/* Mostra sempre le tre righe orizzontali */
|
||||
}
|
||||
}
|
||||
|
||||
/* Stile per mobile: Mantieni il comportamento originale */
|
||||
@media (max-width: 991.98px) {
|
||||
.button-menu-mobile {
|
||||
background-color: #ff5e5e;
|
||||
/* Questo è il colore rosso originale */
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.button-menu-mobile i.ion-close {
|
||||
display: inline-block;
|
||||
/* Mostra la X rossa */
|
||||
}
|
||||
|
||||
.button-menu-mobile i.mdi-menu {
|
||||
display: none;
|
||||
/* Nasconde le tre righe quando la barra è aperta */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<!-- Loader -->
|
||||
<div id="preloader">
|
||||
<div id="status">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="wrapper">
|
||||
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<!-- Start right Content here -->
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start content -->
|
||||
<div class="content">
|
||||
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper ">
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="page-title-box">
|
||||
<div class="btn-group float-right">
|
||||
<ol class="breadcrumb hide-phone p-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="#">CasaDoc</a></li>
|
||||
<li class="breadcrumb-item active">Dashboard</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Dashboard</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title end breadcrumb -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<!-- Statistica: Numero di immobili -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="mdi mdi-home-outline" style="font-size: 2.5rem; color: #85c1e9;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalHomes; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Immobili inseriti</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistica: Numero di persone -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="mdi mdi-account-outline" style="font-size: 2.5rem; color: #82e0aa;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalOwners; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Proprietari registrati</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistica: Numero di documenti -->
|
||||
<!-- Statistica: Numero di documenti -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="mdi mdi-file-outline" style="font-size: 2.5rem; color: #f8c471;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalDocuments; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Documenti caricati</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row text-center mt-4">
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="page-settings.php" class="btn btn-warning d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-book-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Gestione Pagine</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="documents-settings.php" class="btn btn-danger d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-file-cog-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Gestione Documenti</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center mt-4">
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="sharing-roles.php" class="btn btn-info d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-book-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Ruoli Condivisione</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="sections.php" class="btn btn-success d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-file-cog-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Sections</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div><!-- container -->
|
||||
|
||||
</div> <!-- Page content Wrapper -->
|
||||
|
||||
</div> <!-- content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
|
||||
</div>
|
||||
<!-- End Right content here -->
|
||||
|
||||
</div>
|
||||
<!-- END wrapper -->
|
||||
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/popper.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="assets/js/modernizr.min.js"></script>
|
||||
<script src="assets/js/detect.js"></script>
|
||||
<script src="assets/js/fastclick.js"></script>
|
||||
<script src="assets/js/jquery.slimscroll.js"></script>
|
||||
<script src="assets/js/jquery.blockUI.js"></script>
|
||||
<script src="assets/js/waves.js"></script>
|
||||
<script src="assets/js/jquery.nicescroll.js"></script>
|
||||
<script src="assets/js/jquery.scrollTo.min.js"></script>
|
||||
|
||||
<script src="assets/plugins/chart.js/chart.min.js"></script>
|
||||
<script src="assets/pages/dashboard.js"></script>
|
||||
|
||||
<!-- App js -->
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
30
public/userportal/delete-document.php
Normal file
30
public/userportal/delete-document.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$documentId = isset($_POST['document_id']) ? intval($_POST['document_id']) : 0;
|
||||
$fileName = isset($_POST['file_name']) ? $_POST['file_name'] : '';
|
||||
|
||||
if ($documentId > 0 && !empty($fileName)) {
|
||||
// Elimina il file dal server
|
||||
$filePath = "persondocuments/" . $fileName;
|
||||
if (file_exists($filePath)) {
|
||||
unlink($filePath);
|
||||
}
|
||||
|
||||
// Elimina dal database
|
||||
$query = $conn->prepare("DELETE FROM doc_storage WHERE id = ?");
|
||||
$query->bind_param("i", $documentId);
|
||||
if ($query->execute()) {
|
||||
echo json_encode(["success" => true]);
|
||||
} else {
|
||||
echo json_encode(["success" => false, "message" => "Errore durante l'eliminazione dal database."]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(["success" => false, "message" => "Parametri non validi."]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(["success" => false, "message" => "Metodo non consentito."]);
|
||||
}
|
||||
63
public/userportal/delete-home.php
Normal file
63
public/userportal/delete-home.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// Abilita la visualizzazione degli errori (solo per sviluppo, disabilitare in produzione)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Verifica se l'ID della casa è stato passato tramite GET
|
||||
if (isset($_GET['idhome']) && is_numeric($_GET['idhome'])) {
|
||||
$idhome = (int)$_GET['idhome'];
|
||||
|
||||
// Avvia la transazione per gestire l'eliminazione di record correlati
|
||||
$conn->begin_transaction();
|
||||
|
||||
try {
|
||||
// Elimina i documenti associati nella tabella `doc_storage`
|
||||
$stmtDocs = $conn->prepare("DELETE FROM doc_storage WHERE idhome = ?");
|
||||
$stmtDocs->bind_param('i', $idhome);
|
||||
$stmtDocs->execute();
|
||||
$stmtDocs->close();
|
||||
|
||||
// Elimina le condivisioni associate nella tabella `home_sharing`
|
||||
$stmtSharing = $conn->prepare("DELETE FROM home_sharing WHERE idhome = ?");
|
||||
$stmtSharing->bind_param('i', $idhome);
|
||||
$stmtSharing->execute();
|
||||
$stmtSharing->close();
|
||||
|
||||
// Elimina la casa dalla tabella `home`
|
||||
$stmtHome = $conn->prepare("DELETE FROM home WHERE idhome = ?");
|
||||
$stmtHome->bind_param('i', $idhome);
|
||||
$stmtHome->execute();
|
||||
$stmtHome->close();
|
||||
|
||||
// Conferma la transazione
|
||||
$conn->commit();
|
||||
|
||||
// Reindirizza alla lista delle case con un messaggio di successo
|
||||
header("Location: homes-list.php?success=1");
|
||||
exit();
|
||||
} catch (Exception $e) {
|
||||
// Annulla la transazione in caso di errore
|
||||
$conn->rollback();
|
||||
|
||||
// Reindirizza con un messaggio di errore
|
||||
header("Location: homes-list.php?error=1");
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
// Reindirizza se l'ID non è valido
|
||||
header("Location: homes-list.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
23
public/userportal/delete-page.php
Normal file
23
public/userportal/delete-page.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'ID della pagina da eliminare
|
||||
$idpages = intval($_GET['idpages']);
|
||||
|
||||
// Cancella la pagina dal database
|
||||
$query = $conn->prepare("DELETE FROM pages WHERE idpages = ?");
|
||||
$query->bind_param('i', $idpages);
|
||||
|
||||
if ($query->execute()) {
|
||||
header("Location: page-settings.php?success=1");
|
||||
} else {
|
||||
header("Location: page-settings.php?error=1");
|
||||
}
|
||||
|
||||
$query->close();
|
||||
$conn->close();
|
||||
24
public/userportal/delete-role.php
Normal file
24
public/userportal/delete-role.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
if (isset($_GET['idrole'])) {
|
||||
$idrole = intval($_GET['idrole']);
|
||||
|
||||
$query = "DELETE FROM sharing_roles WHERE idrole = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param('i', $idrole);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
header("Location: sharing-roles.php?success=true");
|
||||
} else {
|
||||
header("Location: sharing-roles.php?error=true");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
$conn->close();
|
||||
39
public/userportal/delete-sharing.php
Normal file
39
public/userportal/delete-sharing.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se è stato fornito un ID condivisione
|
||||
if (!isset($_GET['idsharing']) || empty($_GET['idsharing'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID condivisione non valido.']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$idsharing = intval($_GET['idsharing']);
|
||||
|
||||
// Elimina la condivisione dalla tabella
|
||||
$query = $conn->prepare("DELETE FROM home_sharing WHERE idsharing = ?");
|
||||
$query->bind_param('i', $idsharing);
|
||||
|
||||
if ($query->execute()) {
|
||||
// Successo: reindirizza con messaggio di conferma
|
||||
header("Location: share-home.php?success=Condivisione eliminata con successo");
|
||||
exit();
|
||||
} else {
|
||||
// Errore: reindirizza con messaggio di errore
|
||||
header("Location: share-home.php?error=Errore durante l'eliminazione della condivisione");
|
||||
exit();
|
||||
}
|
||||
|
||||
$query->close();
|
||||
$conn->close();
|
||||
@ -1,4 +1,9 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php include('include/headscript.php');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
@ -16,12 +21,40 @@ $queryHome->execute();
|
||||
$resultHome = $queryHome->get_result();
|
||||
$homeData = $resultHome->fetch_assoc();
|
||||
|
||||
// Recupera i documenti dalla tabella 'documents' raggruppati per sezione
|
||||
$queryDocuments = $conn->query("SELECT * FROM documents ORDER BY section");
|
||||
if (!isset($_GET['docpage'])) {
|
||||
$docpage = "legal"; // Slug predefinito
|
||||
} else {
|
||||
$docpage = $_GET['docpage']; // Slug passato via GET
|
||||
}
|
||||
|
||||
// Recupera il `page_id` corrispondente allo slug
|
||||
$queryPageId = $conn->prepare("SELECT idpages FROM pages WHERE slug = ?");
|
||||
$queryPageId->bind_param('s', $docpage);
|
||||
$queryPageId->execute();
|
||||
$resultPageId = $queryPageId->get_result();
|
||||
$pageData = $resultPageId->fetch_assoc();
|
||||
|
||||
if ($pageData) {
|
||||
$page_id = $pageData['idpages']; // Page ID trovato
|
||||
} else {
|
||||
die("Errore: Pagina non valida."); // Slug non trovato
|
||||
}
|
||||
|
||||
// Recupera i documenti associati al `page_id`, con le sezioni
|
||||
$queryDocuments = $conn->prepare("
|
||||
SELECT d.*, s.section_name AS section_name
|
||||
FROM documents d
|
||||
LEFT JOIN sections s ON d.idsections = s.idsections
|
||||
WHERE d.page_id = ?
|
||||
ORDER BY s.section_name, d.document_name
|
||||
");
|
||||
$queryDocuments->bind_param('i', $page_id);
|
||||
$queryDocuments->execute();
|
||||
$resultDocuments = $queryDocuments->get_result();
|
||||
|
||||
$documents = [];
|
||||
while ($row = $queryDocuments->fetch_assoc()) {
|
||||
$documents[$row['section']][] = $row;
|
||||
while ($row = $resultDocuments->fetch_assoc()) {
|
||||
$documents[$row['section_name']][] = $row;
|
||||
}
|
||||
|
||||
// Recupera i documenti già caricati per questa casa
|
||||
@ -34,7 +67,16 @@ $loadedDocuments = [];
|
||||
while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
$loadedDocuments[$row['document_id']][] = $row;
|
||||
}
|
||||
|
||||
// Recupera le pagine disponibili nella tabella 'documents'
|
||||
$queryPages = $conn->query("SELECT * FROM pages ORDER BY namepages");
|
||||
$pages = [];
|
||||
while ($row = $queryPages->fetch_assoc()) {
|
||||
$pages[] = $row;
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
@ -47,7 +89,7 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
<!-- Bootstrap 4 CSS -->
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/dripicons/2.0.0/webfont.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet" />
|
||||
|
||||
@ -56,8 +98,53 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
|
||||
<!-- Dropzone CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.7/dist/umd/popper.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<style>
|
||||
/* Personalizza la riga della sezione */
|
||||
.section-header {
|
||||
background-color: #f8f9fa;
|
||||
/* Sfondo chiaro */
|
||||
border: 1px solid #007bff;
|
||||
/* Bordo blu */
|
||||
color: #007bff;
|
||||
/* Testo blu */
|
||||
font-size: 1.2rem;
|
||||
/* Dimensione del font */
|
||||
font-weight: bold;
|
||||
/* Grassetto */
|
||||
padding: 15px 20px;
|
||||
/* Padding */
|
||||
text-align: left;
|
||||
/* Allinea il testo a sinistra */
|
||||
width: 100%;
|
||||
/* A tutta larghezza */
|
||||
}
|
||||
|
||||
.section-header:hover {
|
||||
background-color: #007bff;
|
||||
/* Sfondo blu al passaggio del mouse */
|
||||
color: #fff;
|
||||
/* Testo bianco al passaggio del mouse */
|
||||
}
|
||||
|
||||
.accordion-button {
|
||||
border-radius: 0 !important;
|
||||
/* Rimuove gli angoli arrotondati */
|
||||
box-shadow: none !important;
|
||||
/* Rimuove l'ombra */
|
||||
}
|
||||
|
||||
/* Icona accanto al titolo */
|
||||
.section-header i {
|
||||
font-size: 1.5rem;
|
||||
/* Dimensione dell'icona */
|
||||
margin-right: 10px;
|
||||
/* Spaziatura a destra dell'icona */
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: bold;
|
||||
@ -110,6 +197,59 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
.btn {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.btn.active {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Stile per l'intestazione della sezione */
|
||||
.accordion-button {
|
||||
background-color: #322999;
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
border: 1px solid #007bff;
|
||||
}
|
||||
|
||||
.accordion-button:hover {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.accordion-button i {
|
||||
font-size: 1.5rem;
|
||||
color: #fff562;
|
||||
}
|
||||
|
||||
.accordion-body {
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
margin-bottom: 20px;
|
||||
padding: 15px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.toggle-dropzone {
|
||||
transition: all 0.3s ease;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.dropzone-container {
|
||||
padding: 10px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px dashed #007bff;
|
||||
border-radius: 8px;
|
||||
display: none;
|
||||
/* Nasconde inizialmente l'area */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -119,7 +259,7 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<br>
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Dettagli della Casa -->
|
||||
@ -129,58 +269,99 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
<p><strong>Indirizzo:</strong> <?php echo htmlspecialchars($homeData['address']) . ', ' . htmlspecialchars($homeData['city']) . ' ' . htmlspecialchars($homeData['zip']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 text-center">
|
||||
<div class="btn-group" role="group" aria-label="Pagine">
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<button
|
||||
class="btn btn-outline-primary filter-btn <?php echo $docpage === $page['slug'] ? 'active' : ''; ?>"
|
||||
onclick="window.location.href='?docpage=<?php echo htmlspecialchars($page['slug']); ?>&idhome=<?php echo htmlspecialchars($idhome); ?>';">
|
||||
<?php echo ucfirst(htmlspecialchars($page['namepages'])); ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sezioni per documenti -->
|
||||
<?php foreach ($documents as $section => $sectionDocuments) { ?>
|
||||
<div class="section-separator"></div>
|
||||
<h5 class="section-title"><?php echo htmlspecialchars($section); ?></h5>
|
||||
<?php foreach ($sectionDocuments as $document) { ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card card-body mb-4">
|
||||
<!-- Titolo del documento -->
|
||||
<p class="document-title">
|
||||
<?php echo htmlspecialchars($document['document_name']); ?>
|
||||
<?php if ($document['is_required']) echo "<strong>(Obbligatorio)</strong>"; ?>
|
||||
<?php if ($document['max_documents'] > 0) echo " - Max: " . $document['max_documents']; ?>
|
||||
</p>
|
||||
<div class="accordion" id="documentSections">
|
||||
<?php foreach ($documents as $sectionName => $sectionDocuments) { ?>
|
||||
<div class="accordion-item">
|
||||
<!-- Header della sezione -->
|
||||
<h2 class="accordion-header" id="heading-<?php echo md5($sectionName); ?>">
|
||||
<button class="accordion-button collapsed section-header full-width" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-<?php echo md5($sectionName); ?>" aria-expanded="false" aria-controls="collapse-<?php echo md5($sectionName); ?>">
|
||||
<i class="fas fa-door-open"></i> <?php echo htmlspecialchars($sectionName); ?>
|
||||
</button>
|
||||
</h2>
|
||||
<!-- Corpo della sezione -->
|
||||
<div id="collapse-<?php echo md5($sectionName); ?>" class="accordion-collapse collapse" aria-labelledby="heading-<?php echo md5($sectionName); ?>" data-bs-parent="#documentSections">
|
||||
<div class="accordion-body">
|
||||
<?php foreach ($sectionDocuments as $document) { ?>
|
||||
<div class="card card-body mb-4">
|
||||
<!-- Titolo del documento -->
|
||||
<div class="document-header d-flex justify-content-between align-items-center p-3 mb-3" style="background-color: #e8f5e9; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);">
|
||||
<div>
|
||||
<span class="document-title fw-bold"><?php echo htmlspecialchars($document['document_name']); ?></span>
|
||||
<?php if ($document['is_required']) { ?>
|
||||
<span class="badge bg-danger ms-2" style="font-size: 1rem; padding: 0.5em 0.8em;">Obbligatorio</span>
|
||||
<?php } ?>
|
||||
<?php if ($document['max_documents'] > 0) { ?>
|
||||
<span class="badge bg-info ms-2" style="font-size: 1rem; padding: 0.5em 0.8em;">Max: <?php echo $document['max_documents']; ?></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<button class="btn btn-sm btn-outline-primary toggle-dropzone" data-target="#dropzone-<?php echo $document['document_id']; ?>">
|
||||
<i class="fas fa-plus"></i> <!-- Icona per il toggle -->
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Area Drag & Drop per il caricamento -->
|
||||
<div class="dropzone mb-3" id="dropzone-<?php echo $document['document_id']; ?>">
|
||||
<div class="dz-message">
|
||||
<i class="fas fa-cloud-upload-alt"></i><br>
|
||||
Trascina qui i documenti o clicca per caricare
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabella dei documenti già caricati -->
|
||||
<h6 class="mt-4">Documenti già caricati:</h6>
|
||||
<table class="table table-bordered document-list-table" id="table-<?php echo $document['document_id']; ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome Documento</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Qui verranno inseriti i documenti caricati per quel documento -->
|
||||
<?php if (isset($loadedDocuments[$document['document_id']])) { ?>
|
||||
<?php foreach ($loadedDocuments[$document['document_id']] as $loadedDoc) { ?>
|
||||
<tr>
|
||||
<td><a href="homedocuments/<?php echo $loadedDoc['filename']; ?>" target="_blank"><?php echo htmlspecialchars($loadedDoc['filename']); ?></a></td>
|
||||
<td><?php echo htmlspecialchars($loadedDoc['created_at']); ?></td>
|
||||
<td><button class="btn btn-danger btn-sm">Elimina</button></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<!-- Area Drag & Drop per il caricamento -->
|
||||
<div class="dropzone-container collapse" id="dropzone-<?php echo $document['document_id']; ?>">
|
||||
<div class="dropzone mb-3">
|
||||
<div class="dz-message">
|
||||
<i class="fas fa-cloud-upload-alt"></i><br>
|
||||
Trascina qui i documenti o clicca per caricare
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tabella dei documenti già caricati -->
|
||||
<h6 class="mt-4">Documenti già caricati:</h6>
|
||||
<?php if (isset($loadedDocuments[$document['document_id']]) && count($loadedDocuments[$document['document_id']]) > 0) { ?>
|
||||
<!-- Mostra la tabella se ci sono documenti caricati -->
|
||||
<table class="table table-bordered document-list-table" id="table-<?php echo $document['document_id']; ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome Documento</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($loadedDocuments[$document['document_id']] as $loadedDoc) { ?>
|
||||
<tr>
|
||||
<td><a href="homedocuments/<?php echo $loadedDoc['filename']; ?>" target="_blank"><?php echo htmlspecialchars($loadedDoc['filename']); ?></a></td>
|
||||
<td><?php echo htmlspecialchars($loadedDoc['created_at']); ?></td>
|
||||
<td><button class="btn btn-danger btn-sm delete-document" data-id="<?php echo $loadedDoc['id']; ?>" data-file="<?php echo $loadedDoc['filename']; ?>">Elimina</button></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<!-- Mostra il messaggio se non ci sono documenti caricati -->
|
||||
<p class="text-muted">Nessun documento caricato</p>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><!-- container -->
|
||||
</div><!-- Page content Wrapper -->
|
||||
</div><!-- content -->
|
||||
@ -197,24 +378,79 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.js"></script>
|
||||
|
||||
<script>
|
||||
// Disabilita l'auto-discover di Dropzone
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
// Inizializza Dropzone per ciascun documento
|
||||
<?php foreach ($documents as $section => $sectionDocuments) { ?>
|
||||
<?php foreach ($sectionDocuments as $document) { ?>
|
||||
new Dropzone("#dropzone-<?php echo $document['document_id']; ?>", {
|
||||
url: "upload-document.php", // URL del caricamento
|
||||
paramName: "file", // Il nome del campo per il file
|
||||
maxFiles: <?php echo $document['max_documents']; ?>, // Imposta il numero massimo di file
|
||||
addRemoveLinks: true,
|
||||
url: "upload-document.php", // URL per il caricamento
|
||||
paramName: "file", // Nome del campo per il file
|
||||
maxFiles: <?php echo $document['max_documents']; ?>, // Numero massimo di file
|
||||
maxFilesize: 5, // Dimensione massima del file in MB
|
||||
addRemoveLinks: true, // Permette di rimuovere i file
|
||||
acceptedFiles: "image/*,application/pdf", // Tipi di file accettati
|
||||
dictDefaultMessage: "Trascina qui i file o clicca per caricarli",
|
||||
dictRemoveFile: "Rimuovi",
|
||||
previewTemplate: `
|
||||
<div class="dz-preview dz-file-preview">
|
||||
<div class="dz-image"><img data-dz-thumbnail /></div>
|
||||
<div class="dz-details">
|
||||
<div class="dz-filename"><span data-dz-name></span></div>
|
||||
<div class="dz-size"><span data-dz-size></span></div>
|
||||
</div>
|
||||
<div class="dz-progress">
|
||||
<span class="dz-upload" data-dz-uploadprogress></span>
|
||||
</div>
|
||||
<div class="dz-error-message"><span data-dz-errormessage></span></div>
|
||||
<div class="dz-success-mark">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
</div>
|
||||
<div class="dz-error-mark">
|
||||
<i class="fas fa-times-circle"></i>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
init: function() {
|
||||
this.on("success", function(file, response) {
|
||||
let tableId = "#table-<?php echo $document['document_id']; ?> tbody";
|
||||
// Aggiorna la tabella dei documenti caricati
|
||||
let row = `<tr>
|
||||
<td><a href="homedocuments/${response.fileName}" target="_blank">${response.fileName}</a></td>
|
||||
<td>${response.uploadDate}</td>
|
||||
<td><button class="btn btn-danger btn-sm">Elimina</button></td>
|
||||
</tr>`;
|
||||
$(tableId).append(row);
|
||||
try {
|
||||
let parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
|
||||
|
||||
if (parsedResponse.success) {
|
||||
// Aggiungi il file alla tabella
|
||||
let tableId = "#table-<?php echo $document['document_id']; ?> tbody";
|
||||
let row = `
|
||||
<tr>
|
||||
<td><a href="homedocuments/${parsedResponse.fileName}" target="_blank">${parsedResponse.fileName}</a></td>
|
||||
<td>${parsedResponse.uploadDate}</td>
|
||||
<td><button class="btn btn-danger btn-sm delete-document" data-id="${parsedResponse.documentId}" data-file="${parsedResponse.fileName}">Elimina</button></td>
|
||||
</tr>`;
|
||||
$(tableId).append(row);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: parsedResponse.message || "Errore nel caricamento",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore nel parsing della risposta:", error);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Risposta dal server non valida.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.on("error", function(file, errorMessage) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: errorMessage || "Si è verificato un problema.",
|
||||
});
|
||||
this.removeFile(file); // Rimuovi il file in caso di errore
|
||||
});
|
||||
},
|
||||
sending: function(file, xhr, formData) {
|
||||
@ -225,6 +461,93 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).on("click", ".delete-document", function() {
|
||||
const documentId = $(this).data("id");
|
||||
const fileName = $(this).data("file");
|
||||
const $row = $(this).closest("tr");
|
||||
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa azione eliminerà il documento in modo permanente.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, elimina",
|
||||
cancelButtonText: "Annulla",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: "delete-document.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
document_id: documentId,
|
||||
file_name: fileName,
|
||||
},
|
||||
success: function(response) {
|
||||
try {
|
||||
const parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
|
||||
|
||||
if (parsedResponse.success) {
|
||||
$row.remove(); // Rimuovi la riga dalla tabella
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Eliminato",
|
||||
text: "Documento eliminato con successo.",
|
||||
timer: 1500,
|
||||
showConfirmButton: false,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: parsedResponse.message || "Impossibile eliminare il documento.",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore durante l'eliminazione:", error);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Risposta dal server non valida.",
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Si è verificato un problema con la richiesta.",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// Gestione del toggle dell'area Dropzone
|
||||
document.querySelectorAll('.toggle-dropzone').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const target = document.querySelector(this.dataset.target);
|
||||
const icon = this.querySelector('i');
|
||||
|
||||
if (target.classList.contains('show')) {
|
||||
target.classList.remove('show');
|
||||
target.style.display = 'none';
|
||||
icon.classList.remove('fa-minus');
|
||||
icon.classList.add('fa-plus');
|
||||
} else {
|
||||
target.classList.add('show');
|
||||
target.style.display = 'block';
|
||||
icon.classList.remove('fa-plus');
|
||||
icon.classList.add('fa-minus');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
479
public/userportal/documents-person.php
Normal file
479
public/userportal/documents-person.php
Normal file
@ -0,0 +1,479 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Database connection
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Get logged-in user ID
|
||||
$iduserlogin = $_SESSION['iduserlogin'];
|
||||
|
||||
// Process POST request and retrieve owner_id
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$owner_id = isset($_POST['owner_id']) ? intval($_POST['owner_id']) : 0;
|
||||
|
||||
if ($owner_id > 0) {
|
||||
// Retrieve owner details
|
||||
$queryOwner = $conn->prepare("
|
||||
SELECT first_name, last_name, company_name, owner_type
|
||||
FROM property_owners
|
||||
WHERE owner_id = ? AND user_id = ?
|
||||
");
|
||||
$queryOwner->bind_param('ii', $owner_id, $iduserlogin);
|
||||
$queryOwner->execute();
|
||||
$resultOwner = $queryOwner->get_result();
|
||||
$ownerDetails = $resultOwner->fetch_assoc();
|
||||
|
||||
if (!$ownerDetails) {
|
||||
die('Errore: Proprietario non trovato o accesso non autorizzato.');
|
||||
}
|
||||
|
||||
// Set display name
|
||||
if ($ownerDetails['owner_type'] === 'individual') {
|
||||
$ownerName = $ownerDetails['first_name'] . ' ' . $ownerDetails['last_name'];
|
||||
} else {
|
||||
$ownerName = $ownerDetails['company_name'];
|
||||
}
|
||||
|
||||
// Make owner_id available to JavaScript
|
||||
echo "<script>var owner_id = $owner_id;</script>";
|
||||
} else {
|
||||
die('Errore: ID proprietario non valido.');
|
||||
}
|
||||
} else {
|
||||
die('Errore: Accesso non autorizzato.');
|
||||
}
|
||||
|
||||
// Set default slug to "person"
|
||||
$docpage = "person";
|
||||
|
||||
// Retrieve page_id for the "person" slug
|
||||
$queryPageId = $conn->prepare("SELECT idpages FROM pages WHERE slug = ?");
|
||||
$queryPageId->bind_param('s', $docpage);
|
||||
$queryPageId->execute();
|
||||
$resultPageId = $queryPageId->get_result();
|
||||
$pageData = $resultPageId->fetch_assoc();
|
||||
|
||||
if ($pageData) {
|
||||
$page_id = $pageData['idpages']; // Page ID found
|
||||
} else {
|
||||
die("Errore: Pagina non valida."); // Slug not found
|
||||
}
|
||||
|
||||
// Retrieve documents associated with page_id, including sections
|
||||
$queryDocuments = $conn->prepare("
|
||||
SELECT d.*, s.section_name AS section_name
|
||||
FROM documents d
|
||||
LEFT JOIN sections s ON d.idsections = s.idsections
|
||||
WHERE d.page_id = ?
|
||||
ORDER BY s.section_name, d.document_name
|
||||
");
|
||||
$queryDocuments->bind_param('i', $page_id);
|
||||
$queryDocuments->execute();
|
||||
$resultDocuments = $queryDocuments->get_result();
|
||||
|
||||
$documents = [];
|
||||
while ($row = $resultDocuments->fetch_assoc()) {
|
||||
$documents[$row['section_name']][] = $row;
|
||||
}
|
||||
|
||||
// Retrieve already uploaded documents for this entity
|
||||
$queryLoadedDocuments = $conn->prepare("
|
||||
SELECT *
|
||||
FROM doc_storage
|
||||
WHERE owner_id = ?
|
||||
");
|
||||
$queryLoadedDocuments->bind_param('i', $owner_id);
|
||||
$queryLoadedDocuments->execute();
|
||||
$resultLoadedDocuments = $queryLoadedDocuments->get_result();
|
||||
|
||||
$loadedDocuments = [];
|
||||
while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
$loadedDocuments[$row['document_id']][] = $row;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Documenti della Casa</title>
|
||||
|
||||
<!-- Bootstrap 4 CSS -->
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/dripicons/2.0.0/webfont.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet" />
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- Dropzone CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<style>
|
||||
/* Reset and full page layout */
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-page {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.page-content-wrapper {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.container-fluid {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Existing styles */
|
||||
.section-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.document-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.dropzone {
|
||||
background-color: #f0f8ff;
|
||||
border: 2px dashed #007bff;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.dropzone:hover {
|
||||
background-color: #e6f5ff;
|
||||
}
|
||||
|
||||
.dropzone .dz-message {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.dropzone .dz-message i {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 10px;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
/* Table scrolling */
|
||||
.document-list-table {
|
||||
display: block;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.document-list-table tbody {
|
||||
display: block;
|
||||
overflow-y: auto;
|
||||
max-height: 250px;
|
||||
}
|
||||
|
||||
.document-list-table thead,
|
||||
.document-list-table tbody tr {
|
||||
display: table;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.section-separator {
|
||||
border-top: 2px solid #ddd;
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.btn.active {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Page Title -->
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h4 class="page-title">Documenti per: <?php echo htmlspecialchars($ownerName); ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Documents Sections -->
|
||||
<?php foreach ($documents as $sectionName => $sectionDocuments) { ?>
|
||||
<div class="section-separator"></div>
|
||||
<h5 class="section-title"><?php echo htmlspecialchars($sectionName); ?></h5>
|
||||
|
||||
<?php foreach ($sectionDocuments as $document) { ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card card-body mb-4">
|
||||
<!-- Document Title -->
|
||||
<p class="document-title">
|
||||
<?php echo htmlspecialchars($document['document_name']); ?>
|
||||
<?php if ($document['is_required']) echo "<strong>(Obbligatorio)</strong>"; ?>
|
||||
<?php if ($document['max_documents'] > 0) echo " - Max: " . $document['max_documents']; ?>
|
||||
</p>
|
||||
|
||||
<!-- Dropzone Area -->
|
||||
<div class="dropzone mb-3" id="dropzone-<?php echo $document['document_id']; ?>">
|
||||
<div class="dz-message">
|
||||
<i class="fas fa-cloud-upload-alt"></i><br>
|
||||
Trascina qui i documenti o clicca per caricare
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Uploaded Documents Table -->
|
||||
<h6 class="mt-4">Documenti già caricati:</h6>
|
||||
<table class="table table-bordered document-list-table" id="table-<?php echo $document['document_id']; ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome Documento</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($loadedDocuments[$document['document_id']])) { ?>
|
||||
<?php foreach ($loadedDocuments[$document['document_id']] as $loadedDoc) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="persondocuments/<?php echo $loadedDoc['filename']; ?>" target="_blank">
|
||||
<?php echo htmlspecialchars($loadedDoc['filename']); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($loadedDoc['created_at']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm delete-document"
|
||||
data-id="<?php echo $loadedDoc['id']; ?>"
|
||||
data-file="<?php echo $loadedDoc['filename']; ?>">
|
||||
Elimina
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer (if needed) -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
|
||||
<!-- Plugin Dropzone -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.js"></script>
|
||||
|
||||
<script>
|
||||
// Disattiva auto-discover di Dropzone per evitare inizializzazioni duplicate
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
// Inizializza Dropzone per ciascun documento
|
||||
<?php foreach ($documents as $sectionName => $sectionDocuments) { ?>
|
||||
<?php foreach ($sectionDocuments as $document) { ?>
|
||||
new Dropzone("#dropzone-<?php echo $document['document_id']; ?>", {
|
||||
url: "upload-document-person.php", // URL per il caricamento
|
||||
paramName: "file", // Nome del campo per il file
|
||||
maxFiles: <?php echo $document['max_documents']; ?>, // Numero massimo di file
|
||||
addRemoveLinks: true,
|
||||
dictDefaultMessage: "Trascina qui i documenti o clicca per caricare",
|
||||
dictRemoveFile: "Rimuovi",
|
||||
acceptedFiles: "application/pdf,image/*", // Solo PDF e immagini
|
||||
init: function() {
|
||||
// Successo nel caricamento
|
||||
this.on("success", function(file, response) {
|
||||
try {
|
||||
// Forza il parsing della risposta se necessario
|
||||
let parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
|
||||
|
||||
if (parsedResponse.success) {
|
||||
let tableId = "#table-<?php echo $document['document_id']; ?> tbody";
|
||||
let row = `
|
||||
<tr>
|
||||
<td><a href="persondocuments/${parsedResponse.fileName}" target="_blank">${parsedResponse.fileName}</a></td>
|
||||
<td>${parsedResponse.uploadDate}</td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm delete-document" data-id="${parsedResponse.documentId}" data-file="${parsedResponse.fileName}">
|
||||
Elimina
|
||||
</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
$(tableId).append(row);
|
||||
|
||||
// Rimuove il file dalla Dropzone
|
||||
this.removeFile(file);
|
||||
|
||||
// Mostra un messaggio di successo
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Caricamento completato",
|
||||
text: "Documento caricato con successo.",
|
||||
timer: 1500,
|
||||
showConfirmButton: false,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore nel caricamento",
|
||||
text: parsedResponse.message || "Si è verificato un problema durante il caricamento.",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore nel parsing della risposta:", error, response);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Risposta dal server non valida.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Gestione degli errori
|
||||
this.on("error", function(file, errorMessage) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore nel caricamento",
|
||||
text: errorMessage || "Si è verificato un problema.",
|
||||
});
|
||||
this.removeFile(file);
|
||||
});
|
||||
},
|
||||
sending: function(file, xhr, formData) {
|
||||
formData.append("entity_type", "person"); // Indica che è per le persone
|
||||
formData.append("owner_id", owner_id); // Invia l'ID del proprietario dal contesto globale
|
||||
formData.append("document_id", "<?php echo $document['document_id']; ?>");
|
||||
}
|
||||
});
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
// Elimina documento con SweetAlert
|
||||
$(document).on("click", ".delete-document", function() {
|
||||
const documentId = $(this).data("id");
|
||||
const fileName = $(this).data("file");
|
||||
const $row = $(this).closest("tr"); // Trova la riga associata al pulsante
|
||||
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa azione eliminerà il documento in modo permanente.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, elimina",
|
||||
cancelButtonText: "Annulla",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: "delete-document.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
document_id: documentId,
|
||||
file_name: fileName,
|
||||
},
|
||||
success: function(response) {
|
||||
try {
|
||||
const parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
|
||||
|
||||
if (parsedResponse.success) {
|
||||
$row.remove(); // Rimuove la riga dalla tabella
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Eliminato",
|
||||
text: "Documento eliminato con successo.",
|
||||
timer: 1500,
|
||||
showConfirmButton: false,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: parsedResponse.message || "Errore durante l'eliminazione del documento.",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore durante l'eliminazione:", error);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Risposta dal server non valida.",
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Si è verificato un problema con la richiesta.",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
380
public/userportal/documents-settings.php
Normal file
380
public/userportal/documents-settings.php
Normal file
@ -0,0 +1,380 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'elenco dei documenti con il nome della pagina e della sezione
|
||||
$queryDocuments = $conn->query("
|
||||
SELECT d.*,
|
||||
p.namepages AS page_name,
|
||||
s.section_name AS section_name
|
||||
FROM documents d
|
||||
LEFT JOIN pages p ON d.page_id = p.idpages
|
||||
LEFT JOIN sections s ON d.idsections = s.idsections
|
||||
ORDER BY d.document_id DESC
|
||||
");
|
||||
|
||||
$documents = [];
|
||||
while ($row = $queryDocuments->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Gestione Documenti</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
<br>
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-4">
|
||||
<div class="col-lg-6">
|
||||
<a href="index.php" class="btn btn-outline-primary btn-block shadow-sm">
|
||||
<i class="mdi mdi-arrow-left"></i> Torna al Dashboard
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<button class="btn btn-outline-success btn-block shadow-sm" data-toggle="modal" data-target="#addDocumentModal">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Documento
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Elenco Documenti</h4>
|
||||
<table id="documentsTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome Documento</th>
|
||||
<th>Pagina</th>
|
||||
<th>Sezione</th>
|
||||
<th>Max Documenti</th>
|
||||
<th>Obbligatorio</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document['document_id']; ?></td>
|
||||
<td><?php echo htmlspecialchars($document['document_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($document['page_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($document['section_name']); ?></td>
|
||||
<td><?php echo $document['max_documents']; ?></td>
|
||||
<td><?php echo $document['is_required'] ? 'Sì' : 'No'; ?></td>
|
||||
<td>
|
||||
<button
|
||||
class="btn btn-sm btn-warning"
|
||||
data-toggle="modal"
|
||||
data-target="#editDocumentModal"
|
||||
data-id="<?php echo $document['document_id']; ?>"
|
||||
data-name="<?php echo htmlspecialchars($document['document_name']); ?>"
|
||||
data-page-id="<?php echo $document['page_id']; ?>"
|
||||
data-section-id="<?php echo $document['idsections']; ?>"
|
||||
data-max-documents="<?php echo htmlspecialchars($document['max_documents']); ?>"
|
||||
data-is-required="<?php echo $document['is_required']; ?>"
|
||||
data-notes="<?php echo htmlspecialchars($document['notes']); ?>">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</button>
|
||||
|
||||
|
||||
<button class="btn btn-sm btn-danger delete-document" data-id="<?php echo $document['document_id']; ?>">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="editDocumentModal" tabindex="-1" role="dialog" aria-labelledby="editDocumentModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="edit-document.php" method="POST">
|
||||
<input type="hidden" id="editDocumentId" name="document_id">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editDocumentModalLabel">Modifica Documento</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Nome Documento -->
|
||||
<div class="form-group">
|
||||
<label for="editDocumentName">Nome Documento</label>
|
||||
<input type="text" class="form-control" id="editDocumentName" name="document_name" required>
|
||||
</div>
|
||||
|
||||
<!-- Pagina -->
|
||||
<div class="form-group">
|
||||
<label for="editPageId">Pagina</label>
|
||||
<select class="form-control" id="editPageId" name="page_id" required>
|
||||
<?php
|
||||
$pagesQuery = $conn->query("SELECT * FROM pages ORDER BY namepages ASC");
|
||||
while ($page = $pagesQuery->fetch_assoc()) {
|
||||
echo "<option value='{$page['idpages']}'>" . htmlspecialchars($page['namepages']) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Sezione -->
|
||||
<div class="form-group">
|
||||
<label for="editSectionId">Sezione</label>
|
||||
<select class="form-control" id="editSectionId" name="idsections">
|
||||
<?php
|
||||
$sectionsQuery = $conn->query("SELECT * FROM sections ORDER BY section_name ASC");
|
||||
while ($section = $sectionsQuery->fetch_assoc()) {
|
||||
echo "<option value='{$section['idsections']}'>" . htmlspecialchars($section['section_name']) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Max Documenti -->
|
||||
<div class="form-group">
|
||||
<label for="editMaxDocuments">Max Documenti</label>
|
||||
<input type="number" class="form-control" id="editMaxDocuments" name="max_documents" min="0">
|
||||
</div>
|
||||
|
||||
<!-- Obbligatorio -->
|
||||
<div class="form-group">
|
||||
<label for="editIsRequired">Obbligatorio</label>
|
||||
<select class="form-control" id="editIsRequired" name="is_required">
|
||||
<option value="0">No</option>
|
||||
<option value="1">Sì</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Note -->
|
||||
<div class="form-group">
|
||||
<label for="editNotes">Note</label>
|
||||
<textarea class="form-control" id="editNotes" name="notes"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-warning">Salva Modifiche</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modale: Aggiungi Documento -->
|
||||
<div class="modal fade" id="addDocumentModal" tabindex="-1" role="dialog" aria-labelledby="addDocumentModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="add-document.php" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addDocumentModalLabel">Aggiungi Documento</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="documentName">Nome Documento</label>
|
||||
<input type="text" class="form-control" id="documentName" name="document_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pageId">Pagina</label>
|
||||
<select class="form-control" id="pageId" name="page_id" required>
|
||||
<?php
|
||||
$pagesQuery = $conn->query("SELECT * FROM pages ORDER BY namepages ASC");
|
||||
while ($page = $pagesQuery->fetch_assoc()) {
|
||||
echo "<option value='{$page['idpages']}'>" . htmlspecialchars($page['namepages']) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sectionId">Sezione</label>
|
||||
<select class="form-control" id="sectionId" name="idsections" required>
|
||||
<?php
|
||||
$sectionsQuery = $conn->query("SELECT * FROM sections ORDER BY section_name ASC");
|
||||
while ($section = $sectionsQuery->fetch_assoc()) {
|
||||
echo "<option value='{$section['idsections']}'>" . htmlspecialchars($section['section_name']) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="maxDocuments">Max Documenti</label>
|
||||
<input type="number" class="form-control" id="maxDocuments" name="max_documents" min="0" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="isRequired">Obbligatorio</label>
|
||||
<select class="form-control" id="isRequired" name="is_required">
|
||||
<option value="0">No</option>
|
||||
<option value="1">Sì</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="notes">Note</label>
|
||||
<textarea class="form-control" id="notes" name="notes"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-success">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#documentsTable').DataTable();
|
||||
|
||||
$('#editDocumentModal').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
|
||||
// Recupera i dati dal pulsante
|
||||
var documentId = button.data('id');
|
||||
var documentName = button.data('name'); // Nome Documento
|
||||
var pageId = button.data('page-id');
|
||||
var sectionId = button.data('section-id'); // ID Sezione
|
||||
var maxDocuments = button.data('max-documents'); // Max Documenti
|
||||
var isRequired = button.data('is-required'); // Obbligatorio
|
||||
var notes = button.data('notes'); // Note
|
||||
|
||||
// Debug (visualizza i dati in console)
|
||||
console.log("Dati ricevuti dal pulsante:");
|
||||
console.log({
|
||||
documentId,
|
||||
documentName,
|
||||
pageId,
|
||||
sectionId,
|
||||
maxDocuments,
|
||||
isRequired,
|
||||
notes
|
||||
});
|
||||
|
||||
// Popola i campi del modale
|
||||
$('#editDocumentId').val(documentId);
|
||||
$('#editDocumentName').val(documentName); // Nome Documento
|
||||
$('#editPageId').val(pageId); // Pagina
|
||||
$('#editSectionId').val(sectionId); // Sezione
|
||||
$('#editMaxDocuments').val(maxDocuments); // Max Documenti
|
||||
$('#editIsRequired').val(isRequired); // Obbligatorio
|
||||
$('#editNotes').val(notes); // Note
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
<?php if (isset($_GET['success'])) { ?>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Documento aggiunto',
|
||||
text: 'Il documento è stato aggiunto con successo.',
|
||||
});
|
||||
<?php } elseif (isset($_GET['error'])) { ?>
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
text: 'Si è verificato un errore durante l\'aggiunta del documento.',
|
||||
});
|
||||
<?php } ?>
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Funzione di eliminazione con SweetAlert
|
||||
$('.delete-document').on('click', function() {
|
||||
var documentId = $(this).data('id'); // Recupera l'ID del documento
|
||||
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: "Questa azione non può essere annullata!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sì, elimina!',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Esegui richiesta AJAX per eliminare
|
||||
$.ajax({
|
||||
url: 'delete-document.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
document_id: documentId
|
||||
},
|
||||
success: function(response) {
|
||||
Swal.fire(
|
||||
'Eliminato!',
|
||||
'Il documento è stato eliminato con successo.',
|
||||
'success'
|
||||
).then(() => {
|
||||
// Ricarica la pagina per aggiornare la tabella
|
||||
location.reload();
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire(
|
||||
'Errore!',
|
||||
'Si è verificato un errore durante l\'eliminazione.',
|
||||
'error'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
61
public/userportal/edit-document.php
Normal file
61
public/userportal/edit-document.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Verifica se la richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$document_id = isset($_POST['document_id']) ? (int)$_POST['document_id'] : 0;
|
||||
$document_name = $conn->real_escape_string($_POST['document_name']);
|
||||
$page_id = isset($_POST['page_id']) ? (int)$_POST['page_id'] : null;
|
||||
$idsections = isset($_POST['idsections']) ? (int)$_POST['idsections'] : null;
|
||||
$max_documents = isset($_POST['max_documents']) ? (int)$_POST['max_documents'] : 0;
|
||||
$is_required = isset($_POST['is_required']) ? (int)$_POST['is_required'] : 0;
|
||||
$notes = !empty($_POST['notes']) ? $conn->real_escape_string($_POST['notes']) : null;
|
||||
|
||||
// Prepara la query di aggiornamento
|
||||
$query = "
|
||||
UPDATE documents
|
||||
SET document_name = ?, page_id = ?, idsections = ?, max_documents = ?, is_required = ?, notes = ?
|
||||
WHERE document_id = ?
|
||||
";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param('siiissi', $document_name, $page_id, $idsections, $max_documents, $is_required, $notes, $document_id);
|
||||
|
||||
// Esegue la query e controlla il risultato
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza con messaggio di successo
|
||||
header("Location: documents-settings.php?success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza con messaggio di errore
|
||||
header("Location: documents-settings.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
26
public/userportal/edit-page.php
Normal file
26
public/userportal/edit-page.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera i dati dal form
|
||||
$idpages = intval($_POST['idpages']);
|
||||
$namepages = $_POST['namepages'];
|
||||
$slug = $_POST['slug'];
|
||||
$descriptionpages = $_POST['descriptionpages'];
|
||||
|
||||
// Aggiorna i dati della pagina nel database
|
||||
$query = $conn->prepare("UPDATE pages SET namepages = ?, slug = ?, descriptionpages = ? WHERE idpages = ?");
|
||||
$query->bind_param('sssi', $namepages, $slug, $descriptionpages, $idpages);
|
||||
|
||||
if ($query->execute()) {
|
||||
header("Location: page-settings.php?success=1");
|
||||
} else {
|
||||
header("Location: page-settings.php?error=1");
|
||||
}
|
||||
|
||||
$query->close();
|
||||
$conn->close();
|
||||
27
public/userportal/edit-role.php
Normal file
27
public/userportal/edit-role.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$idrole = intval($_POST['idrole']);
|
||||
$role_name = $conn->real_escape_string($_POST['role_name']);
|
||||
$description = $conn->real_escape_string($_POST['description']);
|
||||
$permissions = $conn->real_escape_string($_POST['permissions']);
|
||||
|
||||
$query = "UPDATE sharing_roles SET role_name = ?, description = ?, permissions = ? WHERE idrole = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param('sssi', $role_name, $description, $permissions, $idrole);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
header("Location: sharing-roles.php?success=true");
|
||||
} else {
|
||||
header("Location: sharing-roles.php?error=true");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
$conn->close();
|
||||
53
public/userportal/edit-section.php
Normal file
53
public/userportal/edit-section.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se il metodo della richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$idsections = isset($_POST['idsections']) ? (int)$_POST['idsections'] : 0;
|
||||
$section_name = $conn->real_escape_string($_POST['section_name']);
|
||||
$description = $conn->real_escape_string($_POST['description']);
|
||||
|
||||
// Prepara la query di aggiornamento
|
||||
$query = "UPDATE sections SET section_name = ?, description = ? WHERE idsections = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param('ssi', $section_name, $description, $idsections);
|
||||
|
||||
// Esegue la query
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di successo
|
||||
header("Location: sections.php?success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di errore
|
||||
header("Location: sections.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
193
public/userportal/edit-sharing.php
Normal file
193
public/userportal/edit-sharing.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se l'ID della condivisione è fornito
|
||||
$idsharing = isset($_GET['idsharing']) ? (int)$_GET['idsharing'] : 0;
|
||||
if ($idsharing === 0) {
|
||||
die("ID condivisione non valido.");
|
||||
}
|
||||
|
||||
// Recupera i dettagli della condivisione con JOIN per ruolo e tipo di condivisione
|
||||
$query = "
|
||||
SELECT
|
||||
hs.idsharing,
|
||||
hs.idhome,
|
||||
hs.shared_email,
|
||||
hs.sharing_type,
|
||||
hs.shared_sections,
|
||||
hs.expiration_date,
|
||||
sr.role_name,
|
||||
hs.role_id
|
||||
FROM home_Sharing hs
|
||||
LEFT JOIN sharing_roles sr ON hs.role_id = sr.idrole
|
||||
WHERE hs.idsharing = ?
|
||||
";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param('i', $idsharing);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$sharing = $result->fetch_assoc();
|
||||
|
||||
if (!$sharing) {
|
||||
die("Condivisione non trovata.");
|
||||
}
|
||||
|
||||
// Recupera i ruoli di condivisione
|
||||
$rolesQuery = $conn->query("SELECT idrole, role_name FROM sharing_roles ORDER BY role_name ASC");
|
||||
$roles = $rolesQuery->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
// Recupera le sezioni dalla tabella 'sections'
|
||||
$sectionsQuery = $conn->query("SELECT idsections, section_name FROM sections ORDER BY section_name ASC");
|
||||
$sections = $sectionsQuery->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
// Decode delle sezioni condivise salvate nel database
|
||||
$shared_sections = json_decode($sharing['shared_sections'], true) ?: [];
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Modifica Condivisione</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="page-title"><i class="mdi mdi-share-variant" style="color: #5d6d7e;"></i> Modifica Condivisione</h4>
|
||||
<div class="card shadow-lg">
|
||||
<div class="card-body">
|
||||
<form action="save-edit-sharing.php" method="POST">
|
||||
<!-- Campo nascosto per l'ID condivisione -->
|
||||
<input type="hidden" name="idsharing" value="<?php echo $sharing['idsharing']; ?>">
|
||||
<input type="hidden" name="idhome" value="<?php echo $sharing['idhome']; ?>">
|
||||
|
||||
<!-- Email -->
|
||||
<div class="form-group">
|
||||
<label for="shared_email">
|
||||
<i class="mdi mdi-email-outline" style="color: #007bff;"></i> Email condivisa
|
||||
</label>
|
||||
<input type="email" name="shared_email" id="shared_email" class="form-control shadow-sm" required
|
||||
value="<?php echo htmlspecialchars($sharing['shared_email']); ?>">
|
||||
</div>
|
||||
|
||||
<!-- Ruolo -->
|
||||
<div class="form-group">
|
||||
<label for="role_id">
|
||||
<i class="mdi mdi-account-cog-outline" style="color: #28a745;"></i> Ruolo
|
||||
</label>
|
||||
<select name="role_id" id="role_id" class="form-control shadow-sm" required>
|
||||
<option value="">Seleziona un ruolo</option>
|
||||
<?php foreach ($roles as $role) { ?>
|
||||
<option value="<?php echo $role['idrole']; ?>"
|
||||
<?php echo $role['idrole'] == $sharing['role_id'] ? 'selected' : ''; ?>>
|
||||
<?php echo htmlspecialchars($role['role_name']); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Tipo di condivisione -->
|
||||
<div class="form-group">
|
||||
<label for="sharing_type">
|
||||
<i class="mdi mdi-lock-outline" style="color: #ffc107;"></i> Tipo di condivisione
|
||||
</label>
|
||||
<select name="sharing_type" id="sharing_type" class="form-control shadow-sm" required>
|
||||
<option value="read-only" <?php echo ($sharing['sharing_type'] === 'read-only') ? 'selected' : ''; ?>>Solo lettura</option>
|
||||
<option value="add-documents" <?php echo ($sharing['sharing_type'] === 'add-documents') ? 'selected' : ''; ?>>Aggiunta documenti</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Sezioni condivise -->
|
||||
<div class="form-group">
|
||||
<label>
|
||||
<i class="mdi mdi-folder-outline" style="color: #17a2b8;"></i> Sezioni condivise
|
||||
</label>
|
||||
<div>
|
||||
<?php foreach ($sections as $section) { ?>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input shadow-sm"
|
||||
name="shared_sections[]"
|
||||
value="<?php echo $section['idsections']; ?>"
|
||||
<?php echo in_array($section['idsections'], $shared_sections) ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label">
|
||||
<?php echo htmlspecialchars($section['section_name']); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Data di scadenza -->
|
||||
<div class="form-group">
|
||||
<label for="expiration_date">
|
||||
<i class="mdi mdi-calendar-range" style="color: #d9534f;"></i> Data di scadenza
|
||||
</label>
|
||||
<input type="text" name="expiration_date" id="expiration_date" class="form-control flatpickr shadow-sm"
|
||||
value="<?php echo htmlspecialchars($sharing['expiration_date']); ?>">
|
||||
</div>
|
||||
|
||||
<!-- Pulsanti -->
|
||||
<div class="form-group text-right">
|
||||
<button type="submit" class="btn btn-success shadow-sm">
|
||||
<i class="mdi mdi-check-circle-outline"></i> Salva
|
||||
</button>
|
||||
<a href="share-home.php?idhome=<?php echo $sharing['idhome']; ?>" class="btn btn-secondary shadow-sm">
|
||||
<i class="mdi mdi-arrow-left"></i> Annulla
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
<script>
|
||||
// Inizializza il calendario per la data di scadenza
|
||||
$(".flatpickr").flatpickr({
|
||||
enableTime: false,
|
||||
dateFormat: "Y-m-d",
|
||||
minDate: "today"
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Binary file not shown.
BIN
public/userportal/homedocuments/1-1726896676-SnapFeet.pdf
Normal file
BIN
public/userportal/homedocuments/1-1726896676-SnapFeet.pdf
Normal file
Binary file not shown.
BIN
public/userportal/homedocuments/1-1726897640-SnapFeet.pdf
Normal file
BIN
public/userportal/homedocuments/1-1726897640-SnapFeet.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
public/userportal/homedocuments/1-1726914642-SnapFeet.pdf
Normal file
BIN
public/userportal/homedocuments/1-1726914642-SnapFeet.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
public/userportal/homedocuments/1-1733152809-CF_INTEROAury.pdf
Normal file
BIN
public/userportal/homedocuments/1-1733152809-CF_INTEROAury.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
BIN
public/userportal/homedocuments/1-1733154542-1.png
Normal file
BIN
public/userportal/homedocuments/1-1733154542-1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 657 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@ -25,9 +25,12 @@ $result = $stmt->get_result();
|
||||
<!-- Bootstrap 4 CSS -->
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/dripicons/2.0.0/webfont.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
@ -102,16 +105,37 @@ $result = $stmt->get_result();
|
||||
<td><?php echo htmlspecialchars($row['country']); ?></td>
|
||||
<td>
|
||||
<!-- Pulsante per modificare i dettagli della casa -->
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-info btn-sm">
|
||||
<i class="fas fa-info-circle"></i> Dettagli
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-info btn-sm" title="Dettagli">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
</a>
|
||||
<a href="documents-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-info-circle"></i> Documenti
|
||||
|
||||
<!-- Pulsante per i documenti della casa -->
|
||||
<a href="documents-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-primary btn-sm" title="Documenti">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</a>
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-danger btn-sm">
|
||||
<i class="fas fa-info-circle"></i> Elimina
|
||||
|
||||
<!-- Pulsante per condividere la casa -->
|
||||
<a href="share-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-warning btn-sm" title="Condividi">
|
||||
<i class="fas fa-share-alt"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per passaggio proprietà -->
|
||||
<button class="btn btn-secondary btn-sm transfer-property-btn" data-id="<?php echo $row['idhome']; ?>" title="Passaggio Proprietà">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
</button>
|
||||
|
||||
<!-- Pulsante per assegnare le persone proprietarie -->
|
||||
<button class="btn btn-success btn-sm assign-owner-btn" data-id="<?php echo $row['idhome']; ?>" title="Assegna Proprietari">
|
||||
<i class="fas fa-user-plus"></i>
|
||||
</button>
|
||||
|
||||
<!-- Pulsante per eliminare la casa -->
|
||||
<button class="btn btn-danger btn-sm delete-home-btn" data-id="<?php echo $row['idhome']; ?>" title="Elimina">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
@ -148,6 +172,59 @@ $result = $stmt->get_result();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Inizializza DataTables con filtri di colonna
|
||||
var table = $('#homeTable').DataTable();
|
||||
|
||||
// Aggiungi ricerca personalizzata in ogni colonna
|
||||
$('#homeTable thead tr:eq(1) th').each(function(i) {
|
||||
$('input', this).on('keyup change', function() {
|
||||
if (table.column(i).search() !== this.value) {
|
||||
table.column(i).search(this.value).draw();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Gestisci l'eliminazione con SweetAlert
|
||||
$('.delete-home-btn').on('click', function() {
|
||||
var idhome = $(this).data('id'); // Ottieni l'id della casa
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: "Questa azione eliminerà la casa e non può essere annullata.",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sì, elimina',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza al file di eliminazione
|
||||
window.location.href = "delete-home.php?idhome=" + idhome;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
<?php if (isset($_GET['status']) && $_GET['status'] == 'success') { ?>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Eliminazione completata!',
|
||||
text: 'La casa è stata eliminata con successo.'
|
||||
});
|
||||
<?php } elseif (isset($_GET['status']) && $_GET['status'] == 'error') { ?>
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore!',
|
||||
text: 'Si è verificato un errore durante l\'eliminazione della casa.'
|
||||
});
|
||||
<?php } ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -62,7 +62,12 @@
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<li class="menu-title">Amministrazione</li>
|
||||
|
||||
<li class="">
|
||||
<a href="admin.php" class="waves-effect"><i class="dripicons-blog"></i><span> Admin Page </span></a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@ -1,4 +1,45 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database e avvio sessione
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'id utente loggato
|
||||
$iduserlogin = $_SESSION['iduserlogin'];
|
||||
|
||||
// Calcolo del numero di immobili
|
||||
$queryHomes = $conn->prepare("SELECT COUNT(*) AS total_homes FROM home WHERE iduser = ?");
|
||||
$queryHomes->bind_param('i', $iduserlogin);
|
||||
$queryHomes->execute();
|
||||
$resultHomes = $queryHomes->get_result();
|
||||
$totalHomes = $resultHomes->fetch_assoc()['total_homes'];
|
||||
|
||||
// Calcolo del numero di persone
|
||||
$queryOwners = $conn->prepare("SELECT COUNT(*) AS total_owners FROM property_owners WHERE user_id = ?");
|
||||
$queryOwners->bind_param('i', $iduserlogin);
|
||||
$queryOwners->execute();
|
||||
$resultOwners = $queryOwners->get_result();
|
||||
$totalOwners = $resultOwners->fetch_assoc()['total_owners'];
|
||||
|
||||
// Numero di documenti (placeholder per ora)
|
||||
// Calcolo del numero di documenti
|
||||
$queryDocuments = $conn->prepare("
|
||||
SELECT COUNT(*) AS total_documents
|
||||
FROM doc_storage
|
||||
LEFT JOIN home ON doc_storage.idhome = home.idhome
|
||||
WHERE home.iduser = ?
|
||||
");
|
||||
$queryDocuments->bind_param('i', $iduserlogin);
|
||||
$queryDocuments->execute();
|
||||
$resultDocuments = $queryDocuments->get_result();
|
||||
$totalDocuments = $resultDocuments->fetch_assoc()['total_documents'];
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
@ -110,92 +151,97 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="card">
|
||||
<!-- Statistica: Numero di immobili -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="fas fa-tasks text-gradient-success"></i>
|
||||
<i class="mdi mdi-home-outline" style="font-size: 2.5rem; color: #85c1e9;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1">190</h5>
|
||||
<p class="mb-0 font-12 text-muted">---</p>
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalHomes; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Immobili inseriti</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body justify-content-center">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="far fa-gem text-gradient-danger"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1">62</h5>
|
||||
<p class="mb-0 font-12 text-muted">---</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="card">
|
||||
|
||||
<!-- Statistica: Numero di persone -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="fas fa-users text-gradient-warning"></i>
|
||||
<i class="mdi mdi-account-outline" style="font-size: 2.5rem; color: #82e0aa;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1">14</h5>
|
||||
<p class="mb-0 font-12 text-muted">---</p>
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalOwners; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Proprietari registrati</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="card ">
|
||||
|
||||
<!-- Statistica: Numero di documenti -->
|
||||
<!-- Statistica: Numero di documenti -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="icon-contain">
|
||||
<div class="row">
|
||||
<div class="col-2 align-self-center">
|
||||
<i class="fas fa-database text-gradient-primary"></i>
|
||||
<i class="mdi mdi-file-outline" style="font-size: 2.5rem; color: #f8c471;"></i>
|
||||
</div>
|
||||
<div class="col-10 text-right">
|
||||
<h5 class="mt-0 mb-1">$15562</h5>
|
||||
<p class="mb-0 font-12 text-muted">---</p>
|
||||
<h5 class="mt-0 mb-1"><?php echo $totalDocuments; ?></h5>
|
||||
<p class="mb-0 font-14" style="color: #5d6d7e;">Documenti caricati</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card card-body">
|
||||
<h4 class="card-title font-20 mt-0">XLS to RSL</h4>
|
||||
<p class="font-13 text-muted">Import XLS requirements and create a Word document</p>
|
||||
<a href="xlstorsl.php" class="btn btn-primary waves-effect waves-light"><?php echo $gotosection; ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row text-center">
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="homes-list.php" class="btn btn-primary d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-home-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Immobili</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="person-list.php" class="btn btn-success d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-account-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Persone</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="condivisioni.php" class="btn btn-info d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-share-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Condivisioni</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div><!-- container -->
|
||||
|
||||
255
public/userportal/page-settings.php
Normal file
255
public/userportal/page-settings.php
Normal file
@ -0,0 +1,255 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
$message = "";
|
||||
$alertClass = "";
|
||||
|
||||
if (isset($_GET['success'])) {
|
||||
$message = "Operazione completata con successo.";
|
||||
$alertClass = "alert-success";
|
||||
} elseif (isset($_GET['error'])) {
|
||||
$message = "Si è verificato un errore. Riprova.";
|
||||
$alertClass = "alert-danger";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'elenco delle pagine
|
||||
$queryPages = $conn->query("SELECT * FROM pages ORDER BY idpages DESC");
|
||||
$pages = [];
|
||||
while ($row = $queryPages->fetch_assoc()) {
|
||||
$pages[] = $row;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Gestione Pagine</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css">
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<?php if (!empty($message)) { ?>
|
||||
<div class="alert <?php echo $alertClass; ?> alert-dismissible fade show" role="alert">
|
||||
<?php echo $message; ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="row text-center mt-4">
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="page-settings.php" class="btn btn-warning d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-book-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Gestione Pagine</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 mb-4">
|
||||
<a href="documents-settings.php" class="btn btn-danger d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-file-cog-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Gestione Documenti</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Titolo e Pulsanti -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-lg-6">
|
||||
<a href="index.php" class="btn btn-outline-primary btn-block shadow-sm">
|
||||
<i class="mdi mdi-arrow-left"></i> Torna al Dashboard
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<button class="btn btn-outline-success btn-block shadow-sm" data-toggle="modal" data-target="#addPageModal">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Pagina
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabella Pagine -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Elenco Pagine</h4>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome</th>
|
||||
<th>Slug</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<tr>
|
||||
<td><?php echo $page['idpages']; ?></td>
|
||||
<td><?php echo htmlspecialchars($page['namepages']); ?></td>
|
||||
<td><?php echo htmlspecialchars($page['slug']); ?></td>
|
||||
<td><?php echo htmlspecialchars($page['descriptionpages']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-warning" data-toggle="modal" data-target="#editPageModal"
|
||||
data-id="<?php echo $page['idpages']; ?>"
|
||||
data-name="<?php echo htmlspecialchars($page['namepages']); ?>"
|
||||
data-slug="<?php echo htmlspecialchars($page['slug']); ?>"
|
||||
data-description="<?php echo htmlspecialchars($page['descriptionpages']); ?>">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="deletePage(<?php echo $page['idpages']; ?>)">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- container -->
|
||||
</div> <!-- Page content Wrapper -->
|
||||
</div> <!-- content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div> <!-- End Right content here -->
|
||||
</div> <!-- END wrapper -->
|
||||
|
||||
<!-- Modale: Aggiungi Pagina -->
|
||||
<div class="modal fade" id="addPageModal" tabindex="-1" role="dialog" aria-labelledby="addPageModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="add-page.php" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addPageModalLabel">Aggiungi Pagina</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="pageName">Nome Pagina</label>
|
||||
<input type="text" class="form-control" id="pageName" name="namepages" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pageSlug">Slug</label>
|
||||
<input type="text" class="form-control" id="pageSlug" name="slug" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pageDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="pageDescription" name="descriptionpages"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-success">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modale: Modifica Pagina -->
|
||||
<div class="modal fade" id="editPageModal" tabindex="-1" role="dialog" aria-labelledby="editPageModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="edit-page.php" method="POST">
|
||||
<!-- Campo nascosto per l'ID -->
|
||||
<input type="hidden" id="editPageId" name="idpages">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editPageModalLabel">Modifica Pagina</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="editPageName">Nome Pagina</label>
|
||||
<input type="text" class="form-control" id="editPageName" name="namepages" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editPageSlug">Slug</label>
|
||||
<input type="text" class="form-control" id="editPageSlug" name="slug" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editPageDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="editPageDescription" name="descriptionpages"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-warning">Salva Modifiche</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Funzione Delete -->
|
||||
<script>
|
||||
function deletePage(id) {
|
||||
if (confirm("Sei sicuro di voler eliminare questa pagina?")) {
|
||||
window.location.href = "delete-page.php?idpages=" + id;
|
||||
}
|
||||
}
|
||||
|
||||
// Popola i campi del modale di modifica
|
||||
$('#editPageModal').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget); // Bottone che ha aperto il modale
|
||||
console.log("Bottone cliccato:", button); // DEBUG
|
||||
|
||||
var id = button.data('id'); // Recupera l'attributo data-id
|
||||
var name = button.data('name'); // Recupera l'attributo data-name
|
||||
var slug = button.data('slug'); // Recupera l'attributo data-slug
|
||||
var description = button.data('description'); // Recupera l'attributo data-description
|
||||
|
||||
console.log("Dati recuperati:", {
|
||||
id,
|
||||
name,
|
||||
slug,
|
||||
description
|
||||
}); // DEBUG
|
||||
|
||||
// Popola i campi del modale
|
||||
var modal = $(this);
|
||||
modal.find('#editPageId').val(id);
|
||||
modal.find('#editPageName').val(name);
|
||||
modal.find('#editPageSlug').val(slug);
|
||||
modal.find('#editPageDescription').val(description);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -25,7 +25,7 @@ $result = $stmt->get_result();
|
||||
<!-- Bootstrap 4 CSS -->
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/dripicons/2.0.0/webfont.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet" />
|
||||
|
||||
@ -129,10 +129,13 @@ $result = $stmt->get_result();
|
||||
<a href="manage-owner.php?owner_id=<?php echo $row['owner_id']; ?>" class="btn btn-info btn-sm">
|
||||
<i class="fas fa-info-circle"></i> Dettagli
|
||||
</a>
|
||||
<!-- Pulsante per i documenti del proprietario con un margine a sinistra -->
|
||||
<a href="add-docs.php?owner_id=<?php echo $row['owner_id']; ?>" class="btn btn-warning btn-sm ml-2">
|
||||
<i class="fas fa-file-alt"></i> DOCS
|
||||
</a>
|
||||
<form action="documents-person.php" method="POST" style="display:inline;">
|
||||
<input type="hidden" name="owner_id" value="<?php echo $row['owner_id']; ?>">
|
||||
<button type="submit" class="btn btn-warning btn-sm ml-2">
|
||||
<i class="fas fa-file-alt"></i> DOCS
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
77
public/userportal/save-edit-sharing.php
Normal file
77
public/userportal/save-edit-sharing.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se il metodo della richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$idsharing = isset($_POST['idsharing']) ? (int)$_POST['idsharing'] : 0;
|
||||
$idhome = isset($_POST['idhome']) ? (int)$_POST['idhome'] : 0;
|
||||
$shared_email = $conn->real_escape_string($_POST['shared_email']);
|
||||
$role_id = isset($_POST['role_id']) ? (int)$_POST['role_id'] : null;
|
||||
$sharing_type = $conn->real_escape_string($_POST['sharing_type']);
|
||||
$expiration_date = !empty($_POST['expiration_date']) ? $conn->real_escape_string($_POST['expiration_date']) : null;
|
||||
$shared_sections = isset($_POST['shared_sections']) ? $_POST['shared_sections'] : [];
|
||||
|
||||
// Prepara le sezioni condivise come stringa JSON
|
||||
$sections_json = json_encode($shared_sections);
|
||||
|
||||
// Aggiorna i dati nella tabella home_Sharing
|
||||
$query = "
|
||||
UPDATE home_Sharing
|
||||
SET
|
||||
shared_email = ?,
|
||||
role_id = ?,
|
||||
sharing_type = ?,
|
||||
shared_sections = ?,
|
||||
expiration_date = ?
|
||||
WHERE idsharing = ?
|
||||
";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param(
|
||||
'sisssi',
|
||||
$shared_email,
|
||||
$role_id,
|
||||
$sharing_type,
|
||||
$sections_json,
|
||||
$expiration_date,
|
||||
$idsharing
|
||||
);
|
||||
|
||||
// Esegue la query e controlla il risultato
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza alla pagina delle condivisioni con il messaggio di successo
|
||||
header("Location: share-home.php?idhome=$idhome&success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza alla pagina delle condivisioni con il messaggio di errore
|
||||
header("Location: share-home.php?idhome=$idhome&error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
153
public/userportal/save-sharing.php
Normal file
153
public/userportal/save-sharing.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
include('tools/mailer.php'); // Includi il file per l'invio delle email
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se il metodo della richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$idhome = isset($_POST['idhome']) ? (int)$_POST['idhome'] : 0;
|
||||
$shared_email = $conn->real_escape_string($_POST['shared_email']);
|
||||
$role_id = isset($_POST['role_id']) ? (int)$_POST['role_id'] : null;
|
||||
$sharing_type = $conn->real_escape_string($_POST['sharing_type']);
|
||||
$expiration_date = !empty($_POST['expiration_date']) ? $conn->real_escape_string($_POST['expiration_date']) : null;
|
||||
$shared_sections = isset($_POST['shared_sections']) ? $_POST['shared_sections'] : [];
|
||||
|
||||
// Prepara le sezioni condivise come stringa JSON
|
||||
$sections_json = json_encode($shared_sections);
|
||||
|
||||
// Recupera il nome e cognome dell'utente loggato
|
||||
$queryUserDetails = "SELECT first_name, last_name FROM auth_users WHERE id = ?";
|
||||
$stmtUserDetails = $conn->prepare($queryUserDetails);
|
||||
if ($stmtUserDetails === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
$stmtUserDetails->bind_param('i', $iduserlogin);
|
||||
$stmtUserDetails->execute();
|
||||
$resultUserDetails = $stmtUserDetails->get_result();
|
||||
$userDetails = $resultUserDetails->fetch_assoc();
|
||||
$userName = $userDetails['first_name'] . ' ' . $userDetails['last_name'];
|
||||
|
||||
$stmtUserDetails->close();
|
||||
|
||||
// Controlla se l'email è associata a un utente registrato
|
||||
$queryCheckUser = "SELECT id FROM auth_users WHERE email = ?";
|
||||
$stmtCheckUser = $conn->prepare($queryCheckUser);
|
||||
if ($stmtCheckUser === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
$stmtCheckUser->bind_param('s', $shared_email);
|
||||
$stmtCheckUser->execute();
|
||||
$resultCheckUser = $stmtCheckUser->get_result();
|
||||
|
||||
// Determina lo stato e l'idshareduser
|
||||
if ($resultCheckUser->num_rows > 0) {
|
||||
$user = $resultCheckUser->fetch_assoc();
|
||||
$idshareduser = $user['id'];
|
||||
$status = 'accepted'; // Utente già registrato
|
||||
} else {
|
||||
$idshareduser = null;
|
||||
$status = 'pending'; // Utente non registrato
|
||||
}
|
||||
|
||||
$stmtCheckUser->close();
|
||||
|
||||
// Inserisce i dati nella tabella home_Sharing
|
||||
$query = "INSERT INTO home_Sharing (idhome, iduser, shared_email, idshareduser, role_id, sharing_type, shared_sections, expiration_date, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param(
|
||||
'iisssssss',
|
||||
$idhome,
|
||||
$iduserlogin,
|
||||
$shared_email,
|
||||
$idshareduser,
|
||||
$role_id,
|
||||
$sharing_type,
|
||||
$sections_json,
|
||||
$expiration_date,
|
||||
$status
|
||||
);
|
||||
|
||||
// Esegue la query e controlla il risultato
|
||||
if ($stmt->execute()) {
|
||||
// Recupera i dettagli dell'immobile
|
||||
$queryHome = $conn->prepare("SELECT name FROM home WHERE idhome = ?");
|
||||
$queryHome->bind_param('i', $idhome);
|
||||
$queryHome->execute();
|
||||
$resultHome = $queryHome->get_result();
|
||||
$home = $resultHome->fetch_assoc();
|
||||
$homeName = $home['name'];
|
||||
|
||||
// Prepara i dettagli per l'email
|
||||
$subject = "Condivisione Immobile - CASADOC";
|
||||
$body = file_get_contents('templates/emails/shared_property_email.html');
|
||||
|
||||
if ($idshareduser) {
|
||||
// Utente già registrato
|
||||
$body = str_replace(
|
||||
['{EMAIL_SUBJECT}', '{EMAIL_MESSAGE}', '{EMAIL_CTA}'],
|
||||
[
|
||||
"Condivisione Immobile",
|
||||
"L'utente <strong>$userName</strong> ha condiviso con te l'immobile <strong>$homeName</strong>. Puoi trovarlo nella sezione 'Immobili Condivisi' su CASADOC.",
|
||||
"<a href='https://casadoc.app/shared-properties' class='cta'>Visualizza Immobili</a>"
|
||||
],
|
||||
$body
|
||||
);
|
||||
} else {
|
||||
// Utente non registrato
|
||||
$body = str_replace(
|
||||
['{EMAIL_SUBJECT}', '{EMAIL_MESSAGE}', '{EMAIL_CTA}'],
|
||||
[
|
||||
"Registrazione Necessaria",
|
||||
"L'utente <strong>$userName</strong> ha condiviso con te un immobile, ma devi registrarti su CASADOC per visualizzarlo.",
|
||||
"<a href='https://casadoc.app/register' class='cta'>Registrati Ora</a>"
|
||||
],
|
||||
$body
|
||||
);
|
||||
}
|
||||
|
||||
// Invia l'email
|
||||
$mailResult = sendEmail($shared_email, $subject, $body);
|
||||
|
||||
if (!$mailResult['success']) {
|
||||
error_log("Errore nell'invio dell'email: " . $mailResult['message']);
|
||||
}
|
||||
|
||||
// Reindirizza alla pagina delle condivisioni con il messaggio di successo
|
||||
header("Location: share-home.php?idhome=$idhome&success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza alla pagina delle condivisioni con il messaggio di errore
|
||||
header("Location: share-home.php?idhome=$idhome&error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
216
public/userportal/sections.php
Normal file
216
public/userportal/sections.php
Normal file
@ -0,0 +1,216 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'elenco delle sezioni
|
||||
$querySections = $conn->query("SELECT * FROM sections ORDER BY idsections DESC");
|
||||
$sections = [];
|
||||
while ($row = $querySections->fetch_assoc()) {
|
||||
$sections[] = $row;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Gestione Sezioni</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="page-title">Gestione Sezioni</h4>
|
||||
<button class="btn btn-success mb-3" data-toggle="modal" data-target="#addSectionModal">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Sezione
|
||||
</button>
|
||||
<table id="sectionsTable" class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($sections as $section) { ?>
|
||||
<tr>
|
||||
<td><?php echo $section['idsections']; ?></td>
|
||||
<td><?php echo htmlspecialchars($section['section_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($section['description']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-warning btn-sm" data-toggle="modal" data-target="#editSectionModal"
|
||||
data-id="<?php echo $section['idsections']; ?>"
|
||||
data-name="<?php echo htmlspecialchars($section['section_name']); ?>"
|
||||
data-description="<?php echo htmlspecialchars($section['description']); ?>">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-danger btn-sm delete-section"
|
||||
data-id="<?php echo $section['idsections']; ?>">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- container -->
|
||||
</div> <!-- Page content Wrapper -->
|
||||
</div> <!-- content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div> <!-- End Right content here -->
|
||||
</div> <!-- END wrapper -->
|
||||
|
||||
<!-- Modale: Aggiungi Sezione -->
|
||||
<div class="modal fade" id="addSectionModal" tabindex="-1" role="dialog" aria-labelledby="addSectionModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="add-section.php" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addSectionModalLabel">Aggiungi Sezione</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="sectionName">Nome Sezione</label>
|
||||
<input type="text" class="form-control" id="sectionName" name="section_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sectionDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="sectionDescription" name="description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-success">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modale: Modifica Sezione -->
|
||||
<div class="modal fade" id="editSectionModal" tabindex="-1" role="dialog" aria-labelledby="editSectionModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="edit-section.php" method="POST">
|
||||
<input type="hidden" id="editSectionId" name="idsections">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editSectionModalLabel">Modifica Sezione</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="editSectionName">Nome Sezione</label>
|
||||
<input type="text" class="form-control" id="editSectionName" name="section_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editSectionDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="editSectionDescription" name="description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-warning">Salva Modifiche</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#sectionsTable').DataTable();
|
||||
|
||||
// Popola i campi del modale di modifica
|
||||
$('#editSectionModal').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var id = button.data('id');
|
||||
var name = button.data('name');
|
||||
var description = button.data('description');
|
||||
|
||||
$('#editSectionId').val(id);
|
||||
$('#editSectionName').val(name);
|
||||
$('#editSectionDescription').val(description);
|
||||
});
|
||||
|
||||
// Elimina sezione con SweetAlert2
|
||||
$('.delete-section').on('click', function() {
|
||||
var sectionId = $(this).data('id'); // Recupera l'id dal pulsante
|
||||
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: "Questa azione non può essere annullata!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sì, elimina!',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Effettua la chiamata per eliminare la sezione
|
||||
fetch(`delete-section.php?idsections=${sectionId}`, {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
Swal.fire(
|
||||
'Eliminato!',
|
||||
'La sezione è stata eliminata con successo.',
|
||||
'success'
|
||||
).then(() => {
|
||||
// Ricarica la pagina per aggiornare la tabella
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire(
|
||||
'Errore!',
|
||||
'Si è verificato un errore durante l\'eliminazione.',
|
||||
'error'
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
188
public/userportal/share-home.php
Normal file
188
public/userportal/share-home.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'idhome dalla query string
|
||||
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||
|
||||
// Recupera i dettagli dell'immobile
|
||||
$queryHome = $conn->prepare("SELECT * FROM home WHERE idhome = ?");
|
||||
$queryHome->bind_param('i', $idhome);
|
||||
$queryHome->execute();
|
||||
$resultHome = $queryHome->get_result();
|
||||
$homeDetails = $resultHome->fetch_assoc();
|
||||
|
||||
// Recupera tutte le condivisioni per l'immobile specifico
|
||||
$querySharing = $conn->prepare("
|
||||
SELECT
|
||||
hs.*,
|
||||
sr.role_name
|
||||
FROM home_sharing hs
|
||||
LEFT JOIN sharing_roles sr ON hs.role_id = sr.idrole
|
||||
WHERE hs.idhome = ?
|
||||
ORDER BY hs.created_at DESC
|
||||
");
|
||||
$querySharing->bind_param('i', $idhome);
|
||||
$querySharing->execute();
|
||||
$resultSharing = $querySharing->get_result();
|
||||
$sharings = [];
|
||||
|
||||
while ($row = $resultSharing->fetch_assoc()) {
|
||||
// Decode JSON sections
|
||||
$sharedSections = json_decode($row['shared_sections'], true) ?: [];
|
||||
if (!empty($sharedSections)) {
|
||||
// Match section IDs with names from the `sections` table
|
||||
$placeholders = implode(',', array_fill(0, count($sharedSections), '?'));
|
||||
$sectionQuery = $conn->prepare("SELECT section_name FROM sections WHERE idsections IN ($placeholders)");
|
||||
$sectionQuery->bind_param(str_repeat('i', count($sharedSections)), ...$sharedSections);
|
||||
$sectionQuery->execute();
|
||||
$sectionResult = $sectionQuery->get_result();
|
||||
$sectionNames = $sectionResult->fetch_all(MYSQLI_ASSOC);
|
||||
$row['section_names'] = array_column($sectionNames, 'section_name');
|
||||
} else {
|
||||
$row['section_names'] = ['Tutte le sezioni'];
|
||||
}
|
||||
$sharings[] = $row;
|
||||
}
|
||||
|
||||
$queryHome->close();
|
||||
$querySharing->close();
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Gestione Condivisioni</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css">
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
|
||||
<h4 class="page-title">Condivisioni per l'immobile</h4>
|
||||
<p><strong>Dettagli immobile:</strong> <?php echo htmlspecialchars($homeDetails['address']); ?></p>
|
||||
|
||||
<!-- Pulsante per aggiungere una nuova condivisione -->
|
||||
<a href="add-sharing.php?idhome=<?php echo $idhome; ?>" class="btn btn-success mb-3">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Condivisione
|
||||
</a>
|
||||
|
||||
<!-- Tabella delle condivisioni -->
|
||||
<table id="sharingTable" class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Email</th>
|
||||
<th>Ruolo</th>
|
||||
<th>Tipologia</th>
|
||||
<th>Sezioni</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($sharings as $sharing) { ?>
|
||||
<tr>
|
||||
<td><?php echo $sharing['idsharing']; ?></td>
|
||||
<td><?php echo htmlspecialchars($sharing['shared_email']); ?></td>
|
||||
<td><?php echo htmlspecialchars($sharing['role_name'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($sharing['sharing_type']); ?></td>
|
||||
<td>
|
||||
<?php echo implode(', ', $sharing['section_names']); ?>
|
||||
</td>
|
||||
<td><?php echo $sharing['expiration_date'] ?: 'Senza scadenza'; ?></td>
|
||||
<td>
|
||||
<a href="edit-sharing.php?idsharing=<?php echo $sharing['idsharing']; ?>" class="btn btn-warning btn-sm">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</a>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDelete(<?php echo $sharing['idsharing']; ?>)">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SweetAlert -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#sharingTable').DataTable();
|
||||
});
|
||||
|
||||
function confirmDelete(idsharing) {
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: "Questa azione rimuoverà la condivisione in modo permanente.",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Sì, elimina',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Effettua la richiesta per eliminare
|
||||
$.ajax({
|
||||
url: `delete-sharing.php?idsharing=${idsharing}`,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
Swal.fire(
|
||||
'Eliminato!',
|
||||
'La condivisione è stata eliminata con successo.',
|
||||
'success'
|
||||
).then(() => {
|
||||
// Ricarica la pagina
|
||||
location.reload();
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire(
|
||||
'Errore!',
|
||||
'Si è verificato un problema durante l\'eliminazione.',
|
||||
'error'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
230
public/userportal/sharing-roles.php
Normal file
230
public/userportal/sharing-roles.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'elenco dei ruoli
|
||||
$queryRoles = $conn->query("SELECT * FROM sharing_roles ORDER BY idrole DESC");
|
||||
$roles = [];
|
||||
while ($row = $queryRoles->fetch_assoc()) {
|
||||
$roles[] = $row;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Gestione Ruoli Condivisione</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="page-title">Gestione Ruoli di Condivisione</h4>
|
||||
<button class="btn btn-success mb-3" data-toggle="modal" data-target="#addRoleModal">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Ruolo
|
||||
</button>
|
||||
<table id="rolesTable" class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Permessi</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($roles as $role) { ?>
|
||||
<tr>
|
||||
<td><?php echo $role['idrole']; ?></td>
|
||||
<td><?php echo htmlspecialchars($role['role_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($role['description']); ?></td>
|
||||
<td><?php echo htmlspecialchars($role['permissions']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-warning btn-sm" data-toggle="modal" data-target="#editRoleModal"
|
||||
data-id="<?php echo $role['idrole']; ?>"
|
||||
data-name="<?php echo htmlspecialchars($role['role_name']); ?>"
|
||||
data-description="<?php echo htmlspecialchars($role['description']); ?>"
|
||||
data-permissions="<?php echo htmlspecialchars($role['permissions']); ?>">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-danger btn-sm delete-role"
|
||||
data-id="<?php echo $role['idrole']; ?>">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- container -->
|
||||
</div> <!-- Page content Wrapper -->
|
||||
</div> <!-- content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div> <!-- End Right content here -->
|
||||
</div> <!-- END wrapper -->
|
||||
|
||||
<!-- Modale: Aggiungi Ruolo -->
|
||||
<div class="modal fade" id="addRoleModal" tabindex="-1" role="dialog" aria-labelledby="addRoleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="add-role.php" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addRoleModalLabel">Aggiungi Ruolo</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="roleName">Nome Ruolo</label>
|
||||
<input type="text" class="form-control" id="roleName" name="role_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="roleDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="roleDescription" name="description"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="rolePermissions">Permessi (JSON)</label>
|
||||
<textarea class="form-control" id="rolePermissions" name="permissions"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-success">Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modale: Modifica Ruolo -->
|
||||
<div class="modal fade" id="editRoleModal" tabindex="-1" role="dialog" aria-labelledby="editRoleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form action="edit-role.php" method="POST">
|
||||
<input type="hidden" id="editRoleId" name="idrole">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editRoleModalLabel">Modifica Ruolo</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="editRoleName">Nome Ruolo</label>
|
||||
<input type="text" class="form-control" id="editRoleName" name="role_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editRoleDescription">Descrizione</label>
|
||||
<textarea class="form-control" id="editRoleDescription" name="description"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editRolePermissions">Permessi (JSON)</label>
|
||||
<textarea class="form-control" id="editRolePermissions" name="permissions"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Chiudi</button>
|
||||
<button type="submit" class="btn btn-warning">Salva Modifiche</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#rolesTable').DataTable();
|
||||
|
||||
// Popola i campi del modale di modifica
|
||||
$('#editRoleModal').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var id = button.data('id');
|
||||
var name = button.data('name');
|
||||
var description = button.data('description');
|
||||
var permissions = button.data('permissions');
|
||||
|
||||
$('#editRoleId').val(id);
|
||||
$('#editRoleName').val(name);
|
||||
$('#editRoleDescription').val(description);
|
||||
$('#editRolePermissions').val(permissions);
|
||||
});
|
||||
|
||||
// Elimina ruolo con SweetAlert2
|
||||
$('.delete-role').on('click', function() {
|
||||
var roleId = $(this).data('id'); // Recupera l'id dal pulsante
|
||||
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: "Questa azione non può essere annullata!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sì, elimina!',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Effettua la chiamata per eliminare il ruolo
|
||||
fetch(`delete-role.php?idrole=${roleId}`, {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
Swal.fire(
|
||||
'Eliminato!',
|
||||
'Il ruolo è stato eliminato con successo.',
|
||||
'success'
|
||||
).then(() => {
|
||||
// Ricarica la pagina per aggiornare la tabella
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire(
|
||||
'Errore!',
|
||||
'Si è verificato un errore durante l\'eliminazione.',
|
||||
'error'
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
127
public/userportal/templatediv.php
Normal file
127
public/userportal/templatediv.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Recupera l'id immobile (idhome) passato tramite GET
|
||||
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$shared_email = $conn->real_escape_string($_POST['shared_email']);
|
||||
$sharing_type = $conn->real_escape_string($_POST['sharing_type']);
|
||||
$shared_sections = json_encode($_POST['shared_sections']); // Converti le sezioni in JSON
|
||||
$expiration_date = !empty($_POST['expiration_date']) ? $_POST['expiration_date'] : null;
|
||||
|
||||
// Inserimento nel database
|
||||
$query = $conn->prepare("
|
||||
INSERT INTO home_sharing (idhome, shared_email, sharing_type, shared_sections, expiration_date, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, NOW())
|
||||
");
|
||||
$query->bind_param('issss', $idhome, $shared_email, $sharing_type, $shared_sections, $expiration_date);
|
||||
|
||||
if ($query->execute()) {
|
||||
// Reindirizza a share-home.php con l'idhome
|
||||
header("Location: share-home.php?idhome=$idhome&success=1");
|
||||
exit;
|
||||
} else {
|
||||
$error = "Errore nell'inserimento della condivisione. Riprova.";
|
||||
}
|
||||
$query->close();
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Aggiungi Condivisione</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
|
||||
<h4 class="page-title">Aggiungi Condivisione</h4>
|
||||
<?php if (!empty($error)) { ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<form action="add-sharing.php?idhome=<?php echo $idhome; ?>" method="POST">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="sharedEmail">Email del destinatario</label>
|
||||
<input type="email" class="form-control" id="sharedEmail" name="shared_email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="sharingType">Tipologia di Condivisione</label>
|
||||
<select class="form-control" id="sharingType" name="sharing_type" required>
|
||||
<option value="read-only">Sola Lettura</option>
|
||||
<option value="add-documents">Aggiunta Documenti</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="sharedSections">Sezioni Condivise</label>
|
||||
<select class="form-control" id="sharedSections" name="shared_sections[]" multiple required>
|
||||
<option value="documents">Documenti</option>
|
||||
<option value="details">Dettagli</option>
|
||||
<option value="contracts">Contratti</option>
|
||||
</select>
|
||||
<small class="form-text text-muted">Tieni premuto CTRL (o CMD su Mac) per selezionare più opzioni.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="expirationDate">Data di Scadenza (Opzionale)</label>
|
||||
<input type="text" class="form-control flatpickr" id="expirationDate" name="expiration_date">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer text-right">
|
||||
<button type="submit" class="btn btn-success">Salva Condivisione</button>
|
||||
<a href="share-home.php?idhome=<?php echo $idhome; ?>" class="btn btn-secondary">Annulla</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.flatpickr').flatpickr({
|
||||
enableTime: false,
|
||||
dateFormat: "Y-m-d"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,74 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CASADOC - Notifica Condivisione</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
color: #333;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background: #ffffff;
|
||||
border: 1px solid #dddddd;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.email-header {
|
||||
background: #007bff;
|
||||
color: #ffffff;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.email-body {
|
||||
padding: 20px;
|
||||
}
|
||||
.email-footer {
|
||||
background: #f1f1f1;
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #777;
|
||||
}
|
||||
.email-footer a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.highlight {
|
||||
color: #007bff;
|
||||
font-weight: bold;
|
||||
}
|
||||
.cta {
|
||||
margin-top: 20px;
|
||||
display: inline-block;
|
||||
background: #007bff;
|
||||
color: #ffffff;
|
||||
padding: 10px 20px;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="email-container">
|
||||
<div class="email-header">CASADOC</div>
|
||||
<div class="email-body">
|
||||
<h2>{EMAIL_SUBJECT}</h2>
|
||||
<p>{EMAIL_MESSAGE}</p>
|
||||
{EMAIL_CTA}
|
||||
</div>
|
||||
<div class="email-footer">
|
||||
Questo messaggio è stato generato automaticamente da
|
||||
<a href="https://casadoc.app">CASADOC</a>.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
57
public/userportal/tools/mailer.php
Normal file
57
public/userportal/tools/mailer.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
// Includi i file di PHPMailer
|
||||
require '../../../vendor/autoload.php'; // Assicurati che PHPMailer sia installato tramite Composer
|
||||
|
||||
function sendEmail($to, $subject, $body, $attachments = [], $cc = [], $bcc = [])
|
||||
{
|
||||
// Configurazione SMTP
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
// Configurazione server SMTP
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.example.com'; // Sostituisci con il tuo host SMTP
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'your-email@example.com'; // Sostituisci con il tuo indirizzo email
|
||||
$mail->Password = 'your-email-password'; // Sostituisci con la password della tua email
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = 587; // Porta SMTP (spesso 587 per TLS o 465 per SSL)
|
||||
|
||||
// Mittente
|
||||
$mail->setFrom('your-email@example.com', 'Nome Mittente'); // Modifica il nome del mittente
|
||||
|
||||
// Destinatari principali
|
||||
foreach ((array)$to as $recipient) {
|
||||
$mail->addAddress($recipient);
|
||||
}
|
||||
|
||||
// Destinatari CC
|
||||
foreach ((array)$cc as $recipient) {
|
||||
$mail->addCC($recipient);
|
||||
}
|
||||
|
||||
// Destinatari BCC
|
||||
foreach ((array)$bcc as $recipient) {
|
||||
$mail->addBCC($recipient);
|
||||
}
|
||||
|
||||
// Allegati
|
||||
foreach ((array)$attachments as $file) {
|
||||
$mail->addAttachment($file);
|
||||
}
|
||||
|
||||
// Contenuto dell'email
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
|
||||
// Invia l'email
|
||||
$mail->send();
|
||||
return ['success' => true, 'message' => 'Email inviata con successo.'];
|
||||
} catch (Exception $e) {
|
||||
return ['success' => false, 'message' => "Errore nell'invio dell'email: {$mail->ErrorInfo}"];
|
||||
}
|
||||
}
|
||||
88
public/userportal/upload-document-person.php
Normal file
88
public/userportal/upload-document-person.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Controlla la connessione al database
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['success' => false, 'message' => "Connection failed: " . $conn->connect_error]));
|
||||
}
|
||||
|
||||
// Impostazioni della cartella di destinazione
|
||||
$targetDir = "persondocuments/";
|
||||
|
||||
// Recupera i dati inviati tramite POST e FILES
|
||||
$owner_id = isset($_POST['owner_id']) ? intval($_POST['owner_id']) : 0; // `owner_id` dell'owner
|
||||
$document_id = isset($_POST['document_id']) ? intval($_POST['document_id']) : 0;
|
||||
$file = isset($_FILES['file']) ? $_FILES['file'] : null;
|
||||
$expirydate = isset($_POST['expirydate']) ? $_POST['expirydate'] : null;
|
||||
$note = isset($_POST['note']) ? $_POST['note'] : null;
|
||||
|
||||
// Validazione dei dati
|
||||
if ($owner_id === 0 || $document_id === 0 || !$file) {
|
||||
echo json_encode(['success' => false, 'message' => "Invalid input data."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Controlla se il file è stato caricato correttamente
|
||||
if ($file['error'] === UPLOAD_ERR_OK) {
|
||||
// Rinomina il file con lo schema ownerId-timestamp-filename
|
||||
$filename = basename($file['name']);
|
||||
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$newFilename = $owner_id . '-' . time() . '-' . $filename;
|
||||
$targetFilePath = $targetDir . $newFilename;
|
||||
|
||||
// Verifica e crea la cartella se non esiste
|
||||
if (!is_dir($targetDir)) {
|
||||
mkdir($targetDir, 0777, true);
|
||||
}
|
||||
|
||||
// Sposta il file nella cartella di destinazione
|
||||
if (move_uploaded_file($file['tmp_name'], $targetFilePath)) {
|
||||
// Determina lo stato di scadenza
|
||||
$expiry_status = ($expirydate) ? 1 : 0;
|
||||
|
||||
// Inserisce il file nel database
|
||||
$query = "
|
||||
INSERT INTO doc_storage (idhome, owner_id, document_id, filename, expirystatus, expirydate, note, created_at, updated_at)
|
||||
VALUES (NULL, ?, ?, ?, ?, ?, ?, NOW(), NOW())
|
||||
";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("iissss", $owner_id, $document_id, $newFilename, $expiry_status, $expirydate, $note);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
// Ottieni l'ID del documento appena inserito
|
||||
$documentId = $stmt->insert_id;
|
||||
|
||||
// Ottieni la data di caricamento dal database
|
||||
$stmtSelect = $conn->prepare("SELECT created_at FROM doc_storage WHERE id = ?");
|
||||
$stmtSelect->bind_param("i", $documentId);
|
||||
$stmtSelect->execute();
|
||||
$result = $stmtSelect->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$uploadDate = $row['created_at'];
|
||||
$stmtSelect->close();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "File uploaded successfully.",
|
||||
'fileName' => $newFilename,
|
||||
'uploadDate' => $uploadDate,
|
||||
'documentId' => $documentId
|
||||
]);
|
||||
} else {
|
||||
// Rimuove il file se l'inserimento nel DB fallisce
|
||||
unlink($targetFilePath);
|
||||
echo json_encode(['success' => false, 'message' => "Failed to insert into database: " . $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => "Failed to move the file."]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => "File upload error."]);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@ -34,17 +34,38 @@ if ($file && $file['error'] === UPLOAD_ERR_OK) {
|
||||
|
||||
// Sposta il file nella cartella di destinazione
|
||||
if (move_uploaded_file($file['tmp_name'], $targetFilePath)) {
|
||||
// Inserisce il file nel database
|
||||
// Determina lo stato di scadenza
|
||||
$expiry_status = ($expirydate) ? 1 : 0;
|
||||
|
||||
// Inserisce il file nel database
|
||||
$query = "INSERT INTO doc_storage (idhome, document_id, filename, expirystatus, expirydate, note, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, NOW(), NOW())";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("iissss", $idhome, $document_id, $newFilename, $expiry_status, $expirydate, $note);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['success' => true, 'message' => "File uploaded successfully.", 'filename' => $newFilename]);
|
||||
// Ottieni l'ID del documento appena inserito
|
||||
$documentId = $stmt->insert_id;
|
||||
|
||||
// Ottieni la data di caricamento dal database
|
||||
$stmtSelect = $conn->prepare("SELECT created_at FROM doc_storage WHERE id = ?");
|
||||
$stmtSelect->bind_param("i", $documentId);
|
||||
$stmtSelect->execute();
|
||||
$result = $stmtSelect->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$uploadDate = $row['created_at'];
|
||||
$stmtSelect->close();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "File uploaded successfully.",
|
||||
'fileName' => $newFilename,
|
||||
'uploadDate' => $uploadDate,
|
||||
'documentId' => $documentId
|
||||
]);
|
||||
} else {
|
||||
// Rimuove il file se l'inserimento nel DB fallisce
|
||||
unlink($targetFilePath);
|
||||
echo json_encode(['success' => false, 'message' => "Failed to insert into database: " . $stmt->error]);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user