|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/emp.outerorbittech.in/admin/ | |
|
Path: /home2/outerorb/emp.outerorbittech.in/admin/settings.php
Size: 16 KB
Permissions: 0666
<?php
require_once '../config/config.php';
require_once '../includes/helpers.php';
// Check if user is logged in and is admin
session_start();
if (!isset($_SESSION['employee_id']) || $_SESSION['role'] !== 'admin') {
header('Location: ../index.php');
exit;
}
$admin_profile = get_employee_profile($_SESSION['employee_id']);
$message = '';
$error = '';
// Handle settings update
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$setting_key = $_POST['setting_key'] ?? '';
$setting_value = $_POST['setting_value'] ?? '';
if ($setting_key && update_system_setting($setting_key, $setting_value)) {
$message = "Setting updated successfully!";
log_activity($_SESSION['employee_id'], 'update_setting', 'system_settings', null, "Updated $setting_key");
} else {
$error = "Failed to update setting.";
}
}
$settings = get_system_settings();
$stats = get_system_stats();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings - Admin Panel</title>
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="stylesheet" href="../assets/css/polish.css">
<style>
.settings-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.setting-card {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
padding: 1.5rem;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.setting-title {
font-size: 1rem;
font-weight: 600;
margin-bottom: 1rem;
color: #e2e8f0;
}
.setting-form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.form-group label {
color: #cbd5e1;
font-size: 0.875rem;
}
.stat-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.stat-item {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
padding: 1.5rem;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.1);
text-align: center;
}
.stat-label {
color: #a0aec0;
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.stat-value {
font-size: 2rem;
font-weight: bold;
color: #2563eb;
margin-top: 0.5rem;
}
.info-section {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
padding: 1.5rem;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.1);
margin-bottom: 2rem;
}
.info-section h2 {
margin-top: 0;
margin-bottom: 1rem;
color: #e2e8f0;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 0.75rem 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
color: #cbd5e1;
}
.info-value {
color: #e2e8f0;
font-weight: 500;
}
@media (max-width: 768px) {
.settings-grid {
grid-template-columns: 1fr;
}
.stat-grid {
grid-template-columns: repeat(2, 1fr);
}
}
</style>
</head>
<body>
<div class="main-container">
<!-- Sidebar -->
<aside class="sidebar">
<div class="sidebar-header">
<h2>HR Admin</h2>
</div>
<nav class="sidebar-nav">
<a href="dashboard.php" class="nav-link">
<span><i class="fas fa-chart-line"></i> Dashboard</span>
</a>
<a href="users.php" class="nav-link">
<span><i class="fas fa-users"></i> User Management</span>
</a>
<a href="settings.php" class="nav-link active">
<span>⚙️ Settings</span>
</a>
<a href="backups.php" class="nav-link">
<span><i class="fas fa-database"></i> Backups</span>
</a>
<a href="activity-logs.php" class="nav-link">
<span><i class="fas fa-book"></i> Activity Logs</span>
</a>
<a href="logout.php" class="nav-link">
<span><i class="fas fa-sign-out-alt"></i> Logout</span>
</a>
</nav>
</aside>
<!-- Main Content -->
<div class="main-content">
<!-- Top Bar -->
<div class="top-bar">
<div class="top-bar-left">
<h1>System Settings</h1>
</div>
<div class="top-bar-right">
<div class="notification-bell">
<button id="notificationBell" class="bell-button">
<i class="fas fa-bell"></i>
<span class="badge" id="unreadCount">0</span>
</button>
<div id="notificationDropdown" class="notification-dropdown" style="display: none;">
<div class="dropdown-header">Notifications</div>
<div id="notificationList" class="notification-list">
<div class="notification-item">Loading...</div>
</div>
</div>
</div>
<span class="user-greeting">Welcome, <?php echo htmlspecialchars($admin_profile['first_name']); ?></span>
</div>
</div>
<!-- Content Area -->
<div class="content">
<!-- Messages -->
<?php if ($message): ?>
<div class="alert alert-success" role="alert">
✓ <?php echo htmlspecialchars($message); ?>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert">
✖ <?php echo htmlspecialchars($error); ?>
</div>
<?php endif; ?>
<!-- System Statistics -->
<h2>System Statistics</h2>
<div class="stat-grid">
<div class="stat-item">
<div class="stat-label">Total Employees</div>
<div class="stat-value"><?php echo $stats['total_employees']; ?></div>
</div>
<div class="stat-item">
<div class="stat-label">Active Users</div>
<div class="stat-value"><?php echo $stats['active_employees']; ?></div>
</div>
<div class="stat-item">
<div class="stat-label">Admins</div>
<div class="stat-value"><?php echo $stats['admin_count']; ?></div>
</div>
<div class="stat-item">
<div class="stat-label">Pending Leaves</div>
<div class="stat-value"><?php echo $stats['pending_leaves']; ?></div>
</div>
<div class="stat-item">
<div class="stat-label">Payroll Entries</div>
<div class="stat-value"><?php echo $stats['total_payroll_entries']; ?></div>
</div>
<div class="stat-item">
<div class="stat-label">Unread Notifications</div>
<div class="stat-value"><?php echo $stats['unread_notifications']; ?></div>
</div>
</div>
<!-- System Settings -->
<h2>System Configuration</h2>
<div class="settings-grid">
<!-- Company Name -->
<div class="setting-card">
<div class="setting-title">Company Name</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="company_name">
<div class="form-group">
<input type="text" name="setting_value" class="form-control"
value="<?php echo htmlspecialchars($settings['company_name'] ?? 'Your Company'); ?>">
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
<!-- Email -->
<div class="setting-card">
<div class="setting-title">Company Email</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="company_email">
<div class="form-group">
<input type="email" name="setting_value" class="form-control"
value="<?php echo htmlspecialchars($settings['company_email'] ?? 'info@company.com'); ?>">
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
<!-- Phone -->
<div class="setting-card">
<div class="setting-title">Company Phone</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="company_phone">
<div class="form-group">
<input type="tel" name="setting_value" class="form-control"
value="<?php echo htmlspecialchars($settings['company_phone'] ?? '+91-XXXXXXXXXX'); ?>">
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
<!-- Address -->
<div class="setting-card">
<div class="setting-title">Company Address</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="company_address">
<div class="form-group">
<textarea name="setting_value" class="form-control" rows="3"><?php echo htmlspecialchars($settings['company_address'] ?? ''); ?></textarea>
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
<!-- Financial Year Start Month -->
<div class="setting-card">
<div class="setting-title">Financial Year Start</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="fy_start_month">
<div class="form-group">
<select name="setting_value" class="form-control">
<option value="1" <?php echo ($settings['fy_start_month'] ?? '1') === '1' ? 'selected' : ''; ?>>January</option>
<option value="4" <?php echo ($settings['fy_start_month'] ?? '1') === '4' ? 'selected' : ''; ?>>April</option>
<option value="7" <?php echo ($settings['fy_start_month'] ?? '1') === '7' ? 'selected' : ''; ?>>July</option>
</select>
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
<!-- Leave Balance Limit -->
<div class="setting-card">
<div class="setting-title">Annual Leave Balance</div>
<form method="POST" class="setting-form">
<input type="hidden" name="setting_key" value="annual_leave_days">
<div class="form-group">
<input type="number" name="setting_value" class="form-control" min="1" max="60"
value="<?php echo htmlspecialchars($settings['annual_leave_days'] ?? '20'); ?>">
</div>
<button type="submit" class="btn btn-primary" style="font-size: 0.875rem;">Save</button>
</form>
</div>
</div>
<!-- System Information -->
<h2>System Information</h2>
<div class="info-section">
<div class="info-row">
<span class="info-label">PHP Version:</span>
<span class="info-value"><?php echo PHP_VERSION; ?></span>
</div>
<div class="info-row">
<span class="info-label">Server Software:</span>
<span class="info-value"><?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'N/A'; ?></span>
</div>
<div class="info-row">
<span class="info-label">Current Time:</span>
<span class="info-value"><?php echo date('d M Y H:i:s'); ?></span>
</div>
<div class="info-row">
<span class="info-label">Database Status:</span>
<span class="info-value" style="color: #10b981;">✓ Connected</span>
</div>
<div class="info-row">
<span class="info-label">Uploads Directory:</span>
<span class="info-value"><?php echo is_dir('../uploads') ? '✓ Exists' : '✖ Missing'; ?></span>
</div>
<div class="info-row">
<span class="info-label">Backups Directory:</span>
<span class="info-value"><?php echo is_dir('../backups') ? '✓ Exists' : '✖ Missing'; ?></span>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/js/app.js"></script>
<script>
// Load notifications
const notificationBell = document.getElementById('notificationBell');
const notificationDropdown = document.getElementById('notificationDropdown');
notificationBell.addEventListener('click', function(e) {
e.stopPropagation();
notificationDropdown.style.display = notificationDropdown.style.display === 'none' ? 'block' : 'none';
});
document.addEventListener('click', function() {
notificationDropdown.style.display = 'none';
});
</script>
</body>
</html>