diff --git a/.env b/.env index 5f83bcd..3a96daf 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ APP_ENV=production -APP_DEBUG=false +APP_DEBUG=true APP_KEY=base64:RWTN8ZDkeItU6xmobXjl6sRn8ph0XoAHgDpX4+wCdlE= -APP_URL=http://vanguard.test +APP_URL=http://localhost/yogiboook LOG_CHANNEL=stack diff --git a/app/Http/Controllers/Web/Auth/LoginController.php b/app/Http/Controllers/Web/Auth/LoginController.php index cf40d2c..7d8e042 100644 --- a/app/Http/Controllers/Web/Auth/LoginController.php +++ b/app/Http/Controllers/Web/Auth/LoginController.php @@ -16,6 +16,7 @@ use Vanguard\Repositories\Session\SessionRepository; use Vanguard\Repositories\User\UserRepository; use Vanguard\Services\Auth\ThrottlesLogins; use Vanguard\User; +use Vanguard\Models\School; class LoginController extends Controller { @@ -30,32 +31,58 @@ class LoginController extends Controller /** * Show the application login form. */ - public function show(): View + public function show($school = null): View { + // Debug: aggiungiamo un log per verificare se arriviamo qui + \Log::info('LoginController::show chiamato con school = ' . ($school ?? 'null')); + + // Cerca la scuola in base allo slug + $schoolData = null; + if ($school) { + $schoolData = School::where('slug', $school)->first(); + } + return view('auth.login', [ 'socialProviders' => config('auth.social.providers'), + 'school_slug' => $school, + 'school_logo' => $schoolData ? $schoolData->logo : null, ]); } public function login(LoginRequest $request, SessionRepository $sessions): Response|RedirectResponse { + // Debug: aggiungiamo un log per verificare se arriviamo qui + \Log::info('LoginController::login chiamato con input: ' . json_encode($request->all())); + // In case that request throttling is enabled, we have to check if user can perform this request. - // We'll key this by the username and the IP address of the client making these requests into this application. $throttles = (bool) setting('throttle_enabled'); - //Redirect URL that can be passed as hidden field. + // Redirect URL that can be passed as hidden field. $to = $request->has('to') ? '?to=' . $request->get('to') : ''; if ($throttles && $this->hasTooManyLoginAttempts($request)) { return $this->sendLockoutResponse($request); } + // Validazione del campo school + $schoolSlug = $request->input('school'); + if ($schoolSlug) { + $school = School::where('slug', $schoolSlug)->first(); + if (!$school) { + return redirect()->to('login' . $to) + ->withErrors(['school' => trans('auth.school_not_found')]); + } + // Salva lo school_id nella sessione + $request->session()->put('school_id', $school->id); + } else { + // Se il campo school è vuoto, possiamo gestire il caso di default + return redirect()->to('login' . $to) + ->withErrors(['school' => trans('auth.school_required')]); + } + $credentials = $request->getCredentials(); if (! Auth::validate($credentials)) { - // If the login attempt was unsuccessful we will increment the number of attempts - // to log in and redirect the user back to the login form. Of course, when this - // user surpasses their maximum number of attempts they will get locked out. if ($throttles) { $this->incrementLoginAttempts($request); } @@ -94,7 +121,7 @@ class LoginController extends Controller $this->clearLoginAttempts($request); } - // Redirezione basata sul ruolo con la prima lettera maiuscola e prefisso 'userarea/' + // Redirezione basata sul ruolo if ($user->hasRole('Admin')) { return redirect()->to('userarea/admin.php'); } elseif ($user->hasRole('User')) { @@ -105,11 +132,9 @@ class LoginController extends Controller return redirect()->to('userarea/school_dashboard.php'); } - // Fallback nel caso il ruolo non corrisponda return redirect()->intended('userarea/default.php'); } - protected function logoutAndRedirectToTokenPage(Request $request, $user, ?string $redirectPage): RedirectResponse { Auth::logout(); diff --git a/app/Models/School.php b/app/Models/School.php new file mode 100644 index 0000000..ebd6935 --- /dev/null +++ b/app/Models/School.php @@ -0,0 +1,33 @@ + env('MYSQL_ATTR_SSL_CA'), ]) : [], ], - + 'mysql_no_prefix' => [ + 'driver' => 'mysql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', // Nessun prefisso per questa connessione + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + ], 'mariadb' => [ 'driver' => 'mariadb', 'url' => env('DB_URL'), @@ -154,7 +167,7 @@ return [ 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), ], 'default' => [ diff --git a/config/fortify.php b/config/fortify.php index 35577d6..d82513e 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -86,7 +86,7 @@ return [ | */ - 'prefix' => '', + 'prefix' => 'auth', 'domain' => null, diff --git a/public/userarea/add_to_cart.php b/public/userarea/add_to_cart.php new file mode 100644 index 0000000..cc0fb35 --- /dev/null +++ b/public/userarea/add_to_cart.php @@ -0,0 +1,40 @@ + false, 'message' => 'Dati non validi']); + exit; +} + +// Chiave univoca per l'elemento nel carrello +$cart_key = $product_id . '-' . $variation_id . '-' . $class_type_id; + +// Aggiungi o aggiorna il prodotto nel carrello +if (isset($_SESSION['cart'][$cart_key])) { + $_SESSION['cart'][$cart_key]['quantity'] += $quantity; +} else { + $_SESSION['cart'][$cart_key] = [ + 'product_id' => $product_id, + 'variation_id' => $variation_id, + 'class_type_id' => $class_type_id, + 'quantity' => $quantity + ]; +} + +// Calcola il numero totale di elementi nel carrello +$cart_count = array_sum(array_column($_SESSION['cart'], 'quantity')); + +// Rispondi con successo +echo json_encode(['success' => true, 'cart_count' => $cart_count]); diff --git a/public/userarea/checkout.php b/public/userarea/checkout.php new file mode 100644 index 0000000..6802604 --- /dev/null +++ b/public/userarea/checkout.php @@ -0,0 +1,358 @@ +getConnection(); + +// Recupera lo school_id e user_id dalla sessione +$school_id = session('school_id'); +$user_id = $iduserlogin; + +// Debug: verifica il valore di iduserlogin +\Log::info('Valore di iduserlogin: ' . $user_id); + +// Controlla se l'utente è loggato +if (empty($user_id)) { + // Reindirizza alla pagina di login se l'utente non è loggato + header('Location: login.php?error=not_logged_in'); + exit; +} + +$school = null; +$school_name = 'Nessuna scuola selezionata'; +$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo +if ($school_id) { + $school = \Vanguard\Models\School::find($school_id); + if ($school) { + $school_name = $school->name; + $school_logo_path = $school->logo ? url('userarea/photoschool/' . $school->logo) : $school_logo_path; + } +} + +// Inizializza il carrello se non esiste +if (!isset($_SESSION['cart'])) { + $_SESSION['cart'] = []; +} + +// Recupera i prodotti nel carrello +$cart_items = []; +$total_price = 0; +if (!empty($_SESSION['cart'])) { + foreach ($_SESSION['cart'] as $cart_key => $item) { + $product_id = $item['product_id']; + $variation_id = $item['variation_id']; + $class_type_id = $item['class_type_id']; + $quantity = $item['quantity']; + + // Query per ottenere i dettagli del prodotto, variazione e classe + $stmt = $pdo->prepare(" + SELECT p.id AS product_id, p.name AS product_name, pv.id AS variation_id, pv.name AS variation_name, pv.price, c.id AS class_id, c.name AS class_name, c.photo AS class_photo, + ct.id AS class_type_id, ct.level, ct.day_of_week + FROM products p + JOIN product_variations pv ON pv.id = ? + LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL + LEFT JOIN class_types ct ON ct.id = ? + LEFT JOIN classes c ON ct.class_id = c.id + WHERE p.id = ? + "); + $stmt->execute([$variation_id, $class_type_id, $product_id]); + $cart_item = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($cart_item) { + $cart_items[$cart_key] = [ + 'product_id' => $cart_item['product_id'], + 'product_name' => $cart_item['product_name'], + 'variation_id' => $cart_item['variation_id'], + 'variation_name' => $cart_item['variation_name'], + 'class_id' => $cart_item['class_id'], + 'class_name' => $cart_item['class_name'], + 'class_type_id' => $cart_item['class_type_id'], + 'level' => $cart_item['level'], + 'day_of_week' => $cart_item['day_of_week'], + 'photo' => $cart_item['class_photo'] ?: 'default_class_image.jpg', + 'price' => $cart_item['price'], + 'quantity' => $quantity, + 'subtotal' => $cart_item['price'] * $quantity + ]; + $total_price += $cart_item['price'] * $quantity; + } + } +} + +// Calcola il numero totale di elementi nel carrello +$cart_count = array_sum(array_column($_SESSION['cart'], 'quantity')); + +// Gestione della conferma dell'acquisto +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['confirm_purchase'])) { + // Assicurati che non ci siano output prima di questo punto + ob_start(); // Avvia il buffer per catturare eventuali output indesiderati + + if (empty($cart_items)) { + $response = ['success' => false, 'message' => 'Il carrello è vuoto.']; + } else { + try { + // Verifica che user_id non sia NULL (dovrebbe essere già garantito dal controllo sopra) + if (empty($user_id)) { + throw new Exception("L'ID utente non è definito nella sessione."); + } + + // Genera un order_number unico + $stmt = $pdo->query("SELECT MAX(order_number) AS max_order FROM orders"); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $order_number = ($result['max_order'] ?? 0) + 1; + + // Inserisci ogni elemento del carrello come un ordine + foreach ($cart_items as $item) { + $total_entries = null; // Da calcolare in base alla variazione + if (preg_match('/(\d+) Ticket/i', $item['variation_name'], $matches)) { + $total_entries = (int)$matches[1]; + } + $available_entries = $total_entries; + $available_recoveries = 0; // Da definire + $expiration_date = null; // Da definire + $activation_date = date('Y-m-d'); // Oggi + + $stmt = $pdo->prepare(" + INSERT INTO orders ( + order_number, school_id, user_id, product_id, variation_id, class_id, class_type_id, + created_at, payment_method, price, status, total_entries, available_entries, + available_recoveries, expiration_date, activation_date + ) VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), 'direct', ?, 'completed', ?, ?, ?, ?, ?) + "); + $stmt->execute([ + $order_number, + $school_id, + $user_id, + $item['product_id'], + $item['variation_id'], + $item['class_id'], + $item['class_type_id'], + $item['subtotal'], + $total_entries, + $available_entries, + $available_recoveries, + $expiration_date, + $activation_date + ]); + } + + // Svuota il carrello + $_SESSION['cart'] = []; + + // Reindirizza alla pagina di ringraziamento con l'order_number + $response = ['success' => true, 'redirect' => 'thank_you.php?order_number=' . $order_number]; + } catch (Exception $e) { + $response = ['success' => false, 'message' => 'Errore durante l\'acquisto: ' . $e->getMessage()]; + } + } + + // Pulisci il buffer e invia la risposta JSON + ob_end_clean(); + header('Content-Type: application/json'); + echo json_encode($response); + exit; +} +?> + + + + + + + + + + + + + + +
+ + +
+
+
+
+ +
Checkout - Scuola:
+ School Logo + +
Nessuna scuola selezionata
+ Default Logo + +
+
+
+
+
+
+
Riepilogo Carrello
+
+
+
+
+ +

Il carrello è vuoto.

+ +
+ +
+ product image +
+
+

Variazione:

+

Classe:

+

Quantità:

+

Prezzo Unitario:

+

Subtotale:

+
+
+ +
+
+
Totale
+
+
+
+ +
+ +
+
+
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/public/userarea/include/footer.php b/public/userarea/include/footer.php index b33e5b5..2ef8fcc 100644 --- a/public/userarea/include/footer.php +++ b/public/userarea/include/footer.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/public/userarea/include/remove_from_cart.php b/public/userarea/include/remove_from_cart.php new file mode 100644 index 0000000..e232e81 --- /dev/null +++ b/public/userarea/include/remove_from_cart.php @@ -0,0 +1,13 @@ + true]); +} else { + echo json_encode(['success' => false, 'message' => 'Elemento non trovato']); +} diff --git a/public/userarea/include/topbar.php b/public/userarea/include/topbar.php index cf29af6..8a23a48 100644 --- a/public/userarea/include/topbar.php +++ b/public/userarea/include/topbar.php @@ -1,275 +1,241 @@ +getConnection(); + +// Inizializza il carrello se non esiste +if (!isset($_SESSION['cart'])) { + $_SESSION['cart'] = []; +} + +// Recupera i prodotti nel carrello +$cart_items = []; +$total_price = 0; +if (!empty($_SESSION['cart'])) { + foreach ($_SESSION['cart'] as $cart_key => $item) { + $product_id = $item['product_id']; + $variation_id = $item['variation_id']; + $class_type_id = $item['class_type_id']; + $quantity = $item['quantity']; + + // Query per ottenere i dettagli del prodotto, variazione e classe + $stmt = $pdo->prepare(" + SELECT p.name AS product_name, pv.name AS variation_name, pv.price, c.name AS class_name, c.photo AS class_photo, + ct.level, ct.day_of_week + FROM products p + JOIN product_variations pv ON pv.id = ? + LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL + LEFT JOIN class_types ct ON ct.id = ? + LEFT JOIN classes c ON ct.class_id = c.id + WHERE p.id = ? + "); + $stmt->execute([$variation_id, $class_type_id, $product_id]); + $cart_item = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($cart_item) { + $cart_items[$cart_key] = [ + 'product_name' => $cart_item['product_name'], + 'variation_name' => $cart_item['variation_name'], + 'class_name' => $cart_item['class_name'], + 'level' => $cart_item['level'], + 'day_of_week' => $cart_item['day_of_week'], + 'photo' => $cart_item['class_photo'] ?: 'default_class_image.jpg', + 'price' => $cart_item['price'], + 'quantity' => $quantity, + 'subtotal' => $cart_item['price'] * $quantity + ]; + $total_price += $cart_item['price'] * $quantity; + } + } +} + +// Calcola il numero totale di elementi nel carrello +$cart_count = array_sum(array_column($_SESSION['cart'], 'quantity')); +?> +
- -
-
dc -
-
-
New Orders 2 min - ago
-

You have recived new orders

-
-
-
- -
-
- user avatar -
-
-
Althea Cabardo 14 - sec ago
-

Many desktop publishing packages

-
-
-
- -
-
- user avatar -
-
-
Account Created28 min - ago
-

Successfully created new email

-
-
-
- -
-
Ss -
-
-
New Product Approved 2 hrs ago
-

Your new product has approved

-
-
-
- -
-
- user avatar -
-
-
Katherine Pechon 15 - min ago
-

Making this the first true generator

-
-
-
- -
-
-
-
-
Your item is shipped 5 hrs - ago
-

Successfully shipped your item

-
-
-
- -
-
- user avatar -
-
-
New 24 authors1 day - ago
-

24 new authors joined last week

-
-
-
- -
-
- user avatar -
-
-
Peter Costanzo 6 hrs - ago
-

It was popularised in the 1960s

-
-
-
+
\ No newline at end of file + + + \ No newline at end of file diff --git a/public/userarea/photoschool/exyogibook_logo.png b/public/userarea/photoschool/exyogibook_logo.png new file mode 100644 index 0000000..4b1e303 Binary files /dev/null and b/public/userarea/photoschool/exyogibook_logo.png differ diff --git a/public/userarea/photoschool/yogibook_logo.png b/public/userarea/photoschool/yogibook_logo.png new file mode 100644 index 0000000..d939e63 Binary files /dev/null and b/public/userarea/photoschool/yogibook_logo.png differ diff --git a/public/userarea/product_detail.php b/public/userarea/product_detail.php index 799b110..88a9677 100644 --- a/public/userarea/product_detail.php +++ b/public/userarea/product_detail.php @@ -1,12 +1,26 @@ + getConnection(); +// Recupera lo school_id dalla sessione +$school_id = session('school_id'); + +$school = null; +$school_name = 'Nessuna scuola selezionata'; +$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo +if ($school_id) { + $school = \Vanguard\Models\School::find($school_id); + if ($school) { + $school_name = $school->name; + $school_logo_path = $school->logo ? url('userarea/photoschool/' . $school->logo) : $school_logo_path; + } +} + $product_id = $_GET['product_id'] ?? 0; -// Recupera i dettagli del prodotto +// Recupera i dettagli del prodotto, verificando che appartenga alla scuola selezionata $stmt = $pdo->prepare(" SELECT p.id, p.name AS product_name, c.name AS class_name, c.description AS class_description, c.photo AS class_photo @@ -14,14 +28,14 @@ $stmt = $pdo->prepare(" LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL LEFT JOIN class_types ct ON pct.class_type_id = ct.id LEFT JOIN classes c ON ct.class_id = c.id - WHERE p.id = ? + WHERE p.id = ? AND p.school_id = ? GROUP BY p.id "); -$stmt->execute([$product_id]); +$stmt->execute([$product_id, $school_id]); $product = $stmt->fetch(PDO::FETCH_ASSOC); if (!$product) { - die("Prodotto non trovato."); + die("Prodotto non trovato o non appartiene alla scuola selezionata."); } // Recupera le variazioni del prodotto @@ -43,16 +57,29 @@ $stmt = $pdo->prepare(" $stmt->execute([$product_id]); $class_types = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> - - - + + - - - Dettaglio Prodotto - <?php echo htmlspecialchars($product['product_name']); ?> - + + + + + + + + -
-

-
-
- <?php echo htmlspecialchars($product['class_name']); ?> -
-
-

-

- -
- - +
+ + +
+
+
+
+ +
Dettagli Prodotto - Scuola:
+ School Logo + +
Nessuna scuola selezionata
+ Default Logo + +
- -
- - +
+
+
+
+
+
+
+
+
+
+
+ <?php echo htmlspecialchars($product['class_name']); ?> +
+
+
+

+
+ + +
+
+ + +
+
Prezzo: -- €
+ +
+
+
- -
Prezzo: -- €
- -
+
+ +
- + - diff --git a/public/userarea/school_profile.php b/public/userarea/school_profile.php index 8921243..05980aa 100644 --- a/public/userarea/school_profile.php +++ b/public/userarea/school_profile.php @@ -53,12 +53,23 @@ if ($is_new) { 'status' => 'active', 'created_at' => '', 'updated_at' => '', + 'slug' => '', 'first_name' => $school['first_name'], 'last_name' => $school['last_name'], 'email' => $school['email'] ]; } +// Funzione per generare uno slug valido +function generateSlug($string) +{ + $slug = strtolower($string); // Converti in minuscolo + $slug = preg_replace('/[^a-z0-9-]+/', '-', $slug); // Sostituisci caratteri non validi con trattini + $slug = preg_replace('/-+/', '-', $slug); // Rimuovi trattini multipli + $slug = trim($slug, '-'); // Rimuovi trattini all'inizio e alla fine + return $slug; +} + // Gestione del form if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = $_POST['name'] ?? ''; @@ -76,6 +87,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $owner_name = $_POST['owner_name'] ?? ''; $vat_number = $_POST['vat_number'] ?? ''; $status = in_array($_POST['status'], ['active', 'inactive', 'suspended']) ? $_POST['status'] : 'active'; + $slug = isset($_POST['slug']) ? generateSlug($_POST['slug']) : ''; + + // Validazione dello slug + if (empty($slug)) { + $error = "Errore: Lo slug non può essere vuoto."; + } else { + // Controlla se lo slug è univoco + $stmt = $pdo->prepare("SELECT COUNT(*) FROM schools WHERE slug = ? AND id != ?"); + $stmt->execute([$slug, $school['id'] ?? 0]); + $slug_exists = $stmt->fetchColumn(); + + if ($slug_exists) { + $error = "Errore: Lo slug '$slug' è già in uso. Scegli un altro slug."; + } + } // Gestione del caricamento del logo $logo = $school['logo']; @@ -101,89 +127,94 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } - // Aggiorna auth_users (opzionale, se vuoi aggiornare first_name e last_name) - $stmt = $pdo->prepare("UPDATE auth_users SET first_name = ?, last_name = ? WHERE id = ?"); - $stmt->execute([$school['first_name'], $school['last_name'], $iduserlogin]); + // Se non ci sono errori, procedi con il salvataggio + if (!isset($error)) { + // Aggiorna auth_users (opzionale, se vuoi aggiornare first_name e last_name) + $stmt = $pdo->prepare("UPDATE auth_users SET first_name = ?, last_name = ? WHERE id = ?"); + $stmt->execute([$school['first_name'], $school['last_name'], $iduserlogin]); - if ($is_new) { - $stmt = $pdo->prepare(" - INSERT INTO schools (owner_id, name, website, email, phone, description, address_street, address_city, address_postal_code, address_province, address_country, latitude, longitude, owner_name, vat_number, logo, status) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - "); - $success = $stmt->execute([ - $iduserlogin, - $name, - $website, - $email, - $phone, - $description, - $address_street, - $address_city, - $address_postal_code, - $address_province, - $address_country, - $latitude, - $longitude, - $owner_name, - $vat_number, - $logo, - $status - ]); - - if ($success) { - $success_message = "Scuola creata con successo!"; + if ($is_new) { $stmt = $pdo->prepare(" - SELECT s.*, u.first_name, u.last_name, u.email - FROM auth_users u - LEFT JOIN schools s ON s.owner_id = u.id - WHERE u.id = ? + INSERT INTO schools (owner_id, name, website, email, phone, description, address_street, address_city, address_postal_code, address_province, address_country, latitude, longitude, owner_name, vat_number, logo, status, slug) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); - $stmt->execute([$iduserlogin]); - $school = $stmt->fetch(); - $is_new = false; - } else { - $error = "Errore durante la creazione della scuola."; - } - } else { - $stmt = $pdo->prepare(" - UPDATE schools - SET name = ?, website = ?, email = ?, phone = ?, description = ?, address_street = ?, address_city = ?, - address_postal_code = ?, address_province = ?, address_country = ?, latitude = ?, longitude = ?, - owner_name = ?, vat_number = ?, logo = ?, status = ? - WHERE owner_id = ? - "); - $success = $stmt->execute([ - $name, - $website, - $email, - $phone, - $description, - $address_street, - $address_city, - $address_postal_code, - $address_province, - $address_country, - $latitude, - $longitude, - $owner_name, - $vat_number, - $logo, - $status, - $iduserlogin - ]); + $success = $stmt->execute([ + $iduserlogin, + $name, + $website, + $email, + $phone, + $description, + $address_street, + $address_city, + $address_postal_code, + $address_province, + $address_country, + $latitude, + $longitude, + $owner_name, + $vat_number, + $logo, + $status, + $slug + ]); - if ($success) { - $success_message = "Dati aggiornati con successo!"; - $stmt = $pdo->prepare(" - SELECT s.*, u.first_name, u.last_name, u.email - FROM auth_users u - LEFT JOIN schools s ON s.owner_id = u.id - WHERE u.id = ? - "); - $stmt->execute([$iduserlogin]); - $school = $stmt->fetch(); + if ($success) { + $success_message = "Scuola creata con successo!"; + $stmt = $pdo->prepare(" + SELECT s.*, u.first_name, u.last_name, u.email + FROM auth_users u + LEFT JOIN schools s ON s.owner_id = u.id + WHERE u.id = ? + "); + $stmt->execute([$iduserlogin]); + $school = $stmt->fetch(); + $is_new = false; + } else { + $error = "Errore durante la creazione della scuola."; + } } else { - $error = "Errore durante l'aggiornamento dei dati."; + $stmt = $pdo->prepare(" + UPDATE schools + SET name = ?, website = ?, email = ?, phone = ?, description = ?, address_street = ?, address_city = ?, + address_postal_code = ?, address_province = ?, address_country = ?, latitude = ?, longitude = ?, + owner_name = ?, vat_number = ?, logo = ?, status = ?, slug = ? + WHERE owner_id = ? + "); + $success = $stmt->execute([ + $name, + $website, + $email, + $phone, + $description, + $address_street, + $address_city, + $address_postal_code, + $address_province, + $address_country, + $latitude, + $longitude, + $owner_name, + $vat_number, + $logo, + $status, + $slug, + $iduserlogin + ]); + + if ($success) { + $success_message = "Dati aggiornati con successo!"; + $stmt = $pdo->prepare(" + SELECT s.*, u.first_name, u.last_name, u.email + FROM auth_users u + LEFT JOIN schools s ON s.owner_id = u.id + WHERE u.id = ? + "); + $stmt->execute([$iduserlogin]); + $school = $stmt->fetch(); + } else { + $error = "Errore durante l'aggiornamento dei dati."; + } } } } @@ -238,6 +269,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+
+ + + Usa solo lettere minuscole, numeri e trattini (es. yoga-milano). +
@@ -327,6 +363,45 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ + + \ No newline at end of file diff --git a/public/userarea/shop-school.php b/public/userarea/shop-school.php new file mode 100644 index 0000000..33e5b41 --- /dev/null +++ b/public/userarea/shop-school.php @@ -0,0 +1,200 @@ + +getConnection(); + +// Recupera lo school_id dalla sessione +$school_id = session('school_id'); + +$school = null; +$school_name = 'Nessuna scuola selezionata'; +$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo +if ($school_id) { + // Usa il modello School per recuperare i dati della scuola + $school = \Vanguard\Models\School::find($school_id); + if ($school) { + $school_name = $school->name; + $school_logo_path = $school->logo ? url('userarea/' . $school->logo) : $school_logo_path; + } +} + +// Recupera i prodotti con le variazioni e le classi associate, filtrati per scuola +$products = []; +if ($school_id) { + $stmt = $pdo->prepare(" + SELECT p.id, p.name AS product_name, + MIN(pv.price) AS min_price, + MAX(pv.price) AS max_price, + c.name AS class_name, + c.photo AS class_photo + FROM products p + LEFT JOIN product_variations pv ON p.id = pv.product_id + LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL + LEFT JOIN class_types ct ON pct.class_type_id = ct.id + LEFT JOIN classes c ON ct.class_id = c.id + WHERE p.school_id = ? AND p.status = 'active' + GROUP BY p.id + "); + $stmt->execute([$school_id]); + $products = $stmt->fetchAll(PDO::FETCH_ASSOC); +} +?> + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ +
+
+ +
Shop della scuola:
+ School Logo + +
Nessuna scuola selezionata
+ Default Logo + +
+
+ + +
+
+
+
+
Acquista un Prodotto
+
+
+
+
+ +

Nessun prodotto disponibile per questa scuola.

+ +
+ +
+
+ <?php echo htmlspecialchars($product['class_name']); ?> +
+
+

+ +

+

+ Dettagli +
+
+
+ +
+ +
+
+
+
+ + +
+ + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userarea/thank_you.php b/public/userarea/thank_you.php new file mode 100644 index 0000000..e0fd4e6 --- /dev/null +++ b/public/userarea/thank_you.php @@ -0,0 +1,192 @@ + +getConnection(); + +// Recupera lo school_id e user_id dalla sessione +$school_id = session('school_id'); +$user_id = session('iduserlogin'); // Cambiato da 'user_id' a 'iduserlogin' + +// Recupera l'order_number dai parametri GET +$order_number = $_GET['order_number'] ?? 0; + +$school = null; +$school_name = 'Nessuna scuola selezionata'; +$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo +if ($school_id) { + $school = \Vanguard\Models\School::find($school_id); + if ($school) { + $school_name = $school->name; + $school_logo_path = $school->logo ? url('userarea/photoschool/' . $school->logo) : $school_logo_path; + } +} + +// Recupera i dettagli dell'ordine +$order_items = []; +$total_price = 0; +if ($order_number) { + $stmt = $pdo->prepare(" + SELECT o.order_number, o.created_at, o.price, o.total_entries, o.available_entries, o.activation_date, + p.name AS product_name, pv.name AS variation_name, c.name AS class_name, ct.level, ct.day_of_week, c.photo AS class_photo + FROM orders o + JOIN products p ON o.product_id = p.id + JOIN product_variations pv ON o.variation_id = pv.id + LEFT JOIN class_types ct ON o.class_type_id = ct.id + LEFT JOIN classes c ON ct.class_id = c.id + WHERE o.order_number = ? AND o.user_id = ? + "); + $stmt->execute([$order_number, $user_id]); + $order_items = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Calcola il totale + $total_price = array_sum(array_column($order_items, 'price')); +} + +// Se non ci sono ordini, reindirizza (opzionale) +if (empty($order_items)) { + header('Location: index.php'); + exit; +} + +// Prendi la data di creazione dal primo elemento +$order_date = $order_items[0]['created_at']; +?> + + + + + + + + + + + + + +
+ + +
+
+
+
+ +
Grazie per il tuo acquisto! - Scuola:
+ School Logo + +
Grazie per il tuo acquisto!
+ Default Logo + +
+
+
+
+
+
+
Riepilogo Ordine #
+
+
+
+
+ +
Acquisto Completato con Successo!
+

Ordine effettuato il

+
+ +
+ product image +
+
+

Variazione:

+

Classe:

+

Entrate Totali:

+

Prezzo:

+
+
+ +
+
+
Totale
+
+
+ +
+
+
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/public/userarea/user_dashboard.php b/public/userarea/user_dashboard.php new file mode 100644 index 0000000..2697ca6 --- /dev/null +++ b/public/userarea/user_dashboard.php @@ -0,0 +1,295 @@ + +getConnection(); + +// Recupera lo school_id dalla sessione +$school_id = session('school_id'); + +$school = null; +// Costruisci manualmente l'URL assoluto per il logo di default +$base_url = rtrim(env('APP_URL'), '/') . '/public/userarea/'; +$school_logo_path = $base_url . 'yogibook_logo.png'; // Default logo +if ($school_id) { + // Usa il modello School per recuperare i dati della scuola + $school = \Vanguard\Models\School::find($school_id); + if ($school) { + // Se la scuola esiste, aggiorna il percorso del logo + $school_logo_path = $school->logo ? $base_url . $school->logo : $school_logo_path; + } +} + +// Query per i dati dell'utente +$stmt = $pdo->prepare("SELECT first_name, last_name, avatar FROM auth_users WHERE id = ?"); +$stmt->execute([$iduserlogin]); +$user = $stmt->fetch(); +// Dopo aver recuperato i dati dell'utente +$avatar = !empty($user['avatar']) ? '../upload/users/' . $user['avatar'] : '../assets/images/default-avatar.png'; +?> + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + +
+
+ +
Sei loggato nella scuola: name); ?>
+ School Logo + +
Nessuna scuola selezionata
+ Default Logo + +
+
+ +
+
+
+
+
Stato Utente
+
+
+
+
+
+ + +
Ciao, !
+
+ + +
+ +
+
+
+
Lezioni Programmate
+

5

+
+
+
+ +
+
+
+
Ticket da Programmare
+

3

+
+
+
+ +
+
+
+
Lezioni da Confermare
+

2

+
+
+
+
+
+
+ + +
+
+
+
+
Le tue Lezioni Future
+
+
+
+
+ +
+ +
+ +
+ +
+ + + +
+
+ + +
+ +
+
+
+
+
Yoga Flow
+

15 Apr 2025, 18:00

+

Scuola: Yoga Harmony

+

Via Roma 12, Milano

+
+ +
+
+
+ +
+
+
+
+
Hatha Yoga
+

20 Apr 2025, 09:00

+

Scuola: Zen Studio

+

Corso Italia 45, Torino

+
+ +
+
+
+
+
+
+ +
+
+ + +
+ + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 9917287..b78007d 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -17,6 +17,8 @@ return [ 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 'banned' => 'Your account is banned by administrator.', 'max_sessions_reached' => 'You reached the maximum number of active sessions allowed. Please log out on other devices and try again.', + 'school_not_found' => 'The specified school was not found.', + 'school_required' => 'Please specify a school.', '2fa' => [ 'enabled_successfully' => 'Two-Factor Authentication enabled successfully.', diff --git a/resources/views/auth/login.blade - Copia.php b/resources/views/auth/login.blade - Copia.php new file mode 100644 index 0000000..f9d44d0 --- /dev/null +++ b/resources/views/auth/login.blade - Copia.php @@ -0,0 +1,88 @@ +@extends('layouts.auth') + +@section('page-title', trans('Login')) + +@section('content') + +
+
+ +
+ +
+
+
+ @lang('Login') +
+ +
+ @include('auth.social.buttons') + + @include('partials.messages') + +
+ + + + @if (Request::has('to')) + + @endif + +
+ + +
+ +
+ + +
+ + + @if (setting('remember_me')) +
+ + +
+ @endif + + +
+ +
+
+ + @if (setting('forgot_password')) + @lang('I forgot my password') + @endif +
+
+
+ +
+ @if (setting('reg_enabled')) + @lang("Don't have an account?") + ">@lang('Sign Up') + @endif +
+
+ +@stop + +@section('scripts') + + {!! JsValidator::formRequest('Vanguard\Http\Requests\Auth\LoginRequest', '#login-form') !!} +@stop diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index f9d44d0..73c1f07 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -6,7 +6,11 @@
- + @if (isset($school_logo) && $school_logo) + School Logo + @else + Default Logo + @endif
@@ -25,39 +29,48 @@ @if (Request::has('to')) - + @endif +
+ + +
+
+ name="username" + id="username" + class="form-control input-solid" + placeholder="@lang('Email or Username')" + value="{{ old('username') }}">
+ name="password" + id="password" + class="form-control input-solid" + placeholder="@lang('Password')">
- @if (setting('remember_me')) -
- - -
+
+ + +
@endif -
@@ -74,8 +87,8 @@
@if (setting('reg_enabled')) - @lang("Don't have an account?") - ">@lang('Sign Up') + @lang("Don't have an account?") + ">@lang('Sign Up') @endif
@@ -83,6 +96,6 @@ @stop @section('scripts') - - {!! JsValidator::formRequest('Vanguard\Http\Requests\Auth\LoginRequest', '#login-form') !!} -@stop + +{!! JsValidator::formRequest('Vanguard\Http\Requests\Auth\LoginRequest', '#login-form') !!} +@stop \ No newline at end of file diff --git a/resources/views/layouts/auth-cover.blade.php b/resources/views/layouts/auth-cover.blade.php new file mode 100644 index 0000000..77a8207 --- /dev/null +++ b/resources/views/layouts/auth-cover.blade.php @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + @yield('page-title', 'Rocker - Bootstrap 5 Admin Dashboard Template') + + + + +
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+ @yield('content') +
+
+
+
+
+
+
+ + + + + + + + + + + + @yield('scripts') + + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 1db981a..01bc5ef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,7 +3,7 @@ /** * Authentication */ -Route::get('login', 'Auth\LoginController@show'); +Route::get('login/{school?}', 'Auth\LoginController@show'); // Aggiunto {school?} Route::post('login', 'Auth\LoginController@login'); Route::get('logout', 'Auth\LoginController@logout')->name('auth.logout');