Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/Http/Controllers/SponsorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ public function updateSponsorGold(Request $request)
$apartments = Apartment::where('user_id', $superId)->with('sponsorships')->get();
return view('apartments.index', compact('apartments', 'superId'));
}

public function showPaymentPage()
{
$selectedApartments = [];
$totalPrice = 0;

return view('sponsors.payment', compact('selectedApartments', 'totalPrice'));
}
}
4 changes: 4 additions & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.active {
background-color: #FFD700;
color: #000;
}
35 changes: 4 additions & 31 deletions resources/views/sponsors/createBronze.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@

<div class="flex justify-between items-center mt-8">
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
<div id="dropin-container"></div>
<input type="hidden" id="nonce" name="payment_method_nonce">
<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">
Attiva Piano Bronze
</button>
<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">
Procedi al Pagamento
</a>
</div>

</form>
</div>
</div>
Expand All @@ -52,7 +49,6 @@
}

</style>
<script src="https://js.braintreegateway.com/web/dropin/1.31.0/js/dropin.min.js"></script>
<script>
function calculateTotal() {
const checkboxes = document.querySelectorAll('input[name="apartments[]"]:checked');
Expand All @@ -61,28 +57,5 @@ function calculateTotal() {
let total = checkboxes.length * pricePerApartment;
totalPriceElement.textContent = total.toFixed(2) + ' €';
}
fetch('/payment/token')
.then(response => response.json())
.then(data => {
braintree.dropin.create({
authorization: data.token,
container: '#dropin-container'
}, function (createErr, instance) {
if (createErr) {
console.error('Errore nella creazione del Drop-in:', createErr);
return;
}
document.getElementById('submit-button').addEventListener('click', function () {
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.error(err);
return;
}
document.getElementById('nonce').value = payload.nonce;
document.getElementById('payment-form').submit();
});
});
});
});
</script>
</script>
@endsection
94 changes: 28 additions & 66 deletions resources/views/sponsors/createGold.blade.php
Original file line number Diff line number Diff line change
@@ -1,81 +1,44 @@
@extends('dashboard')

@section('content')
<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">
<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">
<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>
<form id="payment-form" action="{{ route('updateSponsorGold') }}" method="POST">

@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-10">
<!-- Foreach degli appartamenti -->
@foreach($apartments as $apartment)
<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">
<img src="{{ $apartment->cover_image }}" alt="Property Image" class="w-full h-56 object-cover">
<div class="p-6">
<h3 class="text-2xl font-semibold text-yellow-400 mb-4">{{ $apartment->title }}</h3>
<p class="text-gray-300 mb-4">{{ Str::limit($apartment->description, 100, '...') }}</p>
<p class="text-yellow-400 font-bold text-lg">Prezzo: 9,99 €</p>

<div class="flex items-center mt-6">
<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 }})">
<label for="apartment-{{ $apartment->id }}" class="text-lg font-semibold text-gray-100">Seleziona</label>
</div>

<!-- Sponsorizzazione Attiva/Inattiva -->
@if($apartment->sponsorships->where('name', 'Gold')->first())
<p class="mt-4 text-sm font-bold text-green-400">Stato: Attivo</p>
@else
<p class="mt-4 text-sm font-bold text-red-500">Stato: Inattivo</p>
@endif
</div>
</div>
<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">
<div class="max-w-5xl mx-auto grid grid-cols-1 gap-8">

<!-- Card Dettagli Appartamenti -->
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Dettagli Appartamenti</h2>
<ul class="mb-6">
@foreach($selectedApartments as $apartment)
<li class="text-lg text-white mb-2">
<strong>{{ $apartment->title }}</strong> - Prezzo: {{ number_format($totalPrice, 2) }} €
</li>
@endforeach
<!-- Fine del foreach -->
</div>

<div class="flex justify-between items-center mt-8">
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
<div id="dropin-container"></div>
</ul>
<p class="text-2xl font-bold text-white">Piano: Gold</p>
<p class="text-2xl font-bold text-white mt-4">Prezzo Totale: <span id="totalPrice">{{ number_format($totalPrice, 2) }} €</span></p>
</div>

<!-- Card Pagamento -->
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Pagamento</h2>
<form action="{{ route('updateSponsorGold') }}" method="POST" id="payment-form">
@csrf
<div id="dropin-container" class="mb-6"></div>
<input type="hidden" id="nonce" name="payment_method_nonce">
<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">
<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">
Attiva Piano Gold
</button>
</div>
</form>
<p class="mt-6 text-sm text-gray-400">
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>.
</p>
</div>

</form>
</div>
</div>

<style>
.hover\:glow:hover {
box-shadow: 0px 0px 10px 5px rgba(0, 77, 77, 0.4);
}
</style>
<script src="https://js.braintreegateway.com/web/dropin/1.31.0/js/dropin.min.js"></script>

<script>
function toggleCardSelection(apartmentId) {
const card = document.getElementById(`card-${apartmentId}`);
const checkbox = document.getElementById(`apartment-${apartmentId}`);

if (checkbox.checked) {
card.classList.add('selected-card');
} else {
card.classList.remove('selected-card');
}

calculateTotal(); // Update the total price whenever a card is selected/deselected
}

function calculateTotal() {
const checkboxes = document.querySelectorAll('input[name="apartments[]"]:checked');
const totalPriceElement = document.getElementById('totalPrice');
const pricePerApartment = 9.99;
let total = checkboxes.length * pricePerApartment;
totalPriceElement.textContent = total.toFixed(2) + ' €';
}

fetch('/payment/token')
.then(response => response.json())
.then(data => {
Expand All @@ -100,5 +63,4 @@ function calculateTotal() {
});
});
</script>

@endsection
67 changes: 28 additions & 39 deletions resources/views/sponsors/createSilver.blade.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
@extends('dashboard')

@section('content')
<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">
<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">
<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>
<form id="payment-form" action="{{ route('updateSponsorSilver') }}" method="POST">

@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-10">
<!-- Foreach degli appartamenti -->
@foreach($apartments as $apartment)
<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">
<img src="{{ $apartment->cover_image }}" alt="Property Image" class="w-full h-56 object-cover">
<div class="p-6">
<h3 class="text-2xl font-semibold text-gray-300 mb-4">{{ $apartment->title }}</h3>
<p class="text-gray-300 mb-4">{{ Str::limit($apartment->description, 100, '...') }}</p>
<p class="text-gray-400 font-bold text-lg">Prezzo: 5,99 €</p>

<div class="flex items-center mt-6">
<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 }})">
<label for="apartment-{{ $apartment->id }}" class="text-lg font-semibold text-gray-100">Seleziona</label>
</div>

<!-- Sponsorizzazione Attiva/Inattiva -->
@if($apartment->sponsorships->where('name', 'Silver')->first())
<p class="mt-4 text-sm font-bold text-green-400">Stato: Attivo</p>
@else
<p class="mt-4 text-sm font-bold text-red-500">Stato: Inattivo</p>
@endif
</div>
</div>
<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">
<div class="max-w-5xl mx-auto grid grid-cols-1 gap-8">

<!-- Card Dettagli Appartamenti -->
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Dettagli Appartamenti</h2>
<ul class="mb-6">
@foreach($selectedApartments as $apartment)
<li class="text-lg text-white mb-2">
<strong>{{ $apartment->title }}</strong> - Prezzo: {{ number_format($totalPrice, 2) }} €
</li>
@endforeach
<!-- Fine del foreach -->
</div>

<div class="flex justify-between items-center mt-8">
<p class="text-2xl font-bold text-white">Prezzo Totale: <span id="totalPrice">0,00 €</span></p>
<div id="dropin-container"></div>
</ul>
<p class="text-2xl font-bold text-white">Piano: Silver</p>
<p class="text-2xl font-bold text-white mt-4">Prezzo Totale: <span id="totalPrice">{{ number_format($totalPrice, 2) }} €</span></p>
</div>

<!-- Card Pagamento -->
<div class="bg-neutral-800 p-8 rounded-3xl shadow-xl">
<h2 class="text-3xl font-extrabold text-gray-100 mb-6 text-center border-b-4 border-yellow-700 pb-4">Pagamento</h2>
<form action="{{ route('updateSponsorSilver') }}" method="POST" id="payment-form">
@csrf
<div id="dropin-container" class="mb-6"></div>
<input type="hidden" id="nonce" name="payment_method_nonce">
<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">
<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">
Attiva Piano Silver
</button>
</div>

</form>
</form>
<p class="mt-6 text-sm text-gray-400">
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
</p>
</div>
</div>
</div>

Expand Down
Loading