|
|
|
@ -3,134 +3,120 @@ require_once 'includes/db.php';
|
|
|
|
require_once 'includes/auth.php';
|
|
|
|
require_once 'includes/auth.php';
|
|
|
|
|
|
|
|
|
|
|
|
checkAuth();
|
|
|
|
checkAuth();
|
|
|
|
checkAdmin(); // Tylko admin tu wejdzie
|
|
|
|
checkAdmin();
|
|
|
|
|
|
|
|
|
|
|
|
$message = '';
|
|
|
|
$message = '';
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
// 0. INICJALIZACJA DOMYŚLNYCH USTAWIEŃ FIRM (jeśli nie istnieją)
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
$default_settings = [
|
|
|
|
$default_settings = [
|
|
|
|
'company_1_name' => 'Moje Przedsiębiorstwo IT',
|
|
|
|
'company_1_name' => 'Moje Przedsiebiorstwo IT',
|
|
|
|
'company_1_details' => 'ul. Główna 1, 00-000 Warszawa | NIP: 0987654321',
|
|
|
|
'company_1_details' => 'ul. Glowna 1, 00-000 Warszawa | NIP: 0987654321',
|
|
|
|
'company_2_name' => 'Spółka Celowa Sp. z o.o.',
|
|
|
|
'company_2_name' => 'Spolka Celowa Sp. z o.o.',
|
|
|
|
'company_2_details' => 'ul. Przykładowa 10, 00-000 Warszawa | NIP: 1234567890 | KRS: 0000123456'
|
|
|
|
'company_2_details' => 'ul. Przykladowa 10, 00-000 Warszawa | NIP: 1234567890 | KRS: 0000123456'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($default_settings as $key => $val) {
|
|
|
|
foreach ($default_settings as $key => $val) {
|
|
|
|
// INSERT IGNORE dodaje wpis tylko wtedy, gdy taki klucz jeszcze nie istnieje w tabeli
|
|
|
|
|
|
|
|
$stmt = $pdo->prepare("INSERT IGNORE INTO " . DB_PREFIX . "settings (setting_key, setting_value) VALUES (?, ?)");
|
|
|
|
$stmt = $pdo->prepare("INSERT IGNORE INTO " . DB_PREFIX . "settings (setting_key, setting_value) VALUES (?, ?)");
|
|
|
|
$stmt->execute([$key, $val]);
|
|
|
|
$stmt->execute([$key, $val]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
// 1. WGRYWANIE LOGO
|
|
|
|
requireCsrfToken();
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['logo'])) {
|
|
|
|
if (isset($_FILES['logo'])) {
|
|
|
|
if ($_FILES['logo']['error'] === 0) {
|
|
|
|
if ($_FILES['logo']['error'] === 0) {
|
|
|
|
$upload_dir = 'uploads/';
|
|
|
|
$upload_dir = 'uploads/';
|
|
|
|
if (!is_dir($upload_dir)) mkdir($upload_dir, 0777, true);
|
|
|
|
if (!is_dir($upload_dir)) {
|
|
|
|
|
|
|
|
mkdir($upload_dir, 0755, true);
|
|
|
|
$file_ext = strtolower(pathinfo($_FILES['logo']['name'], PATHINFO_EXTENSION));
|
|
|
|
}
|
|
|
|
if(in_array($file_ext, ['jpg', 'jpeg', 'png', 'gif', 'svg'])) {
|
|
|
|
|
|
|
|
$new_name = 'logo_' . time() . '.' . $file_ext;
|
|
|
|
$tmpPath = $_FILES['logo']['tmp_name'];
|
|
|
|
$dest_path = $upload_dir . $new_name;
|
|
|
|
$mime = mime_content_type($tmpPath);
|
|
|
|
|
|
|
|
$allowedMimes = [
|
|
|
|
if (move_uploaded_file($_FILES['logo']['tmp_name'], $dest_path)) {
|
|
|
|
'image/jpeg' => 'jpg',
|
|
|
|
$stmt = $pdo->prepare("REPLACE INTO " . DB_PREFIX . "settings (setting_key, setting_value) VALUES ('logo_path', ?)");
|
|
|
|
'image/png' => 'png',
|
|
|
|
$stmt->execute([$dest_path]);
|
|
|
|
'image/gif' => 'gif',
|
|
|
|
$message = "<div class='alert alert-success'>Pomyślnie zaktualizowano logo!</div>";
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($allowedMimes[$mime]) && @getimagesize($tmpPath) !== false) {
|
|
|
|
|
|
|
|
$new_name = 'logo_' . bin2hex(random_bytes(8)) . '.' . $allowedMimes[$mime];
|
|
|
|
|
|
|
|
$dest_path = $upload_dir . $new_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (move_uploaded_file($tmpPath, $dest_path)) {
|
|
|
|
|
|
|
|
$stmt = $pdo->prepare("REPLACE INTO " . DB_PREFIX . "settings (setting_key, setting_value) VALUES ('logo_path', ?)");
|
|
|
|
|
|
|
|
$stmt->execute([$dest_path]);
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-success'>Pomyslnie zaktualizowano logo.</div>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-danger'>Nie udalo sie zapisac pliku.</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$message = "<div class='alert alert-danger'>Błąd: Nie udało się zapisać pliku. Sprawdź uprawnienia folderu 'uploads'.</div>";
|
|
|
|
$message = "<div class='alert alert-warning'>Dozwolone sa tylko prawidlowe pliki JPG, PNG i GIF.</div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-warning'>Błąd: Dozwolone są tylko pliki graficzne (JPG, PNG, GIF, SVG).</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif (isset($_POST['action']) && $_POST['action'] === 'update_company_settings') {
|
|
|
|
}
|
|
|
|
$settings_to_update = ['company_1_name', 'company_1_details', 'company_2_name', 'company_2_details'];
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
try {
|
|
|
|
// 1B. ZAPISYWANIE DANYCH FIRM
|
|
|
|
$pdo->beginTransaction();
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
$update_stmt = $pdo->prepare("UPDATE " . DB_PREFIX . "settings SET setting_value = ? WHERE setting_key = ?");
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_company_settings') {
|
|
|
|
|
|
|
|
$settings_to_update = ['company_1_name', 'company_1_details', 'company_2_name', 'company_2_details'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
$pdo->beginTransaction();
|
|
|
|
|
|
|
|
$update_stmt = $pdo->prepare("UPDATE " . DB_PREFIX . "settings SET setting_value = ? WHERE setting_key = ?");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($settings_to_update as $key) {
|
|
|
|
foreach ($settings_to_update as $key) {
|
|
|
|
if (isset($_POST[$key])) {
|
|
|
|
if (isset($_POST[$key])) {
|
|
|
|
$update_stmt->execute([trim($_POST[$key]), $key]);
|
|
|
|
$update_stmt->execute([trim($_POST[$key]), $key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$pdo->commit();
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-success'>Ustawienia firmowe zostaly zapisane.</div>";
|
|
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
|
|
|
$pdo->rollBack();
|
|
|
|
|
|
|
|
error_log($e->getMessage());
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-danger'>Nie udalo sie zapisac ustawien.</div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pdo->commit();
|
|
|
|
} elseif (isset($_POST['add_user'])) {
|
|
|
|
$message = "<div class='alert alert-success'>Ustawienia firmowe zostały zapisane!</div>";
|
|
|
|
$new_user = trim($_POST['new_username'] ?? '');
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
$new_pass = $_POST['new_password'] ?? '';
|
|
|
|
$pdo->rollBack();
|
|
|
|
$new_role = $_POST['new_role'] ?? 'user';
|
|
|
|
$message = "<div class='alert alert-danger'>Błąd zapisu: " . $e->getMessage() . "</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
if ($new_user !== '' && $new_pass !== '') {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
|
|
|
|
$new_email = trim($_POST['new_email'] ?? '');
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
$hashed_pass = password_hash($new_pass, PASSWORD_BCRYPT);
|
|
|
|
// 2. DODAWANIE UŻYTKOWNIKA
|
|
|
|
$stmt = $pdo->prepare("INSERT INTO " . DB_PREFIX . "users (username, email, password, role) VALUES (?, ?, ?, ?)");
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
$stmt->execute([$new_user, $new_email !== '' ? $new_email : null, $hashed_pass, $new_role === 'admin' ? 'admin' : 'user']);
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['add_user'])) {
|
|
|
|
$message = "<div class='alert alert-success'>Dodano nowego uzytkownika: <strong>" . e($new_user) . "</strong></div>";
|
|
|
|
$new_user = trim($_POST['new_username']);
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
$new_pass = $_POST['new_password'];
|
|
|
|
error_log($e->getMessage());
|
|
|
|
$new_role = $_POST['new_role'];
|
|
|
|
$message = "<div class='alert alert-danger'>Nie udalo sie dodac uzytkownika.</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif (isset($_POST['reset_password'])) {
|
|
|
|
|
|
|
|
$user_id = (int)($_POST['user_id'] ?? 0);
|
|
|
|
|
|
|
|
$new_pass = $_POST['new_password'] ?? '';
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($new_user) && !empty($new_pass)) {
|
|
|
|
if ($user_id > 0 && $new_pass !== '') {
|
|
|
|
try {
|
|
|
|
|
|
|
|
$hashed_pass = password_hash($new_pass, PASSWORD_BCRYPT);
|
|
|
|
$hashed_pass = password_hash($new_pass, PASSWORD_BCRYPT);
|
|
|
|
$stmt = $pdo->prepare("INSERT INTO " . DB_PREFIX . "users (username, password, role) VALUES (?, ?, ?)");
|
|
|
|
$stmt = $pdo->prepare("UPDATE " . DB_PREFIX . "users SET password = ? WHERE id = ?");
|
|
|
|
$stmt->execute([$new_user, $hashed_pass, $new_role]);
|
|
|
|
$stmt->execute([$hashed_pass, $user_id]);
|
|
|
|
$message = "<div class='alert alert-success'>Dodano nowego użytkownika: <strong>$new_user</strong></div>";
|
|
|
|
$message = "<div class='alert alert-info'>Zmieniono haslo dla wybranego uzytkownika.</div>";
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
}
|
|
|
|
$message = "<div class='alert alert-danger'>Błąd: Użytkownik o takiej nazwie prawdopodobnie już istnieje.</div>";
|
|
|
|
} elseif (isset($_POST['delete_user'])) {
|
|
|
|
|
|
|
|
$id_to_delete = (int)($_POST['user_id'] ?? 0);
|
|
|
|
|
|
|
|
if ($id_to_delete !== (int)$_SESSION['user_id']) {
|
|
|
|
|
|
|
|
$stmt = $pdo->prepare("DELETE FROM " . DB_PREFIX . "users WHERE id = ?");
|
|
|
|
|
|
|
|
$stmt->execute([$id_to_delete]);
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-success'>Uzytkownik zostal pomyslnie usuniety.</div>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-warning'>Nie mozesz usunac wlasnego konta administratora.</div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
$users = $pdo->query("SELECT id, username, email, role, oauth_provider, last_login_at FROM " . DB_PREFIX . "users ORDER BY username ASC")->fetchAll();
|
|
|
|
// 3. RESET HASŁA UŻYTKOWNIKA
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['reset_password'])) {
|
|
|
|
|
|
|
|
$user_id = (int)$_POST['user_id'];
|
|
|
|
|
|
|
|
$new_pass = $_POST['new_password'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($new_pass)) {
|
|
|
|
|
|
|
|
$hashed_pass = password_hash($new_pass, PASSWORD_BCRYPT);
|
|
|
|
|
|
|
|
$stmt = $pdo->prepare("UPDATE " . DB_PREFIX . "users SET password = ? WHERE id = ?");
|
|
|
|
|
|
|
|
$stmt->execute([$hashed_pass, $user_id]);
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-info'>Zmieniono hasło dla wybranego użytkownika.</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
// 4. USUWANIE UŻYTKOWNIKA
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
if (isset($_GET['delete'])) {
|
|
|
|
|
|
|
|
$id_to_delete = (int)$_GET['delete'];
|
|
|
|
|
|
|
|
if ($id_to_delete != $_SESSION['user_id']) {
|
|
|
|
|
|
|
|
$stmt = $pdo->prepare("DELETE FROM " . DB_PREFIX . "users WHERE id = ?");
|
|
|
|
|
|
|
|
$stmt->execute([$id_to_delete]);
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-success'>Użytkownik został pomyślnie usunięty.</div>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$message = "<div class='alert alert-warning'>Odmowa: Nie możesz usunąć własnego konta administratora!</div>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
// POBIERANIE DANYCH DO WIDOKU
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
$users = $pdo->query("SELECT id, username, role FROM " . DB_PREFIX . "users")->fetchAll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$settings = [];
|
|
|
|
$settings = [];
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$settings = $pdo->query("SELECT setting_key, setting_value FROM " . DB_PREFIX . "settings")->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
|
|
$settings = $pdo->query("SELECT setting_key, setting_value FROM " . DB_PREFIX . "settings")->fetchAll(PDO::FETCH_KEY_PAIR);
|
|
|
|
} catch(PDOException $e) {
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
// Zabezpieczenie na wypadek awarii tabeli settings
|
|
|
|
error_log($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$current_logo = $settings['logo_path'] ?? '';
|
|
|
|
$current_logo = $settings['logo_path'] ?? '';
|
|
|
|
@ -141,7 +127,7 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Panel Administratora - <?php echo defined('APP_NAME') ? APP_NAME : 'System'; ?></title>
|
|
|
|
<title>Panel administratora - <?php echo e(defined('APP_NAME') ? APP_NAME : 'System'); ?></title>
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
@ -154,20 +140,20 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4 shadow-sm">
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4 shadow-sm">
|
|
|
|
<div class="container">
|
|
|
|
<div class="container">
|
|
|
|
<a class="navbar-brand d-flex align-items-center" href="index.php">
|
|
|
|
<a class="navbar-brand d-flex align-items-center" href="index.php">
|
|
|
|
<?php if($current_logo && file_exists($current_logo)): ?>
|
|
|
|
<?php if ($current_logo && file_exists($current_logo)): ?>
|
|
|
|
<img src="<?php echo $current_logo; ?>" alt="Logo" class="logo-img me-2">
|
|
|
|
<img src="<?php echo e($current_logo); ?>" alt="Logo" class="logo-img me-2">
|
|
|
|
<?php else: ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<span class="me-2">💻</span>
|
|
|
|
<span class="me-2">IT</span>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<strong><?php echo defined('APP_NAME') ? APP_NAME : 'System IT'; ?></strong>
|
|
|
|
<strong><?php echo e(defined('APP_NAME') ? APP_NAME : 'System IT'); ?></strong>
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="navbar-nav ms-auto align-items-center">
|
|
|
|
<div class="navbar-nav ms-auto align-items-center">
|
|
|
|
<button class="btn btn-sm btn-outline-secondary me-3" onclick="toggleDarkMode()">
|
|
|
|
<button class="btn btn-sm btn-outline-secondary me-3" onclick="toggleDarkMode()">
|
|
|
|
<i class="bi bi-moon-stars" id="themeIcon"></i>
|
|
|
|
<i class="bi bi-moon-stars" id="themeIcon"></i>
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
<span class="nav-link text-light me-3 small">Admin: <strong><?php echo $_SESSION['username']; ?></strong></span>
|
|
|
|
<span class="nav-link text-light me-3 small">Admin: <strong><?php echo e($_SESSION['username']); ?></strong></span>
|
|
|
|
<a class="btn btn-outline-light btn-sm me-2" href="index.php"><i class="bi bi-arrow-left"></i> Powrót do zamówień</a>
|
|
|
|
<a class="btn btn-outline-light btn-sm me-2" href="index.php"><i class="bi bi-arrow-left"></i> Powrot do zamowien</a>
|
|
|
|
<a class="btn btn-outline-danger btn-sm" href="logout.php">Wyloguj</a>
|
|
|
|
<a class="btn btn-outline-danger btn-sm" href="logout.php">Wyloguj</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -175,30 +161,30 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
|
|
|
|
|
|
|
|
<div class="container pb-5">
|
|
|
|
<div class="container pb-5">
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
|
|
<h2>Panel Zarządzania Systemem</h2>
|
|
|
|
<h2>Panel zarzadzania systemem</h2>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<?php echo $message; ?>
|
|
|
|
<?php echo $message; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-5 mb-4">
|
|
|
|
<div class="col-md-5 mb-4">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="card shadow-sm mb-4 border-0">
|
|
|
|
<div class="card shadow-sm mb-4 border-0">
|
|
|
|
<div class="card-header bg-secondary text-white">
|
|
|
|
<div class="card-header bg-secondary text-white">
|
|
|
|
<i class="bi bi-image"></i> Ustawienia Wizualne
|
|
|
|
<i class="bi bi-image"></i> Ustawienia wizualne
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="card-body">
|
|
|
|
<form method="POST" enctype="multipart/form-data">
|
|
|
|
<form method="POST" enctype="multipart/form-data">
|
|
|
|
|
|
|
|
<?php echo csrfInput(); ?>
|
|
|
|
<div class="text-center mb-3">
|
|
|
|
<div class="text-center mb-3">
|
|
|
|
<?php if($current_logo && file_exists($current_logo)): ?>
|
|
|
|
<?php if ($current_logo && file_exists($current_logo)): ?>
|
|
|
|
<img src="<?php echo $current_logo; ?>" class="img-thumbnail" style="max-height: 80px;">
|
|
|
|
<img src="<?php echo e($current_logo); ?>" class="img-thumbnail" style="max-height: 80px;" alt="Logo">
|
|
|
|
<?php else: ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<div class="text-muted small">Brak wgranego logo</div>
|
|
|
|
<div class="text-muted small">Brak wgranego logo</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label class="form-label small">Zmień logotyp (PNG/JPG)</label>
|
|
|
|
<label class="form-label small">Zmien logotyp (PNG/JPG/GIF)</label>
|
|
|
|
<input type="file" name="logo" class="form-control form-control-sm" accept="image/*" required>
|
|
|
|
<input type="file" name="logo" class="form-control form-control-sm" accept=".png,.jpg,.jpeg,.gif" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-dark w-100 btn-sm">Wgraj plik na serwer</button>
|
|
|
|
<button type="submit" class="btn btn-dark w-100 btn-sm">Wgraj plik na serwer</button>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
@ -207,28 +193,29 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
|
|
|
|
|
|
|
|
<div class="card shadow-sm border-0 mb-4">
|
|
|
|
<div class="card shadow-sm border-0 mb-4">
|
|
|
|
<div class="card-header bg-info text-dark fw-bold">
|
|
|
|
<div class="card-header bg-info text-dark fw-bold">
|
|
|
|
<i class="bi bi-buildings"></i> Dane firm (Stopki wydruków)
|
|
|
|
<i class="bi bi-buildings"></i> Dane firm
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="card-body">
|
|
|
|
<form method="POST">
|
|
|
|
<form method="POST">
|
|
|
|
|
|
|
|
<?php echo csrfInput(); ?>
|
|
|
|
<input type="hidden" name="action" value="update_company_settings">
|
|
|
|
<input type="hidden" name="action" value="update_company_settings">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label class="form-label small fw-bold text-primary">1. Przedsiębiorstwo (Nazwa)</label>
|
|
|
|
<label class="form-label small fw-bold text-primary">1. Przedsiebiorstwo (Nazwa)</label>
|
|
|
|
<input type="text" name="company_1_name" class="form-control form-control-sm border-primary" value="<?php echo htmlspecialchars($settings['company_1_name'] ?? ''); ?>" required>
|
|
|
|
<input type="text" name="company_1_name" class="form-control form-control-sm border-primary" value="<?php echo e($settings['company_1_name'] ?? ''); ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
|
|
<div class="mb-4">
|
|
|
|
<label class="form-label small fw-bold text-primary">Przedsiębiorstwo (Adres/NIP)</label>
|
|
|
|
<label class="form-label small fw-bold text-primary">Przedsiebiorstwo (Adres/NIP)</label>
|
|
|
|
<input type="text" name="company_1_details" class="form-control form-control-sm" value="<?php echo htmlspecialchars($settings['company_1_details'] ?? ''); ?>">
|
|
|
|
<input type="text" name="company_1_details" class="form-control form-control-sm" value="<?php echo e($settings['company_1_details'] ?? ''); ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mb-3 border-top pt-3">
|
|
|
|
<div class="mb-3 border-top pt-3">
|
|
|
|
<label class="form-label small fw-bold text-success">2. Spółka (Nazwa)</label>
|
|
|
|
<label class="form-label small fw-bold text-success">2. Spolka (Nazwa)</label>
|
|
|
|
<input type="text" name="company_2_name" class="form-control form-control-sm border-success" value="<?php echo htmlspecialchars($settings['company_2_name'] ?? ''); ?>" required>
|
|
|
|
<input type="text" name="company_2_name" class="form-control form-control-sm border-success" value="<?php echo e($settings['company_2_name'] ?? ''); ?>" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
|
|
<div class="mb-4">
|
|
|
|
<label class="form-label small fw-bold text-success">Spółka (Adres/NIP/KRS)</label>
|
|
|
|
<label class="form-label small fw-bold text-success">Spolka (Adres/NIP/KRS)</label>
|
|
|
|
<input type="text" name="company_2_details" class="form-control form-control-sm" value="<?php echo htmlspecialchars($settings['company_2_details'] ?? ''); ?>">
|
|
|
|
<input type="text" name="company_2_details" class="form-control form-control-sm" value="<?php echo e($settings['company_2_details'] ?? ''); ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<button type="submit" class="btn btn-info w-100 btn-sm fw-bold text-dark"><i class="bi bi-save"></i> Zapisz stopki firm</button>
|
|
|
|
<button type="submit" class="btn btn-info w-100 btn-sm fw-bold text-dark"><i class="bi bi-save"></i> Zapisz stopki firm</button>
|
|
|
|
@ -242,26 +229,30 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="card-body">
|
|
|
|
<form method="POST">
|
|
|
|
<form method="POST">
|
|
|
|
|
|
|
|
<?php echo csrfInput(); ?>
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label class="form-label small">Login użytkownika</label>
|
|
|
|
<label class="form-label small">Login uzytkownika</label>
|
|
|
|
<input type="text" name="new_username" class="form-control" required>
|
|
|
|
<input type="text" name="new_username" class="form-control" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label class="form-label small">Hasło początkowe</label>
|
|
|
|
<label class="form-label small">Haslo poczatkowe</label>
|
|
|
|
<input type="password" name="new_password" class="form-control" required>
|
|
|
|
<input type="password" name="new_password" class="form-control" required minlength="8">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
|
|
|
<label class="form-label small">Email do powiazania z Microsoft 365</label>
|
|
|
|
|
|
|
|
<input type="email" name="new_email" class="form-control" placeholder="np. user@firma.pl">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label class="form-label small">Rola w systemie</label>
|
|
|
|
<label class="form-label small">Rola w systemie</label>
|
|
|
|
<select name="new_role" class="form-select">
|
|
|
|
<select name="new_role" class="form-select">
|
|
|
|
<option value="user">Zwykły pracownik</option>
|
|
|
|
<option value="user">Zwykly pracownik</option>
|
|
|
|
<option value="admin">Administrator</option>
|
|
|
|
<option value="admin">Administrator</option>
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button type="submit" name="add_user" class="btn btn-primary w-100"><i class="bi bi-check2-circle"></i> Utwórz konto</button>
|
|
|
|
<button type="submit" name="add_user" class="btn btn-primary w-100"><i class="bi bi-check2-circle"></i> Utworz konto</button>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="col-md-7">
|
|
|
|
<div class="col-md-7">
|
|
|
|
@ -276,49 +267,62 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<th class="px-3">ID</th>
|
|
|
|
<th class="px-3">ID</th>
|
|
|
|
<th>Login</th>
|
|
|
|
<th>Login</th>
|
|
|
|
|
|
|
|
<th>Email</th>
|
|
|
|
<th>Uprawnienia</th>
|
|
|
|
<th>Uprawnienia</th>
|
|
|
|
<th class="text-end px-4">Zarządzaj</th>
|
|
|
|
<th>Zrodlo</th>
|
|
|
|
|
|
|
|
<th class="text-end px-4">Zarzadzaj</th>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tbody>
|
|
|
|
<?php foreach ($users as $u): ?>
|
|
|
|
<?php foreach ($users as $u): ?>
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td class="px-3 text-muted"><?php echo $u['id']; ?></td>
|
|
|
|
<td class="px-3 text-muted"><?php echo (int)$u['id']; ?></td>
|
|
|
|
<td><strong><?php echo htmlspecialchars($u['username']); ?></strong></td>
|
|
|
|
<td><strong><?php echo e($u['username']); ?></strong></td>
|
|
|
|
|
|
|
|
<td class="small text-muted"><?php echo e($u['email'] ?? ''); ?></td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
|
|
|
|
<span class="badge <?php echo $u['role'] === 'admin' ? 'bg-danger' : 'bg-primary'; ?>">
|
|
|
|
|
|
|
|
<?php echo $u['role'] === 'admin' ? 'Administrator' : 'Uzytkownik'; ?>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<td>
|
|
|
|
<span class="badge <?php echo $u['role'] == 'admin' ? 'bg-danger' : 'bg-primary'; ?>">
|
|
|
|
<span class="badge <?php echo $u['oauth_provider'] === 'microsoft' ? 'bg-success' : 'bg-secondary'; ?>">
|
|
|
|
<?php echo $u['role'] == 'admin' ? 'Administrator' : 'Użytkownik'; ?>
|
|
|
|
<?php echo $u['oauth_provider'] === 'microsoft' ? 'Microsoft 365' : 'Lokalne'; ?>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
</td>
|
|
|
|
<td class="text-end px-3">
|
|
|
|
<td class="text-end px-3">
|
|
|
|
<button class="btn btn-sm btn-outline-info me-1" data-bs-toggle="modal" data-bs-target="#resetModal<?php echo $u['id']; ?>">
|
|
|
|
<button class="btn btn-sm btn-outline-info me-1" data-bs-toggle="modal" data-bs-target="#resetModal<?php echo (int)$u['id']; ?>">
|
|
|
|
<i class="bi bi-shield-lock"></i> Reset hasła
|
|
|
|
<i class="bi bi-shield-lock"></i> Reset hasla
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if ($u['id'] != $_SESSION['user_id']): ?>
|
|
|
|
<?php if ((int)$u['id'] !== (int)$_SESSION['user_id']): ?>
|
|
|
|
<a href="?delete=<?php echo $u['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Czy na pewno chcesz bezpowrotnie usunąć to konto?')">
|
|
|
|
<form method="POST" class="d-inline" onsubmit="return confirm('Czy na pewno chcesz bezpowrotnie usunac to konto?')">
|
|
|
|
<i class="bi bi-trash"></i> Usuń
|
|
|
|
<?php echo csrfInput(); ?>
|
|
|
|
</a>
|
|
|
|
<input type="hidden" name="user_id" value="<?php echo (int)$u['id']; ?>">
|
|
|
|
|
|
|
|
<button type="submit" name="delete_user" class="btn btn-sm btn-outline-danger">
|
|
|
|
|
|
|
|
<i class="bi bi-trash"></i> Usun
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
<?php else: ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<button class="btn btn-sm btn-outline-secondary disabled"><i class="bi bi-person-check"></i> To ty</button>
|
|
|
|
<button class="btn btn-sm btn-outline-secondary disabled"><i class="bi bi-person-check"></i> To ty</button>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="modal fade" id="resetModal<?php echo $u['id']; ?>" tabindex="-1" aria-hidden="true">
|
|
|
|
<div class="modal fade" id="resetModal<?php echo (int)$u['id']; ?>" tabindex="-1" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-sm modal-dialog-centered">
|
|
|
|
<div class="modal-dialog modal-sm modal-dialog-centered">
|
|
|
|
<div class="modal-content text-start">
|
|
|
|
<div class="modal-content text-start">
|
|
|
|
<form method="POST">
|
|
|
|
<form method="POST">
|
|
|
|
|
|
|
|
<?php echo csrfInput(); ?>
|
|
|
|
<div class="modal-header bg-light">
|
|
|
|
<div class="modal-header bg-light">
|
|
|
|
<h6 class="modal-title"><i class="bi bi-key"></i> Nowe hasło: <?php echo $u['username']; ?></h6>
|
|
|
|
<h6 class="modal-title"><i class="bi bi-key"></i> Nowe haslo: <?php echo e($u['username']); ?></h6>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="modal-body">
|
|
|
|
<input type="hidden" name="user_id" value="<?php echo $u['id']; ?>">
|
|
|
|
<input type="hidden" name="user_id" value="<?php echo (int)$u['id']; ?>">
|
|
|
|
<label class="form-label small">Wpisz nowe hasło:</label>
|
|
|
|
<label class="form-label small">Wpisz nowe haslo:</label>
|
|
|
|
<input type="password" name="new_password" class="form-control" required minlength="4">
|
|
|
|
<input type="password" name="new_password" class="form-control" required minlength="8">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Anuluj</button>
|
|
|
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Anuluj</button>
|
|
|
|
<button type="submit" name="reset_password" class="btn btn-info btn-sm text-white">Zapisz hasło</button>
|
|
|
|
<button type="submit" name="reset_password" class="btn btn-info btn-sm text-white">Zapisz haslo</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -349,7 +353,7 @@ $current_logo = $settings['logo_path'] ?? '';
|
|
|
|
localStorage.setItem('theme', newTheme);
|
|
|
|
localStorage.setItem('theme', newTheme);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(localStorage.getItem('theme') === 'dark') {
|
|
|
|
if (localStorage.getItem('theme') === 'dark') {
|
|
|
|
document.getElementById('mainHtml').setAttribute('data-bs-theme', 'dark');
|
|
|
|
document.getElementById('mainHtml').setAttribute('data-bs-theme', 'dark');
|
|
|
|
document.getElementById('themeIcon').classList.replace('bi-moon-stars', 'bi-sun');
|
|
|
|
document.getElementById('themeIcon').classList.replace('bi-moon-stars', 'bi-sun');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|