[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: log.php
<?php require_once '../config/database.php'; require_once '../config/functions.php'; requireAuth('accountant'); // Get search parameters $search_user = $_GET['search_user'] ?? ''; $search_action = $_GET['search_action'] ?? ''; $search_entity = $_GET['search_entity'] ?? ''; $date_from = $_GET['date_from'] ?? ''; $date_to = $_GET['date_to'] ?? ''; // Build query $where_conditions = []; $params = []; if ($search_user) { $where_conditions[] = "u.full_name LIKE ?"; $params[] = "%$search_user%"; } if ($search_action) { $where_conditions[] = "al.action_type LIKE ?"; $params[] = "%$search_action%"; } if ($search_entity) { $where_conditions[] = "al.entity_type LIKE ?"; $params[] = "%$search_entity%"; } if ($date_from) { $where_conditions[] = "DATE(al.created_at) >= ?"; $params[] = $date_from; } if ($date_to) { $where_conditions[] = "DATE(al.created_at) <= ?"; $params[] = $date_to; } $where_clause = empty($where_conditions) ? '' : 'WHERE ' . implode(' AND ', $where_conditions); // Get audit logs $stmt = $pdo->prepare(" SELECT al.*, u.full_name as user_name, u.role, eu.full_name as edited_by_name FROM audit_log al JOIN users u ON al.user_id = u.id LEFT JOIN users eu ON al.edited_by = eu.id $where_clause ORDER BY al.created_at DESC LIMIT 200 "); $stmt->execute($params); $audit_logs = $stmt->fetchAll(); $error = ''; $success = ''; // Handle edit audit log if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_log'])) { $log_id = $_POST['log_id'] ?? ''; $new_description = trim($_POST['new_description'] ?? ''); $edit_reason = trim($_POST['edit_reason'] ?? ''); if (!$log_id || !$new_description || !$edit_reason) { $error = 'جميع الحقول مطلوبة'; } else { try { $stmt = $pdo->prepare(" UPDATE audit_log SET description = ?, is_edited = 1, edited_by = ?, edited_at = NOW(), old_value = JSON_SET(COALESCE(old_value, '{}'), '$.edit_reason', ?) WHERE id = ? "); $stmt->execute([$new_description, $_SESSION['user_id'], $edit_reason, $log_id]); $success = 'تم تعديل سجل المراجعة بنجاح'; // Refresh page header("Location: /audit/log.php?success=" . urlencode($success)); exit; } catch (Exception $e) { $error = 'خطأ في تعديل السجل: ' . $e->getMessage(); } } } if (isset($_GET['success'])) { $success = $_GET['success']; } ?> <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>سجل المراجعة المالية - حسابات عربية بن فريش</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> <style> .search-card { background: linear-gradient(135deg, #6f42c1 0%, #e83e8c 100%); color: white; border-radius: 15px; } .audit-row { border-left: 4px solid #dee2e6; transition: all 0.3s ease; } .audit-row:hover { background: #f8f9fa; } .audit-create { border-left-color: #198754; } .audit-update { border-left-color: #ffc107; } .audit-delete { border-left-color: #dc3545; } .audit-login { border-left-color: #0d6efd; } .audit-edited { background: #fff3cd; border-left-color: #fd7e14; } .json-display { background: #f8f9fa; border-radius: 5px; padding: 10px; font-family: monospace; font-size: 0.85rem; max-height: 150px; overflow-y: auto; } </style> </head> <body class="bg-light"> <div class="container-fluid mt-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2><i class="fas fa-clipboard-list me-2"></i>سجل المراجعة المالية</h2> <a href="/dashboard.php" class="btn btn-outline-secondary"> <i class="fas fa-arrow-left me-1"></i>العودة </a> </div> <?php if ($error): ?> <div class="alert alert-danger" role="alert"> <i class="fas fa-exclamation-triangle me-2"></i><?= htmlspecialchars($error) ?> </div> <?php endif; ?> <?php if ($success): ?> <div class="alert alert-success" role="alert"> <i class="fas fa-check-circle me-2"></i><?= htmlspecialchars($success) ?> </div> <?php endif; ?> <!-- Search Filters --> <div class="search-card p-4 mb-4"> <h5 class="mb-3"><i class="fas fa-search me-2"></i>البحث والتصفية</h5> <form method="GET"> <div class="row"> <div class="col-md-3 mb-3"> <label class="form-label">المستخدم</label> <input type="text" class="form-control" name="search_user" value="<?= htmlspecialchars($search_user) ?>" placeholder="اسم المستخدم"> </div> <div class="col-md-3 mb-3"> <label class="form-label">نوع الإجراء</label> <input type="text" class="form-control" name="search_action" value="<?= htmlspecialchars($search_action) ?>" placeholder="create_invoice, login..."> </div> <div class="col-md-3 mb-3"> <label class="form-label">نوع الكيان</label> <input type="text" class="form-control" name="search_entity" value="<?= htmlspecialchars($search_entity) ?>" placeholder="invoice, payment, client..."> </div> <div class="col-md-3 mb-3"> <label class="form-label">من تاريخ</label> <input type="date" class="form-control" name="date_from" value="<?= htmlspecialchars($date_from) ?>"> </div> </div> <div class="row"> <div class="col-md-3 mb-3"> <label class="form-label">إلى تاريخ</label> <input type="date" class="form-control" name="date_to" value="<?= htmlspecialchars($date_to) ?>"> </div> <div class="col-md-9 mb-3 d-flex align-items-end"> <button type="submit" class="btn btn-light me-2"> <i class="fas fa-search me-1"></i>بحث </button> <a href="/audit/log.php" class="btn btn-outline-light"> <i class="fas fa-refresh me-1"></i>إعادة تعيين </a> </div> </div> </form> </div> <!-- Audit Logs --> <div class="card"> <div class="card-header bg-primary text-white"> <h5 class="mb-0"> <i class="fas fa-history me-2"></i> سجل الأنشطة (<?= count($audit_logs) ?>) </h5> </div> <div class="card-body p-0"> <?php if (empty($audit_logs)): ?> <div class="text-center py-5"> <i class="fas fa-inbox fa-3x text-muted mb-3"></i> <p class="text-muted">لا توجد سجلات تطابق معايير البحث</p> </div> <?php else: ?> <div class="list-group list-group-flush"> <?php foreach ($audit_logs as $log): ?> <?php $action_icons = [ 'create' => 'fas fa-plus text-success', 'update' => 'fas fa-edit text-warning', 'delete' => 'fas fa-trash text-danger', 'login' => 'fas fa-sign-in-alt text-primary', 'logout' => 'fas fa-sign-out-alt text-secondary', 'approve' => 'fas fa-check text-success', 'reject' => 'fas fa-times text-danger' ]; $action_type = explode('_', $log['action_type'])[0]; $icon_class = $action_icons[$action_type] ?? 'fas fa-info-circle text-info'; ?> <div class="list-group-item audit-row <?= $log['is_edited'] ? 'audit-edited' : '' ?> audit-<?= $action_type ?>"> <div class="d-flex justify-content-between align-items-start"> <div class="flex-grow-1"> <div class="d-flex align-items-center mb-2"> <i class="<?= $icon_class ?> me-2"></i> <h6 class="mb-0"><?= htmlspecialchars($log['description']) ?></h6> <?php if ($log['is_edited']): ?> <span class="badge bg-warning ms-2">معدل</span> <?php endif; ?> </div> <div class="row"> <div class="col-md-3"> <small class="text-muted">المستخدم:</small> <div><?= htmlspecialchars($log['user_name']) ?></div> <small class="badge bg-secondary"><?= $log['role'] === 'manager' ? 'مدير' : ($log['role'] === 'accountant' ? 'محاسب' : 'مندوب') ?></small> </div> <div class="col-md-3"> <small class="text-muted">نوع الإجراء:</small> <div><?= htmlspecialchars($log['action_type']) ?></div> </div> <div class="col-md-3"> <small class="text-muted">الكيان:</small> <div><?= htmlspecialchars($log['entity_type']) ?> #<?= $log['entity_id'] ?></div> </div> <div class="col-md-3"> <small class="text-muted">التاريخ:</small> <div><?= date('Y-m-d H:i:s', strtotime($log['created_at'])) ?></div> </div> </div> <?php if ($log['old_value'] || $log['new_value']): ?> <div class="mt-3"> <button class="btn btn-sm btn-outline-info" type="button" data-bs-toggle="collapse" data-bs-target="#details<?= $log['id'] ?>"> <i class="fas fa-eye me-1"></i>عرض التفاصيل </button> </div> <div class="collapse mt-2" id="details<?= $log['id'] ?>"> <?php if ($log['old_value']): ?> <div class="mb-2"> <small class="text-muted">القيمة السابقة:</small> <div class="json-display"><?= htmlspecialchars($log['old_value']) ?></div> </div> <?php endif; ?> <?php if ($log['new_value']): ?> <div class="mb-2"> <small class="text-muted">القيمة الجديدة:</small> <div class="json-display"><?= htmlspecialchars($log['new_value']) ?></div> </div> <?php endif; ?> </div> <?php endif; ?> <?php if ($log['is_edited']): ?> <div class="mt-2"> <small class="text-warning"> <i class="fas fa-edit me-1"></i> تم التعديل بواسطة <?= htmlspecialchars($log['edited_by_name']) ?> في <?= date('Y-m-d H:i', strtotime($log['edited_at'])) ?> </small> </div> <?php endif; ?> </div> <div class="flex-shrink-0"> <?php if (hasRole('manager') && !$log['is_edited']): ?> <button class="btn btn-sm btn-outline-warning" data-bs-toggle="modal" data-bs-target="#editModal<?= $log['id'] ?>"> <i class="fas fa-edit"></i> </button> <?php endif; ?> </div> </div> </div> <!-- Edit Modal --> <?php if (hasRole('manager') && !$log['is_edited']): ?> <div class="modal fade" id="editModal<?= $log['id'] ?>" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">تعديل سجل المراجعة</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <form method="POST"> <div class="modal-body"> <input type="hidden" name="log_id" value="<?= $log['id'] ?>"> <div class="mb-3"> <label class="form-label">الوصف الحالي</label> <div class="form-control bg-light"><?= htmlspecialchars($log['description']) ?></div> </div> <div class="mb-3"> <label class="form-label">الوصف الجديد *</label> <textarea class="form-control" name="new_description" rows="3" required><?= htmlspecialchars($log['description']) ?></textarea> </div> <div class="mb-3"> <label class="form-label">سبب التعديل *</label> <textarea class="form-control" name="edit_reason" rows="2" placeholder="اكتب سبب تعديل هذا السجل..." required></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button> <button type="submit" name="edit_log" class="btn btn-warning">حفظ التعديل</button> </div> </form> </div> </div> </div> <?php endif; ?> <?php endforeach; ?> </div> <?php endif; ?> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.87 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285