{% extends 'base.html.twig' %}
{% block title %}
<title>MON PANIER | LIONS CLUB Laclaireau | comté de Chiny </title>
<meta name="description" content="MON PANIER | LIONS CLUB Laclaireau | comté de Chiny">
{% endblock %}
{% block body %}
<style>
th
{
font-weight:bold
}
</style>
<div class="container pt-250">
<div class="row">
<div class="col-12">
<h1 class="p16-b bb-green mb-4 d-inline-block text-uppercase">Mon panier de réservations</h1>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Titre</th>
<th scope="col">Date</th>
<th scope="col">Quantité</th>
<th scope="col">Total</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
{% set total = 0 %}
{% for res in resa %}
{% set total = total + res.total %}
<tr>
<th scope="row">
{% if res.evenements.image != 'ok' %}
<img src="{{asset('uploads/'~res.evenements.image)}}" alt="{{res.evenements.titre}}" class="img-thumbnail" style="height:100px">
{% else %}
<img src="{{asset('uploads/default.png')}}" alt="{{res.evenements.titre}}" class="img-thumbnail"style="height:100px">
{% endif %}
</th>
<td>{{res.evenements.titre}}</td>
<td>{{res.evenements.date|date('d-m-Y')}} {{res.evenements.heure}}</td>
<td>{{res.nbPlaces}}</td>
<td>{{res.total}}€</td>
<td><a href="{{path('deletePanier',{'id':res.id})}}" onclick="return confirm('Etes-vous sûr ?')"><i class="fa fa-trash" style="font-size:20px; color:red"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-12">
<h2 style="float:right">Total de la commande : {{total}}€</h2>
</div>
</div>
<br>
<div class="row">
<div class="col-6"></div>
<div class="col-6" style="text-align:right">
{% if ignore == 0 %}
<a href="{{path('stripeForm')}}"> <button class="btn btn-info">Carte bancaire</button></a>
{% else %}
<a href="{{path('validationCmd',{'id':app.user.id})}}"> <button class="btn btn-success">Valider la réservation</button></a>
{% endif %}
</div>
</div>
<!--<script src="https://www.paypal.com/sdk/js?client-id=AX08AWg4eJEOIxaqCkXR7UDWl017IzQTErNfiqNqLfLXEZPfFG39U0vIa_-ZeNP1-GYaxOzIVmfz6XV9&enable-funding=venmo¤cy=EUR" data-sdk-integration-source="button-factory"></script>-->
<script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=EUR" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"custom_id": {{app.user.id}},"description":"Paiement Théâtre Lions Club","amount":{"currency_code":"EUR","value":{{total}}}}],
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
//console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
var obj = orderData.purchase_units[0].custom_id;
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
if(orderData.status == 'COMPLETED')
{
element.innerHTML = '<h3 style="color:green">Merci pour votre paiement!</h3>';
document.location.href="../validation-de-la-commande/"+obj;
}
else
{
element.innerHTML = '<h3 style="color:red">Erreur de paiement</h3>';
}
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
<br><b><br><br>
</div>
</div>
</div>
{% endblock %}