Skip to content

Commit 5ee4364

Browse files
committed
creato pagina pagamento
1 parent c2def5b commit 5ee4364

File tree

7 files changed

+144
-136
lines changed

7 files changed

+144
-136
lines changed

app/Http/Controllers/SponsorController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,12 @@ public function updateSponsorGold(Request $request)
6868
$apartments = Apartment::where('user_id', $superId)->with('sponsorships')->get();
6969
return view('apartments.index', compact('apartments', 'superId'));
7070
}
71+
72+
public function showPaymentPage()
73+
{
74+
$selectedApartments = [];
75+
$totalPrice = 0;
76+
77+
return view('sponsors.payment', compact('selectedApartments', 'totalPrice'));
78+
}
7179
}

resources/css/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
.active {
5+
background-color: #FFD700;
6+
color: #000;
7+
}

resources/views/sponsors/createBronze.blade.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@
3535

3636
<div class="flex justify-between items-center mt-8">
3737
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
38-
<div id="dropin-container"></div>
39-
<input type="hidden" id="nonce" name="payment_method_nonce">
40-
<button type="submit" id="submit-button" class="px-8 py-4 bg-gradient-to-t from-yellow-600 to-yellow-800 text-white rounded-full shadow-lg hover:bg-yellow-500 focus:outline-none focus:ring-4 focus:ring-yellow-400 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
41-
Attiva Piano Bronze
42-
</button>
38+
<a href="{{ route('payment') }}" class="px-8 py-4 bg-gradient-to-t from-yellow-600 to-yellow-800 text-white rounded-full shadow-lg hover:bg-yellow-500 focus:outline-none focus:ring-4 focus:ring-yellow-400 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
39+
Procedi al Pagamento
40+
</a>
4341
</div>
44-
4542
</form>
4643
</div>
4744
</div>
@@ -52,7 +49,6 @@
5249
}
5350
5451
</style>
55-
<script src="https://js.braintreegateway.com/web/dropin/1.31.0/js/dropin.min.js"></script>
5652
<script>
5753
function calculateTotal() {
5854
const checkboxes = document.querySelectorAll('input[name="apartments[]"]:checked');
@@ -61,28 +57,5 @@ function calculateTotal() {
6157
let total = checkboxes.length * pricePerApartment;
6258
totalPriceElement.textContent = total.toFixed(2) + '';
6359
}
64-
fetch('/payment/token')
65-
.then(response => response.json())
66-
.then(data => {
67-
braintree.dropin.create({
68-
authorization: data.token,
69-
container: '#dropin-container'
70-
}, function (createErr, instance) {
71-
if (createErr) {
72-
console.error('Errore nella creazione del Drop-in:', createErr);
73-
return;
74-
}
75-
document.getElementById('submit-button').addEventListener('click', function () {
76-
instance.requestPaymentMethod(function (err, payload) {
77-
if (err) {
78-
console.error(err);
79-
return;
80-
}
81-
document.getElementById('nonce').value = payload.nonce;
82-
document.getElementById('payment-form').submit();
83-
});
84-
});
85-
});
86-
});
87-
</script>
60+
</script>
8861
@endsection
Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,44 @@
11
@extends('dashboard')
22

33
@section('content')
4-
<div class="flex items-center justify-center min-h-screen bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 py-12 px-4">
5-
<div class="max-w-5xl mx-auto bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 p-10 rounded-3xl shadow-xl">
6-
<h2 class="text-4xl font-extrabold text-gray-100 mb-8 text-center border-b-4 border-yellow-500 pb-4">Seleziona Appartamenti per il Piano Gold</h2>
7-
<form id="payment-form" action="{{ route('updateSponsorGold') }}" method="POST">
8-
9-
@csrf
10-
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-10">
11-
<!-- Foreach degli appartamenti -->
12-
@foreach($apartments as $apartment)
13-
<div id="card-{{ $apartment->id }}" class="apartment-card hover:glow relative rounded-xl shadow-lg bg-neutral-800 hover:shadow-2xl transform hover:scale-105 transition-all duration-300 overflow-hidden">
14-
<img src="{{ $apartment->cover_image }}" alt="Property Image" class="w-full h-56 object-cover">
15-
<div class="p-6">
16-
<h3 class="text-2xl font-semibold text-yellow-400 mb-4">{{ $apartment->title }}</h3>
17-
<p class="text-gray-300 mb-4">{{ Str::limit($apartment->description, 100, '...') }}</p>
18-
<p class="text-yellow-400 font-bold text-lg">Prezzo: 9,99 €</p>
19-
20-
<div class="flex items-center mt-6">
21-
<input type="checkbox" name="apartments[]" value="{{ $apartment->id }}" id="apartment-{{ $apartment->id }}" class="mr-3 h-5 w-5 text-yellow-500 border-gray-500 bg-neutral-700 rounded focus:ring focus:ring-yellow-300 focus:ring-opacity-50 transition" onchange="toggleCardSelection({{ $apartment->id }})">
22-
<label for="apartment-{{ $apartment->id }}" class="text-lg font-semibold text-gray-100">Seleziona</label>
23-
</div>
24-
25-
<!-- Sponsorizzazione Attiva/Inattiva -->
26-
@if($apartment->sponsorships->where('name', 'Gold')->first())
27-
<p class="mt-4 text-sm font-bold text-green-400">Stato: Attivo</p>
28-
@else
29-
<p class="mt-4 text-sm font-bold text-red-500">Stato: Inattivo</p>
30-
@endif
31-
</div>
32-
</div>
4+
<div class="flex flex-col items-center justify-center min-h-screen bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 py-12 px-4">
5+
<div class="max-w-5xl mx-auto grid grid-cols-1 gap-8">
6+
7+
<!-- Card Dettagli Appartamenti -->
8+
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
9+
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Dettagli Appartamenti</h2>
10+
<ul class="mb-6">
11+
@foreach($selectedApartments as $apartment)
12+
<li class="text-lg text-white mb-2">
13+
<strong>{{ $apartment->title }}</strong> - Prezzo: {{ number_format($totalPrice, 2) }}
14+
</li>
3315
@endforeach
34-
<!-- Fine del foreach -->
35-
</div>
36-
37-
<div class="flex justify-between items-center mt-8">
38-
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
39-
<div id="dropin-container"></div>
16+
</ul>
17+
<p class="text-2xl font-bold text-white">Piano: Gold</p>
18+
<p class="text-2xl font-bold text-white mt-4">Prezzo Totale: <span id="totalPrice">{{ number_format($totalPrice, 2) }} €</span></p>
19+
</div>
20+
21+
<!-- Card Pagamento -->
22+
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
23+
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Pagamento</h2>
24+
<form action="{{ route('updateSponsorGold') }}" method="POST" id="payment-form">
25+
@csrf
26+
<div id="dropin-container" class="mb-6"></div>
4027
<input type="hidden" id="nonce" name="payment_method_nonce">
41-
<button type="submit" id="submit-button" class="px-8 py-4 bg-gradient-to-t from-yellow-400 to-yellow-600 text-white rounded-full shadow-lg hover:bg-yellow-500 focus:outline-none focus:ring-4 focus:ring-yellow-400 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
28+
<button type="submit" id="submit-button" class="w-full px-8 py-4 bg-gradient-to-t from-yellow-600 to-yellow-800 text-white rounded-full shadow-lg hover:bg-yellow-500 focus:outline-none focus:ring-4 focus:ring-yellow-400 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
4229
Attiva Piano Gold
4330
</button>
44-
</div>
31+
</form>
32+
<p class="mt-6 text-sm text-gray-400">
33+
Inviando questo ordine autorizzi il nostro servizio a eseguire l'addebito dell'importo di € {{ number_format($totalPrice, 2) }} per un periodo di prova di 3 mesi. Se non recedi prima della scadenza dell'anzidetto periodo di prova, autorizzi il nostro servizio a eseguire automaticamente addebiti mensili di € {{ number_format($totalPrice, 2) }} ciascuno fino alla disdetta del tuo abbonamento. Se la tariffa dovesse cambiare, te ne daremo preventiva comunicazione scritta. In qualsiasi momento puoi verificare la data di scadenza del tuo periodo di prova <a href="#" class="text-yellow-500 hover:underline">qui</a>. Le condizioni e i termini del servizio sono disponibili <a href="#" class="text-yellow-500 hover:underline">qui</a>; le istruzioni per la disdetta e l'esercizio del diritto di recesso sono disponibili <a href="#" class="text-yellow-500 hover:underline">qui</a>.
34+
</p>
35+
</div>
4536

46-
</form>
4737
</div>
4838
</div>
4939

50-
<style>
51-
.hover\:glow:hover {
52-
box-shadow: 0px 0px 10px 5px rgba(0, 77, 77, 0.4);
53-
}
54-
</style>
5540
<script src="https://js.braintreegateway.com/web/dropin/1.31.0/js/dropin.min.js"></script>
56-
5741
<script>
58-
function toggleCardSelection(apartmentId) {
59-
const card = document.getElementById(`card-${apartmentId}`);
60-
const checkbox = document.getElementById(`apartment-${apartmentId}`);
61-
62-
if (checkbox.checked) {
63-
card.classList.add('selected-card');
64-
} else {
65-
card.classList.remove('selected-card');
66-
}
67-
68-
calculateTotal(); // Update the total price whenever a card is selected/deselected
69-
}
70-
71-
function calculateTotal() {
72-
const checkboxes = document.querySelectorAll('input[name="apartments[]"]:checked');
73-
const totalPriceElement = document.getElementById('totalPrice');
74-
const pricePerApartment = 9.99;
75-
let total = checkboxes.length * pricePerApartment;
76-
totalPriceElement.textContent = total.toFixed(2) + '';
77-
}
78-
7942
fetch('/payment/token')
8043
.then(response => response.json())
8144
.then(data => {
@@ -100,5 +63,4 @@ function calculateTotal() {
10063
});
10164
});
10265
</script>
103-
10466
@endsection

resources/views/sponsors/createSilver.blade.php

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,38 @@
11
@extends('dashboard')
22

33
@section('content')
4-
<div class="flex items-center justify-center min-h-screen bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 py-12 px-4">
5-
<div class="max-w-5xl mx-auto bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 p-10 rounded-3xl shadow-xl">
6-
<h2 class="text-4xl font-extrabold text-gray-100 mb-8 text-center border-b-4 border-gray-300 pb-4">Seleziona Appartamenti per il Piano Silver</h2>
7-
<form id="payment-form" action="{{ route('updateSponsorSilver') }}" method="POST">
8-
9-
@csrf
10-
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-10">
11-
<!-- Foreach degli appartamenti -->
12-
@foreach($apartments as $apartment)
13-
<div id="card-{{ $apartment->id }}" class="apartment-card hover:glow relative rounded-xl shadow-lg bg-neutral-800 hover:shadow-2xl transform hover:scale-105 transition-all duration-300 overflow-hidden">
14-
<img src="{{ $apartment->cover_image }}" alt="Property Image" class="w-full h-56 object-cover">
15-
<div class="p-6">
16-
<h3 class="text-2xl font-semibold text-gray-300 mb-4">{{ $apartment->title }}</h3>
17-
<p class="text-gray-300 mb-4">{{ Str::limit($apartment->description, 100, '...') }}</p>
18-
<p class="text-gray-400 font-bold text-lg">Prezzo: 5,99 €</p>
19-
20-
<div class="flex items-center mt-6">
21-
<input type="checkbox" name="apartments[]" value="{{ $apartment->id }}" id="apartment-{{ $apartment->id }}" class="mr-3 h-5 w-5 text-yellow-500 border-gray-500 bg-neutral-700 rounded focus:ring focus:ring-gray-300 focus:ring-opacity-50 transition" onchange="toggleCardSelection({{ $apartment->id }})">
22-
<label for="apartment-{{ $apartment->id }}" class="text-lg font-semibold text-gray-100">Seleziona</label>
23-
</div>
24-
25-
<!-- Sponsorizzazione Attiva/Inattiva -->
26-
@if($apartment->sponsorships->where('name', 'Silver')->first())
27-
<p class="mt-4 text-sm font-bold text-green-400">Stato: Attivo</p>
28-
@else
29-
<p class="mt-4 text-sm font-bold text-red-500">Stato: Inattivo</p>
30-
@endif
31-
</div>
32-
</div>
4+
<div class="flex flex-col items-center justify-center min-h-screen bg-gradient-to-r from-neutral-900 via-[#003441] to-neutral-900 py-12 px-4">
5+
<div class="max-w-5xl mx-auto grid grid-cols-1 gap-8">
6+
7+
<!-- Card Dettagli Appartamenti -->
8+
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
9+
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Dettagli Appartamenti</h2>
10+
<ul class="mb-6">
11+
@foreach($selectedApartments as $apartment)
12+
<li class="text-lg text-white mb-2">
13+
<strong>{{ $apartment->title }}</strong> - Prezzo: {{ number_format($totalPrice, 2) }}
14+
</li>
3315
@endforeach
34-
<!-- Fine del foreach -->
35-
</div>
36-
37-
<div class="flex justify-between items-center mt-8">
38-
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
39-
<div id="dropin-container"></div>
16+
</ul>
17+
<p class="text-2xl font-bold text-white">Piano: Silver</p>
18+
<p class="text-2xl font-bold text-white mt-4">Prezzo Totale: <span id="totalPrice">{{ number_format($totalPrice, 2) }} €</span></p>
19+
</div>
20+
21+
<!-- Card Pagamento -->
22+
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
23+
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Pagamento</h2>
24+
<form action="{{ route('updateSponsorSilver') }}" method="POST" id="payment-form">
25+
@csrf
26+
<div id="dropin-container" class="mb-6"></div>
4027
<input type="hidden" id="nonce" name="payment_method_nonce">
41-
<button type="submit" id="submit-button" class="px-8 py-4 bg-gradient-to-t from-gray-300 to-gray-500 text-white rounded-full shadow-lg hover:bg-gray-400 focus:outline-none focus:ring-4 focus:ring-gray-300 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
28+
<button type="submit" id="submit-button" class="w-full px-8 py-4 bg-gradient-to-t from-yellow-600 to-yellow-800 text-white rounded-full shadow-lg hover:bg-yellow-500 focus:outline-none focus:ring-4 focus:ring-yellow-400 transition-all ease-in-out duration-300 transform hover:scale-105 h-14 opacity-100">
4229
Attiva Piano Silver
4330
</button>
44-
</div>
45-
46-
</form>
31+
</form>
32+
<p class="mt-6 text-sm text-gray-400">
33+
Inviando questo ordine autorizzi il nostro servizio a eseguire l'addebito dell'importo di € {{ number_format($totalPrice, 2) }} per un periodo di prova di 3 mesi. Se non recedi prima della scadenza dell'anzidetto periodo di prova, autorizzi il nostro servizio a eseguire automaticamente addebiti mensili di € {{ number_format($totalPrice, 2) }} ciascuno fino alla disdetta del tuo abbonamento. Se la tariffa dovesse cambiare, te ne daremo preventiva comunicazione scritta. In qualsiasi momento puoi verificare
34+
</p>
35+
</div>
4736
</div>
4837
</div>
4938

0 commit comments

Comments
 (0)