Compare commits

..

No commits in common. "ai-dev" and "master" have entirely different histories.

19 changed files with 143 additions and 947 deletions

View File

@ -1,34 +0,0 @@
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #F8F9FA;
color: #212529;
}
.navbar-brand {
font-weight: 700;
}
.hero {
background: linear-gradient(to bottom, rgba(13, 110, 253, 0.05), rgba(255, 255, 255, 0));
padding: 6rem 0;
}
.hero h1 {
font-weight: 800;
font-size: 3.5rem;
}
.feature-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 4rem;
height: 4rem;
border-radius: 0.75rem;
}
.footer {
padding: 3rem 0;
background-color: #FFFFFF;
}

View File

@ -1 +0,0 @@
// No custom JS needed for this initial step, but the file is here for future use.

View File

@ -1,303 +0,0 @@
<?php
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/header.php';
$pdo = db();
$user_id = $_SESSION['user_id'];
$errors = [];
$success_message = '';
// First, get the company_id for the logged-in user
$stmt = $pdo->prepare("SELECT id FROM companies WHERE user_id = ?");
$stmt->execute([$user_id]);
$company = $stmt->fetch();
$company_id = $company ? $company['id'] : null;
// Handle POST requests
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $company_id) {
$action = $_POST['action'] ?? '';
// ADD ACCOUNT
if ($action === 'add_account') {
$account_code = trim($_POST['account_code'] ?? '');
$account_name = trim($_POST['account_name'] ?? '');
$account_type = trim($_POST['account_type'] ?? '');
$description = trim($_POST['description'] ?? '');
if (empty($account_code) || empty($account_name) || empty($account_type)) {
$errors[] = 'Account Code, Name, and Type are required.';
}
if (empty($errors)) {
$stmt = $pdo->prepare("INSERT INTO chart_of_accounts (company_id, account_code, account_name, account_type, description) VALUES (?, ?, ?, ?, ?)");
if ($stmt->execute([$company_id, $account_code, $account_name, $account_type, $description])) {
$success_message = 'Account added successfully!';
} else {
$errors[] = 'Failed to add account. The account code may already exist.';
}
}
}
// EDIT ACCOUNT
if ($action === 'edit_account') {
$account_id = $_POST['account_id'] ?? null;
$account_code = trim($_POST['account_code'] ?? '');
$account_name = trim($_POST['account_name'] ?? '');
$account_type = trim($_POST['account_type'] ?? '');
$description = trim($_POST['description'] ?? '');
if (empty($account_id) || empty($account_code) || empty($account_name) || empty($account_type)) {
$errors[] = 'All fields are required for editing.';
}
if (empty($errors)) {
$stmt = $pdo->prepare("UPDATE chart_of_accounts SET account_code = ?, account_name = ?, account_type = ?, description = ? WHERE id = ? AND company_id = ?");
if ($stmt->execute([$account_code, $account_name, $account_type, $description, $account_id, $company_id])) {
$success_message = 'Account updated successfully!';
} else {
$errors[] = 'Failed to update account. The account code may already exist for another account.';
}
}
}
// DELETE ACCOUNT
if ($action === 'delete_account') {
$account_id = $_POST['account_id'] ?? null;
if (empty($account_id)) {
$errors[] = 'Invalid account for deletion.';
}
if (empty($errors)) {
$stmt = $pdo->prepare("DELETE FROM chart_of_accounts WHERE id = ? AND company_id = ?");
if ($stmt->execute([$account_id, $company_id])) {
$success_message = 'Account deleted successfully!';
} else {
$errors[] = 'Failed to delete account.';
}
}
}
}
// Fetch all accounts for the company
$accounts = [];
if ($company_id) {
$stmt = $pdo->prepare("SELECT * FROM chart_of_accounts WHERE company_id = ? ORDER BY account_code");
$stmt->execute([$company_id]);
$accounts = $stmt->fetchAll();
}
require_once __DIR__ . '/includes/sidebar.php';
?>
<div class="d-flex justify-content-between align-items-center">
<h1 class="h2">Chart of Accounts</h1>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addAccountModal">Add New Account</button>
</div>
<p>This is the list of all financial accounts for your company.</p>
<?php if (!$company_id): ?>
<div class="alert alert-warning">Please <a href="/company_setup.php">set up your company</a> before managing accounts.</div>
<?php endif; ?>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo htmlspecialchars($error); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($success_message)): ?>
<div class="alert alert-success">
<p class="mb-0"><?php echo htmlspecialchars($success_message); ?></p>
</div>
<?php endif; ?>
<div class="card mt-4">
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Code</th>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (!empty($accounts)): ?>
<?php foreach ($accounts as $account): ?>
<tr>
<td><?php echo htmlspecialchars($account['account_code']); ?></td>
<td><?php echo htmlspecialchars($account['account_name']); ?></td>
<td><?php echo htmlspecialchars($account['account_type']); ?></td>
<td><?php echo htmlspecialchars($account['description']); ?></td>
<td>
<button class="btn btn-sm btn-outline-primary edit-btn"
data-bs-toggle="modal"
data-bs-target="#editAccountModal"
data-id="<?php echo $account['id']; ?>"
data-code="<?php echo htmlspecialchars($account['account_code']); ?>"
data-name="<?php echo htmlspecialchars($account['account_name']); ?>"
data-type="<?php echo htmlspecialchars($account['account_type']); ?>"
data-description="<?php echo htmlspecialchars($account['description']); ?>">
Edit
</button>
<button class="btn btn-sm btn-outline-danger delete-btn"
data-bs-toggle="modal"
data-bs-target="#deleteAccountModal"
data-id="<?php echo $account['id']; ?>">
Delete
</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center">No accounts found. Please add one.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<!-- Add Account Modal -->
<div class="modal fade" id="addAccountModal" tabindex="-1" aria-labelledby="addAccountModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addAccountModalLabel">Add New Account</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="/chart_of_accounts.php" method="POST">
<input type="hidden" name="action" value="add_account">
<div class="mb-3">
<label for="accountCode" class="form-label">Account Code</label>
<input type="text" class="form-control" id="accountCode" name="account_code" required>
</div>
<div class="mb-3">
<label for="accountName" class="form-label">Account Name</label>
<input type="text" class="form-control" id="accountName" name="account_name" required>
</div>
<div class="mb-3">
<label for="accountType" class="form-label">Account Type</label>
<select class="form-select" id="accountType" name="account_type" required>
<option value="" disabled selected>Select a type</option>
<option value="Asset">Asset</option>
<option value="Liability">Liability</option>
<option value="Equity">Equity</option>
<option value="Revenue">Revenue</option>
<option value="Expense">Expense</option>
</select>
</div>
<div class="mb-3">
<label for="accountDescription" class="form-label">Description</label>
<textarea class="form-control" id="accountDescription" name="description" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Save Account</button>
</form>
</div>
</div>
</div>
</div>
<!-- Edit Account Modal -->
<div class="modal fade" id="editAccountModal" tabindex="-1" aria-labelledby="editAccountModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editAccountModalLabel">Edit Account</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="/chart_of_accounts.php" method="POST">
<input type="hidden" name="action" value="edit_account">
<input type="hidden" name="account_id" id="editAccountId">
<div class="mb-3">
<label for="editAccountCode" class="form-label">Account Code</label>
<input type="text" class="form-control" id="editAccountCode" name="account_code" required>
</div>
<div class="mb-3">
<label for="editAccountName" class="form-label">Account Name</label>
<input type="text" class="form-control" id="editAccountName" name="account_name" required>
</div>
<div class="mb-3">
<label for="editAccountType" class="form-label">Account Type</label>
<select class="form-select" id="editAccountType" name="account_type" required>
<option value="Asset">Asset</option>
<option value="Liability">Liability</option>
<option value="Equity">Equity</option>
<option value="Revenue">Revenue</option>
<option value="Expense">Expense</option>
</select>
</div>
<div class="mb-3">
<label for="editAccountDescription" class="form-label">Description</label>
<textarea class="form-control" id="editAccountDescription" name="description" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</div>
</div>
<!-- Delete Account Modal -->
<div class="modal fade" id="deleteAccountModal" tabindex="-1" aria-labelledby="deleteAccountModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteAccountModalLabel">Delete Account</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this account? This action cannot be undone.</p>
<form action="/chart_of_accounts.php" method="POST">
<input type="hidden" name="action" value="delete_account">
<input type="hidden" name="account_id" id="deleteAccountId">
<div class="d-flex justify-content-end">
<button type="button" class="btn btn-secondary me-2" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Delete Account</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Handle Edit Modal
var editModal = document.getElementById('editAccountModal');
editModal.addEventListener('show.bs.modal', function (event) {
var button = event.relatedTarget;
var id = button.getAttribute('data-id');
var code = button.getAttribute('data-code');
var name = button.getAttribute('data-name');
var type = button.getAttribute('data-type');
var description = button.getAttribute('data-description');
var modalTitle = editModal.querySelector('.modal-title');
var modalBody = editModal.querySelector('.modal-body');
modalTitle.textContent = 'Edit Account: ' + name;
modalBody.querySelector('#editAccountId').value = id;
modalBody.querySelector('#editAccountCode').value = code;
modalBody.querySelector('#editAccountName').value = name;
modalBody.querySelector('#editAccountType').value = type;
modalBody.querySelector('#editAccountDescription').value = description;
});
// Handle Delete Modal
var deleteModal = document.getElementById('deleteAccountModal');
deleteModal.addEventListener('show.bs.modal', function (event) {
var button = event.relatedTarget;
var id = button.getAttribute('data-id');
var modalBody = deleteModal.querySelector('.modal-body');
modalBody.querySelector('#deleteAccountId').value = id;
});
});
</script>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -1,97 +0,0 @@
<?php
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/header.php';
$pdo = db();
$user_id = $_SESSION['user_id'];
$company = null;
$errors = [];
$success_message = '';
// Fetch existing company data
$stmt = $pdo->prepare("SELECT * FROM companies WHERE user_id = ?");
$stmt->execute([$user_id]);
$company = $stmt->fetch();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$address = trim($_POST['address'] ?? '');
$currency = trim($_POST['currency'] ?? 'SGD');
$gst_number = trim($_POST['gst_number'] ?? '');
if (empty($name)) {
$errors[] = 'Company name is required.';
}
if (empty($errors)) {
if ($company) {
// Update existing record
$stmt = $pdo->prepare("UPDATE companies SET name = ?, address = ?, currency = ?, gst_number = ? WHERE user_id = ?");
if ($stmt->execute([$name, $address, $currency, $gst_number, $user_id])) {
$success_message = 'Company settings updated successfully!';
} else {
$errors[] = 'Failed to update settings. Please try again.';
}
} else {
// Insert new record
$stmt = $pdo->prepare("INSERT INTO companies (user_id, name, address, currency, gst_number) VALUES (?, ?, ?, ?, ?)");
if ($stmt->execute([$user_id, $name, $address, $currency, $gst_number])) {
$success_message = 'Company settings saved successfully!';
} else {
$errors[] = 'Failed to save settings. Please try again.';
}
}
// Refresh company data after update/insert
$stmt = $pdo->prepare("SELECT * FROM companies WHERE user_id = ?");
$stmt->execute([$user_id]);
$company = $stmt->fetch();
}
}
require_once __DIR__ . '/includes/sidebar.php';
?>
<h1 class="h2">Company Settings</h1>
<p>Use this form to set up or update your company's details. This information will be used on invoices and other official documents.</p>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo htmlspecialchars($error); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($success_message)): ?>
<div class="alert alert-success">
<p class="mb-0"><?php echo htmlspecialchars($success_message); ?></p>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<form action="/company_setup.php" method="POST">
<div class="mb-3">
<label for="companyName" class="form-label">Company Name</label>
<input type="text" class="form-control" id="companyName" name="name" value="<?php echo htmlspecialchars($company['name'] ?? ''); ?>" required>
</div>
<div class="mb-3">
<label for="companyAddress" class="form-label">Address</label>
<textarea class="form-control" id="companyAddress" name="address" rows="3"><?php echo htmlspecialchars($company['address'] ?? ''); ?></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="companyCurrency" class="form-label">Base Currency</label>
<input type="text" class="form-control" id="companyCurrency" name="currency" value="<?php echo htmlspecialchars($company['currency'] ?? 'SGD'); ?>" required>
</div>
<div class="col-md-6 mb-3">
<label for="companyGst" class="form-label">GST Number (if applicable)</label>
<input type="text" class="form-control" id="companyGst" name="gst_number" value="<?php echo htmlspecialchars($company['gst_number'] ?? ''); ?>">
</div>
</div>
<button type="submit" class="btn btn-primary">Save Settings</button>
</form>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -1,19 +0,0 @@
<?php require_once __DIR__ . '/includes/header.php'; ?>
<?php require_once __DIR__ . '/includes/sidebar.php'; ?>
<h1 class="h2">Dashboard</h1>
<p>Welcome, <?php echo htmlspecialchars($_SESSION['user_name']); ?>! This is your main dashboard. From here you can manage all aspects of your business.</p>
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Company Setup</h5>
<p class="card-text">Before you can start creating invoices or tracking inventory, you need to set up your company details.</p>
<a href="/company_setup.php" class="btn btn-primary">Go to Company Setup</a>
</div>
</div>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -1,25 +0,0 @@
<?php
require_once __DIR__ . '/config.php';
function run_migrations() {
$pdo = db();
$migrationsDir = __DIR__ . '/migrations';
$files = glob($migrationsDir . '/*.sql');
sort($files);
foreach ($files as $file) {
echo "Running migration: " . basename($file) . "\n";
$sql = file_get_contents($file);
try {
$pdo->exec($sql);
} catch (PDOException $e) {
echo "Error running migration: " . $e->getMessage() . "\n";
return false;
}
}
echo "Migrations completed successfully.\n";
return true;
}
run_migrations();

View File

@ -1,10 +0,0 @@
CREATE TABLE IF NOT EXISTS `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,11 +0,0 @@
CREATE TABLE IF NOT EXISTS `companies` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
`address` TEXT,
`currency` VARCHAR(10) DEFAULT 'SGD',
`gst_number` VARCHAR(50),
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,12 +0,0 @@
CREATE TABLE IF NOT EXISTS `chart_of_accounts` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`company_id` INT NOT NULL,
`account_code` VARCHAR(20) NOT NULL,
`account_name` VARCHAR(255) NOT NULL,
`account_type` ENUM('Asset', 'Liability', 'Equity', 'Revenue', 'Expense') NOT NULL,
`description` TEXT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `company_account_code` (`company_id`, `account_code`),
FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,11 +0,0 @@
CREATE TABLE IF NOT EXISTS `customers` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`company_id` INT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255),
`phone` VARCHAR(50),
`address` TEXT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,17 +0,0 @@
<?php
require_once __DIR__ . '/config.php';
try {
// Connect to MySQL without specifying a database
$pdo = new PDO('mysql:host=' . DB_HOST, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
// Create the database if it doesn't exist
$pdo->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`");
echo "Database '" . DB_NAME . "' created or already exists.\n";
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}

View File

@ -1,10 +0,0 @@
</div>
<!-- End of main content area -->
</main>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@ -1,38 +0,0 @@
<?php require_once __DIR__ . '/session.php'; protect_page(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - FAST ACCOUNTING</title>
<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?v=<?php echo time(); ?>">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="/dashboard.php">FAST ACCOUNTING</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 ms-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-person-circle"></i> <?php echo htmlspecialchars($_SESSION['user_name'] ?? 'User'); ?>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="logout.php">Logout</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">

View File

@ -1,14 +0,0 @@
<?php
session_start();
function is_logged_in() {
return isset($_SESSION['user_id']);
}
function protect_page() {
if (!is_logged_in()) {
$_SESSION['login_errors'] = ['Please log in to access that page.'];
header('Location: /login.php');
exit;
}
}

View File

@ -1,29 +0,0 @@
<?php $current_page = basename($_SERVER['PHP_SELF']); ?>
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link <?php echo ($current_page == 'dashboard.php') ? 'active' : ''; ?>" href="/dashboard.php">
<i class="bi bi-house-door"></i>
Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php echo ($current_page == 'company_setup.php') ? 'active' : ''; ?>" href="/company_setup.php">
<i class="bi bi-gear"></i>
Company Settings
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php echo ($current_page == 'chart_of_accounts.php') ? 'active' : ''; ?>" href="/chart_of_accounts.php">
<i class="bi bi-journal-text"></i>
Chart of Accounts
</a>
</li>
<!-- Add more links here -->
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">

345
index.php
View File

@ -1,209 +1,150 @@
<?php require_once 'includes/session.php'; ?>
<!DOCTYPE html>
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$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.0">
<title>FAST ACCOUNTING</title>
<meta name="description" content="Modern, full-stack accounting software for any business. Manage invoices, inventory, and financial reports with ease.">
<meta name="keywords" content="accounting software, invoicing, inventory management, financial reporting, GST, purchase orders, sales orders, small business accounting, Built with Flatlogic Generator">
<meta property="og:title" content="FAST ACCOUNTING">
<meta property="og:description" content="Modern, full-stack accounting software for any business. Manage invoices, inventory, and financial reports with ease.">
<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'] ?? ''); ?>">
<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="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;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<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>
<!-- Header -->
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top shadow-sm">
<div class="container">
<a class="navbar-brand" href="#">FAST ACCOUNTING</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 ms-auto">
<li class="nav-item"><a class="nav-link" href="#features">Features</a></li>
<li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<a href="dashboard.php" class="btn btn-outline-primary">Dashboard</a>
</li>
<li class="nav-item mx-lg-2">
<a href="logout.php" class="btn btn-primary">Logout</a>
</li>
<?php else: ?>
<li class="nav-item mx-lg-2">
<button class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#loginModal">Login</button>
</li>
<li class="nav-item">
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#signupModal">Sign Up</button>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<header class="hero text-center">
<div class="container">
<h1 class="display-4">Modern Accounting, Made Simple.</h1>
<p class="lead text-muted my-4">The all-in-one accounting platform to manage your finances, from invoices to inventory. <br>Focus on your business, we'll handle the numbers.</p>
<button class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#signupModal">Get Started for Free</button>
</div>
</header>
<!-- Features Section -->
<section id="features" class="py-5">
<div class="container">
<div class="text-center mb-5">
<h2>Everything Your Business Needs</h2>
<p class="lead text-muted">A complete suite of tools to streamline your financial operations.</p>
</div>
<div class="row g-4">
<div class="col-md-4">
<div class="card h-100 text-center p-4 border-0 shadow-sm">
<div class="feature-icon bg-primary text-white bg-opacity-75 mb-3 mx-auto">
<i class="bi bi-receipt-cutoff fs-2"></i>
</div>
<h3 class="h5">Easy Invoicing</h3>
<p class="text-muted">Create and send professional invoices in seconds. Track payments and get paid faster.</p>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 text-center p-4 border-0 shadow-sm">
<div class="feature-icon bg-success text-white bg-opacity-75 mb-3 mx-auto">
<i class="bi bi-box-seam fs-2"></i>
</div>
<h3 class="h5">Inventory Control</h3>
<p class="text-muted">Manage stock levels, track goods, and automate purchase orders to avoid stockouts.</p>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 text-center p-4 border-0 shadow-sm">
<div class="feature-icon bg-info text-white bg-opacity-75 mb-3 mx-auto">
<i class="bi bi-bar-chart-line fs-2"></i>
</div>
<h3 class="h5">Financial Reports</h3>
<p class="text-muted">Generate real-time reports like P&L, Balance Sheets, and Trial Balance with one click.</p>
</div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="footer border-top">
<div class="container text-center">
<p class="text-muted">&copy; <?php echo date("Y"); ?> FAST ACCOUNTING. All Rights Reserved.</p>
</div>
</footer>
<!-- Login Modal -->
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="loginModalLabel">Login to your Account</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="login.php" method="POST">
<?php if (isset($_SESSION['login_errors'])): ?>
<div class="alert alert-danger">
<?php foreach ($_SESSION['login_errors'] as $error): ?>
<p><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['success_message'])): ?>
<div class="alert alert-success">
<p><?php echo $_SESSION['success_message']; ?></p>
</div>
<?php endif; ?>
<div class="mb-3">
<label for="loginEmail" class="form-label">Email address</label>
<input type="email" name="email" class="form-control" id="loginEmail" required>
</div>
<div class="mb-3">
<label for="loginPassword" class="form-label">Password</label>
<input type="password" name="password" class="form-control" id="loginPassword" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
</form>
</div>
</div>
</div>
<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>
<!-- Signup Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" aria-labelledby="signupModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="signupModalLabel">Create a New Account</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="register.php" method="POST">
<?php if (isset($_SESSION['register_errors'])): ?>
<div class="alert alert-danger">
<?php foreach ($_SESSION['register_errors'] as $error): ?>
<p><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="mb-3">
<label for="signupName" class="form-label">Your Name</label>
<input type="text" name="name" class="form-control" id="signupName" required>
</div>
<div class="mb-3">
<label for="signupEmail" class="form-label">Email address</label>
<input type="email" name="email" class="form-control" id="signupEmail" required>
</div>
<div class="mb-3">
<label for="signupPassword" class="form-label">Password</label>
<input type="password" name="password" class="form-control" id="signupPassword" required>
</div>
<div class="mb-3">
<label for="signupPasswordConfirm" class="form-label">Confirm Password</label>
<input type="password" name="password_confirm" class="form-control" id="signupPasswordConfirm" required>
</div>
<button type="submit" class="btn btn-primary w-100">Create Account</button>
</form>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
<?php if (isset($_SESSION['login_errors']) || isset($_SESSION['success_message'])): ?>
var loginModal = new bootstrap.Modal(document.getElementById('loginModal'));
loginModal.show();
<?php
unset($_SESSION['login_errors']);
unset($_SESSION['success_message']);
?>
<?php endif; ?>
<?php if (isset($_SESSION['register_errors'])): ?>
var signupModal = new bootstrap.Modal(document.getElementById('signupModal'));
signupModal.show();
<?php unset($_SESSION['register_errors']); ?>
<?php endif; ?>
});
</script>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>

View File

@ -1,40 +0,0 @@
<?php
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/session.php';
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'A valid email is required.';
}
if (empty($password)) {
$errors[] = 'Password is required.';
}
if (empty($errors)) {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['name'];
header('Location: /dashboard.php');
exit;
} else {
$errors[] = 'Invalid email or password.';
}
}
$_SESSION['login_errors'] = $errors;
header('Location: /index.php#loginModal');
exit;
}
// This script does not render HTML. It only processes the form.
header('Location: /index.php');
exit;

View File

@ -1,21 +0,0 @@
<?php
require_once __DIR__ . '/includes/session.php';
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
header('Location: /index.php');
exit;

View File

@ -1,53 +0,0 @@
<?php
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/session.php';
$errors = [];
$success_message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
$password_confirm = $_POST['password_confirm'] ?? '';
if (empty($name)) {
$errors[] = 'Name is required.';
}
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'A valid email is required.';
}
if (empty($password)) {
$errors[] = 'Password is required.';
}
if ($password !== $password_confirm) {
$errors[] = 'Passwords do not match.';
}
if (empty($errors)) {
$pdo = db();
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$errors[] = 'Email already in use.';
} else {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
if ($stmt->execute([$name, $email, $hashed_password])) {
$_SESSION['success_message'] = 'Registration successful! Please login.';
header('Location: /index.php#loginModal');
exit;
} else {
$errors[] = 'Something went wrong. Please try again.';
}
}
}
// To display errors, we would need to render a form here.
// For now, we redirect back to the form with errors in session.
$_SESSION['register_errors'] = $errors;
header('Location: /index.php#signupModal');
exit;
}
// This script does not render HTML. It only processes the form.
header('Location: /index.php');
exit;