Compare commits

..

5 Commits

Author SHA1 Message Date
Flatlogic Bot
2c6acf1c3f v5 2025-10-29 10:52:50 +00:00
Flatlogic Bot
1b9afa40ef v4 2025-10-29 10:45:26 +00:00
Flatlogic Bot
9584826cb1 v3 2025-10-29 10:27:50 +00:00
Flatlogic Bot
3f67ab6fd2 v2 2025-10-29 10:11:09 +00:00
Flatlogic Bot
6569b2ca89 v1 2025-10-29 10:04:19 +00:00
22 changed files with 1402 additions and 144 deletions

41
_footer.php Normal file
View File

@ -0,0 +1,41 @@
<?php
// Shared footer
?>
<footer class="bg-light text-center text-lg-start mt-auto">
<div class="container p-4">
<div class="row">
<div class="col-lg-6 col-md-12 mb-4 mb-md-0">
<h5 class="text-uppercase">MeToo Platform</h5>
<p>
La tua soluzione affidabile per servizi a domicilio. Connettiamo clienti e fornitori con semplicità e sicurezza.
</p>
</div>
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
<h5 class="text-uppercase">Link Utili</h5>
<ul class="list-unstyled mb-0">
<li>
<a href="register_provider.php" class="text-dark">Lavora con noi</a>
</li>
<li>
<a href="contact.php" class="text-dark">Contatti</a>
</li>
<li>
<a href="#" class="text-dark">Privacy Policy</a>
</li>
</ul>
</div>
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
<h5 class="text-uppercase">Seguici</h5>
<ul class="list-unstyled d-flex justify-content-center justify-content-lg-start">
<li><a href="#" class="text-dark me-3"><i class="bi bi-facebook"></i></a></li>
<li><a href="#" class="text-dark me-3"><i class="bi bi-instagram"></i></a></li>
<li><a href="#" class="text-dark"><i class="bi bi-linkedin"></i></a></li>
</ul>
</div>
</div>
</div>
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.05);">
© <?= date('Y') ?> Copyright:
<a class="text-dark" href="index.php">MeTooApp.com</a>
</div>
</footer>

53
_header.php Normal file
View File

@ -0,0 +1,53 @@
<?php
session_start();
// Shared header and navigation
?>
<header class="bg-white shadow-sm sticky-top">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<a class="navbar-brand fw-bold text-primary" href="index.php">MeToo</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-nav" aria-controls="main-nav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="main-nav">
<ul class="navbar-nav mx-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="index.php#services">Servizi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register_provider.php">Diventa un Fornitore</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contattaci</a>
</li>
</ul>
<ul class="navbar-nav">
<?php if (isset($_SESSION['user_id'])):
?>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Ciao, <?= htmlspecialchars($_SESSION['user_name']) ?>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Dashboard</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="logout.php">Logout</a></li>
</ul>
</li>
<?php
else:
?>
<li class="nav-item">
<a href="login.php" class="btn btn-outline-primary">Login</a>
</li>
<li class="nav-item ms-lg-2 mt-2 mt-lg-0">
<a href="register.php" class="btn btn-primary">Registrati</a>
</li>
<?php
endif;
?>
</ul>
</div>
</div>
</nav>
</header>

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

@ -0,0 +1,90 @@
/* Custom Styles */
body {
font-family: 'Poppins', sans-serif;
background-color: #F8F9FA;
}
.hero-section {
background: url('https://images.pexels.com/photos/4239031/pexels-photo-4239031.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1') no-repeat center center;
background-size: cover;
position: relative;
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(45deg, rgba(32, 222, 110, 0.8), rgba(40, 167, 69, 0.8));
}
.hero-section .container {
position: relative;
z-index: 2;
}
.search-card {
background-color: #FFFFFF;
padding: 2rem;
border-radius: 0.75rem;
box-shadow: 0 8px 30px rgba(0,0,0,0.1);
margin-top: 2rem;
}
.btn-primary {
background-color: #20de6e;
border-color: #20de6e;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 600;
}
.btn-primary:hover {
background-color: #18b35a;
border-color: #18b35a;
}
.how-it-works {
padding: 80px 0;
}
.step-icon {
font-size: 3rem;
color: #20de6e;
}
/* Auth pages styling */
.choice-card {
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.choice-card:hover {
transform: translateY(-5px);
box-shadow: 0 12px 40px rgba(0,0,0,0.12) !important;
}
.text-primary {
color: #20de6e !important;
}
.btn-outline-primary {
--bs-btn-color: #20de6e;
--bs-btn-border-color: #20de6e;
--bs-btn-hover-color: #fff;
--bs-btn-hover-bg: #20de6e;
--bs-btn-hover-border-color: #20de6e;
--bs-btn-active-color: #fff;
--bs-btn-active-bg: #20de6e;
--bs-btn-active-border-color: #20de6e;
--bs-btn-disabled-color: #20de6e;
--bs-btn-disabled-bg: transparent;
}
.navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(32, 222, 110, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

53
assets/js/main.js Normal file
View File

@ -0,0 +1,53 @@
// Main javascript file
document.addEventListener('DOMContentLoaded', function() {
const locationInputs = document.querySelectorAll('input[name="location"]');
if (locationInputs.length === 0) {
return;
}
const COMUNI_URL = 'https://raw.githubusercontent.com/matteocontrini/comuni-json/master/comuni.json';
const IP_GEOLOCATION_URL = 'http://ip-api.com/json';
// Create a datalist for suggestions
const datalist = document.createElement('datalist');
datalist.id = 'comuni-list';
document.body.appendChild(datalist);
// Attach the datalist to the input fields
locationInputs.forEach(input => {
input.setAttribute('list', datalist.id);
input.setAttribute('autocomplete', 'off'); // Disable browser's own autocomplete
});
// Fetch comuni and populate datalist
fetch(COMUNI_URL)
.then(response => response.json())
.then(data => {
data.forEach(comune => {
const option = document.createElement('option');
option.value = comune.nome;
datalist.appendChild(option);
});
})
.catch(error => {
console.error('Error fetching Italian municipalities:', error);
});
// Fetch IP-based geolocation and pre-fill the input
fetch(IP_GEOLOCATION_URL)
.then(response => response.json())
.then(data => {
if (data && data.city) {
locationInputs.forEach(input => {
// Only set the value if the input is currently empty
if (input.value.trim() === '') {
input.value = data.city;
}
});
}
})
.catch(error => {
console.error('Error fetching IP geolocation:', error);
});
});

126
contact.php Normal file
View File

@ -0,0 +1,126 @@
<?php
$page_title = 'Contattaci';
$success_message = '';
$error_message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once __DIR__ . '/mail/MailService.php';
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$message = trim($_POST['message'] ?? '');
if (empty($name) || empty($email) || empty($message)) {
$error_message = 'Tutti i campi sono obbligatori.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error_message = 'Indirizzo email non valido.';
} else {
// The recipient is handled by the MAIL_TO environment variable.
$res = MailService::sendContactMessage($name, $email, $message);
if (!empty($res['success'])) {
$success_message = 'Messaggio inviato con successo! Ti risponderemo il prima possibile.';
// Clear form
$_POST = array();
} else {
$error_message = 'Si è verificato un errore. Riprova più tardi.';
// In a real application, you should log the detailed error: $res['error']
}
}
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($page_title) ?> - MeToo</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="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@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<header class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand fw-bold" href="index.php">MeToo</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="index.php#services">Servizi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Diventa un Fornitore</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contattaci</a>
</li>
<li class="nav-item mx-lg-2">
<a class="btn btn-outline-primary" href="#">Login</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" href="#">Registrati</a>
</li>
</ul>
</div>
</div>
</header>
<main class="container" style="padding-top: 100px; padding-bottom: 60px;">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card shadow-sm border-0" style="border-radius: 0.5rem;">
<div class="card-body p-5">
<h1 class="card-title text-center mb-4"><?= htmlspecialchars($page_title) ?></h1>
<p class="text-center text-muted mb-5">Hai domande o hai bisogno di aiuto? Compila il form qui sotto.</p>
<?php if ($success_message): ?>
<div class="alert alert-success"><?= $success_message ?></div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?= $error_message ?></div>
<?php endif; ?>
<div class="alert alert-info">
<strong>Nota:</strong> Questo form è per scopi dimostrativi. Le email vengono inviate a un indirizzo di test. Per usare il tuo server di posta, configura le variabili SMTP nel file <code>.env</code>.
</div>
<form action="contact.php" method="POST" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Nome</label>
<input type="text" class="form-control" id="name" name="name" required value="<?= htmlspecialchars($_POST['name'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required value="<?= htmlspecialchars($_POST['email'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="message" class="form-label">Messaggio</label>
<textarea class="form-control" id="message" name="message" rows="5" required><?= htmlspecialchars($_POST['message'] ?? '') ?></textarea>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Invia Messaggio</button>
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<footer class="bg-light py-4">
<div class="container text-center text-muted">
<p>&copy; <?= date('Y') ?> MeToo. Tutti i diritti riservati.</p>
</div>
</footer>
<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>
</body>
</html>

29
db/migrate.php Normal file
View File

@ -0,0 +1,29 @@
<?php
require_once __DIR__ . '/config.php';
try {
// Connect without specifying a database
$pdo_admin = 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_admin->exec("CREATE DATABASE IF NOT EXISTS " . DB_NAME);
echo "Database '" . DB_NAME . "' created or already exists.\n";
// Now connect to the created database
$pdo = db();
$migrations = glob(__DIR__ . '/migrations/*.sql');
sort($migrations);
foreach ($migrations as $migration) {
echo "Running migration: " . basename($migration) . "...\n";
$sql = file_get_contents($migration);
$pdo->exec($sql);
echo "Migration successful.\n";
}
echo "\nAll migrations completed successfully.\n";
} catch (PDOException $e) {
die("Database migration failed: " . $e->getMessage());
}

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
user_type ENUM('customer', 'provider') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS service_categories (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE
);

View File

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS services (
id INT AUTO_INCREMENT PRIMARY KEY,
provider_id INT NOT NULL,
category_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (provider_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (category_id) REFERENCES service_categories(id)
);

View File

@ -0,0 +1,7 @@
INSERT INTO service_categories (name) VALUES
('Pulizie'),
('Riparazioni'),
('Assistenza alla persona'),
('Giardinaggio'),
('Lezioni private'),
('Babysitting');

View File

@ -0,0 +1 @@
ALTER TABLE `users` ADD `location` VARCHAR(255) NULL DEFAULT NULL AFTER `user_type`;

237
index.php
View File

@ -1,150 +1,109 @@
<?php <?php
declare(strict_types=1); require_once 'db/config.php';
@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> <!DOCTYPE html>
<html lang="en"> <html lang="it">
<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.0">
<title>New Style</title> <title>MeToo - Servizi a Domicilio</title>
<?php <meta name="description" content="Piattaforma di prenotazioni di servizi a domicilio come pulizie, assistenza, riparazioni e altro. Built with Flatlogic Generator.">
// Read project preview data from environment <meta name="keywords" content="servizi a domicilio, prenotazione online, pulizie domestiche, assistenza alla persona, riparazioni, spesa a domicilio, professionisti locali, marketplace servizi, Built with Flatlogic Generator">
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; <!-- Social Media Meta Tags -->
?> <meta property="og:title" content="MeToo - Servizi a Domicilio">
<?php if ($projectDescription): ?> <meta property="og:description" content="Trova e prenota i migliori professionisti per servizi a domicilio. Semplice, rapido e affidabile.">
<!-- Meta description --> <meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' /> <meta property="og:url" content="<?php echo htmlspecialchars((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'], ENT_QUOTES, 'UTF-8'); ?>">
<!-- Open Graph meta tags --> <meta name="twitter:card" content="summary_large_image">
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <!-- Bootstrap 5 CSS -->
<?php endif; ?> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<?php if ($projectImageUrl): ?> <!-- Bootstrap Icons -->
<!-- Open Graph image --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" /> <!-- Google Fonts (Poppins) -->
<!-- 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.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@300;400;600;700&display=swap" rel="stylesheet">
<style> <!-- Custom CSS -->
:root { <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
--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"> <?php include __DIR__ . '/_header.php'; ?>
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <?php if (isset($_SESSION['user_id'])): ?>
<span class="sr-only">Loading…</span> <?php
if ($_SESSION['user_type'] === 'provider') {
include __DIR__ . '/views/dashboard_provider.php';
} else {
include __DIR__ . '/views/dashboard_customer.php';
}
?>
<?php else: ?>
<!-- Hero Section -->
<section class="hero-section">
<div class="container">
<h1 class="display-4 fw-bold">Servizi a domicilio, semplici e affidabili.</h1>
<p class="lead col-lg-8 mx-auto">Trova i migliori professionisti nella tua zona per pulizie, riparazioni, assistenza e molto altro. Inizia ora.</p>
<div class="col-lg-8 mx-auto">
<div class="search-card text-dark">
<form action="search.php" method="GET">
<div class="row g-3 align-items-center">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-text bg-transparent border-0"><i class="bi bi-search"></i></span>
<input type="text" class="form-control border-0" name="q" placeholder="Che servizio cerchi?">
</div> </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> </div>
</main> <div class="col-lg-4">
<footer> <div class="input-group">
Page updated: <?= htmlspecialchars($now) ?> (UTC) <span class="input-group-text bg-transparent border-0"><i class="bi bi-geo-alt"></i></span>
</footer> <input type="text" class="form-control border-0" name="location" placeholder="Comune">
</div>
</div>
<div class="col-lg-2">
<button type="submit" class="btn btn-primary w-100">Cerca</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- How It Works -->
<section class="how-it-works text-center">
<div class="container">
<h2 class="pb-2 border-bottom">Come funziona</h2>
<div class="row mt-5">
<div class="col-md-4">
<div class="step-icon mb-3"><i class="bi bi-search"></i></div>
<h3>1. Cerca</h3>
<p>Descrivi il servizio di cui hai bisogno e indica la tua zona.</p>
</div>
<div class="col-md-4">
<div class="step-icon mb-3"><i class="bi bi-calendar-check"></i></div>
<h3>2. Prenota</h3>
<p>Scegli il fornitore che preferisci, visualizza il preventivo e prenota.</p>
</div>
<div class="col-md-4">
<div class="step-icon mb-3"><i class="bi bi-emoji-smile"></i></div>
<h3>3. Rilassati</h3>
<p>Un professionista qualificato si prenderà cura di tutto.</p>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php include __DIR__ . '/_footer.php'; ?>
<!-- Bootstrap 5 JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body> </body>
</html> </html>

101
login.php Normal file
View File

@ -0,0 +1,101 @@
<?php
session_start();
require_once 'db/config.php';
$pageTitle = "Login";
$pageDescription = "Accedi alla piattaforma per prenotare o offrire servizi.";
$error = null;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($email) || empty($password)) {
$error = "Per favore, inserisci email e password.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Password is correct, start session
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_type'] = $user['user_type'];
$_SESSION['user_name'] = $user['first_name'];
// Redirect to a logged-in page (e.g., dashboard)
header("Location: index.php");
exit;
} else {
$error = "Email o password non validi.";
}
} catch (PDOException $e) {
$error = "Errore del database. Riprova più tardi.";
// error_log($e->getMessage());
}
}
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($pageTitle) ?> - MeToo</title>
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
<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=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card shadow-sm border-0">
<div class="card-body p-4">
<h1 class="card-title text-center mb-4 h2">Accedi</h1>
<p class="text-center text-muted mb-4">Bentornato! Accedi per gestire i tuoi servizi.</p>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form action="login.php" method="POST" novalidate>
<div class="mb-3">
<label for="email" class="form-label">Indirizzo Email</label>
<input type="email" class="form-control" id="email" name="email" required value="<?= htmlspecialchars($email ?? '') ?>">
</div>
<div class="mb-4">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Login</button>
</div>
</form>
<div class="text-center mt-4">
<p class="mb-0">Non hai un account? <a href="register.php">Registrati ora</a></p>
</div>
</div>
</div>
</div>
</div>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

6
logout.php Normal file
View File

@ -0,0 +1,6 @@
<?php
session_start();
session_unset();
session_destroy();
header("Location: index.php");
exit;

148
manage_services.php Normal file
View File

@ -0,0 +1,148 @@
<?php
require_once 'db/config.php';
require_once '_header.php';
// Ensure user is a provider
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'provider') {
header("Location: index.php");
exit;
}
$provider_id = $_SESSION['user_id'];
$error = null;
$success = null;
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['add_service'])) {
$name = trim($_POST['name'] ?? '');
$description = trim($_POST['description'] ?? '');
$category_id = $_POST['category_id'] ?? null;
$price = $_POST['price'] ?? '';
if (empty($name) || empty($category_id) || empty($price)) {
$error = "Nome, categoria e prezzo sono obbligatori.";
} elseif (!is_numeric($price) || $price < 0) {
$error = "Il prezzo non è valido.";
} else {
try {
$pdo = db();
$stmt = $pdo->prepare(
"INSERT INTO services (provider_id, category_id, name, description, price) VALUES (?, ?, ?, ?, ?)"
);
if ($stmt->execute([$provider_id, $category_id, $name, $description, $price])) {
$success = "Servizio aggiunto con successo!";
} else {
$error = "Errore durante l'aggiunta del servizio.";
}
} catch (PDOException $e) {
$error = "Errore del database: " . $e->getMessage();
}
}
}
// Fetch data for the page
try {
$pdo = db();
// Fetch categories
$categories_stmt = $pdo->query("SELECT * FROM service_categories ORDER BY name");
$categories = $categories_stmt->fetchAll();
// Fetch provider's services
$services_stmt = $pdo->prepare(
"SELECT s.*, sc.name as category_name FROM services s JOIN service_categories sc ON s.category_id = sc.id WHERE s.provider_id = ? ORDER BY s.created_at DESC"
);
$services_stmt->execute([$provider_id]);
$services = $services_stmt->fetchAll();
} catch (PDOException $e) {
// Die on critical database error
die("Errore di connessione al database: " . $e->getMessage());
}
$pageTitle = "Gestisci Servizi";
?>
<main class="container my-5">
<h1 class="mb-4"><?= htmlspecialchars($pageTitle) ?></h1>
<?php if ($success): ?>
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<!-- Add Service Form -->
<div class="card mb-4">
<div class="card-header">
<h2 class="h5 mb-0">Aggiungi un nuovo servizio</h2>
</div>
<div class="card-body">
<form action="manage_services.php" method="POST">
<div class="row">
<div class="col-md-6 mb-3">
<label for="name" class="form-label">Nome Servizio</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="col-md-6 mb-3">
<label for="category_id" class="form-label">Categoria</label>
<select class="form-select" id="category_id" name="category_id" required>
<option value="">Seleziona una categoria</option>
<?php foreach ($categories as $category): ?>
<option value="<?= $category['id'] ?>"><?= htmlspecialchars($category['name']) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="mb-3">
<label for="description" class="form-label">Descrizione</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
</div>
<div class="mb-3">
<label for="price" class="form-label">Prezzo ()</label>
<input type="number" step="0.01" class="form-control" id="price" name="price" required>
</div>
<button type="submit" name="add_service" class="btn btn-primary">Aggiungi Servizio</button>
</form>
</div>
</div>
<!-- List of Services -->
<div class="card">
<div class="card-header">
<h2 class="h5 mb-0">I tuoi servizi</h2>
</div>
<div class="card-body">
<?php if (empty($services)): ?>
<p>Non hai ancora aggiunto nessun servizio.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Nome</th>
<th>Categoria</th>
<th>Prezzo</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
<?php foreach ($services as $service): ?>
<tr>
<td><?= htmlspecialchars($service['name']) ?></td>
<td><?= htmlspecialchars($service['category_name']) ?></td>
<td> <?= htmlspecialchars(number_format($service['price'], 2, ',', '.')) ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-secondary disabled">Modifica</a>
<a href="#" class="btn btn-sm btn-outline-danger disabled">Elimina</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</main>
<?php
require_once '_footer.php';
?>

65
register.php Normal file
View File

@ -0,0 +1,65 @@
<?php
$pageTitle = "Registrati";
$pageDescription = "Inizia a usare la nostra piattaforma registrandoti come cliente o fornitore.";
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($pageTitle) ?> - MeToo</title>
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
<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=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<div class="text-center">
<h1 class="display-5 fw-bold mb-3">Crea il tuo account</h1>
<p class="lead text-muted mb-5">Scegli il tipo di profilo più adatto a te.</p>
</div>
<div class="row justify-content-center g-4">
<div class="col-lg-5 col-md-6">
<div class="card h-100 text-center shadow-sm border-0 choice-card">
<div class="card-body p-5">
<i class="bi bi-person-circle display-3 text-primary mb-3"></i>
<h2 class="h3">Sono un Cliente</h2>
<p class="text-muted">Sto cercando un professionista per un servizio a domicilio.</p>
<div class="d-grid mt-4">
<a href="register_customer.php" class="btn btn-outline-primary btn-lg">Registrati come Cliente</a>
</div>
</div>
</div>
</div>
<div class="col-lg-5 col-md-6">
<div class="card h-100 text-center shadow-sm border-0 choice-card">
<div class="card-body p-5">
<i class="bi bi-briefcase-fill display-3 text-success mb-3"></i>
<h2 class="h3">Sono un Fornitore</h2>
<p class="text-muted">Voglio offrire i miei servizi professionali sulla piattaforma.</p>
<div class="d-grid mt-4">
<a href="register_provider.php" class="btn btn-success btn-lg">Registrati come Fornitore</a>
</div>
</div>
</div>
</div>
</div>
<div class="text-center mt-5">
<p>Hai già un account? <a href="login.php">Accedi qui</a>.</p>
</div>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

127
register_customer.php Normal file
View File

@ -0,0 +1,127 @@
<?php
require_once 'db/config.php';
$pageTitle = "Registrazione Cliente";
$pageDescription = "Crea il tuo account cliente per iniziare a prenotare servizi.";
// Registration logic
$error = null;
$success = null;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
$confirm_password = $_POST['confirm_password'] ?? '';
// Split name into first and last name
$name_parts = explode(' ', $name, 2);
$first_name = $name_parts[0];
$last_name = $name_parts[1] ?? '';
if (empty($first_name) || empty($email) || empty($password)) {
$error = "Tutti i campi sono obbligatori.";
} elseif ($password !== $confirm_password) {
$error = "Le password non coincidono.";
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = "L'indirizzo email non è valido.";
} else {
try {
$pdo = db();
// Check if email already exists
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$error = "Un account con questa email esiste già.";
} else {
// Hash the password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert the new user
$insert_stmt = $pdo->prepare(
"INSERT INTO users (first_name, last_name, email, password, user_type) VALUES (?, ?, ?, ?, 'customer')"
);
if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password])) {
$success = "Registrazione completata! Ora puoi effettuare il login.";
} else {
$error = "Si è verificato un errore durante la registrazione. Riprova.";
}
}
} catch (PDOException $e) {
// In a real app, you would log this error.
$error = "Errore del database. Riprova più tardi.";
// error_log($e->getMessage());
}
}
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($pageTitle) ?> - MeToo</title>
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
<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=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="card shadow-sm border-0">
<div class="card-body p-4">
<h1 class="card-title text-center mb-4 h2">Registrati come Cliente</h1>
<p class="text-center text-muted mb-4">Crea un account per trovare e prenotare servizi in modo facile e veloce.</p>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success" role="alert"><?= htmlspecialchars($success) ?></div>
<?php else: ?>
<form action="register_customer.php" method="POST" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Nome Completo</label>
<input type="text" class="form-control" id="name" name="name" required value="<?= htmlspecialchars($name ?? '') ?>">
</div>
<div class="mb-3">
<label for="email" class="form-label">Indirizzo Email</label>
<input type="email" class="form-control" id="email" name="email" required value="<?= htmlspecialchars($email ?? '') ?>">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-4">
<label for="confirm_password" class="form-label">Conferma Password</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Crea Account</button>
</div>
</form>
<?php endif; ?>
<div class="text-center mt-4">
<p class="mb-0">Sei un fornitore? <a href="register_provider.php">Registrati qui</a>.</p>
<p>Hai già un account? <a href="login.php">Accedi</a>.</p>
</div>
</div>
</div>
</div>
</div>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

131
register_provider.php Normal file
View File

@ -0,0 +1,131 @@
<?php
require_once 'db/config.php';
$pageTitle = "Registrazione Fornitore";
$pageDescription = "Unisciti alla nostra rete di professionisti. Registrati per offrire i tuoi servizi.";
$error = null;
$success = null;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$location = trim($_POST['location'] ?? '');
$password = $_POST['password'] ?? '';
$confirm_password = $_POST['confirm_password'] ?? '';
// Split name into first and last name
$name_parts = explode(' ', $name, 2);
$first_name = $name_parts[0];
$last_name = $name_parts[1] ?? '';
if (empty($first_name) || empty($email) || empty($password) || empty($location)) {
$error = "Tutti i campi sono obbligatori.";
} elseif ($password !== $confirm_password) {
$error = "Le password non coincidono.";
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = "L'indirizzo email non è valido.";
} else {
try {
$pdo = db();
// Check if email already exists
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$error = "Un account con questa email esiste già.";
} else {
// Hash the password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert the new user
$insert_stmt = $pdo->prepare(
"INSERT INTO users (first_name, last_name, email, password, user_type, location) VALUES (?, ?, ?, ?, 'provider', ?)"
);
if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password, $location])) {
$success = "Registrazione completata! Ora puoi effettuare il login.";
} else {
$error = "Si è verificato un errore durante la registrazione. Riprova.";
}
}
} catch (PDOException $e) {
// In a real app, you would log this error.
$error = "Errore del database. Riprova più tardi.";
// error_log($e->getMessage());
}
}
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($pageTitle) ?> - MeToo</title>
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
<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=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="card shadow-sm border-0">
<div class="card-body p-4">
<h1 class="card-title text-center mb-4 h2">Registrati come Fornitore</h1>
<p class="text-center text-muted mb-4">Crea il tuo account per offrire i tuoi servizi sulla nostra piattaforma.</p>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success" role="alert"><?= htmlspecialchars($success) ?></div>
<?php else: ?>
<form action="register_provider.php" method="POST" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Nome Completo</label>
<input type="text" class="form-control" id="name" name="name" required value="<?= htmlspecialchars($name ?? '') ?>">
</div>
<div class="mb-3">
<label for="email" class="form-label">Indirizzo Email</label>
<input type="email" class="form-control" id="email" name="email" required value="<?= htmlspecialchars($email ?? '') ?>">
</div>
<div class="mb-3">
<label for="location" class="form-label">Comune</label>
<input type="text" class="form-control" id="location" name="location" required value="<?= htmlspecialchars($location ?? '') ?>">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-4">
<label for="confirm_password" class="form-label">Conferma Password</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-success btn-lg">Crea Account da Fornitore</button>
</div>
</form>
<?php endif; ?>
<div class="text-center mt-4">
<p class="mb-0">Sei un cliente? <a href="register_customer.php">Registrati qui</a>.</p>
<p>Hai già un account? <a href="login.php">Accedi</a>.</p>
</div>
</div>
</div>
</div>
</div>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

120
search.php Normal file
View File

@ -0,0 +1,120 @@
<?php
require_once 'db/config.php';
$query = $_GET['q'] ?? '';
$location = $_GET['location'] ?? '';
$results = [];
if (!empty($query) || !empty($location)) {
try {
$pdo = db();
$sql = "
SELECT
s.id,
s.name,
s.description,
s.price,
c.name as category_name,
u.first_name,
u.last_name,
u.location
FROM services s
JOIN users u ON s.provider_id = u.id
JOIN service_categories c ON s.category_id = c.id
WHERE u.user_type = 'provider'
";
$params = [];
if (!empty($query)) {
$sql .= " AND (s.name LIKE :query OR s.description LIKE :query)";
$params[':query'] = '%' . $query . '%';
}
if (!empty($location)) {
$sql .= " AND u.location LIKE :location";
$params[':location'] = '%' . $location . '%';
}
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
$results = $stmt->fetchAll();
} catch (PDOException $e) {
// In a real app, you would log this error.
$error_message = "Si è verificato un errore durante la ricerca. Riprova più tardi.";
}
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Risultati della Ricerca - MeToo</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.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<h1 class="mb-4">Risultati della ricerca</h1>
<div class="row mb-4">
<div class="col">
<form action="search.php" method="GET" class="row g-3">
<div class="col-md-6">
<input type="text" class="form-control" name="q" placeholder="Che servizio cerchi?" value="<?= htmlspecialchars($query) ?>">
</div>
<div class="col-md-4">
<input type="text" class="form-control" name="location" placeholder="Comune" value="<?= htmlspecialchars($location) ?>">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary w-100">Cerca</button>
</div>
</form>
</div>
</div>
<?php if (isset($error_message)): ?>
<div class="alert alert-danger"><?= $error_message ?></div>
<?php elseif (empty($results)): ?>
<div class="alert alert-info">
Nessun servizio trovato per "<?= htmlspecialchars($query) ?>" <?= !empty($location) ? 'a ' . htmlspecialchars($location) : '' ?>. Prova a modificare i criteri di ricerca.
</div>
<?php else: ?>
<p class="text-muted">Trovati <?= count($results) ?> risultati.</p>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
<?php foreach ($results as $service): ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><?= htmlspecialchars($service['name']) ?></h5>
<h6 class="card-subtitle mb-2 text-muted"><?= htmlspecialchars($service['category_name']) ?></h6>
<p class="card-text"><?= htmlspecialchars(substr($service['description'], 0, 100)) ?>...</p>
<p class="card-text">
<strong>Prezzo:</strong> <?= htmlspecialchars(number_format($service['price'], 2, ',', '.')) ?><br>
<strong>Fornitore:</strong> <?= htmlspecialchars($service['first_name'] . ' ' . $service['last_name']) ?><br>
<strong>Comune:</strong> <?= htmlspecialchars($service['location']) ?>
</p>
<a href="service.php?id=<?= $service['id'] ?>" class="btn btn-primary">Vedi Dettagli</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<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>
</body>
</html>

137
service.php Normal file
View File

@ -0,0 +1,137 @@
<?php
require_once 'db/config.php';
$service_id = $_GET['id'] ?? null;
if (!$service_id) {
header("Location: index.php");
exit;
}
$service = null;
$other_providers = [];
$error_message = null;
try {
$pdo = db();
// Fetch the main service details
$sql = "
SELECT
s.id,
s.name,
s.description,
s.price,
c.name as category_name,
u.first_name,
u.last_name,
u.location
FROM services s
JOIN users u ON s.provider_id = u.id
JOIN service_categories c ON s.category_id = c.id
WHERE s.id = :service_id AND u.user_type = 'provider'
";
$stmt = $pdo->prepare($sql);
$stmt->execute([':service_id' => $service_id]);
$service = $stmt->fetch();
if ($service) {
// Fetch other providers offering a service with the same name in the same location
$sql_others = "
SELECT
u.first_name,
u.last_name,
u.location,
s.price
FROM services s
JOIN users u ON s.provider_id = u.id
WHERE s.name = :service_name
AND u.location = :location
AND s.id != :service_id
AND u.user_type = 'provider'
ORDER BY s.price ASC
";
$stmt_others = $pdo->prepare($sql_others);
$stmt_others->execute([
':service_name' => $service['name'],
':location' => $service['location'],
':service_id' => $service_id
]);
$other_providers = $stmt_others->fetchAll();
}
} catch (PDOException $e) {
$error_message = "Si è verificato un errore. Riprova più tardi.";
// In a real app, you would log this error: error_log($e->getMessage());
}
$pageTitle = $service ? htmlspecialchars($service['name']) : "Servizio non trovato";
$pageDescription = $service ? htmlspecialchars(substr($service['description'], 0, 155)) : "";
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $pageTitle ?> - MeToo</title>
<meta name="description" content="<?= $pageDescription ?>">
<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.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main class="container my-5">
<?php if ($error_message): ?>
<div class="alert alert-danger"><?= $error_message ?></div>
<?php elseif (!$service): ?>
<div class="alert alert-warning">Servizio non trovato.</div>
<?php else: ?>
<div class="row">
<div class="col-lg-8">
<div class="card">
<div class="card-body">
<h1 class="card-title h2"><?= htmlspecialchars($service['name']) ?></h1>
<h6 class="card-subtitle mb-3 text-muted"><?= htmlspecialchars($service['category_name']) ?></h6>
<p class="lead"><?= htmlspecialchars($service['description']) ?></p>
<hr>
<p>
<strong>Prezzo:</strong> <?= htmlspecialchars(number_format($service['price'], 2, ',', '.')) ?><br>
<strong>Fornitore:</strong> <?= htmlspecialchars($service['first_name'] . ' ' . $service['last_name']) ?><br>
<strong>Comune:</strong> <?= htmlspecialchars($service['location']) ?>
</p>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Migliori fornitori in zona</h5>
<?php if (empty($other_providers)): ?>
<p class="text-muted">Nessun altro fornitore trovato in questa zona per questo servizio.</p>
<?php else: ?>
<ul class="list-group list-group-flush">
<?php foreach ($other_providers as $provider): ?>
<li class="list-group-item d-flex justify-content-between align-items-center">
<?= htmlspecialchars($provider['first_name'] . ' ' . $provider['last_name']) ?>
<span class="badge bg-primary rounded-pill"> <?= htmlspecialchars(number_format($provider['price'], 2, ',', '.')) ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
<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>
</body>
</html>

View File

@ -0,0 +1,16 @@
<main class="container my-5">
<h1 class="mb-4">Ciao, <?= htmlspecialchars($_SESSION['user_name']) ?>!</h1>
<p class="lead">Benvenuto nella tua dashboard cliente.</p>
<hr>
<div class="row">
<div class="col-md-12">
<h2>Le tue prenotazioni</h2>
<div class="card">
<div class="card-body text-center">
<p class="card-text">Non hai ancora nessuna prenotazione attiva.</p>
<a href="/#services" class="btn btn-primary">Cerca un servizio</a>
</div>
</div>
</div>
</div>
</main>

View File

@ -0,0 +1,24 @@
<main class="container my-5">
<h1 class="mb-4">Ciao, <?= htmlspecialchars($_SESSION['user_name']) ?>!</h1>
<p class="lead">Benvenuto nella tua dashboard fornitore.</p>
<hr>
<div class="row g-4">
<div class="col-md-6">
<h2>Gestisci Servizi</h2>
<div class="card">
<div class="card-body">
<p class="card-text">Aggiungi, modifica o rimuovi i servizi che offri.</p>
<a href="manage_services.php" class="btn btn-primary">Gestisci i tuoi servizi</a>
</div>
</div>
</div>
<div class="col-md-6">
<h2>Il tuo calendario</h2>
<div class="card">
<div class="card-body text-center">
<p class="card-text">La funzionalità calendario sarà disponibile a breve.</p>
</div>
</div>
</div>
</div>
</main>