172 lines
8.1 KiB
PHP
172 lines
8.1 KiB
PHP
<?php
|
||
session_start();
|
||
require_once 'db/config.php';
|
||
|
||
$is_logged_in = isset($_SESSION['user_id']);
|
||
$user_permissions = [];
|
||
$contacts = [];
|
||
|
||
if ($is_logged_in) {
|
||
$pdo = db();
|
||
$stmt = $pdo->prepare("SELECT can_view, can_add, can_delete, can_edit, is_admin FROM users WHERE id = ?");
|
||
$stmt->execute([$_SESSION['user_id']]);
|
||
$user_permissions = $stmt->fetch();
|
||
|
||
if ($user_permissions['can_view']) {
|
||
$stmt = $pdo->query("SELECT * FROM contacts");
|
||
$contacts = $stmt->fetchAll();
|
||
}
|
||
}
|
||
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="tr">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>rehber</title>
|
||
<meta name="description" content="Built with Flatlogic Generator">
|
||
<meta name="keywords" content="rehber, contact management, web application, user directory, online address book, contact list, php directory, Built with Flatlogic Generator">
|
||
|
||
<meta property="og:title" content="rehber">
|
||
<meta property="og:description" content="Built with Flatlogic Generator">
|
||
<meta property="og:image" content="">
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta name="twitter:image" content="">
|
||
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||
<link rel="stylesheet" href="assets/css/custom.css">
|
||
</head>
|
||
<body>
|
||
|
||
<?php if ($is_logged_in && $user_permissions['can_view']): ?>
|
||
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
||
<div class="container-fluid">
|
||
<a class="navbar-brand" href="/">
|
||
<?php
|
||
$logo_path = 'assets/images/logo.png';
|
||
if (file_exists($logo_path)) {
|
||
echo '<img src="' . $logo_path . '?v=' . time() . '" alt="Logo" style="max-height: 40px; margin-right: 10px;">';
|
||
} else {
|
||
echo '<i class="bi bi-book-half me-2"></i>';
|
||
}
|
||
?>
|
||
rehber
|
||
</a>
|
||
<div class="d-flex">
|
||
<a href="logout.php" class="btn btn-outline-secondary">Çıkış Yap</a>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<main class="container my-4">
|
||
<div class="d-flex justify-content-between align-items-center mb-4 flex-wrap">
|
||
<h1 class="h2">Contact Directory</h1>
|
||
<div class="d-flex gap-2">
|
||
<?php if ($user_permissions['can_add']): ?>
|
||
<button class="btn btn-primary">
|
||
<i class="bi bi-plus-circle me-2"></i>Add Record
|
||
</button>
|
||
<?php endif; ?>
|
||
<button class="btn btn-outline-secondary">
|
||
<i class="bi bi-box-arrow-up-right me-2"></i>Export
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card p-3">
|
||
<div class="row mb-3">
|
||
<div class="col-md-6">
|
||
<div class="input-group">
|
||
<span class="input-group-text"><i class="bi bi-search"></i></span>
|
||
<input type="text" id="searchInput" class="form-control" placeholder="Search contacts...">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="table-responsive">
|
||
<table class="table table-striped table-hover align-middle">
|
||
<thead class="thead-light">
|
||
<tr>
|
||
<th class="sortable-header" data-column-index="0">Cust. Code <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="1">Ticari Unvan <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="2">Şehir <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="3">Ad Soyad <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="4">Telefon <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="5">E-posta <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="sortable-header" data-column-index="6">Grup <i class="bi bi-arrow-down-up"></i></th>
|
||
<th class="text-end">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="contactTableBody">
|
||
<?php foreach ($contacts as $contact): ?>
|
||
<tr>
|
||
<td><?php echo htmlspecialchars($contact['Cust.Code']); ?></td>
|
||
<td><?php echo htmlspecialchars($contact['Ticari Unvan']); ?></td>
|
||
<td><?php echo htmlspecialchars($contact['Sehir']); ?></td>
|
||
<td><?php echo htmlspecialchars($contact['Ad'] . ' ' . $contact['Soyad']); ?></td>
|
||
<td><?php echo htmlspecialchars($contact['Telefon']); ?></td>
|
||
<td><a href="mailto:<?php echo htmlspecialchars($contact['E-posta']); ?>"><?php echo htmlspecialchars($contact['E-posta']); ?></a></td>
|
||
<td><span class="badge bg-secondary bg-opacity-25 text-dark"><?php echo htmlspecialchars($contact['Grup Adı']); ?></span></td>
|
||
<td class="text-end">
|
||
<?php if ($user_permissions['can_edit']): ?>
|
||
<a href="#" class="action-icon me-2" data-bs-toggle="tooltip" title="Edit"><i class="bi bi-pencil-square"></i></a>
|
||
<?php endif; ?>
|
||
<?php if ($user_permissions['can_delete']): ?>
|
||
<a href="#" class="action-icon" data-bs-toggle="tooltip" title="Delete"><i class="bi bi-trash"></i></a>
|
||
<?php endif; ?>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
<footer class="text-center text-muted py-4">
|
||
<small>© <?php echo date("Y"); ?> rehber. All rights reserved.</small><br>
|
||
<small>Built with Flatlogic Generator</small>
|
||
</footer>
|
||
|
||
<?php if ($user_permissions['is_admin']): ?>
|
||
<div style="position: fixed; bottom: 10px; left: 10px; z-index: 1030;">
|
||
<a href="admin.php" class="btn btn-outline-secondary btn-sm">
|
||
<i class="bi bi-gear"></i> Admin Panel
|
||
</a>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php else: ?>
|
||
<div class="container">
|
||
<div class="row justify-content-center align-items-center vh-100">
|
||
<div class="col-md-6 text-center">
|
||
<h1 class="mb-4">Seyidoğlu Asistan Rehber Sistemine Hoşgeldiniz</h1>
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">Giriş Yap</h5>
|
||
<?php if (isset($_GET['error'])): ?>
|
||
<div class="alert alert-danger">Kullanıcı adı veya şifre hatalı.</div>
|
||
<?php endif; ?>
|
||
<form action="login.php" method="post">
|
||
<div class="mb-3">
|
||
<input type="text" name="username" class="form-control" placeholder="Kullanıcı Adı" required>
|
||
</div>
|
||
<div class="mb-3">
|
||
<input type="password" name="password" class="form-control" placeholder="Şifre" required>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary">Giriş</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||
<script src="assets/js/main.js"></script>
|
||
</body>
|
||
</html>
|