43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
include('include/headscript.php');
|
|
include('include/shop_context.php');
|
|
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
|
|
if (!isset($iduserlogin) || empty($active_shop_id)) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
function setFlash(string $type, string $text): void
|
|
{
|
|
$_SESSION['flash'] = ['type' => $type, 'text' => $text];
|
|
}
|
|
|
|
$id = (int)($_POST['customer_id'] ?? 0);
|
|
|
|
if ($id <= 0) {
|
|
setFlash('danger', 'Cliente non valido.');
|
|
header("Location: customers.php");
|
|
exit;
|
|
}
|
|
|
|
// Verifica appartenenza al salone attivo (sicurezza)
|
|
$chk = $pdo->prepare("SELECT id FROM customers WHERE id = ? AND shop_id = ? LIMIT 1");
|
|
$chk->execute([$id, $active_shop_id]);
|
|
if (!$chk->fetch()) {
|
|
setFlash('danger', 'Cliente non trovato in questo salone.');
|
|
header("Location: customers.php");
|
|
exit;
|
|
}
|
|
|
|
$del = $pdo->prepare("DELETE FROM customers WHERE id = ? AND shop_id = ?");
|
|
$del->execute([$id, $active_shop_id]);
|
|
|
|
setFlash('success', 'Cliente eliminato.');
|
|
header("Location: customers.php");
|
|
exit;
|