This commit is contained in:
Flatlogic Bot 2025-12-22 16:26:09 +00:00
parent 1e68a2dcc7
commit 9a73bf01c4
6 changed files with 254 additions and 13 deletions

26
assets/css/custom.css Normal file
View File

@ -0,0 +1,26 @@
/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap');
body {
direction: rtl; /* Right-to-left layout */
font-family: 'Tajawal', sans-serif; /* Arabic-friendly font */
background-color: #f8f9fa;
}
.main-content {
min-height: calc(100vh - 56px); /* Full height minus navbar */
}
.navbar {
background-color: #ffffff;
border-bottom: 1px solid #dee2e6;
}
.card {
border: none;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}
.table {
vertical-align: middle;
}

84
db/setup.php Normal file
View File

@ -0,0 +1,84 @@
<?php
// Simple script to setup database tables and seed initial data.
// This is for demonstration and initial setup.
// In a real-world scenario, a proper migration tool should be used.
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Set PDO to throw exceptions on error
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Starting database setup...\n";
// Table: clinics
$sql_clinics = "
CREATE TABLE IF NOT EXISTS `clinics` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`specialization` VARCHAR(255),
`phone` VARCHAR(50),
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
$pdo->exec($sql_clinics);
echo "Table 'clinics' created successfully or already exists.\n";
// Table: users
$sql_users = "
CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`clinic_id` INT NOT NULL,
`mobile` VARCHAR(50) NOT NULL UNIQUE,
`name` VARCHAR(255) NOT NULL,
`role` ENUM('admin', 'doctor', 'assistant') NOT NULL,
`is_active` BOOLEAN DEFAULT TRUE,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`clinic_id`) REFERENCES `clinics`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
$pdo->exec($sql_users);
echo "Table 'users' created successfully or already exists.\n";
// Table: patients
$sql_patients = "
CREATE TABLE IF NOT EXISTS `patients` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`clinic_id` INT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`mobile` VARCHAR(50) NULL,
`notes` TEXT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`clinic_id`) REFERENCES `clinics`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
$pdo->exec($sql_patients);
echo "Table 'patients' created successfully or already exists.\n";
// --- SEED DATA ---
// Check if clinic exists
$stmt = $pdo->query("SELECT id FROM `clinics` WHERE id = 1");
if ($stmt->rowCount() == 0) {
$pdo->exec("INSERT INTO `clinics` (`id`, `name`, `specialization`, `phone`) VALUES (1, 'عيادة الأمل', 'الطب العام', '1234567890')");
echo "Seeded 'clinics' table.\n";
// Seed users only if clinic was just created
$pdo->exec("INSERT INTO `users` (`clinic_id`, `mobile`, `name`, `role`) VALUES (1, '966500000001', 'د. أحمد محمود', 'doctor')");
$pdo->exec("INSERT INTO `users` (`clinic_id`, `mobile`, `name`, `role`) VALUES (1, '966500000002', 'فاطمة علي', 'assistant')");
echo "Seeded 'users' table.\n";
// Seed patients only if clinic was just created
$pdo->exec("INSERT INTO `patients` (`clinic_id`, `name`, `mobile`) VALUES (1, 'خالد الغامدي', '966510000001')");
$pdo->exec("INSERT INTO `patients` (`clinic_id`, `name`, `mobile`) VALUES (1, 'سارة عبدالله', '966510000002')");
$pdo->exec("INSERT INTO `patients` (`clinic_id`, `name`, `mobile`) VALUES (1, 'محمد الزهراني', '966510000003')");
echo "Seeded 'patients' table.\n";
} else {
echo "Data already seeded.\n";
}
echo "Database setup finished successfully!\n";
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}

View File

@ -132,19 +132,20 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
</style> </style>
</head> </head>
<body> <body>
<main> <?php require_once __DIR__ . '/layout_header.php'; ?>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1> <div class="container-fluid p-4">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <h1 class="h3 mb-4">لوحة التحكم</h1>
<span class="sr-only">Loading…</span> <div class="row">
</div> <div class="col-12">
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> <div class="card p-4 text-center">
<p class="hint">This page will update automatically as the plan is implemented.</p> <h2>أهلاً بك في نظام إدارة العيادة</h2>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p> <p>اختر من القائمة للتنقل بين أقسام النظام.</p>
</div>
</div>
</div> </div>
</main> </div>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <?php require_once __DIR__ . '/layout_footer.php'; ?>
</footer>
</body> </body>
</html> </html>

7
layout_footer.php Normal file
View File

@ -0,0 +1,7 @@
</main>
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

59
layout_header.php Normal file
View File

@ -0,0 +1,59 @@
<?php
$current_page = basename($_SERVER['PHP_SELF']);
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clinic CRM</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light sticky-top">
<div class="container-fluid">
<a class="navbar-brand fw-bold" href="index.php">Clinic CRM</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link <?php echo ($current_page == 'index.php') ? 'active' : ''; ?>" href="index.php"><i class="bi bi-house-door-fill me-1"></i> الرئيسية</a>
</li>
<li class="nav-item">
<a class="nav-link <?php echo ($current_page == 'patients.php') ? 'active' : ''; ?>" href="patients.php"><i class="bi bi-people-fill me-1"></i> المرضى</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#"><i class="bi bi-calendar-event-fill me-1"></i> المواعيد</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#"><i class="bi bi-bell-fill me-1"></i> المتابعة</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-person-circle me-1"></i> د. أحمد
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">الإعدادات</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">تسجيل الخروج</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<main class="main-content">

64
patients.php Normal file
View File

@ -0,0 +1,64 @@
<?php
require_once __DIR__ . '/layout_header.php';
require_once __DIR__ . '/db/config.php';
$patients = [];
try {
$pdo = db();
$stmt = $pdo->query("SELECT id, name, mobile, created_at FROM patients WHERE clinic_id = 1 ORDER BY created_at DESC");
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// In a real app, log this error and show a user-friendly message.
error_log("DB Error: " . $e->getMessage());
}
?>
<div class="container-fluid p-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3">قائمة المرضى</h1>
<a href="#" class="btn btn-primary">
<i class="bi bi-plus-circle-fill me-2"></i> إضافة مريض جديد
</a>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th scope="col">#</th>
<th scope="col">الاسم</th>
<th scope="col">رقم الموبايل</th>
<th scope="col">تاريخ التسجيل</th>
<th scope="col">إجراءات</th>
</tr>
</thead>
<tbody>
<?php if (empty($patients)): ?>
<tr>
<td colspan="5" class="text-center">لا يوجد مرضى لعرضهم.</td>
</tr>
<?php else: ?>
<?php foreach ($patients as $patient): ?>
<tr>
<th scope="row"><?php echo htmlspecialchars($patient['id']); ?></th>
<td><?php echo htmlspecialchars($patient['name']); ?></td>
<td><?php echo htmlspecialchars($patient['mobile']); ?></td>
<td><?php echo (new DateTime($patient['created_at']))->format('Y-m-d'); ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-primary"><i class="bi bi-eye-fill"></i></a>
<a href="#" class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil-fill"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php require_once __DIR__ . '/layout_footer.php'; ?>