{% extends 'base.html.twig' %}
{% block body %}
<br/>
<main id="main">
<section id="pricing" class="pricing section-bg">
<div class="container">
<div class="section-title" data-aos="fade-up">
<br/>
<h3 class="text-center">Hosting solution for your business</h3>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<div>
{{ include('hosting/hosting_search_form.html.twig') }}
</div>
<br/>
<div>
<table class="table table-striped">
<thead>
<tr>
<th class="table-dark">{{ 'entreprise.domain_name' | trans }}</th>
<th class="table-dark">{{ 'entreprise.price' | trans }}</th>
<th class="table-dark">{{ 'entreprise.status' | trans }}</th>
<th class="table-dark">{{ 'entreprise.selection' | trans }}</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{ result.DomainName }}.{{ result.TLD }}</td>
<td>{{ result.Price }}</td>
{% set statut = 'entreprise.' ~ result.Status %}
<td>{{ statut | trans }}</td>
<td>
{% if result.Status == 'available' %}
<form action="{{ path('add_to_card') }}">
<input value="{{ result.DomainName }}" name="nom_de_domaine" hidden />
<input value="{{ result.TLD }}" name="tld" hidden />
<input value="{{ result.Price }}" name="prix" hidden />
<span class="btn-bleu-fonce btn-add-to-cart">{{ 'entreprise.add_to_cart' | trans }}</span>
</form>
{% else %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col">
<div class="col">
<a href="" class="btn-bleu-fonce">{{ 'entreprise.select_all' | trans }}</a>
</div>
</div>
<div class="col">
<a href="{{ path('choose_hosting_plan') }}" class="btn btn-warning btn-lg btn-block rounded">{{ 'entreprise.order' | trans }}</a>
</div>
</div>
</div>
</section>
</main>
{% endblock body %}
{% block javascripts %}
{{ parent() }}
{% set translate = 'js/' ~ app.request.locale ~ '_translate.js' %}
<script type="text/javascript" src="{{ asset(translate) }}"></script>
<script type="text/javascript">
$(function(){
var $btnAddToCart = $('.btn-add-to-cart');
var $checkoutItems = $('.checkoutItems');
$btnAddToCart.click(function(e){
//e.preventDefault();
var $myButton = $(this);
$myButton.attr('disabled', true);
var $form = $(this).parent();
$.ajax({
url: $form.attr('action'),
method: 'POST',
data: $form.serialize(),
//processData: false,
//contentType: false,
success: function (data, textStatus, jqXHR) {
var $nb = parseInt($checkoutItems.text());
$nb++;
toastr.success(t('Added to cart'));
$checkoutItems.text($nb);
},
error: function(jqXHR, textStatus, errorThrown ){
toastr.error(t('An error occured, try again'));
}
});
});
});
</script>
{% endblock javascripts %}