Auto commit: 2025-11-21T11:50:01.278Z

This commit is contained in:
Flatlogic Bot 2025-11-21 11:50:01 +00:00
parent b92dd24dc9
commit 004e3d3a7d
7 changed files with 421 additions and 140 deletions

99
add_sale.php Normal file
View File

@ -0,0 +1,99 @@
<?php
$products = [
[
"name" => "Lean Beef Mince",
"image" => "assets/pasted-20251121-114725-33d5afd9.jpg",
"calories" => 150,
"protein" => 20,
"carbs" => 0,
"fat" => 7,
],
[
"name" => "Chicken Breast",
"image" => "assets/vm-shot-2025-11-21T11-47-05-928Z.jpg",
"calories" => 165,
"protein" => 31,
"carbs" => 0,
"fat" => 3.6,
],
[
"name" => "Salmon Fillet",
"image" => "https://images.pexels.com/photos/3296279/pexels-photo-3296279.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
"calories" => 208,
"protein" => 20,
"carbs" => 0,
"fat" => 13,
],
[
"name" => "Broccoli",
"image" => "https://images.pexels.com/photos/4057737/pexels-photo-4057737.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
"calories" => 55,
"protein" => 3.7,
"carbs" => 11,
"fat" => 0.6,
],
];
$success_message = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Basic validation
if (!empty($_POST['product_name']) && !empty($_POST['quantity']) && is_numeric($_POST['quantity'])) {
// In a real app, you would save this to a database.
// For now, we just show a success message.
$product_name = htmlspecialchars($_POST['product_name']);
$quantity = htmlspecialchars($_POST['quantity']);
$success_message = "Successfully added $quantity sale(s) for $product_name!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Sale - Sales Tracker</title>
<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=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="mobile-container">
<header class="app-header">
<a href="index.php" class="back-button">&larr;</a>
<h1>Add a New Sale</h1>
</header>
<main class="main-content">
<?php if ($success_message): ?>
<div class="alert success">
<?php echo $success_message; ?>
</div>
<?php endif; ?>
<form action="add_sale.php" method="POST" class="add-sale-form">
<div class="form-group">
<label for="product_name">Product</label>
<select id="product_name" name="product_name" required>
<option value="" disabled selected>Select a product</option>
<?php foreach ($products as $product): ?>
<option value="<?php echo htmlspecialchars($product['name']); ?>"><?php echo htmlspecialchars($product['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="quantity">Quantity</label>
<input type="number" id="quantity" name="quantity" min="1" value="1" required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Record Sale</button>
</div>
</form>
</main>
</div>
</body>
</html>

19
api/pexels.php Normal file
View File

@ -0,0 +1,19 @@
<?php
header('Content-Type: application/json');
require_once __DIR__.'/../includes/pexels.php';
$q = isset($_GET['query']) ? $_GET['query'] : 'nature';
$orientation = isset($_GET['orientation']) ? $_GET['orientation'] : 'portrait';
$url = 'https://api.pexels.com/v1/search?query=' . urlencode($q) . '&orientation=' . urlencode($orientation) . '&per_page=1&page=1';
$data = pexels_get($url);
if (!$data || empty($data['photos'])) { echo json_encode(['error'=>'Failed to fetch image']); exit; }
$photo = $data['photos'][0];
$src = $photo['src']['large2x'] ?? ($photo['src']['large'] ?? $photo['src']['original']);
$target = __DIR__ . '/../assets/images/pexels/' . $photo['id'] . '.jpg';
download_to($src, $target);
// Return minimal info and local relative path
echo json_encode([
'id' => $photo['id'],
'local' => 'assets/images/pexels/' . $photo['id'] . '.jpg',
'photographer' => $photo['photographer'] ?? null,
'photographer_url' => $photo['photographer_url'] ?? null,
]);

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

@ -0,0 +1,198 @@
body {
background-color: #1a1a2e;
font-family: 'Poppins', sans-serif;
color: #e0e0e0;
}
.mobile-container {
max-width: 480px;
margin: auto;
background-color: transparent;
min-height: 100vh;
position: relative;
overflow: hidden;
}
.background-gradient {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 50vh;
background: linear-gradient(to bottom, #1f4287, #1a1a2e);
z-index: -1;
}
.app-header {
background: transparent;
color: white;
position: sticky;
top: 0;
z-index: 1030;
}
.product-card {
border-radius: 1rem;
overflow: hidden;
position: relative;
height: 200px;
background-size: cover;
background-position: center;
display: flex;
align-items: flex-end;
color: white;
box-shadow: 0 10px 20px rgba(0,0,0,0.2), 0 6px 6px rgba(0,0,0,0.2);
transition: transform 0.3s ease;
}
.product-card:hover {
transform: translateY(-5px);
}
.card-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}
.card-content {
position: relative;
z-index: 1;
padding: 1rem;
width: 100%;
}
.card-title {
font-weight: 600;
margin-bottom: 0.25rem;
}
.card-text {
font-size: 0.9rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.nutrient-badge {
font-size: 0.75rem;
padding: 0.3em 0.6em;
background-color: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(5px);
border-radius: 50px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
/* Add Sale Page & Form */
.add-sale-form {
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.form-group {
display: flex;
flex-direction: column;
}
.form-group label {
margin-bottom: 8px;
font-weight: 600;
color: #f0f0f0;
}
.form-group input,
.form-group select {
padding: 12px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.3);
background-color: rgba(0, 0, 0, 0.2);
color: #fff;
font-family: 'Poppins', sans-serif;
font-size: 1rem;
}
.form-group select {
appearance: none;
-webkit-appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 15px center;
padding-right: 40px;
}
.form-group input:focus,
.form-group select:focus {
outline: none;
border-color: #8E44AD;
box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.5);
}
.btn.btn-primary {
padding: 15px;
border: none;
border-radius: 8px;
background: linear-gradient(45deg, #8E44AD, #C0392B);
color: white;
font-weight: 600;
font-size: 1.1rem;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.btn.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.back-button {
position: absolute;
left: 15px;
top: 50%;
transform: translateY(-50%);
font-size: 1.8rem;
color: white;
text-decoration: none;
}
.alert.success {
padding: 15px;
background-color: rgba(46, 204, 113, 0.8);
color: white;
border-radius: 8px;
margin-bottom: 20px;
text-align: center;
}
/* Floating Action Button */
.fab {
position: fixed;
bottom: 30px;
right: 30px;
width: 60px;
height: 60px;
background: linear-gradient(45deg, #8E44AD, #C0392B);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 28px;
text-decoration: none;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
transition: all 0.3s ease;
z-index: 1000;
}
.fab:hover {
transform: scale(1.1);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

25
includes/pexels.php Normal file
View File

@ -0,0 +1,25 @@
<?php
function pexels_key() {
$k = getenv('PEXELS_KEY');
return $k && strlen($k) > 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18';
}
function pexels_get($url) {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ],
CURLOPT_TIMEOUT => 15,
]);
$resp = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true);
return null;
}
function download_to($srcUrl, $destPath) {
$data = file_get_contents($srcUrl);
if ($data === false) return false;
if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true);
return file_put_contents($destPath, $data) !== false;
}

196
index.php
View File

@ -1,150 +1,90 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
@ini_set('display_errors', '1'); // Mock data for products. In a real app, this would come from a database.
@error_reporting(E_ALL); $products = [
@date_default_timezone_set('UTC'); ['id' => 1, 'name' => 'Avocado', 'calories' => 160, 'protein' => 2, 'carbs' => 9, 'fat' => 15],
['id' => 2, 'name' => 'Chicken Breast', 'calories' => 165, 'protein' => 31, 'carbs' => 0, 'fat' => 3.6],
['id' => 3, 'name' => 'Salmon Fillet', 'calories' => 208, 'protein' => 20, 'carbs' => 0, 'fat' => 13],
['id' => 4, 'name' => 'Brown Rice', 'calories' => 111, 'protein' => 2.6, 'carbs' => 23, 'fat' => 0.9],
['id' => 5, 'name' => 'Broccoli', 'calories' => 55, 'protein' => 3.7, 'carbs' => 11, 'fat' => 0.6],
['id' => 6, 'name' => 'Apple', 'calories' => 52, 'protein' => 0.3, 'carbs' => 14, 'fat' => 0.2],
['id' => 7, 'name' => 'Banana', 'calories' => 89, 'protein' => 1.1, 'carbs' => 23, 'fat' => 0.3],
['id' => 8, 'name' => 'Almonds', 'calories' => 579, 'protein' => 21, 'carbs' => 22, 'fat' => 49],
];
$phpVersion = PHP_VERSION; $projectName = $_SERVER['PROJECT_NAME'] ?? 'Sales & Nutrition';
$now = date('Y-m-d H:i:s');
?> ?>
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title> <title><?= htmlspecialchars($projectName) ?></title>
<?php
// Read project preview data from environment <?php
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Track your sales and product nutrition information easily.';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?> ?>
<?php if ($projectDescription): ?> <meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Meta description --> <meta property="og:title" content="<?= htmlspecialchars($projectName) ?>" />
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags --> <meta property="twitter:card" content="summary" />
<meta property="twitter:title" content="<?= htmlspecialchars($projectName) ?>" />
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?> <?php if ($projectImageUrl): ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" /> <meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" /> <meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?> <?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/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.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <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"> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
<style> <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
: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> </head>
<body> <body>
<main>
<div class="card"> <div class="mobile-container">
<h1>Analyzing your requirements and generating your website…</h1> <div class="background-gradient"></div>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <header class="app-header p-3 text-center">
<span class="sr-only">Loading…</span> <h1 class="h4 mb-0"><?= htmlspecialchars($projectName) ?></h1>
</header>
<main class="p-3">
<h2 class="h5 mb-3 text-white">Products</h2>
<div class="list-group">
<?php foreach ($products as $product): ?>
<?php
$imageUrl = 'https://picsum.photos/seed/' . $product['id'] . '/400/200';
// Note: The Pexels API integration can be used here for higher quality images.
// Example: $imageUrl = 'api/pexels.php?query=' . urlencode($product['name']);
?>
<div class="product-card mb-4" style="background-image: url('<?= $imageUrl ?>');">
<div class="card-overlay"></div>
<div class="card-content">
<h5 class="card-title"><?= htmlspecialchars($product['name']) ?></h5>
<p class="card-text"><?= (int)$product['calories'] ?> kcal</p>
<div class="d-flex gap-2 mt-2">
<span class="badge nutrient-badge">
Protein: <?= (float)$product['protein'] ?>g
</span>
<span class="badge nutrient-badge">
Carbs: <?= (float)$product['carbs'] ?>g
</span>
<span class="badge nutrient-badge">
Fat: <?= (float)$product['fat'] ?>g
</span>
</div> </div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> </div>
<p class="hint">This page will update automatically as the plan is implemented.</p> </div>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p> <?php endforeach; ?>
</div> </div>
</main> </main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <a href="add_sale.php" class="fab">+</a>
</footer> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body> </body>
</html> </html>