Debug nb_paniers_livres dans function getLivraisonPaniersEligibles
Ignore la livraison en cours de modification dans la fonction getLivraisonLastQuinzGroupeAtDate Debug function getNbLivraisonForContratAtDate Ajout garde fou modifications groupe/date/quinz_groupe edition livraisons Debug modalFormLivraison_getPanierCompoLegumes en cas de legume null Suppression de l'automatisation du rafraichissement automatique du prochain groupe de quinzaine dans le formulaire livraison Suppression des warnings dans les listes de contrats archivés
This commit is contained in:
parent
cf5d9b58bb
commit
e9a95d2829
|
|
@ -75,14 +75,15 @@ function getLivraisonsList($order='id',$sens='ASC', $groupe=0, $archive=0, $limi
|
|||
return $list;
|
||||
}
|
||||
|
||||
function getLivraisonLastQuinzGroupeAtDate($groupe, $date) {
|
||||
function getLivraisonLastQuinzGroupeAtDate($groupe, $date, $ignore=0) {
|
||||
$grp = NULL;
|
||||
|
||||
$sql = "SELECT ".LIVRAISONS_TABLE.".`quinz_groupe` FROM ".LIVRAISONS_TABLE
|
||||
." WHERE ".LIVRAISONS_TABLE.".del=0"
|
||||
." AND ".LIVRAISONS_TABLE.".paniers_groupe=".intval($groupe)
|
||||
." AND ".LIVRAISONS_TABLE.".date<='".$date."'"
|
||||
." ORDER BY ".LIVRAISONS_TABLE.".date DESC LIMIT 0,1";
|
||||
." AND ".LIVRAISONS_TABLE.".date<='".$date."'";
|
||||
if((int)$ignore>0) $sql .= " AND ".LIVRAISONS_TABLE.".ref!=".intval($ignore);
|
||||
$sql .= " ORDER BY ".LIVRAISONS_TABLE.".date DESC LIMIT 0,1";
|
||||
|
||||
$r = $GLOBALS['db_admin']['man']->select($sql);
|
||||
|
||||
|
|
@ -351,7 +352,7 @@ function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $pa
|
|||
|
||||
if(!$r['erreur']) {
|
||||
foreach($r['datas'] as $i) {
|
||||
$i["nb_paniers_livres"] = getNbLivraisonForContratAtDate($i['ref'], $date) + intval($i["np_paniers_distrib_avt_saisie"]);
|
||||
$i["nb_paniers_livres"] = getNbLivraisonForContratAtDate($i['contrat_ref'], $date) + intval($i["np_paniers_distrib_avt_saisie"]);
|
||||
$i["nb_paniers_restants"] = intval($i["nb_paniers"])-$i["nb_paniers_livres"];
|
||||
$i["frequence_print"] = CONTRATS_FREQUENCES[$i["frequence"]];
|
||||
if($i["frequence"] == "quinz") $i["frequence_print"] .= " <small>(groupe ".$i["quinz_groupe"].")</small>";
|
||||
|
|
@ -430,7 +431,7 @@ function getNbLivraisonForContratAtDate($contrat, $date) {
|
|||
$GLOBALS['errors'][] = "Une erreur est survenue durant la récupération du nombre de livraison du contrat dans le base de données !".$er;
|
||||
}
|
||||
|
||||
return $i;
|
||||
return $nb;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -283,18 +283,38 @@ function modalFormLivraison_init(modal) {
|
|||
modal.find("select[name=paniers_groupe]").change(function(e) {
|
||||
$(this).blur();
|
||||
modalFormLivraison_loadPaniers(modal, []);
|
||||
modalFormLivraison_loadNextGroupe(modal);
|
||||
});
|
||||
modal.find("input[name=date]").on("blur change", function(e) {
|
||||
modalFormLivraison_loadPaniers(modal, []);
|
||||
modalFormLivraison_loadNextGroupe(modal);
|
||||
});
|
||||
modal.find("input[name=date]").keydown(function(e) { if(e.keyCode==13) { e.preventDefault(); $(this).blur(); } })
|
||||
modal.find("select[name=quinz_groupe]").change(function(e) {
|
||||
$(this).blur();
|
||||
modalFormLivraison_loadPaniers(modal, []);
|
||||
});
|
||||
|
||||
modal.find("button.btnLoadNextQuinzGroup").click(function(e) {
|
||||
e.preventDefault(); $(this).blur();
|
||||
$datas = {
|
||||
'action' : 'last_quinz_groupe',
|
||||
'groupe' : modal.find("select[name=paniers_groupe]").val(),
|
||||
'date' : modal.find("input[name=date]").val()
|
||||
};
|
||||
edit_id = parseInt(modal.attr("edit_id"));
|
||||
if(edit_id>0) $datas.ignore = edit_id;
|
||||
$.post(livraisonsConf.baseURL, $datas, function(result) {
|
||||
$grp = "A";
|
||||
if(result == "A") $grp = "B";
|
||||
else if(result != "B") return;
|
||||
modal.find("select[name=quinz_groupe]").val($grp);
|
||||
modalFormLivraison_loadPaniers(modal, []);
|
||||
}).fail(function() { alert("ERREUR SERVEUR (modal form livraison - get next groupe)"); });
|
||||
});
|
||||
|
||||
modal.find("button.btnLivraisonEnableEditField").click(function(e) {
|
||||
e.preventDefault(); $(this).blur();
|
||||
$(this).parent().find(".form-control, .btnLoadNextQuinzGroup").each( function(n,e) { $(this).prop("disabled", !$(this).prop("disabled")); });
|
||||
});
|
||||
|
||||
// TAB PANIERS
|
||||
modal.find("thead.paniersList td.status").click(function(e) {
|
||||
var allChecked = true;
|
||||
|
|
@ -306,14 +326,19 @@ function modalFormLivraison_init(modal) {
|
|||
modalFormLivraison_clear(modal);
|
||||
}
|
||||
|
||||
function modalFormLivraison_loadDatas(modal,id) {
|
||||
function modalFormLivraison_loadDatas(modal,id,copy) {
|
||||
$.post(livraisonsConf.baseURL, { 'ref' : id, 'action' : 'getDatas' }, function(jsonTxt) {
|
||||
var datas = JSON.parse(jsonTxt);
|
||||
|
||||
|
||||
modal.find("select[name=paniers_groupe]").val(datas.paniers_groupe_ref);
|
||||
modal.find("input[name=date]").val(datas.date);
|
||||
modal.find("select[name=quinz_groupe]").val(datas.quinz_groupe);
|
||||
|
||||
if(copy!==true) {
|
||||
modal.find("div.tabGeneral .form-control, .btnLoadNextQuinzGroup").prop("disabled", true);
|
||||
modal.find("button.btnLivraisonEnableEditField").removeClass("hide");
|
||||
}
|
||||
|
||||
modalFormLivraison_loadPaniers(modal, datas.paniers_contrats);
|
||||
modalFormLivraison_udpateCompo(modal, datas.legumes);
|
||||
|
||||
|
|
@ -331,26 +356,15 @@ function modalFormLivraison_clear(modal) {
|
|||
modal.find("input[name=date]").val(getTodayDate("yyyy-mm-dd"));
|
||||
modal.find("select[name=quinz_groupe]").val("A");
|
||||
|
||||
modal.find("div.tabGeneral .form-control, .btnLoadNextQuinzGroup").prop("disabled", false);
|
||||
modal.find("button.btnLivraisonEnableEditField").addClass("hide");
|
||||
|
||||
modalFormLivraison_clearPaniers(modal);
|
||||
modalFormLivraison_clearCompo(modal);
|
||||
}
|
||||
|
||||
// LIVRAISON - PANIERS
|
||||
|
||||
function modalFormLivraison_loadNextGroupe(modal) {
|
||||
$datas = {
|
||||
'action' : 'last_quinz_groupe',
|
||||
'groupe' : modal.find("select[name=paniers_groupe]").val(),
|
||||
'date' : modal.find("input[name=date]").val()
|
||||
};
|
||||
$.post(livraisonsConf.baseURL, $datas, function(result) {
|
||||
$grp = "A";
|
||||
if(result == "A") $grp = "B";
|
||||
else if(result != "B") return;
|
||||
modal.find("select[name=quinz_groupe]").val($grp);
|
||||
}).fail(function() { alert("ERREUR SERVEUR (modal form livraison - get next groupe)"); });
|
||||
}
|
||||
|
||||
function modalFormLivraison_loadPaniers(modal, paniers) {
|
||||
datas = {
|
||||
'action' : 'paniers_eligibles',
|
||||
|
|
@ -826,7 +840,7 @@ function modalFormLivraison_getPanierCompoLegumes(modal, ref) {
|
|||
var legumes = [];
|
||||
table.find("tr.legume").each(function(n,e) {
|
||||
datas = modalFormLivraison_getPanierCompoLegumeDatas($(this));
|
||||
if(typeof(datas) == "object") legumes.push(datas);
|
||||
if(typeof(datas) == "object" && datas!=null) legumes.push(datas);
|
||||
});
|
||||
|
||||
return legumes;
|
||||
|
|
@ -836,7 +850,7 @@ function modalFormLivraison_getPanierCompoLegumeDatas(tr) {
|
|||
ref = parseInt( tr.attr('ref') );
|
||||
if(ref>0) {
|
||||
tdNom = tr.find("td.nom");
|
||||
return {
|
||||
datas = {
|
||||
'ref' : ref,
|
||||
'nom' : tdNom.html(),
|
||||
'tarif_ref' : parseInt( tdNom.attr("tarif_ref") ),
|
||||
|
|
@ -844,6 +858,8 @@ function modalFormLivraison_getPanierCompoLegumeDatas(tr) {
|
|||
'tarif_unite' : tdNom.attr("tarif_unite"),
|
||||
'quantite' : parseFloat( tr.find("td.quantite").html() )
|
||||
}
|
||||
if(datas.tarif_ref>0 && datas.quantite>0) return datas;
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ switch($action) {
|
|||
if(!isset($_REQUEST['date'])) die("NO DATE");
|
||||
$date = checkDateFormat($_REQUEST['date'], "mysql_date");
|
||||
if(is_null($date)) die("WRONG DATE");
|
||||
die( strval( getLivraisonLastQuinzGroupeAtDate(intval($_REQUEST['groupe']), $date) ) );
|
||||
$ignore = 0;
|
||||
if(isset($_REQUEST['ignore']) && (int)$_REQUEST['ignore']>0) $ignore = intval($_REQUEST['ignore']);
|
||||
die( strval( getLivraisonLastQuinzGroupeAtDate(intval($_REQUEST['groupe']), $date, $ignore) ) );
|
||||
} break;
|
||||
// PANIERS ELIGIBLES
|
||||
case "paniers_eligibles": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{foreach from=$list item=i}
|
||||
<tr class="{if $i.archive>0}archive{/if}{if $i.warning_nb_paniers && $i.ignore_warning==0} warning{/if}{if $i.nb_paniers_restants<=0 && $i.ignore_warning==0} danger{/if}">
|
||||
<tr class="{if $i.archive>0}archive{else}{if $i.warning_nb_paniers && $i.ignore_warning==0}warning{/if}{if $i.nb_paniers_restants<=0 && $i.ignore_warning==0} danger{/if}{/if}">
|
||||
<td class="center visible-lg id">{$i.ref}</td>
|
||||
<td class="name"><a href="#" class="btnViewContrat" ref={$i.ref}>{$i.client_prenom} {$i.client_nom}</a></td>
|
||||
<td class="visible-lg groupe">{$i.groupe_nom}</td>
|
||||
|
|
|
|||
|
|
@ -10,19 +10,27 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<button class="btn btn-xs btn-default pull-right glyphicon glyphicon-edit btnLivraisonEnableEditField"></button>
|
||||
<label>groupe de paniers :</label>
|
||||
<select class="form-control" name="paniers_groupe">{include file='paniers_groupes/paniers_groupes_select_list.tpl'}</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-xs btn-default pull-right glyphicon glyphicon-edit btnLivraisonEnableEditField"></button>
|
||||
<label>date :</label>
|
||||
<input type="date" class="form-control" name="date" placeholder="date de début">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>groupe bi-hebdo :</label>
|
||||
<select class="form-control" name="quinz_groupe">
|
||||
<option value="A">Groupe A</option>
|
||||
<option value="B">Groupe B</option>
|
||||
</select>
|
||||
<button class="btn btn-xs btn-default pull-right glyphicon glyphicon-edit btnLivraisonEnableEditField"></button>
|
||||
<label>groupe quinzaine :</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" name="quinz_groupe">
|
||||
<option value="A">Groupe A</option>
|
||||
<option value="B">Groupe B</option>
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btnLoadNextQuinzGroup"><i class="glyphicon glyphicon-refresh"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue