Skip to content
Extraits de code Groupes Projets
Valider e8a5a8ad rédigé par JALIK's avatar JALIK
Parcourir les fichiers

AFTER MERGE : Ajout de la fonction addSpecial dans Menu

parents c91bf306 bb1d6b51
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
foreach($utilisateur->getCommandes() as $commande){ foreach($utilisateur->getCommandes() as $commande){
?> ?>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading text-left">
Vous avez commandé : <br/>
</div>
<div class="panel-body"> <div class="panel-body">
<div class="text-left"> <div class="text-left">
Vous avez commandé : <br/><?php echo $commande->toString();?> <?php echo $commande->toString();?>
</div> </div>
<html>
<form method="post"> <form method="post">
<button class="btn btn-danger btn-xs" name="supprime" style="float: right; margin-bottom: 10px;">Supprimer</button> <button class="btn btn-danger btn-xs" name="supprime" style="float: right; margin-bottom: 10px;">Supprimer</button>
</form> </form>
......
...@@ -20,13 +20,21 @@ ...@@ -20,13 +20,21 @@
{?> {?>
<div class="input-group"> <div class="input-group">
<label class="input-group-addon"><?php echo $typeFood?></label> <label class="input-group-addon"><?php echo $typeFood?></label>
<select name=<?php echo $typeFood['nomType']?> class="form-control"> <select name=<?php echo $typeFood['nomType'];?> class="form-control" onchange="show_special(this)">
<option value="0">Cliquez pour voir les choix</option> <option value="0" slected>Cliquez pour voir les choix</option>
<?php <?php
foreach($typeFood['Foods'] as $food) foreach($typeFood['Foods'] as $food)
{?> {?>
<option value=<?php echo $food['nameFood']?>><?php echo $food['nameFood']." (".$food['priceFood'].")"?></option> <option value="<?php echo $food['nameFood'];?>"><?php echo $food['nameFood']." (".$food['priceFood'].")";?></option>
<?php <?php
int $j = 0;
foreach($food['idSpecial'] as $id)
{?>
<input name="nbMin<?php echo $j;?>" type="hidden" value="<?php echo $food['nbMinSpecial'][$j]; ?>"></span>
<input name="nbMax<?php echo $j;?>" type="hidden" value="<?php echo $food['nbMax'][$j]; ?>"></span>
<?php
$j++;
}
}?> }?>
</select> </select>
</div> </div>
...@@ -35,87 +43,20 @@ ...@@ -35,87 +43,20 @@
</div> </div>
<?php <?php
}?> }?>
</form> </form>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var current_max_meats = 0; function show_special(selectObject)
$('select').change(function ()
{
var food_type_id = $(this).attr('data-food-type');
var parent_sauces = $('#sauce-checkboxes-'+food_type_id).attr('id');
var parent_meats = $('#meat-checkboxes-'+food_type_id).attr('id');
current_max_meats = parseInt($('select[name="'+$(this).attr('name')+'"] option:selected').attr('data-max-meats'));
if ($(this).val() === "0") {
$("#hidden-"+food_type_id).slideUp(200);
refresh_sauce_checkboxes(parent_sauces, true);
refresh_meat_checkboxes(parent_meats, true);
}
else
$("#hidden-"+food_type_id).slideDown(200);
if ($(this).val() === "0")
$('#meat-message-'+food_type_id).html('<strong>Choisissez votre ou vos viandes :</strong>');
else
if (current_max_meats === 1)
$('#meat-message-'+food_type_id).html('<strong>Choisissez votre viande :</strong>');
else
$('#meat-message-'+food_type_id).html('<strong>Choisissez vos viandes <span class="text-danger">('+current_max_meats+' au maximum)</span> :</strong>');
refresh_meat_checkboxes(parent_meats);
})
$('input[type="checkbox"]').click(function ()
{ {
var parent_sauces = $(this).parents('[id^="sauce-checkboxes-"]').attr('id'); var value = selectObject.value;
refresh_sauce_checkboxes(parent_sauces); if (value != "0")
var parent_meats = $(this).parents('[id^="meat-checkboxes-"]').attr('id');
refresh_meat_checkboxes(parent_meats);
})
$('[id^="reset-sauces-"]').click(function ()
{
var id_div = $(this).attr('data-food-type');
refresh_sauce_checkboxes('sauce-checkboxes-'+id_div, true);
})
$('[id^="reset-meats-"]').click(function ()
{
var id_div = $(this).attr('data-food-type');
refresh_meat_checkboxes('meat-checkboxes-'+id_div, true);
})
function refresh_sauce_checkboxes(parent_sauces, clear=false)
{ {
var number_checked_sauces = $('#'+parent_sauces+' input[type="checkbox"]:checked').length; plural_message = ngettext('votre', 'vos', special_count);
if (number_checked_sauces > 2 || clear)
$('#'+parent_sauces+' input[type="checkbox"]').prop('checked', false).prop('disabled', false);
else if (number_checked_sauces === 2)
$('#'+parent_sauces+' input[type="checkbox"]').not(':checked').prop('disabled', true);
else
$('#'+parent_sauces+' input[type="checkbox"]').not(':checked').prop('disabled', false);
} }
function refresh_meat_checkboxes(parent_meats, clear=false)
{
var number_checked_meats = $('#'+parent_meats+' input[type="checkbox"]:checked').length;
if (number_checked_meats > current_max_meats || clear)
$('#'+parent_meats+' input[type="checkbox"]').prop('checked', false).prop('disabled', false);
else if (number_checked_meats === current_max_meats)
$('#'+parent_meats+' input[type="checkbox"]').not(':checked').prop('disabled', true);
else
$('#'+parent_meats+' input[type="checkbox"]').not(':checked').prop('disabled', false);
} }
$('[id^="hidden-"]').hide();
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -27,6 +27,8 @@ $menu3 = new Menu(3,$nourriture3,array($special0,$special1,$special2)); ...@@ -27,6 +27,8 @@ $menu3 = new Menu(3,$nourriture3,array($special0,$special1,$special2));
require_once("Controller/set_utilisateur.php"); require_once("Controller/set_utilisateur.php");
require_once('Model/infos_njv.php'); require_once('Model/infos_njv.php');
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter