From d6a64fd4599f3633edea2d68d44c7c495f884005 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Fri, 10 Apr 2026 13:15:46 +0200 Subject: [PATCH 1/5] fix: stylesheet separatore pannello admin --- src/admin/index.php | 2 +- src/admin/manageOrders.php | 2 +- src/admin/manageProducts.php | 2 +- src/admin/manageUsers.php | 2 +- src/assets/style.css | 9 +++++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/admin/index.php b/src/admin/index.php index 332c703..a3a8ae5 100644 --- a/src/admin/index.php +++ b/src/admin/index.php @@ -81,7 +81,7 @@ if ($result_total_products) {
  • Gestione ordini
  • Gestione prodotti
  • Gestione utenti
  • -
    +
  • Ritorna al tuo account
  • diff --git a/src/admin/manageOrders.php b/src/admin/manageOrders.php index 4a293dd..cd087d6 100644 --- a/src/admin/manageOrders.php +++ b/src/admin/manageOrders.php @@ -101,7 +101,7 @@ if ($result === false) {
  • Gestione ordini
  • Gestione prodotti
  • Gestione utenti
  • -
    +
  • Ritorna al tuo account
  • diff --git a/src/admin/manageProducts.php b/src/admin/manageProducts.php index 354b686..c79c661 100644 --- a/src/admin/manageProducts.php +++ b/src/admin/manageProducts.php @@ -55,7 +55,7 @@ if ($role !== 'admin') {
  • Gestione ordini
  • Gestione prodotti
  • Gestione utenti
  • -
    +
  • Ritorna al tuo account
  • diff --git a/src/admin/manageUsers.php b/src/admin/manageUsers.php index 5a100a2..153a6d9 100644 --- a/src/admin/manageUsers.php +++ b/src/admin/manageUsers.php @@ -106,7 +106,7 @@ if ($result === false) {
  • Gestione ordini
  • Gestione prodotti
  • Gestione utenti
  • -
    +
  • Ritorna al tuo account
  • diff --git a/src/assets/style.css b/src/assets/style.css index 31af370..72a7100 100644 --- a/src/assets/style.css +++ b/src/assets/style.css @@ -256,6 +256,15 @@ form button:hover { padding: 20px; } +.admin-divider{ + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ddd; + margin: 1em 0; + padding: 0; +} + .admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); From 83adb359f86df6fa0f7407a2cb03755e538c3993 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Fri, 10 Apr 2026 13:43:07 +0200 Subject: [PATCH 2/5] Implementazione gestione prodotti in pannello admin --- src/admin/manageProducts.php | 112 ++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/src/admin/manageProducts.php b/src/admin/manageProducts.php index c79c661..0270496 100644 --- a/src/admin/manageProducts.php +++ b/src/admin/manageProducts.php @@ -22,6 +22,63 @@ if ($role !== 'admin') { http_response_code(403); die("Accesso negato. Solo gli amministratori possono accedere a questa sezione."); } + +// Gestione aggiornamenti +if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) { + $product_id = $_POST['product_id']; + $name = $_POST['name']; + $description = $_POST['description']; + $category_id = $_POST['category_id']; + $price = $_POST['price']; + $stock = $_POST['stock']; + + // Gestione immagine + $image_path = $_POST['current_image']; + if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) { + $target_dir = "../img/"; + $target_file = $target_dir . basename($_FILES["image"]["name"]); + $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); + // Controlli base + if (in_array($imageFileType, ['jpg', 'png', 'jpeg', 'gif'])) { + if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { + $image_path = "/img/" . basename($_FILES["image"]["name"]); + } + } + } + + // Update DB + $sql_update = "UPDATE Products SET ProductName = ?, Description = ?, CategoryID = ?, Price = ?, StockQuantity = ?, ImagePath = ? WHERE ProductID = ?"; + $stmt_update = $conn->prepare($sql_update); + $stmt_update->bind_param("ssidisi", $name, $description, $category_id, $price, $stock, $image_path, $product_id); + $stmt_update->execute(); + $stmt_update->close(); + + // Redirect + header("Location: manageProducts.php"); + exit(); +} + +// Ottieni categorie +$categories = []; +$sql_cat = "SELECT CategoryID, Name FROM Categories"; +$stmt_cat = $conn->prepare($sql_cat); +$stmt_cat->execute(); +$result_cat = $stmt_cat->get_result(); +while ($row = $result_cat->fetch_assoc()) { + $categories[] = $row; +} +$stmt_cat->close(); + +// Ottieni prodotti +$products = []; +$sql_prod = "SELECT ProductID, ProductName, Description, Price, StockQuantity, ImagePath, CategoryID FROM Products"; +$stmt_prod = $conn->prepare($sql_prod); +$stmt_prod->execute(); +$result_prod = $stmt_prod->get_result(); +while ($row = $result_prod->fetch_assoc()) { + $products[] = $row; +} +$stmt_prod->close(); ?> @@ -32,6 +89,13 @@ if ($role !== 'admin') { Gestione Prodotti - TechStore +
    @@ -60,8 +124,52 @@ if ($role !== 'admin') {
    -

    Gestione prodotti

    -

    WIP

    +

    Gestione Prodotti

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IDNomeDescrizioneCategoriaPrezzoStockImmagineAzioni
    + + +
    + + + +
    +
    + Immagine
    + +
    From 72c8872c39214861d3631c8cd1a8115370ced91c Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Fri, 10 Apr 2026 13:47:54 +0200 Subject: [PATCH 3/5] fix: percorso immagine in pagina gestione prodotti gestito incorrettamente --- src/admin/manageProducts.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/admin/manageProducts.php b/src/admin/manageProducts.php index 0270496..88a3cd5 100644 --- a/src/admin/manageProducts.php +++ b/src/admin/manageProducts.php @@ -33,15 +33,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) { $stock = $_POST['stock']; // Gestione immagine - $image_path = $_POST['current_image']; + $image_path = basename($_POST['current_image']); if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) { $target_dir = "../img/"; - $target_file = $target_dir . basename($_FILES["image"]["name"]); + $image_name = basename($_FILES["image"]["name"]); + $target_file = $target_dir . $image_name; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Controlli base if (in_array($imageFileType, ['jpg', 'png', 'jpeg', 'gif'])) { if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { - $image_path = "/img/" . basename($_FILES["image"]["name"]); + $image_path = $image_name; } } } @@ -161,9 +162,10 @@ $stmt_prod->close(); - Immagine
    + + Immagine
    - + From caef4421f16f699a1b7d5faa28c7e83ebeaa6717 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Mon, 13 Apr 2026 13:19:41 +0200 Subject: [PATCH 4/5] Aggiunta stylesheet pagina gestione prodotti --- src/admin/manageProducts.php | 39 ++++++++-------- src/assets/style.css | 86 ++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 18 deletions(-) diff --git a/src/admin/manageProducts.php b/src/admin/manageProducts.php index 88a3cd5..75a64e7 100644 --- a/src/admin/manageProducts.php +++ b/src/admin/manageProducts.php @@ -141,32 +141,35 @@ $stmt_prod->close(); - -
    - - - - - + + + + - - -
    - - - + + +
    + + +
    - + - Immagine
    - - - + Immagine
    +
    + + +
    + + diff --git a/src/assets/style.css b/src/assets/style.css index 72a7100..53457d6 100644 --- a/src/assets/style.css +++ b/src/assets/style.css @@ -256,6 +256,92 @@ form button:hover { padding: 20px; } +.product-table { + width: 100%; + border-collapse: collapse; + margin-top: 20px; +} + +.product-table th, +.product-table td { + border: 1px solid #ddd; + padding: 12px; + vertical-align: top; +} + +.product-table th { + background-color: #f8f9fa; + font-weight: 700; + text-align: left; +} + +.product-row:hover { + background-color: #f7f9fb; +} + +.product-name-input, +.product-description-textarea, +.product-category-select, +.product-price-input, +.stock-input, +.product-image-input { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; +} + +.product-description-textarea { + min-height: 80px; + resize: vertical; +} + +.stock-control { + display: flex; + align-items: center; + gap: 8px; +} + +.stock-button { + width: 32px; + height: 32px; + border: none; + border-radius: 4px; + background-color: #007bff; + color: #fff; + cursor: pointer; +} + +.stock-button:hover { + background-color: #0056b3; +} + +.product-image-preview { + max-width: 100px; + display: block; + margin-bottom: 8px; +} + +.image-upload { + display: flex; + flex-direction: column; + gap: 8px; +} + +.save-button { + padding: 10px 16px; + background-color: #28a745; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; +} + +.save-button:hover { + background-color: #218838; +} + .admin-divider{ display: block; height: 1px; From 364c512bfbd49168502e7dba4f439491ffe23067 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Mon, 13 Apr 2026 13:32:22 +0200 Subject: [PATCH 5/5] Implementazione aggiunta prodotto in pagina admin --- src/admin/manageProducts.php | 75 ++++++++++++++++++++++++++++++++++++ src/assets/style.css | 48 +++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/src/admin/manageProducts.php b/src/admin/manageProducts.php index 75a64e7..b886971 100644 --- a/src/admin/manageProducts.php +++ b/src/admin/manageProducts.php @@ -59,6 +59,37 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) { exit(); } +// Gestione aggiunta nuovo prodotto +if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add'])) { + $name = $_POST['name']; + $description = $_POST['description']; + $category_id = $_POST['category_id']; + $price = $_POST['price']; + $stock = $_POST['stock']; + $image_path = ''; + + if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) { + $target_dir = "../img/"; + $image_name = basename($_FILES["image"]["name"]); + $target_file = $target_dir . $image_name; + $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); + if (in_array($imageFileType, ['jpg', 'png', 'jpeg', 'gif'])) { + if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { + $image_path = $image_name; + } + } + } + + $sql_insert = "INSERT INTO Products (ProductName, Description, CategoryID, Price, StockQuantity, ImagePath) VALUES (?, ?, ?, ?, ?, ?)"; + $stmt_insert = $conn->prepare($sql_insert); + $stmt_insert->bind_param("ssidis", $name, $description, $category_id, $price, $stock, $image_path); + $stmt_insert->execute(); + $stmt_insert->close(); + + header("Location: manageProducts.php"); + exit(); +} + // Ottieni categorie $categories = []; $sql_cat = "SELECT CategoryID, Name FROM Categories"; @@ -91,11 +122,20 @@ $stmt_prod->close(); @@ -126,6 +166,41 @@ $stmt_prod->close();

    Gestione Prodotti

    + + diff --git a/src/assets/style.css b/src/assets/style.css index 53457d6..823f33c 100644 --- a/src/assets/style.css +++ b/src/assets/style.css @@ -279,6 +279,54 @@ form button:hover { background-color: #f7f9fb; } +.add-product-panel { + margin-bottom: 24px; + padding: 18px; + border: 1px solid #ddd; + border-radius: 8px; + background-color: #fdfdfd; +} + +.add-product-panel h2 { + margin-top: 0; + margin-bottom: 16px; + color: #333; + font-size: 1.25rem; +} + +.add-product-form { + display: grid; + gap: 16px; +} + +.add-product-form .form-row { + display: grid; + gap: 8px; +} + +.add-product-form label { + font-weight: 600; + color: #444; +} + +.toggle-button { + padding: 10px 16px; + background-color: #17a2b8; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; + margin-bottom: 16px; +} + +.toggle-button:hover { + background-color: #117a8b; +} + +.add-product-panel.collapsed { + display: none; +} + .product-name-input, .product-description-textarea, .product-category-select,