adding drugs
This commit is contained in:
parent
c3784f3565
commit
defcfeb7da
@ -1,18 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'db/config.php';
|
require 'db/config.php';
|
||||||
$db = db();
|
$db = db();
|
||||||
|
// Ensure buffered query is on if possible (though config might override)
|
||||||
|
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
|
||||||
|
|
||||||
$files = glob('db/migrations/*.sql');
|
$files = glob('db/migrations/*.sql');
|
||||||
sort($files);
|
sort($files);
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
echo "Processing $file...\n";
|
echo "Processing $file...\n";
|
||||||
$sql = file_get_contents($file);
|
$sql_content = file_get_contents($file);
|
||||||
try {
|
$sql_content = preg_replace('/--.*$/m', '', $sql_content);
|
||||||
$db->exec($sql);
|
$statements = explode(';', $sql_content);
|
||||||
echo "Done.\n";
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo "Error: " . $e->getMessage() . "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ($statements as $sql) {
|
||||||
|
$sql = trim($sql);
|
||||||
|
if (empty($sql)) continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Use query() instead of exec() to handle potential result sets (like SELECT 1)
|
||||||
|
// and close the cursor explicitly.
|
||||||
|
$stmt = $db->query($sql);
|
||||||
|
if ($stmt) {
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
echo "Executed: " . substr(str_replace("\n", " ", $sql), 0, 60) . "...\n";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$msg = $e->getMessage();
|
||||||
|
if (strpos($msg, "Duplicate column") !== false ||
|
||||||
|
strpos($msg, "already exists") !== false ||
|
||||||
|
strpos($msg, "Duplicate key") !== false) {
|
||||||
|
echo "Skipped (Exists): " . substr(str_replace("\n", " ", $sql), 0, 60) . "...\n";
|
||||||
|
} else {
|
||||||
|
echo "Error: " . $msg . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "All migrations applied.\n";
|
||||||
|
|||||||
14
db/migrations/20260305_create_suppliers_module.sql
Normal file
14
db/migrations/20260305_create_suppliers_module.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS suppliers (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name_en VARCHAR(255) NOT NULL,
|
||||||
|
name_ar VARCHAR(255) NOT NULL,
|
||||||
|
contact_person VARCHAR(255),
|
||||||
|
phone VARCHAR(50),
|
||||||
|
email VARCHAR(100),
|
||||||
|
address TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE drugs ADD COLUMN expiry_date DATE DEFAULT NULL;
|
||||||
|
ALTER TABLE drugs ADD COLUMN supplier_id INT DEFAULT NULL;
|
||||||
|
ALTER TABLE drugs ADD CONSTRAINT fk_drugs_supplier FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL;
|
||||||
12
drugs.php
Normal file
12
drugs.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
$section = 'drugs';
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
require_once __DIR__ . '/helpers.php';
|
||||||
|
$db = db();
|
||||||
|
$lang = $_SESSION['lang'] ?? 'en';
|
||||||
|
|
||||||
|
require_once __DIR__ . '/includes/actions.php';
|
||||||
|
require_once __DIR__ . '/includes/common_data.php';
|
||||||
|
require_once __DIR__ . '/includes/layout/header.php';
|
||||||
|
require_once __DIR__ . '/includes/pages/drugs.php';
|
||||||
|
require_once __DIR__ . '/includes/layout/footer.php';
|
||||||
12
drugs_groups.php
Normal file
12
drugs_groups.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
$section = 'drugs_groups';
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
require_once __DIR__ . '/helpers.php';
|
||||||
|
$db = db();
|
||||||
|
$lang = $_SESSION['lang'] ?? 'en';
|
||||||
|
|
||||||
|
require_once __DIR__ . '/includes/actions.php';
|
||||||
|
require_once __DIR__ . '/includes/common_data.php';
|
||||||
|
require_once __DIR__ . '/includes/layout/header.php';
|
||||||
|
require_once __DIR__ . '/includes/pages/drugs_groups.php';
|
||||||
|
require_once __DIR__ . '/includes/layout/footer.php';
|
||||||
@ -626,7 +626,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} elseif ($_POST['action'] === 'add_drug_group') {
|
} elseif ($_POST['action'] === 'add_drug_group') {
|
||||||
$name_en = $_POST['name_en'] ?? '';
|
$name_en = $_POST['name_en'] ?? '';
|
||||||
$name_ar = $_POST['name_ar'] ?? '';
|
$name_ar = $_POST['name_ar'] ?? '';
|
||||||
@ -663,10 +662,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$dosage = $_POST['default_dosage'] ?? '';
|
$dosage = $_POST['default_dosage'] ?? '';
|
||||||
$instructions = $_POST['default_instructions'] ?? '';
|
$instructions = $_POST['default_instructions'] ?? '';
|
||||||
$price = $_POST['price'] ?? 0;
|
$price = $_POST['price'] ?? 0;
|
||||||
|
$expiry_date = $_POST['expiry_date'] ?: null;
|
||||||
|
$supplier_id = $_POST['supplier_id'] ?: null;
|
||||||
|
|
||||||
if ($name_en && $name_ar) {
|
if ($name_en && $name_ar) {
|
||||||
$stmt = $db->prepare("INSERT INTO drugs (name_en, name_ar, group_id, description_en, description_ar, default_dosage, default_instructions, price) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
$stmt = $db->prepare("INSERT INTO drugs (name_en, name_ar, group_id, description_en, description_ar, default_dosage, default_instructions, price, expiry_date, supplier_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$stmt->execute([$name_en, $name_ar, $group_id, $desc_en, $desc_ar, $dosage, $instructions, $price]);
|
$stmt->execute([$name_en, $name_ar, $group_id, $desc_en, $desc_ar, $dosage, $instructions, $price, $expiry_date, $supplier_id]);
|
||||||
$_SESSION['flash_message'] = __('add_drug') . ' ' . __('successfully');
|
$_SESSION['flash_message'] = __('add_drug') . ' ' . __('successfully');
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
}
|
}
|
||||||
@ -680,10 +681,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$dosage = $_POST['default_dosage'] ?? '';
|
$dosage = $_POST['default_dosage'] ?? '';
|
||||||
$instructions = $_POST['default_instructions'] ?? '';
|
$instructions = $_POST['default_instructions'] ?? '';
|
||||||
$price = $_POST['price'] ?? 0;
|
$price = $_POST['price'] ?? 0;
|
||||||
|
$expiry_date = $_POST['expiry_date'] ?: null;
|
||||||
|
$supplier_id = $_POST['supplier_id'] ?: null;
|
||||||
|
|
||||||
if ($id && $name_en && $name_ar) {
|
if ($id && $name_en && $name_ar) {
|
||||||
$stmt = $db->prepare("UPDATE drugs SET name_en = ?, name_ar = ?, group_id = ?, description_en = ?, description_ar = ?, default_dosage = ?, default_instructions = ?, price = ? WHERE id = ?");
|
$stmt = $db->prepare("UPDATE drugs SET name_en = ?, name_ar = ?, group_id = ?, description_en = ?, description_ar = ?, default_dosage = ?, default_instructions = ?, price = ?, expiry_date = ?, supplier_id = ? WHERE id = ?");
|
||||||
$stmt->execute([$name_en, $name_ar, $group_id, $desc_en, $desc_ar, $dosage, $instructions, $price, $id]);
|
$stmt->execute([$name_en, $name_ar, $group_id, $desc_en, $desc_ar, $dosage, $instructions, $price, $expiry_date, $supplier_id, $id]);
|
||||||
$_SESSION['flash_message'] = __('edit_drug') . ' ' . __('successfully');
|
$_SESSION['flash_message'] = __('edit_drug') . ' ' . __('successfully');
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
}
|
}
|
||||||
@ -695,7 +698,139 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
}
|
}
|
||||||
|
} elseif ($_POST['action'] === 'add_supplier') {
|
||||||
|
$name_en = $_POST['name_en'] ?? '';
|
||||||
|
$name_ar = $_POST['name_ar'] ?? '';
|
||||||
|
$contact = $_POST['contact_person'] ?? '';
|
||||||
|
$phone = $_POST['phone'] ?? '';
|
||||||
|
$email = $_POST['email'] ?? '';
|
||||||
|
$address = $_POST['address'] ?? '';
|
||||||
|
|
||||||
|
if ($name_en && $name_ar) {
|
||||||
|
$stmt = $db->prepare("INSERT INTO suppliers (name_en, name_ar, contact_person, phone, email, address) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
|
$stmt->execute([$name_en, $name_ar, $contact, $phone, $email, $address]);
|
||||||
|
$_SESSION['flash_message'] = __('add_supplier') . ' ' . __('successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
} elseif ($_POST['action'] === 'edit_supplier') {
|
||||||
|
$id = $_POST['id'] ?? '';
|
||||||
|
$name_en = $_POST['name_en'] ?? '';
|
||||||
|
$name_ar = $_POST['name_ar'] ?? '';
|
||||||
|
$contact = $_POST['contact_person'] ?? '';
|
||||||
|
$phone = $_POST['phone'] ?? '';
|
||||||
|
$email = $_POST['email'] ?? '';
|
||||||
|
$address = $_POST['address'] ?? '';
|
||||||
|
|
||||||
|
if ($id && $name_en && $name_ar) {
|
||||||
|
$stmt = $db->prepare("UPDATE suppliers SET name_en = ?, name_ar = ?, contact_person = ?, phone = ?, email = ?, address = ? WHERE id = ?");
|
||||||
|
$stmt->execute([$name_en, $name_ar, $contact, $phone, $email, $address, $id]);
|
||||||
|
$_SESSION['flash_message'] = __('edit_supplier') . ' ' . __('successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
} elseif ($_POST['action'] === 'delete_supplier') {
|
||||||
|
$id = $_POST['id'] ?? '';
|
||||||
|
if ($id) {
|
||||||
|
$stmt = $db->prepare("DELETE FROM suppliers WHERE id = ?");
|
||||||
|
$stmt->execute([$id]);
|
||||||
|
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
} elseif ($_POST['action'] === 'import_drugs_groups') {
|
||||||
|
if (isset($_FILES['csv_file']) && $_FILES['csv_file']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = fopen($_FILES['csv_file']['tmp_name'], 'r');
|
||||||
|
// Skip header
|
||||||
|
fgetcsv($file);
|
||||||
|
|
||||||
|
$stmt = $db->prepare("INSERT INTO drugs_groups (name_en, name_ar) VALUES (?, ?)");
|
||||||
|
$checkStmt = $db->prepare("SELECT id FROM drugs_groups WHERE name_en = ?");
|
||||||
|
|
||||||
|
while (($row = fgetcsv($file)) !== false) {
|
||||||
|
$name_en = $row[0] ?? '';
|
||||||
|
$name_ar = $row[1] ?? '';
|
||||||
|
|
||||||
|
if ($name_en) {
|
||||||
|
// Check duplicate
|
||||||
|
$checkStmt->execute([$name_en]);
|
||||||
|
if (!$checkStmt->fetch()) {
|
||||||
|
$stmt->execute([$name_en, $name_ar]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
$_SESSION['flash_message'] = __('import_successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
} elseif ($_POST['action'] === 'import_drugs') {
|
||||||
|
if (isset($_FILES['csv_file']) && $_FILES['csv_file']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = fopen($_FILES['csv_file']['tmp_name'], 'r');
|
||||||
|
// Skip header
|
||||||
|
fgetcsv($file);
|
||||||
|
|
||||||
|
$stmt = $db->prepare("INSERT INTO drugs (name_en, name_ar, group_id, price, expiry_date, supplier_id) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
$groupMap = [];
|
||||||
|
$supplierMap = [];
|
||||||
|
|
||||||
|
while (($row = fgetcsv($file)) !== false) {
|
||||||
|
$name_en = $row[0] ?? '';
|
||||||
|
$name_ar = $row[1] ?? '';
|
||||||
|
$group_name = $row[2] ?? '';
|
||||||
|
$price = $row[3] ?? 0;
|
||||||
|
$expiry = $row[4] ?? null; // YYYY-MM-DD
|
||||||
|
$supplier_name = $row[5] ?? '';
|
||||||
|
|
||||||
|
if ($name_en) {
|
||||||
|
$group_id = null;
|
||||||
|
if ($group_name) {
|
||||||
|
if (isset($groupMap[$group_name])) {
|
||||||
|
$group_id = $groupMap[$group_name];
|
||||||
|
} else {
|
||||||
|
$gStmt = $db->prepare("SELECT id FROM drugs_groups WHERE name_en = ? OR name_ar = ?");
|
||||||
|
$gStmt->execute([$group_name, $group_name]);
|
||||||
|
$gRes = $gStmt->fetch();
|
||||||
|
if ($gRes) {
|
||||||
|
$group_id = $gRes['id'];
|
||||||
|
} else {
|
||||||
|
// Create group
|
||||||
|
$cgStmt = $db->prepare("INSERT INTO drugs_groups (name_en, name_ar) VALUES (?, ?)");
|
||||||
|
$cgStmt->execute([$group_name, $group_name]);
|
||||||
|
$group_id = $db->lastInsertId();
|
||||||
|
}
|
||||||
|
$groupMap[$group_name] = $group_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$supplier_id = null;
|
||||||
|
if ($supplier_name) {
|
||||||
|
if (isset($supplierMap[$supplier_name])) {
|
||||||
|
$supplier_id = $supplierMap[$supplier_name];
|
||||||
|
} else {
|
||||||
|
$sStmt = $db->prepare("SELECT id FROM suppliers WHERE name_en = ? OR name_ar = ?");
|
||||||
|
$sStmt->execute([$supplier_name, $supplier_name]);
|
||||||
|
$sRes = $sStmt->fetch();
|
||||||
|
if ($sRes) {
|
||||||
|
$supplier_id = $sRes['id'];
|
||||||
|
} else {
|
||||||
|
// Create supplier
|
||||||
|
$csStmt = $db->prepare("INSERT INTO suppliers (name_en, name_ar) VALUES (?, ?)");
|
||||||
|
$csStmt->execute([$supplier_name, $supplier_name]);
|
||||||
|
$supplier_id = $db->lastInsertId();
|
||||||
|
}
|
||||||
|
$supplierMap[$supplier_name] = $supplier_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate date
|
||||||
|
if ($expiry && !strtotime($expiry)) $expiry = null;
|
||||||
|
|
||||||
|
$stmt->execute([$name_en, $name_ar, $group_id, $price, $expiry, $supplier_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
$_SESSION['flash_message'] = __('import_successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($redirect) {
|
if ($redirect) {
|
||||||
|
|||||||
@ -120,14 +120,15 @@ $site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['comp
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Drugs Module -->
|
<!-- Drugs Module -->
|
||||||
<a href="#drugsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['drugs', 'drugs_groups']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
|
<a href="#drugsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['drugs', 'drugs_groups', 'suppliers']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
|
||||||
<span><i class="bi bi-capsule me-2"></i> <?php echo __('drugs'); ?></span>
|
<span><i class="bi bi-capsule me-2"></i> <?php echo __('drugs'); ?></span>
|
||||||
<i class="bi bi-chevron-down small"></i>
|
<i class="bi bi-chevron-down small"></i>
|
||||||
</a>
|
</a>
|
||||||
<div class="collapse <?php echo in_array($section, ['drugs', 'drugs_groups']) ? 'show' : ''; ?>" id="drugsSubmenu">
|
<div class="collapse <?php echo in_array($section, ['drugs', 'drugs_groups', 'suppliers']) ? 'show' : ''; ?>" id="drugsSubmenu">
|
||||||
<div class="sidebar-submenu">
|
<div class="sidebar-submenu">
|
||||||
<a href="drugs.php" class="sidebar-link py-2 <?php echo $section === 'drugs' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('drugs'); ?></a>
|
<a href="drugs.php" class="sidebar-link py-2 <?php echo $section === 'drugs' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('drugs'); ?></a>
|
||||||
<a href="drugs_groups.php" class="sidebar-link py-2 <?php echo $section === 'drugs_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('groups'); ?></a>
|
<a href="drugs_groups.php" class="sidebar-link py-2 <?php echo $section === 'drugs_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('groups'); ?></a>
|
||||||
|
<a href="suppliers.php" class="sidebar-link py-2 <?php echo $section === 'suppliers' ? 'active' : ''; ?>"><i class="bi bi-truck me-2"></i> <?php echo __('suppliers'); ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,10 @@ $search_name = $_GET['name'] ?? '';
|
|||||||
$search_group = $_GET['group_id'] ?? '';
|
$search_group = $_GET['group_id'] ?? '';
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT d.*, g.name_$lang as group_name
|
SELECT d.*, g.name_$lang as group_name, s.name_$lang as supplier_name
|
||||||
FROM drugs d
|
FROM drugs d
|
||||||
LEFT JOIN drugs_groups g ON d.group_id = g.id
|
LEFT JOIN drugs_groups g ON d.group_id = g.id
|
||||||
|
LEFT JOIN suppliers s ON d.supplier_id = s.id
|
||||||
WHERE 1=1";
|
WHERE 1=1";
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
@ -27,14 +28,23 @@ $drugs = $stmt->fetchAll();
|
|||||||
// Fetch all groups for filter dropdown
|
// Fetch all groups for filter dropdown
|
||||||
$gStmt = $db->query("SELECT * FROM drugs_groups ORDER BY name_$lang");
|
$gStmt = $db->query("SELECT * FROM drugs_groups ORDER BY name_$lang");
|
||||||
$all_drug_groups = $gStmt->fetchAll();
|
$all_drug_groups = $gStmt->fetchAll();
|
||||||
|
|
||||||
|
// Fetch all suppliers
|
||||||
|
$sStmt = $db->query("SELECT * FROM suppliers ORDER BY name_$lang");
|
||||||
|
$all_suppliers = $sStmt->fetchAll();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<h3 class="fw-bold text-secondary"><?php echo __('drugs'); ?></h3>
|
<h3 class="fw-bold text-secondary"><?php echo __('drugs'); ?></h3>
|
||||||
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addDrugModal">
|
<div>
|
||||||
|
<button class="btn btn-outline-primary shadow-sm me-2" data-bs-toggle="modal" data-bs-target="#importDrugsModal">
|
||||||
|
<i class="bi bi-upload me-1"></i> <?php echo __('import_csv'); ?>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addDrugModal" onclick="resetDrugModal()">
|
||||||
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_drug'); ?>
|
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_drug'); ?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Search Bar -->
|
<!-- Search Bar -->
|
||||||
<div class="card shadow-sm border-0 mb-4">
|
<div class="card shadow-sm border-0 mb-4">
|
||||||
@ -72,7 +82,8 @@ $all_drug_groups = $gStmt->fetchAll();
|
|||||||
<th class="px-4 py-3">#</th>
|
<th class="px-4 py-3">#</th>
|
||||||
<th class="py-3"><?php echo __('drug_name'); ?></th>
|
<th class="py-3"><?php echo __('drug_name'); ?></th>
|
||||||
<th class="py-3"><?php echo __('drug_group'); ?></th>
|
<th class="py-3"><?php echo __('drug_group'); ?></th>
|
||||||
<th class="py-3"><?php echo __('default_dosage'); ?></th>
|
<th class="py-3"><?php echo __('expiry_date'); ?></th>
|
||||||
|
<th class="py-3"><?php echo __('supplier'); ?></th>
|
||||||
<th class="py-3"><?php echo __('price'); ?></th>
|
<th class="py-3"><?php echo __('price'); ?></th>
|
||||||
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -80,7 +91,7 @@ $all_drug_groups = $gStmt->fetchAll();
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php if (empty($drugs)): ?>
|
<?php if (empty($drugs)): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-center py-5 text-muted">
|
<td colspan="7" class="text-center py-5 text-muted">
|
||||||
<i class="bi bi-capsule display-4 d-block mb-3"></i>
|
<i class="bi bi-capsule display-4 d-block mb-3"></i>
|
||||||
<?php echo __('no_drugs_found'); ?>
|
<?php echo __('no_drugs_found'); ?>
|
||||||
</td>
|
</td>
|
||||||
@ -105,11 +116,8 @@ $all_drug_groups = $gStmt->fetchAll();
|
|||||||
<?php echo htmlspecialchars($drug['group_name'] ?? '-'); ?>
|
<?php echo htmlspecialchars($drug['group_name'] ?? '-'); ?>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td><?php echo htmlspecialchars($drug['expiry_date'] ?? '-'); ?></td>
|
||||||
<span class="text-muted small italic">
|
<td><?php echo htmlspecialchars($drug['supplier_name'] ?? '-'); ?></td>
|
||||||
<?php echo htmlspecialchars($drug['default_dosage'] ?? '-'); ?>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="text-secondary fw-bold"><?php echo number_format($drug['price'], 2); ?></td>
|
<td class="text-secondary fw-bold"><?php echo number_format($drug['price'], 2); ?></td>
|
||||||
<td class="text-end px-4">
|
<td class="text-end px-4">
|
||||||
<div class="btn-group shadow-sm border rounded bg-white">
|
<div class="btn-group shadow-sm border rounded bg-white">
|
||||||
@ -133,3 +141,188 @@ $all_drug_groups = $gStmt->fetchAll();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Add/Edit Drug Modal -->
|
||||||
|
<div class="modal fade" id="addDrugModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-primary text-white">
|
||||||
|
<h5 class="modal-title" id="drugModalTitle"><?php echo __('add_drug'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" id="drugAction" value="add_drug">
|
||||||
|
<input type="hidden" name="id" id="drugId">
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('name_en'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_en" id="drugNameEn" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('name_ar'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_ar" id="drugNameAr" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('drug_group'); ?></label>
|
||||||
|
<select class="form-select" name="group_id" id="drugGroupId">
|
||||||
|
<option value=""><?php echo __('select_group'); ?></option>
|
||||||
|
<?php foreach ($all_drug_groups as $group): ?>
|
||||||
|
<option value="<?php echo $group['id']; ?>">
|
||||||
|
<?php echo htmlspecialchars($group['name_' . $lang]); ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('price'); ?></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">$</span>
|
||||||
|
<input type="number" step="0.01" class="form-control" name="price" id="drugPrice">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('expiry_date'); ?></label>
|
||||||
|
<input type="date" class="form-control" name="expiry_date" id="drugExpiry">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('supplier'); ?></label>
|
||||||
|
<select class="form-select" name="supplier_id" id="drugSupplierId">
|
||||||
|
<option value=""><?php echo __('select_supplier'); ?></option>
|
||||||
|
<?php foreach ($all_suppliers as $supplier): ?>
|
||||||
|
<option value="<?php echo $supplier['id']; ?>">
|
||||||
|
<?php echo htmlspecialchars($supplier['name_' . $lang]); ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('default_dosage'); ?></label>
|
||||||
|
<input type="text" class="form-control" name="default_dosage" id="drugDosage">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('default_instructions'); ?></label>
|
||||||
|
<input type="text" class="form-control" name="default_instructions" id="drugInstructions">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-label"><?php echo __('description_en'); ?></label>
|
||||||
|
<textarea class="form-control" name="description_en" id="drugDescEn" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-label"><?php echo __('description_ar'); ?></label>
|
||||||
|
<textarea class="form-control" name="description_ar" id="drugDescAr" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('close'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo __('save'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Import Drugs Modal -->
|
||||||
|
<div class="modal fade" id="importDrugsModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-primary text-white">
|
||||||
|
<h5 class="modal-title"><?php echo __('import_drugs'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="action" value="import_drugs">
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><?php echo __('upload_csv_file'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="file" class="form-control" name="csv_file" accept=".csv" required>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-info small mb-0">
|
||||||
|
<i class="bi bi-info-circle me-1"></i> <?php echo __('csv_format_drugs'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('close'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo __('import'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delete Drug Modal -->
|
||||||
|
<div class="modal fade" id="deleteDrugModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-danger text-white">
|
||||||
|
<h5 class="modal-title"><?php echo __('delete_drug'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" value="delete_drug">
|
||||||
|
<input type="hidden" name="id" id="deleteDrugId">
|
||||||
|
<div class="modal-body p-4 text-center">
|
||||||
|
<div class="mb-3 text-danger">
|
||||||
|
<i class="bi bi-exclamation-triangle display-1"></i>
|
||||||
|
</div>
|
||||||
|
<p class="mb-0 fs-5"><?php echo __('are_you_sure_delete'); ?></p>
|
||||||
|
<p class="text-muted small"><?php echo __('action_cannot_be_undone'); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light justify-content-center">
|
||||||
|
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-danger px-4"><?php echo __('delete'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function resetDrugModal() {
|
||||||
|
document.getElementById('drugModalTitle').textContent = '<?php echo __('add_drug'); ?>';
|
||||||
|
document.getElementById('drugAction').value = 'add_drug';
|
||||||
|
document.getElementById('drugId').value = '';
|
||||||
|
|
||||||
|
document.getElementById('drugNameEn').value = '';
|
||||||
|
document.getElementById('drugNameAr').value = '';
|
||||||
|
document.getElementById('drugGroupId').value = '';
|
||||||
|
document.getElementById('drugPrice').value = '';
|
||||||
|
document.getElementById('drugDosage').value = '';
|
||||||
|
document.getElementById('drugInstructions').value = '';
|
||||||
|
document.getElementById('drugDescEn').value = '';
|
||||||
|
document.getElementById('drugDescAr').value = '';
|
||||||
|
document.getElementById('drugExpiry').value = '';
|
||||||
|
document.getElementById('drugSupplierId').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditDrugModal(drug) {
|
||||||
|
document.getElementById('drugModalTitle').textContent = '<?php echo __('edit_drug'); ?>';
|
||||||
|
document.getElementById('drugAction').value = 'edit_drug';
|
||||||
|
document.getElementById('drugId').value = drug.id;
|
||||||
|
|
||||||
|
document.getElementById('drugNameEn').value = drug.name_en;
|
||||||
|
document.getElementById('drugNameAr').value = drug.name_ar;
|
||||||
|
document.getElementById('drugGroupId').value = drug.group_id || '';
|
||||||
|
document.getElementById('drugPrice').value = drug.price;
|
||||||
|
document.getElementById('drugDosage').value = drug.default_dosage;
|
||||||
|
document.getElementById('drugInstructions').value = drug.default_instructions;
|
||||||
|
document.getElementById('drugDescEn').value = drug.description_en;
|
||||||
|
document.getElementById('drugDescAr').value = drug.description_ar;
|
||||||
|
document.getElementById('drugExpiry').value = drug.expiry_date || '';
|
||||||
|
document.getElementById('drugSupplierId').value = drug.supplier_id || '';
|
||||||
|
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('addDrugModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDeleteDrugModal(id) {
|
||||||
|
document.getElementById('deleteDrugId').value = id;
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('deleteDrugModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -6,10 +6,15 @@ $groups = $stmt->fetchAll();
|
|||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<h3 class="fw-bold text-secondary"><?php echo __('drugs_groups'); ?></h3>
|
<h3 class="fw-bold text-secondary"><?php echo __('drugs_groups'); ?></h3>
|
||||||
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addDrugGroupModal">
|
<div>
|
||||||
|
<button class="btn btn-outline-primary shadow-sm me-2" data-bs-toggle="modal" data-bs-target="#importDrugsGroupsModal">
|
||||||
|
<i class="bi bi-upload me-1"></i> <?php echo __('import_csv'); ?>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addDrugGroupModal" onclick="resetGroupModal()">
|
||||||
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_drug_group'); ?>
|
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_drug_group'); ?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card shadow-sm border-0">
|
<div class="card shadow-sm border-0">
|
||||||
<div class="card-body p-0">
|
<div class="card-body p-0">
|
||||||
@ -59,3 +64,117 @@ $groups = $stmt->fetchAll();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Add/Edit Drug Group Modal -->
|
||||||
|
<div class="modal fade" id="addDrugGroupModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-primary text-white">
|
||||||
|
<h5 class="modal-title" id="groupModalTitle"><?php echo __('add_drug_group'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" id="groupAction" value="add_drug_group">
|
||||||
|
<input type="hidden" name="id" id="groupId">
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><?php echo __('name_en'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_en" id="groupNameEn" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><?php echo __('name_ar'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_ar" id="groupNameAr" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('close'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo __('save'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Import Drugs Groups Modal -->
|
||||||
|
<div class="modal fade" id="importDrugsGroupsModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-primary text-white">
|
||||||
|
<h5 class="modal-title"><?php echo __('import_csv'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="action" value="import_drugs_groups">
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><?php echo __('upload_csv_file'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="file" class="form-control" name="csv_file" accept=".csv" required>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-info small mb-0">
|
||||||
|
<i class="bi bi-info-circle me-1"></i> <?php echo __('csv_format_groups'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('close'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo __('import'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delete Drug Group Modal -->
|
||||||
|
<div class="modal fade" id="deleteDrugGroupModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-danger text-white">
|
||||||
|
<h5 class="modal-title"><?php echo __('delete_drug_group'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" value="delete_drug_group">
|
||||||
|
<input type="hidden" name="id" id="deleteGroupId">
|
||||||
|
<div class="modal-body p-4 text-center">
|
||||||
|
<div class="mb-3 text-danger">
|
||||||
|
<i class="bi bi-exclamation-triangle display-1"></i>
|
||||||
|
</div>
|
||||||
|
<p class="mb-0 fs-5"><?php echo __('are_you_sure_delete'); ?></p>
|
||||||
|
<p class="text-muted small"><?php echo __('action_cannot_be_undone'); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light justify-content-center">
|
||||||
|
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-danger px-4"><?php echo __('delete'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function resetGroupModal() {
|
||||||
|
document.getElementById('groupModalTitle').textContent = '<?php echo __('add_drug_group'); ?>';
|
||||||
|
document.getElementById('groupAction').value = 'add_drug_group';
|
||||||
|
document.getElementById('groupId').value = '';
|
||||||
|
|
||||||
|
document.getElementById('groupNameEn').value = '';
|
||||||
|
document.getElementById('groupNameAr').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditDrugGroupModal(group) {
|
||||||
|
document.getElementById('groupModalTitle').textContent = '<?php echo __('edit_drug_group'); ?>';
|
||||||
|
document.getElementById('groupAction').value = 'edit_drug_group';
|
||||||
|
document.getElementById('groupId').value = group.id;
|
||||||
|
|
||||||
|
document.getElementById('groupNameEn').value = group.name_en;
|
||||||
|
document.getElementById('groupNameAr').value = group.name_ar;
|
||||||
|
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('addDrugGroupModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDeleteDrugGroupModal(id) {
|
||||||
|
document.getElementById('deleteGroupId').value = id;
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('deleteDrugGroupModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
200
includes/pages/suppliers.php
Normal file
200
includes/pages/suppliers.php
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
$search = $_GET['search'] ?? '';
|
||||||
|
|
||||||
|
$query = "SELECT * FROM suppliers WHERE name_en LIKE ? OR name_ar LIKE ? OR contact_person LIKE ? OR phone LIKE ? ORDER BY id DESC";
|
||||||
|
$params = ["%$search%", "%$search%", "%$search%", "%$search%"];
|
||||||
|
|
||||||
|
$stmt = $db->prepare($query);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$suppliers = $stmt->fetchAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h3 class="fw-bold text-secondary"><?php echo __('suppliers'); ?></h3>
|
||||||
|
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addSupplierModal" onclick="resetSupplierModal()">
|
||||||
|
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_supplier'); ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Search Bar -->
|
||||||
|
<div class="card shadow-sm border-0 mb-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="GET" action="">
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
|
||||||
|
<input type="text" name="search" class="form-control bg-light border-start-0" placeholder="<?php echo __('search'); ?>..." value="<?php echo htmlspecialchars($search); ?>">
|
||||||
|
<button type="submit" class="btn btn-secondary"><?php echo __('search'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card shadow-sm border-0">
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light text-secondary">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3">#</th>
|
||||||
|
<th class="py-3"><?php echo __('name'); ?></th>
|
||||||
|
<th class="py-3"><?php echo __('contact_person'); ?></th>
|
||||||
|
<th class="py-3"><?php echo __('phone'); ?></th>
|
||||||
|
<th class="py-3"><?php echo __('email'); ?></th>
|
||||||
|
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if (empty($suppliers)): ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="text-center py-5 text-muted">
|
||||||
|
<i class="bi bi-truck display-4 d-block mb-3"></i>
|
||||||
|
<?php echo __('no_suppliers_found'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($suppliers as $supplier): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="px-4 fw-medium text-secondary"><?php echo $supplier['id']; ?></td>
|
||||||
|
<td>
|
||||||
|
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($supplier['name_'.$lang]); ?></div>
|
||||||
|
<small class="text-muted"><?php echo htmlspecialchars($supplier['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
|
||||||
|
</td>
|
||||||
|
<td><?php echo htmlspecialchars($supplier['contact_person'] ?? '-'); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($supplier['phone'] ?? '-'); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($supplier['email'] ?? '-'); ?></td>
|
||||||
|
<td class="text-end px-4">
|
||||||
|
<div class="btn-group shadow-sm border rounded bg-white">
|
||||||
|
<button class="btn btn-link text-primary py-1 px-2 border-end"
|
||||||
|
onclick="showEditSupplierModal(<?php echo htmlspecialchars(json_encode($supplier, JSON_UNESCAPED_UNICODE)); ?>)"
|
||||||
|
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
|
||||||
|
<i class="bi bi-pencil-square"></i>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-link text-danger py-1 px-2"
|
||||||
|
onclick="showDeleteSupplierModal(<?php echo $supplier['id']; ?>)"
|
||||||
|
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
|
||||||
|
<i class="bi bi-trash3"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add/Edit Supplier Modal -->
|
||||||
|
<div class="modal fade" id="addSupplierModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-primary text-white">
|
||||||
|
<h5 class="modal-title" id="supplierModalTitle"><?php echo __('add_supplier'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" id="supplierAction" value="add_supplier">
|
||||||
|
<input type="hidden" name="id" id="supplierId">
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('name_en'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_en" id="supplierNameEn" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('name_ar'); ?> <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="name_ar" id="supplierNameAr" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('contact_person'); ?></label>
|
||||||
|
<input type="text" class="form-control" name="contact_person" id="supplierContact">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('phone'); ?></label>
|
||||||
|
<input type="text" class="form-control" name="phone" id="supplierPhone">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('email'); ?></label>
|
||||||
|
<input type="email" class="form-control" name="email" id="supplierEmail">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label"><?php echo __('address'); ?></label>
|
||||||
|
<input type="text" class="form-control" name="address" id="supplierAddress">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('close'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo __('save'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delete Supplier Modal -->
|
||||||
|
<div class="modal fade" id="deleteSupplierModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content border-0 shadow">
|
||||||
|
<div class="modal-header bg-danger text-white">
|
||||||
|
<h5 class="modal-title"><?php echo __('delete_supplier'); ?></h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="">
|
||||||
|
<input type="hidden" name="action" value="delete_supplier">
|
||||||
|
<input type="hidden" name="id" id="deleteSupplierId">
|
||||||
|
<div class="modal-body p-4 text-center">
|
||||||
|
<div class="mb-3 text-danger">
|
||||||
|
<i class="bi bi-exclamation-triangle display-1"></i>
|
||||||
|
</div>
|
||||||
|
<p class="mb-0 fs-5"><?php echo __('are_you_sure_delete'); ?></p>
|
||||||
|
<p class="text-muted small"><?php echo __('action_cannot_be_undone'); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light justify-content-center">
|
||||||
|
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-danger px-4"><?php echo __('delete'); ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function resetSupplierModal() {
|
||||||
|
document.getElementById('supplierModalTitle').textContent = '<?php echo __('add_supplier'); ?>';
|
||||||
|
document.getElementById('supplierAction').value = 'add_supplier';
|
||||||
|
document.getElementById('supplierId').value = '';
|
||||||
|
|
||||||
|
document.getElementById('supplierNameEn').value = '';
|
||||||
|
document.getElementById('supplierNameAr').value = '';
|
||||||
|
document.getElementById('supplierContact').value = '';
|
||||||
|
document.getElementById('supplierPhone').value = '';
|
||||||
|
document.getElementById('supplierEmail').value = '';
|
||||||
|
document.getElementById('supplierAddress').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditSupplierModal(supplier) {
|
||||||
|
document.getElementById('supplierModalTitle').textContent = '<?php echo __('edit_supplier'); ?>';
|
||||||
|
document.getElementById('supplierAction').value = 'edit_supplier';
|
||||||
|
document.getElementById('supplierId').value = supplier.id;
|
||||||
|
|
||||||
|
document.getElementById('supplierNameEn').value = supplier.name_en;
|
||||||
|
document.getElementById('supplierNameAr').value = supplier.name_ar;
|
||||||
|
document.getElementById('supplierContact').value = supplier.contact_person || '';
|
||||||
|
document.getElementById('supplierPhone').value = supplier.phone || '';
|
||||||
|
document.getElementById('supplierEmail').value = supplier.email || '';
|
||||||
|
document.getElementById('supplierAddress').value = supplier.address || '';
|
||||||
|
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('addSupplierModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDeleteSupplierModal(id) {
|
||||||
|
document.getElementById('deleteSupplierId').value = id;
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('deleteSupplierModal'));
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
42
lang.php
42
lang.php
@ -228,7 +228,25 @@ $translations = [
|
|||||||
'no_drugs_found' => 'No drugs found',
|
'no_drugs_found' => 'No drugs found',
|
||||||
'select_drug' => 'Select Drug',
|
'select_drug' => 'Select Drug',
|
||||||
'select' => 'Select',
|
'select' => 'Select',
|
||||||
|
'are_you_sure_delete' => 'Are you sure you want to delete?',
|
||||||
|
'action_cannot_be_undone' => 'This action cannot be undone.',
|
||||||
|
'select_group' => 'Select Group',
|
||||||
|
'suppliers' => 'Suppliers',
|
||||||
|
'add_supplier' => 'Add Supplier',
|
||||||
|
'edit_supplier' => 'Edit Supplier',
|
||||||
|
'delete_supplier' => 'Delete Supplier',
|
||||||
|
'no_suppliers_found' => 'No suppliers found',
|
||||||
|
'contact_person' => 'Contact Person',
|
||||||
|
'select_supplier' => 'Select Supplier',
|
||||||
|
'expiry_date' => 'Expiry Date',
|
||||||
|
'supplier' => 'Supplier',
|
||||||
|
'import' => 'Import',
|
||||||
|
'import_csv' => 'Import CSV',
|
||||||
|
'upload_csv_file' => 'Upload CSV File',
|
||||||
|
'download_sample' => 'Download Sample',
|
||||||
|
'import_successfully' => 'Imported successfully',
|
||||||
|
'csv_format_drugs' => 'CSV Format: Name (EN), Name (AR), Group Name, Price, Expiry Date (YYYY-MM-DD), Supplier Name',
|
||||||
|
'csv_format_groups' => 'CSV Format: Name (EN), Name (AR)',
|
||||||
],
|
],
|
||||||
'ar' => [
|
'ar' => [
|
||||||
'attachment' => 'المرفق',
|
'attachment' => 'المرفق',
|
||||||
@ -440,7 +458,7 @@ $translations = [
|
|||||||
'company_logo' => 'شعار الشركة',
|
'company_logo' => 'شعار الشركة',
|
||||||
'company_favicon' => 'أيقونة الشركة',
|
'company_favicon' => 'أيقونة الشركة',
|
||||||
'save_changes' => 'حفظ التغييرات',
|
'save_changes' => 'حفظ التغييرات',
|
||||||
'settings_updated_successfully' => 'تم تحديث الإعدادات بنجاح',
|
'settings_updated_successfully' => 'Settings updated successfully',
|
||||||
'prescriptions' => 'الوصفات الطبية',
|
'prescriptions' => 'الوصفات الطبية',
|
||||||
'add_drug' => 'إضافة دواء',
|
'add_drug' => 'إضافة دواء',
|
||||||
'drug_name' => 'اسم الدواء',
|
'drug_name' => 'اسم الدواء',
|
||||||
@ -460,6 +478,24 @@ $translations = [
|
|||||||
'no_drugs_found' => 'لم يتم العثور على أدوية',
|
'no_drugs_found' => 'لم يتم العثور على أدوية',
|
||||||
'select_drug' => 'اختر الدواء',
|
'select_drug' => 'اختر الدواء',
|
||||||
'select' => 'اختيار',
|
'select' => 'اختيار',
|
||||||
|
'are_you_sure_delete' => 'Are you sure you want to delete?',
|
||||||
|
'action_cannot_be_undone' => 'This action cannot be undone.',
|
||||||
|
'select_group' => 'Select Group',
|
||||||
|
'suppliers' => 'الموردين',
|
||||||
|
'add_supplier' => 'إضافة مورد',
|
||||||
|
'edit_supplier' => 'تعديل مورد',
|
||||||
|
'delete_supplier' => 'حذف مورد',
|
||||||
|
'no_suppliers_found' => 'لم يتم العثور على موردين',
|
||||||
|
'contact_person' => 'شخص الاتصال',
|
||||||
|
'select_supplier' => 'اختر المورد',
|
||||||
|
'expiry_date' => 'تاريخ الانتهاء',
|
||||||
|
'supplier' => 'المورد',
|
||||||
|
'import' => 'استيراد',
|
||||||
|
'import_csv' => 'استيراد ملف CSV',
|
||||||
|
'upload_csv_file' => 'رفع ملف CSV',
|
||||||
|
'download_sample' => 'تحميل نموذج',
|
||||||
|
'import_successfully' => 'تم الاستيراد بنجاح',
|
||||||
|
'csv_format_drugs' => 'تنسيق CSV: الاسم (إنجليزي)، الاسم (عربي)، اسم المجموعة، السعر، تاريخ الانتهاء، اسم المورد',
|
||||||
|
'csv_format_groups' => 'تنسيق CSV: الاسم (إنجليزي)، الاسم (عربي)',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@ -22,7 +22,7 @@ try {
|
|||||||
SELECT
|
SELECT
|
||||||
v.*,
|
v.*,
|
||||||
p.name as patient_name,
|
p.name as patient_name,
|
||||||
p.age,
|
p.dob,
|
||||||
p.gender,
|
p.gender,
|
||||||
d.name_en as doctor_name_en,
|
d.name_en as doctor_name_en,
|
||||||
d.name_ar as doctor_name_ar,
|
d.name_ar as doctor_name_ar,
|
||||||
@ -103,7 +103,7 @@ try {
|
|||||||
<strong>Patient Name:</strong> <?php echo htmlspecialchars($visit['patient_name']); ?>
|
<strong>Patient Name:</strong> <?php echo htmlspecialchars($visit['patient_name']); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<strong>Age:</strong> <?php echo $visit['age'] ?? 'N/A'; ?>
|
<strong>Age:</strong> <?php echo calculate_age($visit['dob']); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<strong>Gender:</strong> <?php echo $visit['gender']; ?>
|
<strong>Gender:</strong> <?php echo $visit['gender']; ?>
|
||||||
|
|||||||
5
suppliers.php
Normal file
5
suppliers.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
$section = 'suppliers';
|
||||||
|
require_once __DIR__ . '/includes/layout/header.php';
|
||||||
|
require_once __DIR__ . '/includes/pages/suppliers.php';
|
||||||
|
require_once __DIR__ . '/includes/layout/footer.php';
|
||||||
Loading…
x
Reference in New Issue
Block a user