diff --git a/index.php b/index.php index b15ee60..3f88b32 100644 --- a/index.php +++ b/index.php @@ -35,6 +35,15 @@ if ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER[ } session_start(); +if (isset($_GET['action']) && $_GET['action'] === 'switch_outlet') { + $target = (int)$_GET['id']; + if (($_SESSION['user_role_name'] ?? '') === 'Administrator') { + $_SESSION['outlet_id'] = $target === 0 ? null : $target; + } + header("Location: " . ($_SERVER['HTTP_REFERER'] ?? 'index.php')); + exit; +} + if (isset($_GET['action']) && $_GET['action'] === 'download_items_template') { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=items_import_template.csv'); @@ -3014,6 +3023,11 @@ $page_num = isset($_GET["p"]) ? (int)$_GET["p"] : 1; if ($page_num < 1) $page_num = 1; $offset = ($page_num - 1) * $limit; switch ($page) { + case 'outlets': + $stmt = db()->prepare("SELECT * FROM outlets ORDER BY id DESC"); + $stmt->execute(); + $data['outlets'] = $stmt->fetchAll(); + break; case 'suppliers': $where = ["1=1"]; $params = []; @@ -4184,6 +4198,26 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; + query("SELECT * FROM outlets WHERE status = 'active'")->fetchAll(PDO::FETCH_ASSOC); + $cur_out = $_SESSION['outlet_id'] ?? 0; + $cur_name = 'All Outlets'; + foreach ($outlets as $o) { if ($o['id'] == $cur_out) $cur_name = $o['name']; } + ?> +
| ID | +Name | +Address | +Phone | +Status | +Created At | +Actions | +
|---|---|---|---|---|---|---|
| #= $o['id'] ?> | += htmlspecialchars($o['name']) ?> | += htmlspecialchars($o['address'] ?: '-') ?> | += htmlspecialchars($o['phone'] ?: '-') ?> | += ucfirst($o['status']) ?> | += htmlspecialchars($o['created_at']) ?> | ++ + + + + | +