diff --git a/composer.json b/composer.json index b1f6636..bdb9ccc 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 14be15f..b67297b 100644 --- a/composer.lock +++ b/composer.lock @@ -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" } diff --git a/public/userportal/add-document.php b/public/userportal/add-document.php new file mode 100644 index 0000000..6ccdabf --- /dev/null +++ b/public/userportal/add-document.php @@ -0,0 +1,59 @@ +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(); diff --git a/public/userportal/add-page.php b/public/userportal/add-page.php new file mode 100644 index 0000000..a055140 --- /dev/null +++ b/public/userportal/add-page.php @@ -0,0 +1,25 @@ +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(); diff --git a/public/userportal/add-role.php b/public/userportal/add-role.php new file mode 100644 index 0000000..f443f98 --- /dev/null +++ b/public/userportal/add-role.php @@ -0,0 +1,39 @@ +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(); diff --git a/public/userportal/add-section.php b/public/userportal/add-section.php new file mode 100644 index 0000000..533f31e --- /dev/null +++ b/public/userportal/add-section.php @@ -0,0 +1,52 @@ +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(); diff --git a/public/userportal/add-sharing.php b/public/userportal/add-sharing.php new file mode 100644 index 0000000..9cfb0c9 --- /dev/null +++ b/public/userportal/add-sharing.php @@ -0,0 +1,187 @@ + +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; + } +} +?> + + + + + + + + Aggiungi Condivisione + + + + + + + + +
+ +
+
+ +
+
+
+
+
+
+

+ Aggiungi Condivisione +

+
+
+
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ +
+ + +
+ +
+
+ + +
+ + +
+ + +
+ + + Annulla + +
+
+
+
+
+
+
+
+
+ +
+
+ + + + + + + \ No newline at end of file diff --git a/public/userportal/admin.php b/public/userportal/admin.php new file mode 100644 index 0000000..478573b --- /dev/null +++ b/public/userportal/admin.php @@ -0,0 +1,291 @@ + +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']; +?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + +
+ + + + + +
+ +
+ + + +
+ +
+ +
+
+
+
+ +
+

Dashboard

+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+
+
+

Immobili inseriti

+
+
+
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+

Proprietari registrati

+
+
+
+
+
+
+ + + +
+
+
+
+
+
+ +
+
+
+

Documenti caricati

+
+
+
+
+
+
+ + +
+
+
+ + + + + + + + + + + + + + +
+ +
+ +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/delete-document.php b/public/userportal/delete-document.php new file mode 100644 index 0000000..f4cc7dc --- /dev/null +++ b/public/userportal/delete-document.php @@ -0,0 +1,30 @@ + 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."]); +} diff --git a/public/userportal/delete-home.php b/public/userportal/delete-home.php new file mode 100644 index 0000000..644c64c --- /dev/null +++ b/public/userportal/delete-home.php @@ -0,0 +1,63 @@ +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(); diff --git a/public/userportal/delete-page.php b/public/userportal/delete-page.php new file mode 100644 index 0000000..8e65c5a --- /dev/null +++ b/public/userportal/delete-page.php @@ -0,0 +1,23 @@ +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(); diff --git a/public/userportal/delete-role.php b/public/userportal/delete-role.php new file mode 100644 index 0000000..fd828ad --- /dev/null +++ b/public/userportal/delete-role.php @@ -0,0 +1,24 @@ +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(); diff --git a/public/userportal/delete-sharing.php b/public/userportal/delete-sharing.php new file mode 100644 index 0000000..468037b --- /dev/null +++ b/public/userportal/delete-sharing.php @@ -0,0 +1,39 @@ +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(); diff --git a/public/userportal/documents-home.php b/public/userportal/documents-home.php index 3ec628a..d5edd56 100644 --- a/public/userportal/documents-home.php +++ b/public/userportal/documents-home.php @@ -1,4 +1,9 @@ - + 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; +} ?> + + @@ -47,7 +89,7 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) { - + @@ -56,8 +98,53 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) { + + + @@ -119,7 +259,7 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
- +
@@ -129,58 +269,99 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {

Indirizzo:

+
+
+
+ + + +
+ +
+
- $sectionDocuments) { ?> -
-
- -
-
-
- -

- - (Obbligatorio)"; ?> - 0) echo " - Max: " . $document['max_documents']; ?> -

+
+ $sectionDocuments) { ?> +
+ +

+ +

+ +
+
+ +
+ +
+
+ + + Obbligatorio + + 0) { ?> + Max: + +
+ +
- -
-
-
- Trascina qui i documenti o clicca per caricare -
-
- -
Documenti già caricati:
- - - - - - - - - - - - - - - - - - + +
+
+
+
+ Trascina qui i documenti o clicca per caricare +
+
+
+ +
Documenti già caricati:
+ 0) { ?> + +
Nome DocumentoData CaricamentoAzioni
+ + + + + + + + + + + + + + + + +
Nome DocumentoData CaricamentoAzioni
+ + +

Nessun documento caricato

- - + +
+
- +
+ + +
@@ -197,24 +378,79 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) { + + + \ No newline at end of file diff --git a/public/userportal/documents-person.php b/public/userportal/documents-person.php new file mode 100644 index 0000000..9f5eb17 --- /dev/null +++ b/public/userportal/documents-person.php @@ -0,0 +1,479 @@ + 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 ""; + } 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; +} +?> + + + + + + + + Documenti della Casa + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+ +
+
+

Documenti per:

+
+
+ + + $sectionDocuments) { ?> +
+
+ + +
+
+
+ +

+ + (Obbligatorio)"; ?> + 0) echo " - Max: " . $document['max_documents']; ?> +

+ + +
+
+
+ Trascina qui i documenti o clicca per caricare +
+
+ + +
Documenti già caricati:
+ + + + + + + + + + + + + + + + + + + +
Nome DocumentoData CaricamentoAzioni
+ + + + + +
+
+
+
+ + +
+
+
+
+ + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/documents-settings.php b/public/userportal/documents-settings.php new file mode 100644 index 0000000..a7aae62 --- /dev/null +++ b/public/userportal/documents-settings.php @@ -0,0 +1,380 @@ + +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; +} +?> + + + + + + + + Gestione Documenti + + + + + + + + + + + +
+ + +
+
+ +
+
+
+
+ +
+ + +
+
+ +
+
+
+
+

Elenco Documenti

+ + + + + + + + + + + + + + + + + + + + + + + + + +
IDNome DocumentoPaginaSezioneMax DocumentiObbligatorioAzioni
+ + + + + +
+
+
+
+
+ +
+
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/edit-document.php b/public/userportal/edit-document.php new file mode 100644 index 0000000..4f14a23 --- /dev/null +++ b/public/userportal/edit-document.php @@ -0,0 +1,61 @@ +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(); diff --git a/public/userportal/edit-page.php b/public/userportal/edit-page.php new file mode 100644 index 0000000..b6c826b --- /dev/null +++ b/public/userportal/edit-page.php @@ -0,0 +1,26 @@ +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(); diff --git a/public/userportal/edit-role.php b/public/userportal/edit-role.php new file mode 100644 index 0000000..2bbc02b --- /dev/null +++ b/public/userportal/edit-role.php @@ -0,0 +1,27 @@ +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(); diff --git a/public/userportal/edit-section.php b/public/userportal/edit-section.php new file mode 100644 index 0000000..2692235 --- /dev/null +++ b/public/userportal/edit-section.php @@ -0,0 +1,53 @@ +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(); diff --git a/public/userportal/edit-sharing.php b/public/userportal/edit-sharing.php new file mode 100644 index 0000000..481a7f8 --- /dev/null +++ b/public/userportal/edit-sharing.php @@ -0,0 +1,193 @@ +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) ?: []; +?> + + + + + + + + Modifica Condivisione + + + + + + + + + +
+ +
+
+ + +
+
+
+
+

Modifica Condivisione

+
+
+
+ + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ +
+ > + +
+ +
+
+ + +
+ + +
+ + +
+ + + Annulla + +
+
+
+
+
+
+
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/public/userportal/homedocuments/1-1726896643-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726896643-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726896643-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726896676-SnapFeet.pdf b/public/userportal/homedocuments/1-1726896676-SnapFeet.pdf new file mode 100644 index 0000000..5375c1f Binary files /dev/null and b/public/userportal/homedocuments/1-1726896676-SnapFeet.pdf differ diff --git a/public/userportal/homedocuments/1-1726897640-SnapFeet.pdf b/public/userportal/homedocuments/1-1726897640-SnapFeet.pdf new file mode 100644 index 0000000..5375c1f Binary files /dev/null and b/public/userportal/homedocuments/1-1726897640-SnapFeet.pdf differ diff --git a/public/userportal/homedocuments/1-1726897711-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726897711-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726897711-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726897924-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726897924-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726897924-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726897973-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726897973-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726897973-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726898064-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726898064-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726898064-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726914242-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726914242-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726914242-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726914487-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726914487-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726914487-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726914496-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726914496-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726914496-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726914630-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1726914630-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1726914630-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1726914642-SnapFeet.pdf b/public/userportal/homedocuments/1-1726914642-SnapFeet.pdf new file mode 100644 index 0000000..5375c1f Binary files /dev/null and b/public/userportal/homedocuments/1-1726914642-SnapFeet.pdf differ diff --git a/public/userportal/homedocuments/1-1733150889-2024-07-09 10-20.pdf b/public/userportal/homedocuments/1-1733150889-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/homedocuments/1-1733150889-2024-07-09 10-20.pdf differ diff --git a/public/userportal/homedocuments/1-1733150938-23-2145fail-highlight.pdf b/public/userportal/homedocuments/1-1733150938-23-2145fail-highlight.pdf new file mode 100644 index 0000000..f0d3b72 Binary files /dev/null and b/public/userportal/homedocuments/1-1733150938-23-2145fail-highlight.pdf differ diff --git a/public/userportal/homedocuments/1-1733152809-CF_INTEROAury.pdf b/public/userportal/homedocuments/1-1733152809-CF_INTEROAury.pdf new file mode 100644 index 0000000..428cc11 Binary files /dev/null and b/public/userportal/homedocuments/1-1733152809-CF_INTEROAury.pdf differ diff --git a/public/userportal/homedocuments/1-1733154344-CI_FRONTE_RETROAury.pdf b/public/userportal/homedocuments/1-1733154344-CI_FRONTE_RETROAury.pdf new file mode 100644 index 0000000..77fd639 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154344-CI_FRONTE_RETROAury.pdf differ diff --git a/public/userportal/homedocuments/1-1733154367-logo_snapfeet_b (3).png b/public/userportal/homedocuments/1-1733154367-logo_snapfeet_b (3).png new file mode 100644 index 0000000..56ac196 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154367-logo_snapfeet_b (3).png differ diff --git a/public/userportal/homedocuments/1-1733154535-Contratto Claudio Sironi.pdf b/public/userportal/homedocuments/1-1733154535-Contratto Claudio Sironi.pdf new file mode 100644 index 0000000..d2c46d8 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154535-Contratto Claudio Sironi.pdf differ diff --git a/public/userportal/homedocuments/1-1733154542-1.png b/public/userportal/homedocuments/1-1733154542-1.png new file mode 100644 index 0000000..970ee01 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154542-1.png differ diff --git a/public/userportal/homedocuments/1-1733154717-23-2145fail-highlight.pdf b/public/userportal/homedocuments/1-1733154717-23-2145fail-highlight.pdf new file mode 100644 index 0000000..f0d3b72 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154717-23-2145fail-highlight.pdf differ diff --git a/public/userportal/homedocuments/1-1733154736-Contratto Claudio Sironi.pdf b/public/userportal/homedocuments/1-1733154736-Contratto Claudio Sironi.pdf new file mode 100644 index 0000000..d2c46d8 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154736-Contratto Claudio Sironi.pdf differ diff --git a/public/userportal/homedocuments/1-1733154760-logo_snapfeet_b (3).png b/public/userportal/homedocuments/1-1733154760-logo_snapfeet_b (3).png new file mode 100644 index 0000000..56ac196 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154760-logo_snapfeet_b (3).png differ diff --git a/public/userportal/homedocuments/1-1733154789-logo_snapfeet_b (3).png b/public/userportal/homedocuments/1-1733154789-logo_snapfeet_b (3).png new file mode 100644 index 0000000..56ac196 Binary files /dev/null and b/public/userportal/homedocuments/1-1733154789-logo_snapfeet_b (3).png differ diff --git a/public/userportal/homes-list.php b/public/userportal/homes-list.php index f98a8bc..f1d9b74 100644 --- a/public/userportal/homes-list.php +++ b/public/userportal/homes-list.php @@ -25,9 +25,12 @@ $result = $stmt->get_result(); + + + @@ -102,16 +105,37 @@ $result = $stmt->get_result(); - - Dettagli + + - - Documenti + + + + - - Elimina + + + + + + + + + + + + + + + @@ -148,6 +172,59 @@ $result = $stmt->get_result(); }); }); + + + \ No newline at end of file diff --git a/public/userportal/include/navigationbar.php b/public/userportal/include/navigationbar.php index d945283..05c848f 100644 --- a/public/userportal/include/navigationbar.php +++ b/public/userportal/include/navigationbar.php @@ -62,7 +62,12 @@ + +
  • + Admin Page + +
  • diff --git a/public/userportal/index.php b/public/userportal/index.php index 21a1be0..bdfe2cb 100644 --- a/public/userportal/index.php +++ b/public/userportal/index.php @@ -1,4 +1,45 @@ +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']; +?> + + @@ -110,92 +151,97 @@
    -
    -
    + +
    +
    - +
    -
    190
    -

    ---

    +
    +

    Immobili inseriti

    -
    -
    -
    -
    -
    -
    - -
    -
    -
    62
    -

    ---

    -
    -
    -
    -
    -
    -
    -
    -
    + + +
    +
    - +
    -
    14
    -

    ---

    +
    +

    Proprietari registrati

    -
    -
    + + + +
    +
    - +
    -
    $15562
    -

    ---

    +
    +

    Documenti caricati

    -
    -
    -
    -
    - -
    -
    -

    XLS to RSL

    -

    Import XLS requirements and create a Word document

    -
    -
    + + + + + + + +
    diff --git a/public/userportal/page-settings.php b/public/userportal/page-settings.php new file mode 100644 index 0000000..21960b3 --- /dev/null +++ b/public/userportal/page-settings.php @@ -0,0 +1,255 @@ + + + +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; +} +?> + + + + + + + + Gestione Pagine + + + + + + + + +
    + + +
    +
    + + +
    +
    + + + + + + +
    + +
    + +
    +
    + + +
    +
    +
    +
    +

    Elenco Pagine

    + + + + + + + + + + + + + + + + + + + + + + +
    IDNomeSlugDescrizioneAzioni
    + + +
    +
    +
    +
    +
    + +
    +
    +
    + + +
    +
    + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/person-list.php b/public/userportal/person-list.php index d381007..1a008f7 100644 --- a/public/userportal/person-list.php +++ b/public/userportal/person-list.php @@ -25,7 +25,7 @@ $result = $stmt->get_result(); - + @@ -129,10 +129,13 @@ $result = $stmt->get_result(); Dettagli - - - DOCS - +
    + + +
    +
    diff --git a/public/userportal/persondocuments/1-1733144312-23-2145fail-highlight.pdf b/public/userportal/persondocuments/1-1733144312-23-2145fail-highlight.pdf new file mode 100644 index 0000000..f0d3b72 Binary files /dev/null and b/public/userportal/persondocuments/1-1733144312-23-2145fail-highlight.pdf differ diff --git a/public/userportal/persondocuments/1-1733144749-Contratto Claudio Sironi.pdf b/public/userportal/persondocuments/1-1733144749-Contratto Claudio Sironi.pdf new file mode 100644 index 0000000..d2c46d8 Binary files /dev/null and b/public/userportal/persondocuments/1-1733144749-Contratto Claudio Sironi.pdf differ diff --git a/public/userportal/persondocuments/1-1733145117-2024-07-09 10-20.pdf b/public/userportal/persondocuments/1-1733145117-2024-07-09 10-20.pdf new file mode 100644 index 0000000..1e39140 Binary files /dev/null and b/public/userportal/persondocuments/1-1733145117-2024-07-09 10-20.pdf differ diff --git a/public/userportal/persondocuments/1-1733146052-CI_FRONTE_RETROAury.pdf b/public/userportal/persondocuments/1-1733146052-CI_FRONTE_RETROAury.pdf new file mode 100644 index 0000000..77fd639 Binary files /dev/null and b/public/userportal/persondocuments/1-1733146052-CI_FRONTE_RETROAury.pdf differ diff --git a/public/userportal/persondocuments/1-1733146367-logo_snapfeet_b (3).png b/public/userportal/persondocuments/1-1733146367-logo_snapfeet_b (3).png new file mode 100644 index 0000000..56ac196 Binary files /dev/null and b/public/userportal/persondocuments/1-1733146367-logo_snapfeet_b (3).png differ diff --git a/public/userportal/persondocuments/1-1733146735-questionario_reportify.pdf b/public/userportal/persondocuments/1-1733146735-questionario_reportify.pdf new file mode 100644 index 0000000..54db95e Binary files /dev/null and b/public/userportal/persondocuments/1-1733146735-questionario_reportify.pdf differ diff --git a/public/userportal/save-edit-sharing.php b/public/userportal/save-edit-sharing.php new file mode 100644 index 0000000..03dcb6e --- /dev/null +++ b/public/userportal/save-edit-sharing.php @@ -0,0 +1,77 @@ +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(); diff --git a/public/userportal/save-sharing.php b/public/userportal/save-sharing.php new file mode 100644 index 0000000..cdddcc1 --- /dev/null +++ b/public/userportal/save-sharing.php @@ -0,0 +1,153 @@ +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 $userName ha condiviso con te l'immobile $homeName. Puoi trovarlo nella sezione 'Immobili Condivisi' su CASADOC.", + "Visualizza Immobili" + ], + $body + ); + } else { + // Utente non registrato + $body = str_replace( + ['{EMAIL_SUBJECT}', '{EMAIL_MESSAGE}', '{EMAIL_CTA}'], + [ + "Registrazione Necessaria", + "L'utente $userName ha condiviso con te un immobile, ma devi registrarti su CASADOC per visualizzarlo.", + "Registrati Ora" + ], + $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(); diff --git a/public/userportal/sections.php b/public/userportal/sections.php new file mode 100644 index 0000000..435a76e --- /dev/null +++ b/public/userportal/sections.php @@ -0,0 +1,216 @@ + +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; +} +?> + + + + + + + + Gestione Sezioni + + + + + + + + + +
    + +
    +
    + + +
    +
    +
    +
    +

    Gestione Sezioni

    + + + + + + + + + + + + + + + + + + + + +
    IDNomeDescrizioneAzioni
    + + +
    +
    +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/share-home.php b/public/userportal/share-home.php new file mode 100644 index 0000000..887919f --- /dev/null +++ b/public/userportal/share-home.php @@ -0,0 +1,188 @@ + + +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(); +?> + + + + + + + + Gestione Condivisioni + + + + + + + + +
    + + +
    +
    + + +
    +
    + +

    Condivisioni per l'immobile

    +

    Dettagli immobile:

    + + + + Aggiungi Condivisione + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IDEmailRuoloTipologiaSezioniScadenzaAzioni
    + + + + + + +
    + +
    +
    +
    + +
    +
    + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/sharing-roles.php b/public/userportal/sharing-roles.php new file mode 100644 index 0000000..29cd475 --- /dev/null +++ b/public/userportal/sharing-roles.php @@ -0,0 +1,230 @@ + +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; +} +?> + + + + + + + + Gestione Ruoli Condivisione + + + + + + + + + +
    + +
    +
    + + +
    +
    +
    +
    +

    Gestione Ruoli di Condivisione

    + + + + + + + + + + + + + + + + + + + + + + +
    IDNomeDescrizionePermessiAzioni
    + + + +
    +
    +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userportal/templatediv.php b/public/userportal/templatediv.php new file mode 100644 index 0000000..6d0448c --- /dev/null +++ b/public/userportal/templatediv.php @@ -0,0 +1,127 @@ + + +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(); +} +?> + + + + + + + + Aggiungi Condivisione + + + + + + + + +
    + + +
    +
    + + +
    +
    + +

    Aggiungi Condivisione

    + +
    + + +
    +
    +
    +
    + + +
    + +
    + + +
    + +
    + + + Tieni premuto CTRL (o CMD su Mac) per selezionare più opzioni. +
    + +
    + + +
    +
    + + +
    +
    + +
    +
    +
    + +
    +
    + + + + + + + diff --git a/public/userportal/templates/emails/shared_property_email.html b/public/userportal/templates/emails/shared_property_email.html new file mode 100644 index 0000000..66d7401 --- /dev/null +++ b/public/userportal/templates/emails/shared_property_email.html @@ -0,0 +1,74 @@ + + + + + + CASADOC - Notifica Condivisione + + + + + + diff --git a/public/userportal/tools/mailer.php b/public/userportal/tools/mailer.php new file mode 100644 index 0000000..d139040 --- /dev/null +++ b/public/userportal/tools/mailer.php @@ -0,0 +1,57 @@ +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}"]; + } +} diff --git a/public/userportal/upload-document-person.php b/public/userportal/upload-document-person.php new file mode 100644 index 0000000..b960e83 --- /dev/null +++ b/public/userportal/upload-document-person.php @@ -0,0 +1,88 @@ +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(); diff --git a/public/userportal/upload-document.php b/public/userportal/upload-document.php index 91079e5..54d73ef 100644 --- a/public/userportal/upload-document.php +++ b/public/userportal/upload-document.php @@ -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]); }