From 353a0f1f3b4db29fad3e4831fe48b85afd0aac80 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 15 Feb 2026 15:19:05 +0000 Subject: [PATCH] employee detail page --- api/get_labour_stats.php | 26 +++ api/search.php | 8 +- employee_detail.php | 239 +++++++++++++++++++----- employees.php | 9 +- expense_files.php | 26 ++- expenses.php | 2 +- files.php | 26 ++- labour.php | 385 +++++++++++++++++++++++++++++++++++---- labour_files.php | 26 ++- project_detail.php | 187 +++++++++++++++++++ projects.php | 57 +++++- 11 files changed, 893 insertions(+), 98 deletions(-) create mode 100644 api/get_labour_stats.php create mode 100644 project_detail.php diff --git a/api/get_labour_stats.php b/api/get_labour_stats.php new file mode 100644 index 0000000..a90a72c --- /dev/null +++ b/api/get_labour_stats.php @@ -0,0 +1,26 @@ +prepare(" + SELECT entry_date, SUM(hours) as total_hours + FROM labour_entries + WHERE employee_id = ? AND entry_date BETWEEN ? AND ? + GROUP BY entry_date + "); + $stmt->execute([$employee_id, $start_date, $end_date]); + echo json_encode($stmt->fetchAll()); +} catch (Exception $e) { + echo json_encode(['error' => $e->getMessage()]); +} diff --git a/api/search.php b/api/search.php index c966953..b47ee0f 100644 --- a/api/search.php +++ b/api/search.php @@ -15,13 +15,17 @@ try { $db = db(); // Search Projects - $stmt = $db->prepare("SELECT id, name, code FROM projects WHERE name LIKE ? OR code LIKE ? LIMIT 5"); + $stmt = $db->prepare("SELECT id, name, code, is_archived FROM projects WHERE name LIKE ? OR code LIKE ? LIMIT 5"); $stmt->execute(['%' . $q . '%', '%' . $q . '%']); foreach ($stmt->fetchAll() as $row) { + $label = $row['name'] . ' (' . $row['code'] . ')'; + if ($row['is_archived']) { + $label .= ' [ARCHIVED]'; + } $results[] = [ 'type' => 'Project', 'id' => $row['id'], - 'label' => $row['name'] . ' (' . $row['code'] . ')', + 'label' => $label, 'url' => 'project_detail.php?id=' . $row['id'] ]; } diff --git a/employee_detail.php b/employee_detail.php index c4fa2a1..1d2401a 100644 --- a/employee_detail.php +++ b/employee_detail.php @@ -27,15 +27,61 @@ $stmt = $db->prepare(" JOIN labour_types lt ON l.labour_type_id = lt.id WHERE l.employee_id = ? ORDER BY l.entry_date DESC - LIMIT 20 + LIMIT 10 "); $stmt->execute([$id]); -$entries = $stmt->fetchAll(); +$labourEntries = $stmt->fetchAll(); // Fetch summary stats -$stats = $db->prepare("SELECT SUM(hours) as total_hours, COUNT(*) as entry_count FROM labour_entries WHERE employee_id = ?"); -$stats->execute([$id]); +$stats = $db->prepare(" + SELECT + (SELECT SUM(hours) FROM labour_entries WHERE employee_id = ?) as total_hours, + (SELECT COUNT(DISTINCT project_id) FROM labour_entries WHERE employee_id = ?) as project_count, + (SELECT COUNT(*) FROM attachments a JOIN labour_entries le ON a.entity_id = le.id WHERE a.entity_type = 'labour_entry' AND le.employee_id = ?) as file_count +"); +$stats->execute([$id, $id, $id]); $stats = $stats->fetch(); + +// Fetch recent expenses (linked via attachments uploaded by this employee name) +$expenseStmt = $db->prepare(" + SELECT ex.*, et.name as expense_type, s.name as supplier_name, p.name as project_name + FROM expenses ex + JOIN expense_types et ON ex.expense_type_id = et.id + LEFT JOIN suppliers s ON ex.supplier_id = s.id + JOIN projects p ON ex.project_id = p.id + JOIN attachments a ON a.entity_id = ex.id AND a.entity_type = 'expense' + WHERE a.uploaded_by = ? + ORDER BY ex.entry_date DESC + LIMIT 10 +"); +$expenseStmt->execute([$employee['name']]); +$expenseEntries = $expenseStmt->fetchAll(); + +// Fetch recent files (uploaded by this employee or linked to their labour) +$fileStmt = $db->prepare(" + SELECT a.*, + COALESCE(le.entry_date, ex.entry_date) as entry_date, + COALESCE(p1.name, p2.name) as project_name + FROM attachments a + LEFT JOIN labour_entries le ON a.entity_id = le.id AND a.entity_type = 'labour_entry' + LEFT JOIN projects p1 ON le.project_id = p1.id + LEFT JOIN expenses ex ON a.entity_id = ex.id AND a.entity_type = 'expense' + LEFT JOIN projects p2 ON ex.project_id = p2.id + WHERE a.uploaded_by = ? OR (a.entity_type = 'labour_entry' AND le.employee_id = ?) + ORDER BY a.created_at DESC + LIMIT 10 +"); +$fileStmt->execute([$employee['name'], $id]); +$recentFiles = $fileStmt->fetchAll(); + +function formatBytes($bytes, $precision = 2) { + $units = ['B', 'KB', 'MB', 'GB', 'TB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + $bytes /= pow(1024, $pow); + return round($bytes, $precision) . ' ' . $units[$pow]; +} ?>
@@ -43,69 +89,178 @@ $stats = $stats->fetch();

-

+

• Joined

+ Add Labour +
+
+ + +
+
+
+
+
Total Hours
+

+ Across all projects +
+
+
+
+
+
+
Projects
+

+ Involved in +
+
+
+
+
+
+
Files Uploaded
+

+ Labour & Expenses +
+
+
+
+
+
+
Email
+

+ Contact Info +
+
-
-
-
Information
-
-
- - -
-
- - -
-
- - + +
+
+
+
Recent Labour Entries
+ View All +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
DateProjectTypeHours
No entries found.
-
-
-
- Recent Labour Entries - View All + + +
+
+
+
Recent Expenses Captured
+ View All
- - - - +
Date
+ + + - - + - - - - + + - + - - - - - + + + + + + + + +
Date Project TypeHoursNotesAmount
No entries found for this employee.
No expenses captured by this employee.
50 ? '...' : '' ?>$
+
+
+
+
+ + +
+
+
+
Recent Files & Attachments
+ View All Files +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/employees.php b/employees.php index 28bc60b..ad21778 100644 --- a/employees.php +++ b/employees.php @@ -103,7 +103,11 @@ include __DIR__ . '/includes/header.php'; - + diff --git a/expense_files.php b/expense_files.php index 1b37a60..f5da647 100644 --- a/expense_files.php +++ b/expense_files.php @@ -4,19 +4,29 @@ require_once __DIR__ . '/db/config.php'; $tenant_id = 1; -// Get Projects for filter -$projects_stmt = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name ASC"); -$projects_stmt->execute([$tenant_id]); -$all_projects = $projects_stmt->fetchAll(); - // Filters $project_filter = $_GET['project_id'] ?? ''; $start_date = $_GET['start_date'] ?? ''; $end_date = $_GET['end_date'] ?? ''; +$include_archived = isset($_GET['include_archived']) && $_GET['include_archived'] === '1'; + +// Get Projects for filter +$projects_sql = "SELECT id, name FROM projects WHERE tenant_id = ?"; +if (!$include_archived) { + $projects_sql .= " AND is_archived = 0"; +} +$projects_sql .= " ORDER BY name ASC"; +$projects_stmt = db()->prepare($projects_sql); +$projects_stmt->execute([$tenant_id]); +$all_projects = $projects_stmt->fetchAll(); $where_clauses = ["a.tenant_id = ?", "a.entity_type = 'expense'"]; $params = [$tenant_id]; +if (!$include_archived) { + $where_clauses[] = "p.is_archived = 0"; +} + if ($project_filter) { $where_clauses[] = "ex.project_id = ?"; $params[] = $project_filter; @@ -84,6 +94,12 @@ include __DIR__ . '/includes/header.php'; +
+
+ onchange="this.form.submit()"> + +
+
diff --git a/expenses.php b/expenses.php index 5558ce2..6afb8a0 100644 --- a/expenses.php +++ b/expenses.php @@ -60,7 +60,7 @@ $expenseEntries = db()->prepare(" $expenseEntries->execute([$tenant_id]); $expenseList = $expenseEntries->fetchAll(); -$projects = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name"); +$projects = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? AND is_archived = 0 ORDER BY name"); $projects->execute([$tenant_id]); $projectList = $projects->fetchAll(); diff --git a/files.php b/files.php index 44a7f2c..dd6432c 100644 --- a/files.php +++ b/files.php @@ -4,19 +4,29 @@ require_once __DIR__ . '/db/config.php'; $tenant_id = 1; -// Get Projects for filter -$projects_stmt = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name ASC"); -$projects_stmt->execute([$tenant_id]); -$all_projects = $projects_stmt->fetchAll(); - // Filters $project_filter = $_GET['project_id'] ?? ''; $start_date = $_GET['start_date'] ?? ''; $end_date = $_GET['end_date'] ?? ''; +$include_archived = isset($_GET['include_archived']) && $_GET['include_archived'] === '1'; + +// Get Projects for filter +$projects_sql = "SELECT id, name FROM projects WHERE tenant_id = ?"; +if (!$include_archived) { + $projects_sql .= " AND is_archived = 0"; +} +$projects_sql .= " ORDER BY name ASC"; +$projects_stmt = db()->prepare($projects_sql); +$projects_stmt->execute([$tenant_id]); +$all_projects = $projects_stmt->fetchAll(); $where_clauses = ["a.tenant_id = ?"]; $params = [$tenant_id]; +if (!$include_archived) { + $where_clauses[] = "(lp.is_archived = 0 OR ep.is_archived = 0 OR (a.entity_type NOT IN ('labour_entry', 'expense')))"; +} + if ($project_filter) { $where_clauses[] = "(le.project_id = ? OR ex.project_id = ?)"; $params[] = $project_filter; @@ -92,6 +102,12 @@ include __DIR__ . '/includes/header.php';
+
+
+ onchange="this.form.submit()"> + +
+
diff --git a/labour.php b/labour.php index 2414f8b..fa6eca4 100644 --- a/labour.php +++ b/labour.php @@ -4,43 +4,77 @@ require_once __DIR__ . '/db/config.php'; $tenant_id = 1; -// Handle Add Labour +// Handle Bulk Labour +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bulk_labour'])) { + $project_id = (int)($_POST['bulk_project_id'] ?? 0); + $employee_id = (int)($_POST['bulk_employee_id'] ?? 0); + $labour_type_id = (int)($_POST['bulk_labour_type_id'] ?? 0); + $evidence_type_id = (int)($_POST['bulk_evidence_type_id'] ?? 0); + $notes = $_POST['bulk_notes'] ?? ''; + + $days = $_POST['bulk_days'] ?? []; // Array of date => hours + + if ($project_id && $employee_id && !empty($days)) { + $db = db(); + foreach ($days as $date => $hours) { + $hours = (float)$hours; + if ($hours <= 0) continue; + + $stmt = $db->prepare("INSERT INTO labour_entries (tenant_id, project_id, employee_id, entry_date, hours, labour_type_id, evidence_type_id, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([$tenant_id, $project_id, $employee_id, $date, $hours, $labour_type_id, $evidence_type_id, $notes]); + } + + $stmt = $db->prepare("INSERT INTO activity_log (tenant_id, action, details) VALUES (?, ?, ?)"); + $stmt->execute([$tenant_id, 'Bulk Labour Added', "Logged hours for employee ID $employee_id via bulk entry"]); + + header("Location: labour.php?success=1"); + exit; + } +} if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_labour'])) { $project_id = (int)($_POST['project_id'] ?? 0); - $employee_id = (int)($_POST['employee_id'] ?? 0); + $employee_ids = isset($_POST['employee_ids']) ? array_map('intval', $_POST['employee_ids']) : []; + if (empty($employee_ids) && isset($_POST['employee_id'])) { + $employee_ids = [(int)$_POST['employee_id']]; + } + $entry_date = $_POST['entry_date'] ?? date('Y-m-d'); $hours = (float)($_POST['hours'] ?? 0); $labour_type_id = (int)($_POST['labour_type_id'] ?? 0); $evidence_type_id = (int)($_POST['evidence_type_id'] ?? 0); $notes = $_POST['notes'] ?? ''; - if ($project_id && $employee_id && $hours > 0) { - $stmt = db()->prepare("INSERT INTO labour_entries (tenant_id, project_id, employee_id, entry_date, hours, labour_type_id, evidence_type_id, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); - $stmt->execute([$tenant_id, $project_id, $employee_id, $entry_date, $hours, $labour_type_id, $evidence_type_id, $notes]); - $labour_entry_id = (int)db()->lastInsertId(); + if ($project_id && !empty($employee_ids) && $hours > 0) { + $db = db(); + foreach ($employee_ids as $employee_id) { + $stmt = $db->prepare("INSERT INTO labour_entries (tenant_id, project_id, employee_id, entry_date, hours, labour_type_id, evidence_type_id, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([$tenant_id, $project_id, $employee_id, $entry_date, $hours, $labour_type_id, $evidence_type_id, $notes]); + $labour_entry_id = (int)$db->lastInsertId(); - // Handle File Uploads - if (!empty($_FILES['attachments']['name'][0])) { - foreach ($_FILES['attachments']['tmp_name'] as $key => $tmp_name) { - if ($_FILES['attachments']['error'][$key] === UPLOAD_ERR_OK) { - $file_name = $_FILES['attachments']['name'][$key]; - $file_size = $_FILES['attachments']['size'][$key]; - $mime_type = $_FILES['attachments']['type'][$key]; - $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); - $new_file_name = uniqid() . '.' . $file_ext; - $file_path = 'uploads/' . $new_file_name; + // Handle File Uploads (only for the first one or all? Usually all if it's a team entry) + if (!empty($_FILES['attachments']['name'][0])) { + foreach ($_FILES['attachments']['tmp_name'] as $key => $tmp_name) { + if ($_FILES['attachments']['error'][$key] === UPLOAD_ERR_OK) { + $file_name = $_FILES['attachments']['name'][$key]; + $file_size = $_FILES['attachments']['size'][$key]; + $mime_type = $_FILES['attachments']['type'][$key]; + $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); + $new_file_name = uniqid() . '.' . $file_ext; + $file_path = 'uploads/' . $new_file_name; + + if (!is_dir('uploads')) mkdir('uploads', 0775, true); + if (move_uploaded_file($tmp_name, $file_path)) { + $stmt = $db->prepare("INSERT INTO attachments (tenant_id, entity_type, entity_id, file_name, file_path, file_size, mime_type, uploaded_by) VALUES (?, 'labour_entry', ?, ?, ?, ?, ?, ?)"); + $stmt->execute([$tenant_id, $labour_entry_id, $file_name, $file_path, $file_size, $mime_type, $currentUserName]); + } - if (!is_dir('uploads')) mkdir('uploads', 0775, true); - if (move_uploaded_file($tmp_name, $file_path)) { - $stmt = db()->prepare("INSERT INTO attachments (tenant_id, entity_type, entity_id, file_name, file_path, file_size, mime_type, uploaded_by) VALUES (?, 'labour_entry', ?, ?, ?, ?, ?, 'John Manager')"); - $stmt->execute([$tenant_id, $labour_entry_id, $file_name, $file_path, $file_size, $mime_type]); } } } } - $stmt = db()->prepare("INSERT INTO activity_log (tenant_id, action, details) VALUES (?, ?, ?)"); - $stmt->execute([$tenant_id, 'Labour Added', "Logged $hours hours for employee ID $employee_id"]); + $stmt = $db->prepare("INSERT INTO activity_log (tenant_id, action, details) VALUES (?, ?, ?)"); + $stmt->execute([$tenant_id, 'Labour Added', "Logged $hours hours for " . count($employee_ids) . " employee(s)"]); header("Location: labour.php?success=1"); exit; @@ -61,7 +95,7 @@ $labourEntries = db()->prepare(" $labourEntries->execute([$tenant_id]); $labourList = $labourEntries->fetchAll(); -$projects = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name"); +$projects = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? AND is_archived = 0 ORDER BY name"); $projects->execute([$tenant_id]); $projectList = $projects->fetchAll(); @@ -77,6 +111,28 @@ $evidenceTypes = db()->prepare("SELECT * FROM evidence_types WHERE tenant_id = ? $evidenceTypes->execute([$tenant_id]); $evidenceTypeList = $evidenceTypes->fetchAll(); +// Find current employee (mocked as user_id 1) +$currentUser = db()->prepare("SELECT name FROM users WHERE id = 1"); +$currentUser->execute(); +$currentUserName = $currentUser->fetchColumn() ?: 'System'; + +$currentEmployeeStmt = db()->prepare("SELECT id FROM employees WHERE user_id = 1 AND tenant_id = ?"); +$currentEmployeeStmt->execute([$tenant_id]); +$currentEmployeeId = $currentEmployeeStmt->fetchColumn() ?: null; + +$teams = db()->prepare("SELECT * FROM teams WHERE tenant_id = ? ORDER BY name"); +$teams->execute([$tenant_id]); +$teamList = $teams->fetchAll(); + +$teamMembers = db()->prepare("SELECT * FROM employee_teams WHERE tenant_id = ?"); +$teamMembers->execute([$tenant_id]); +$teamMemberList = $teamMembers->fetchAll(); +// Group by team +$teamMembersGrouped = []; +foreach ($teamMemberList as $tm) { + $teamMembersGrouped[$tm['team_id']][] = $tm['employee_id']; +} + $pageTitle = "SR&ED Manager - Labour Tracking"; include __DIR__ . '/includes/header.php'; ?> @@ -84,7 +140,10 @@ include __DIR__ . '/includes/header.php';

Labour Tracking

- +
+ + +
@@ -145,7 +204,48 @@ include __DIR__ . '/includes/header.php';
FilenameLinked ToProjectSizeDateAction
No files found.
+
+ + +
+
+ + + + View +
+ + + + $/h - + View +
+ + + + + + + + +
+
+
+
+
+
+
+
Labour Details
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + + + diff --git a/labour_files.php b/labour_files.php index 8a392b8..3194de3 100644 --- a/labour_files.php +++ b/labour_files.php @@ -4,19 +4,29 @@ require_once __DIR__ . '/db/config.php'; $tenant_id = 1; -// Get Projects for filter -$projects_stmt = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name ASC"); -$projects_stmt->execute([$tenant_id]); -$all_projects = $projects_stmt->fetchAll(); - // Filters $project_filter = $_GET['project_id'] ?? ''; $start_date = $_GET['start_date'] ?? ''; $end_date = $_GET['end_date'] ?? ''; +$include_archived = isset($_GET['include_archived']) && $_GET['include_archived'] === '1'; + +// Get Projects for filter +$projects_sql = "SELECT id, name FROM projects WHERE tenant_id = ?"; +if (!$include_archived) { + $projects_sql .= " AND is_archived = 0"; +} +$projects_sql .= " ORDER BY name ASC"; +$projects_stmt = db()->prepare($projects_sql); +$projects_stmt->execute([$tenant_id]); +$all_projects = $projects_stmt->fetchAll(); $where_clauses = ["a.tenant_id = ?", "a.entity_type = 'labour_entry'"]; $params = [$tenant_id]; +if (!$include_archived) { + $where_clauses[] = "p.is_archived = 0"; +} + if ($project_filter) { $where_clauses[] = "le.project_id = ?"; $params[] = $project_filter; @@ -84,6 +94,12 @@ include __DIR__ . '/includes/header.php';
+
+
+ onchange="this.form.submit()"> + +
+
diff --git a/project_detail.php b/project_detail.php new file mode 100644 index 0000000..b30bd84 --- /dev/null +++ b/project_detail.php @@ -0,0 +1,187 @@ +prepare("SELECT * FROM projects WHERE id = ?"); +$project->execute([$id]); +$project = $project->fetch(); + +if (!$project) { + die("Project not found."); +} + +$pageTitle = "Project Detail: " . htmlspecialchars($project['name']); +include __DIR__ . '/includes/header.php'; + +// Fetch recent labour +$labourStmt = $db->prepare(" + SELECT l.*, e.name as employee_name, lt.name as labour_type + FROM labour_entries l + JOIN employees e ON l.employee_id = e.id + JOIN labour_types lt ON l.labour_type_id = lt.id + WHERE l.project_id = ? + ORDER BY l.entry_date DESC + LIMIT 10 +"); +$labourStmt->execute([$id]); +$labourEntries = $labourStmt->fetchAll(); + +// Fetch recent expenses +$expenseStmt = $db->prepare(" + SELECT ex.*, et.name as expense_type, s.name as supplier_name + FROM expenses ex + JOIN expense_types et ON ex.expense_type_id = et.id + LEFT JOIN suppliers s ON ex.supplier_id = s.id + WHERE ex.project_id = ? + ORDER BY ex.entry_date DESC + LIMIT 10 +"); +$expenseStmt->execute([$id]); +$expenseEntries = $expenseStmt->fetchAll(); + +// Stats +$statsStmt = $db->prepare(" + SELECT + (SELECT SUM(hours) FROM labour_entries WHERE project_id = ?) as total_hours, + (SELECT SUM(amount) FROM expenses WHERE project_id = ?) as total_expenses +"); +$statsStmt->execute([$id, $id]); +$stats = $statsStmt->fetch(); + +?> + +
+
+
+ +

()

+ + + Archived + +
+
+ + Unarchive + + Archive Project + + + + Add Labour + +
+
+ +
+
+
+
+
Total Hours
+

+ Budget: +
+
+
+
+
+
+
Total Expenses
+

$

+
+
+
+
+
+
+
Type
+

+
+
+
+
+
+
+
Start Date
+

+
+
+
+
+ +
+
+
+
+ Recent Labour + View All +
+
+
+ + + + + + + + + + + + + + + + + +
DateEmployeeHours
+
+
+
+
+
+
+
+ Recent Expenses + View All +
+
+
+ + + + + + + + + + + + + + + + + +
DateTypeAmount
$
+
+
+
+
+
+
+ + diff --git a/projects.php b/projects.php index 224ae49..650fdb9 100644 --- a/projects.php +++ b/projects.php @@ -26,12 +26,29 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_project'])) { } } +// Handle Archive/Unarchive +if (isset($_GET['archive'])) { + $id = (int)$_GET['archive']; + $stmt = db()->prepare("UPDATE projects SET is_archived = 1 WHERE id = ? AND tenant_id = ?"); + $stmt->execute([$id, $tenant_id]); + header("Location: projects.php?archived=1"); + exit; +} +if (isset($_GET['unarchive'])) { + $id = (int)$_GET['unarchive']; + $stmt = db()->prepare("UPDATE projects SET is_archived = 0 WHERE id = ? AND tenant_id = ?"); + $stmt->execute([$id, $tenant_id]); + header("Location: projects.php?unarchived=1"); + exit; +} + // Fetch Data $search = $_GET['search'] ?? ''; $status_filter = $_GET['status'] ?? ''; $date_preset = $_GET['date_preset'] ?? ''; $start_from = $_GET['start_from'] ?? ''; $start_to = $_GET['start_to'] ?? ''; +$include_archived = isset($_GET['include_archived']) && $_GET['include_archived'] === '1'; $query = " SELECT p.*, @@ -42,6 +59,10 @@ $query = " WHERE p.tenant_id = ?"; $params = [$tenant_id]; +if (!$include_archived) { + $query .= " AND p.is_archived = 0"; +} + if ($search) { $query .= " AND (p.name LIKE ? OR p.code LIKE ?)"; $params[] = "%$search%"; @@ -97,6 +118,18 @@ include __DIR__ . '/includes/header.php';
+ + + + + +
@@ -126,7 +159,10 @@ include __DIR__ . '/includes/header.php'; ?> -
+ + + Archived +
@@ -142,7 +178,18 @@ include __DIR__ . '/includes/header.php'; - + @@ -174,6 +221,12 @@ include __DIR__ . '/includes/header.php';
+
+
+ > + +
+