Auto commit: 2025-11-02T19:50:28.947Z

This commit is contained in:
Flatlogic Bot 2025-11-02 19:50:28 +00:00
parent 9e7d84b413
commit 1d5ec407b8
7 changed files with 388 additions and 148 deletions

54
add_member.php Normal file
View File

@ -0,0 +1,54 @@
<?php
session_start();
require_once 'db/config.php';
$status = 'error';
$message = 'An unexpected error occurred.';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$role = trim($_POST['role'] ?? '');
if (empty($name) || empty($email) || empty($role)) {
$message = 'Please fill in all required fields.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$message = 'Please provide a valid email address.';
} else {
try {
$db = db();
// Check if email already exists
$stmt = $db->prepare("SELECT id FROM team_members WHERE email = :email");
$stmt->bindParam(':email', $email);
$stmt->execute();
if ($stmt->fetch()) {
$message = 'A member with this email address already exists.';
} else {
// Insert new member
$sql = "INSERT INTO team_members (name, email, role) VALUES (:name, :email, :role)";
$stmt = $db->prepare($sql);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':role', $role);
if ($stmt->execute()) {
$status = 'success';
$message = 'New team member added successfully!';
} else {
$message = 'Failed to add new member. Please try again.';
}
}
} catch (PDOException $e) {
// In a real app, log the error instead of showing it to the user
// error_log($e->getMessage());
$message = 'Database error. Could not add member.';
}
}
} else {
$message = 'Invalid request method.';
}
header('Location: team.php?status=' . $status . '&msg=' . urlencode($message));
exit();

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

@ -0,0 +1,79 @@
/*
* Custom Styles for TEST-CRM-APLIKACIJA
* Palette:
* Primary: #3B82F6
* Secondary: #6B7280
* Background: #F9FAFB
* Surface/Card: #FFFFFF
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #F9FAFB;
color: #374151; /* Gray 700 */
}
.navbar {
background-color: #FFFFFF;
border-bottom: 1px solid #E5E7EB; /* Gray 200 */
}
.btn-primary {
background-color: #3B82F6;
border-color: #3B82F6;
font-weight: 500;
}
.btn-primary:hover {
background-color: #2563EB;
border-color: #2563EB;
}
.card {
border: 1px solid #E5E7EB; /* Gray 200 */
border-radius: 0.5rem; /* rounded-lg */
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}
.table {
background-color: #FFFFFF;
}
.table thead th {
border-bottom-width: 1px;
border-color: #E5E7EB; /* Gray 200 */
font-weight: 600;
color: #4B5563; /* Gray 600 */
text-transform: uppercase;
letter-spacing: 0.05em;
font-size: 0.75rem;
}
.badge {
font-weight: 500;
font-size: 0.75rem;
padding: 0.3em 0.6em;
}
.modal-content {
border-radius: 0.5rem;
border: none;
}
.form-label {
font-weight: 500;
color: #374151; /* Gray 700 */
}
.toast {
width: 350px;
max-width: 100%;
font-size: .875rem;
background-color: rgba(255,255,255,.85);
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.1);
box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
border-radius: .25rem;
}

33
db/setup.php Normal file
View File

@ -0,0 +1,33 @@
<?php
require_once 'config.php';
try {
$db = db();
$sql = "
CREATE TABLE IF NOT EXISTS `team_members` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL UNIQUE,
`role` VARCHAR(100) NOT NULL,
`status` VARCHAR(50) DEFAULT 'active',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);";
$db->exec($sql);
echo "Table 'team_members' created successfully (if it didn't exist).<br>";
// Optional: Seed with some data
$stmt = $db->query("SELECT COUNT(*) FROM team_members");
if ($stmt->fetchColumn() == 0) {
$seed_sql = "
INSERT INTO `team_members` (name, email, role, status) VALUES
('John Doe', 'john.doe@example.com', 'Admin', 'active'),
('Jane Smith', 'jane.smith@example.com', 'Project Manager', 'active'),
('Peter Jones', 'peter.jones@example.com', 'Team Member', 'inactive');
";
$db->exec($seed_sql);
echo "Seeded 'team_members' table with initial data.<br>";
}
} catch (PDOException $e) {
die("DB setup failed: " . $e->getMessage());
}

45
includes/footer.php Normal file
View File

@ -0,0 +1,45 @@
</main>
<!-- Toast Container -->
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
<div id="notificationToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto" id="toastTitle"></strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body" id="toastBody">
</div>
</div>
</div>
<!-- Bootstrap 5 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
const status = urlParams.get('status');
const msg = urlParams.get('msg');
if (status && msg) {
const toastEl = document.getElementById('notificationToast');
const toastTitleEl = document.getElementById('toastTitle');
const toastBodyEl = document.getElementById('toastBody');
toastTitleEl.textContent = status === 'success' ? 'Success' : 'Error';
toastBodyEl.textContent = decodeURIComponent(msg);
toastEl.classList.remove('hide');
toastEl.classList.add('show');
if(status === 'success') {
toastEl.classList.add('bg-success-subtle');
} else {
toastEl.classList.add('bg-danger-subtle');
}
const toast = new bootstrap.Toast(toastEl);
toast.show();
}
});
</script>
</body>
</html>

47
includes/header.php Normal file
View File

@ -0,0 +1,47 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TEST-CRM-APLIKACIJA</title>
<meta name="description" content="Built with Flatlogic Generator">
<meta name="keywords" content="crm, customer relationship management, project management, team collaboration, invoicing, sales, leads, flatlogic">
<meta property="og:title" content="TEST-CRM-APLIKACIJA">
<meta property="og:description" content="Built with Flatlogic Generator">
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.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 bg-white shadow-sm">
<div class="container-fluid">
<a class="navbar-brand fw-bold text-primary" href="index.php">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">
<li class="nav-item">
<a class="nav-link" href="index.php">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="team.php">Team</a>
</li>
<!-- Other links will go here -->
</ul>
</div>
</div>
</nav>
<main class="container-fluid mt-4">

169
index.php
View File

@ -1,150 +1,23 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
<?php require_once 'includes/header.php'; ?>
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
<div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold">Welcome to your CRM</h1>
<div class="col-lg-6 mx-auto">
<p class="lead mb-4">This is the starting point for your new application. We've set up a sample "Team Members" page for you to get started.</p>
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a href="team.php" class="btn btn-primary btn-lg px-4 gap-3">Manage Team Members</a>
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Learn More</button>
</div>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
</div>
<?php
// This will run the setup script one time
if (!file_exists('db/setup_done.flag')) {
echo '<div class="container"><div class="alert alert-info">Running one-time database setup...</div></div>';
include 'db/setup.php';
file_put_contents('db/setup_done.flag', 'done');
}
?>
<?php require_once 'includes/footer.php'; ?>

109
team.php Normal file
View File

@ -0,0 +1,109 @@
<?php
require_once 'includes/header.php';
require_once 'db/config.php';
// Fetch team members
$members = [];
try {
$db = db();
$stmt = $db->query("SELECT id, name, email, role, status, created_at FROM team_members ORDER BY created_at DESC");
$members = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// In a real app, you'd log this error. For now, we'll just show a message.
echo '<div class="alert alert-danger">Could not connect to the database.</div>';
}
?>
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h1 class="h4 mb-0">Team Members</h1>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addMemberModal">
<i class="bi bi-plus-lg"></i> Add Member
</button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Role</th>
<th scope="col">Status</th>
<th scope="col">Joined</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($members)): ?>
<tr>
<td colspan="6" class="text-center text-muted">No team members found. Add one to get started!</td>
</tr>
<?php else: ?>
<?php foreach ($members as $member): ?>
<tr>
<td class="fw-medium"><?php echo htmlspecialchars($member['name']); ?></td>
<td><?php echo htmlspecialchars($member['email']); ?></td>
<td><?php echo htmlspecialchars($member['role']); ?></td>
<td>
<?php
$status_class = $member['status'] === 'active' ? 'bg-success-subtle text-success-emphasis' : 'bg-secondary-subtle text-secondary-emphasis';
echo '<span class="badge ' . $status_class . '">' . htmlspecialchars(ucfirst($member['status'])) . '</span>';
?>
</td>
<td><?php echo date('M d, Y', strtotime($member['created_at'])); ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil"></i></a>
<a href="#" class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Add Member Modal -->
<div class="modal fade" id="addMemberModal" tabindex="-1" aria-labelledby="addMemberModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addMemberModalLabel">Add New Team Member</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="add_member.php" method="POST">
<div class="modal-body">
<div class="mb-3">
<label for="name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role" required>
<option selected disabled value="">Choose...</option>
<option value="Admin">Admin</option>
<option value="Project Manager">Project Manager</option>
<option value="Team Member">Team Member</option>
<option value="Sales/Lead Manager">Sales/Lead Manager</option>
<option value="Finance">Finance</option>
<option value="Support Agent">Support Agent</option>
<option value="Client">Client</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save Member</button>
</div>
</form>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>