Commit 9946d4bf authored by Mat's avatar Mat
Browse files

Formulaire OffreLegumesSelect, affiche les données du légumes à insérer

parent 74d8e7f1
......@@ -50,6 +50,14 @@ api_legume_search:
_controller: APIBundle:LegumeAPI:search
methods: [ GET ]
api_legume_insert_read:
path: /legume/inserer/{id}
requirements:
id: \d+
defaults:
_controller: APIBundle:LegumeAPI:ReadOne
methods: [ GET ]
api_legume_insert:
path: /legume/inserer/{id}
requirements:
......@@ -58,7 +66,6 @@ api_legume_insert:
_controller: APIBundle:LegumeAPI:insert
methods: [ POST ]
## CRUD OffreAPI
api_offre_create:
......
......@@ -34,14 +34,15 @@ class OffreLegumesInsertType extends AbstractType
->orderBy('o.reference', 'DESC');
},
'choice_label' => 'getReference',
'label' => 'Offres en préparation',
'label' => 'Choisissez une offre',
'placeholder' => 'Offres en préparation :',
'attr' => array('class' => 'form-control form-control-sm'),
));
}
);
$builder->add('sauver', SubmitType::class, array(
'label' => 'Enregistrer',
'label' => 'Insérer',
'attr' => array('class' => 'btn btn-dark mb-2')
));
}
......
......@@ -308,7 +308,7 @@
AJAX('GET', submitURL, function(request)
{
let json = JSON.parse(request.responseText);
titleForm.textContent = 'Légume # ' + json.id;
titleForm.textContent = 'Légume # ' + formatNumber(legumeId, 3);
form.querySelector('#legume_nom').value = json.nom;
......@@ -350,13 +350,13 @@
copyBtn.addEventListener('click', function()
{
let legumeId = this.dataset.legumeId;
let r = confirm('Dupliquer la rangée n°' + legumeId
let r = confirm('Dupliquer la rangée n°' + formatNumber(legumeId, 3)
+ '\nSouhaitez-vous continuer ?\n');
if (r === true) {
submitURL = Routing.generate('api_legume_duplicate', {'id': legumeId });
AJAX('GET', submitURL, function()
{
reloadTableLegume();
reloadTableLegume(paginate);
});
}
});
......@@ -378,12 +378,13 @@
deleteBtn.addEventListener('click', function()
{
let legumeId = this.dataset.legumeId;
let r = confirm('Effacer le légume n°' + legumeId
let r = confirm('Effacer le légume n°' + formatNumber(legumeId, 3)
+ '\nCette action n\'est pas réversible. Souhaitez-vous continuer ?\n');
if (r === true) {
submitURL = Routing.generate('api_legume_delete', {'id': legumeId});
AJAX('DELETE', submitURL, function () {
reloadTableLegume();
AJAX('DELETE', submitURL, function()
{
reloadTableLegume(paginate);
});
}
});
......@@ -410,15 +411,25 @@
submitURL = Routing.generate('api_legume_insert', {'id': legumeId});
let titleInsertForm = document.querySelector('#form-offre-legume-insert');
titleInsertForm.textContent = 'Insérer le légume # ' + jsonRow.id;
AJAX('GET', submitURL, function(request)
titleInsertForm.textContent = 'Insérer le légume # ' + formatNumber(legumeId, 3) + ' dans une offre';
let imageInsertForm = document.querySelector('#form-offre-legume-insert-img');
imageInsertForm.innerHTML = '<div class="logo-md"><div class="crop"><img src="/web/uploads/images/legumes/'
+ jsonRow.image + '" /></div></div>';
let descriptionInsertForm = document.querySelector('#form-offre-legume-insert-div');
descriptionInsertForm.innerHTML = '<h5>' + jsonRow.nom + '</h5>'
+ '<p>' + jsonRow.description + '</p>'
+ (jsonRow.revente ? '<p>Origine: ' + jsonRow.origine + '</p>' : '')
+ '<p>' + (jsonRow.quantite_min ? ' Min: ' + jsonRow.quantite_min : '')
+ (jsonRow.quantite_max ? ' | Max: ' + jsonRow.quantite_max : '')
+ (jsonRow.quantite_step ? ' | Step: ' + jsonRow.quantite_step : '') + '</p>'
+ '<p>' + jsonRow.prix_unitaire + ' €/' + jsonRow.unite + '</p>'
;
AJAX('GET', submitURL, function()
{
console.log('getget');
let json = JSON.parse(request.responseText);
reloadTableLegume();
reloadTableLegume(paginate);
});
});
return insertBtn;
......@@ -494,6 +505,7 @@
{
reloadTableLegume(paginate);
$('.form-legume-modal').modal('hide'); // en jquery
$('.form-offre-legume-insert-modal').modal('hide'); // en jquery
},
form);
});
......
......@@ -9,9 +9,23 @@
</button>
</div>
{{ form_start(formOffreLegumesInsert) }}
<div class="modal-body">
{{ form_errors(formOffreLegumesInsert) }}
<div class="form-group row">
<div class="col-sm-4">
<div id="form-offre-legume-insert-img"></div>
</div>
<div class="col-sm-8">
<div id="form-offre-legume-insert-div"></div>
</div>
</div>
{{ form_errors(formOffreLegumesInsert) }}
<div class="form-group row">
<div class="col-sm-4">
......
......@@ -134,23 +134,40 @@ span#rebours {
padding: 3rem;
}
.logo-md {
width: 150px;
height: 150px;
}
.logo-sm {
width: 50px;
height: 50px;
}
.logo-md,
.logo-sm {
display: inline-block;
vertical-align: top;
overflow: hidden;
}
.logo-md, .logo-md .crop,
.logo-sm, .logo-sm .crop {
border-radius: 5px;
}
.logo-md .crop,
.logo-sm .crop {
height: 100%;
position: relative;
overflow: hidden;
}
.logo-md .crop img {
height: 150px; /*
width: 100px;*/
}
.logo-sm .crop img {
height: 50px; /*
width: 50px;*/
}
.logo-md .crop img,
.logo-sm .crop img {
height: 50px;
min-width: 100%;
min-height: 100%;
display: block;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment