Debug function getClientComplementDuAtDate avec prise en charge des complements avt saisie
Table hover dans les formulaires livraisons Groupement des paniers d'un même client dans la feuille d'émargement
This commit is contained in:
parent
23ed75e434
commit
415d04537d
|
|
@ -141,6 +141,25 @@ function getClientAbsences($id) { return getClientAbsencesList("fin", "DESC", $i
|
||||||
function getClientComplementDuAtDate($id, $date) {
|
function getClientComplementDuAtDate($id, $date) {
|
||||||
$val = 0;
|
$val = 0;
|
||||||
|
|
||||||
|
// CONTRATS
|
||||||
|
$sql = "SELECT"
|
||||||
|
." CASE WHEN ISNULL(`complement_avt_saisie`)"
|
||||||
|
." THEN 0.0"
|
||||||
|
." ELSE `complement_avt_saisie`"
|
||||||
|
." END as 'complement_avt_saisie'"
|
||||||
|
." FROM ".CONTRATS_TABLE
|
||||||
|
." WHERE `client`=".intval($id)
|
||||||
|
." AND `date`<'".$date."'";
|
||||||
|
|
||||||
|
$r = $GLOBALS['db_admin']['man']->select($sql,1);
|
||||||
|
|
||||||
|
if(!$r['erreur']) $val += floatval($r['datas']['complement_avt_saisie']);
|
||||||
|
else {
|
||||||
|
$er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']);
|
||||||
|
return "Une erreur est survenue durant la récupération du complement dû par le client dans le base de données !".$er;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PANIERS
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." CASE WHEN ISNULL( SUM(`complement`) - SUM(`complement_regle`) )"
|
." CASE WHEN ISNULL( SUM(`complement`) - SUM(`complement_regle`) )"
|
||||||
." THEN 0.00"
|
." THEN 0.00"
|
||||||
|
|
@ -155,10 +174,10 @@ function getClientComplementDuAtDate($id, $date) {
|
||||||
|
|
||||||
$r = $GLOBALS['db_admin']['man']->select($sql,1);
|
$r = $GLOBALS['db_admin']['man']->select($sql,1);
|
||||||
|
|
||||||
if(!$r['erreur']) $val = $r['datas']['complement_du'];
|
if(!$r['erreur']) $val += floatval($r['datas']['complement_du']);
|
||||||
else {
|
else {
|
||||||
$er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']);
|
$er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']);
|
||||||
$GLOBALS['errors'][] = "Une erreur est survenue durant la récupération dû complement du par le client dans le base de données !".$er;
|
return "Une erreur est survenue durant la récupération du complement dû par le client dans le base de données !".$er;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
|
|
|
||||||
|
|
@ -142,24 +142,42 @@ function getLivraisonEmargementList($paniers_eligibles, $date, $lieu=0) {
|
||||||
if($l["ref"] == $lieu || !$lieu>0) {
|
if($l["ref"] == $lieu || !$lieu>0) {
|
||||||
foreach($l["paniers"] as $pType) {
|
foreach($l["paniers"] as $pType) {
|
||||||
foreach($pType["paniers"] as $p) {
|
foreach($pType["paniers"] as $p) {
|
||||||
|
if(array_key_exists($p["client_ref"], $list)) {
|
||||||
if($p["present"]) {
|
if($p["present"]) {
|
||||||
$du = getClientComplementDuAtDate($p["client_ref"], $date);
|
$o = $list[$p["client_ref"]];
|
||||||
if($du > 0) $p["complement_du"] = "$du €";
|
|
||||||
else if($du < 0) $p["complement_du"] = abs($du)." € d'avoir";
|
|
||||||
else $p["complement_du"] = "/";
|
|
||||||
|
|
||||||
if((float)$p["complement"]>0) $p["complement"] .= " €";
|
// COMPLEMENT
|
||||||
else $p["complement"] = "";
|
if((float)$p["complement"]>0) $o["complement_print"] = number_format(($o["complement"] + $p["complement"]), 2, '.', ' ')." €";
|
||||||
|
// COMPLEMENT REGLE
|
||||||
|
if((float)$p["complement_regle"]>0) $o["complement_regle_print"] = number_format(($o["complement_regle"] + $p["complement_regle"]), 2, '.', ' ')." €";
|
||||||
|
// PANIERS
|
||||||
|
$o["paniers"][] = $p;
|
||||||
|
|
||||||
if((float)$p["complement_regle"]>0) $p["complement_regle"] .= " €";
|
$list[$p["client_ref"]] = $o;
|
||||||
else $p["complement_regle"] = "";
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$p["complement_du"] = "/";
|
$p["complement_du_print"] = "/";
|
||||||
$p["complement"] = "/";
|
$p["complement_print"] = "";
|
||||||
$p["complement_regle"] = "/";
|
$p["complement_regle_print"] = "";
|
||||||
|
|
||||||
|
if($p["present"]) {
|
||||||
|
// COMPLEMENT DU
|
||||||
|
$p["complement_du"] = getClientComplementDuAtDate($p["client_ref"], $date);
|
||||||
|
if($p["complement_du"] > 0) $p["complement_du_print"] = number_format($p["complement_du"], 2, '.', ' ')." €";
|
||||||
|
else if($p["complement_du"] < 0) $p["complement_du_print"] = number_format(abs($p["complement_du"]), 2, '.', ' ')." € d'avoir";
|
||||||
|
|
||||||
|
// COMPLEMENT
|
||||||
|
if((float)$p["complement"]>0) $p["complement_print"] = number_format($p["complement"], 2, '.', ' ')." €";
|
||||||
|
// COMPLEMENT REGLE
|
||||||
|
if((float)$p["complement_regle"]>0) $p["complement_regle_print"] = number_format($p["complement_regle"], 2, '.', ' ')." €";
|
||||||
|
// PANIERS
|
||||||
|
$p["paniers"] = array();
|
||||||
|
$p["paniers"][] = $p;
|
||||||
|
}
|
||||||
|
|
||||||
|
$list[$p["client_ref"]] = $p;
|
||||||
}
|
}
|
||||||
$list[] = $p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -376,7 +394,6 @@ function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $pa
|
||||||
}
|
}
|
||||||
|
|
||||||
// AJOUT
|
// AJOUT
|
||||||
|
|
||||||
$list[$lieu]["paniers"][$pType]["paniers"][] = $i;
|
$list[$lieu]["paniers"][$pType]["paniers"][] = $i;
|
||||||
if($i["present"]) {
|
if($i["present"]) {
|
||||||
$list[$lieu]["nb_paniers"]++;
|
$list[$lieu]["nb_paniers"]++;
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,8 @@
|
||||||
|
|
||||||
.formLivraison table.panier tr.legume td.unite { width: 40px; }
|
.formLivraison table.panier tr.legume td.unite { width: 40px; }
|
||||||
|
|
||||||
|
.formLivraison table.panier tr.editing { background-color: #cdebf8; }
|
||||||
|
|
||||||
.formLivraison table.panier th.nb_paniers_restants,
|
.formLivraison table.panier th.nb_paniers_restants,
|
||||||
.formLivraison table.panier td.nb_paniers_restants { width: 120px; text-align: center; }
|
.formLivraison table.panier td.nb_paniers_restants { width: 120px; text-align: center; }
|
||||||
|
|
||||||
|
|
@ -233,6 +235,12 @@ table.emargement .nb_paniers { max-width: 25px; }
|
||||||
table.emargement .complement { max-width: 40px; }
|
table.emargement .complement { max-width: 40px; }
|
||||||
table.emargement .signature { max-width: 60px; }
|
table.emargement .signature { max-width: 60px; }
|
||||||
|
|
||||||
|
table.emargement .type.multi_paniers,
|
||||||
|
table.emargement .nb_paniers.multi_paniers {
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
table.emargement tr.absent { background-color: #F0F0F0; }
|
table.emargement tr.absent { background-color: #F0F0F0; }
|
||||||
|
|
||||||
table.emargement tr.absent td.nom,
|
table.emargement tr.absent td.nom,
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ function modalViewLivraison_loadPaniers() {
|
||||||
modalViewLivraison.find("div.tabPaniers tr:not(.absent) td.complement").each(function(n,e) {
|
modalViewLivraison.find("div.tabPaniers tr:not(.absent) td.complement").each(function(n,e) {
|
||||||
$(this).addClass("editable").dblclick(function(e) {
|
$(this).addClass("editable").dblclick(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
$(this).parent().addClass("editing");
|
||||||
val = parseFloat( $(this).html() );
|
val = parseFloat( $(this).html() );
|
||||||
var ipt = $("<input class='editable complement' type='text' old_value='0'>");
|
var ipt = $("<input class='editable complement' type='text' old_value='0'>");
|
||||||
$(this).html("").append(ipt);
|
$(this).html("").append(ipt);
|
||||||
|
|
@ -199,6 +200,7 @@ function modalViewLivraison_loadPaniers() {
|
||||||
|
|
||||||
if(val>0) ipt.val(val).attr("old_value", val);
|
if(val>0) ipt.val(val).attr("old_value", val);
|
||||||
ipt.blur(function(e) {
|
ipt.blur(function(e) {
|
||||||
|
$(this).parent().parent().removeClass("editing");
|
||||||
if( $(this).hasClass("saving") ) return;
|
if( $(this).hasClass("saving") ) return;
|
||||||
if( parseFloat($(this).attr("old_value"))>0 ) ipt.parent().html(number_format(parseFloat($(this).attr("old_value")), 2)+" €");
|
if( parseFloat($(this).attr("old_value"))>0 ) ipt.parent().html(number_format(parseFloat($(this).attr("old_value")), 2)+" €");
|
||||||
else ipt.parent().html(".")
|
else ipt.parent().html(".")
|
||||||
|
|
@ -211,12 +213,25 @@ function modalViewLivraison_loadPaniers() {
|
||||||
modalViewLivraison.find("div.tabPaniers tr:not(.absent) td.complement_regle").each(function(n,e) {
|
modalViewLivraison.find("div.tabPaniers tr:not(.absent) td.complement_regle").each(function(n,e) {
|
||||||
$(this).addClass("editable").dblclick(function(e) {
|
$(this).addClass("editable").dblclick(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
$(this).parent().addClass("editing");
|
||||||
val = parseFloat( $(this).html() );
|
val = parseFloat( $(this).html() );
|
||||||
var ipt = $("<input class='editable complement_regle' type='text' old_value='0'>");
|
var ipt = $("<input class='editable complement_regle' type='text' old_value='0'>");
|
||||||
$(this).html("").append(ipt);
|
$(this).html("").append(ipt);
|
||||||
initFloatInput(ipt);
|
initFloatInput(ipt);
|
||||||
|
ipt.keypress( function(event) {
|
||||||
|
if(event.keyCode==13) {
|
||||||
|
$(this).addClass("saving");
|
||||||
|
modalViewLivraison_saveComplement( $(this) );
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if(val>0) ipt.val(val).attr("old_value", val);
|
if(val>0) ipt.val(val).attr("old_value", val);
|
||||||
ipt.blur(function(e) { modalViewLivraison_saveComplement( $(this) ); });
|
ipt.blur(function(e) {
|
||||||
|
$(this).parent().parent().removeClass("editing");
|
||||||
|
if( $(this).hasClass("saving") ) return;
|
||||||
|
if( parseFloat($(this).attr("old_value"))>0 ) ipt.parent().html(number_format(parseFloat($(this).attr("old_value")), 2)+" €");
|
||||||
|
else ipt.parent().html(".")
|
||||||
|
});
|
||||||
ipt.select();
|
ipt.select();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -451,7 +466,7 @@ function modalFormLivraison_udpateCompo(modal, paniersTypes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function modalFormLivraison_addPanierTypeCompo(modal, datas) {
|
function modalFormLivraison_addPanierTypeCompo(modal, datas) {
|
||||||
var table = $("<table class='panier'></table>")
|
var table = $("<table class='panier table-hover'></table>")
|
||||||
.attr("ref", datas.ref)
|
.attr("ref", datas.ref)
|
||||||
.attr("modal", modal.attr('id'));
|
.attr("modal", modal.attr('id'));
|
||||||
|
|
||||||
|
|
@ -467,6 +482,7 @@ function modalFormLivraison_addPanierTypeCompo(modal, datas) {
|
||||||
|
|
||||||
btnCopyCompo.click(function(e) {
|
btnCopyCompo.click(function(e) {
|
||||||
e.preventDefault(); $(this).blur();
|
e.preventDefault(); $(this).blur();
|
||||||
|
if(e.clientX==0 && e.clientY==0) return;
|
||||||
modalFormLivraison_copyPanierTypeCompo(modal, table, $(this));
|
modalFormLivraison_copyPanierTypeCompo(modal, table, $(this));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -537,6 +553,7 @@ function modalFormLivraison_addPanierTypeCompoLegume(modal, panier, datas) {
|
||||||
|
|
||||||
/*** INITIALIZE ***/
|
/*** INITIALIZE ***/
|
||||||
tdNom.dblclick(function(e) {
|
tdNom.dblclick(function(e) {
|
||||||
|
$(this).parent().addClass("editing");
|
||||||
var ipt = $("<input class='editable legume' type='text'>").val($(this).html());
|
var ipt = $("<input class='editable legume' type='text'>").val($(this).html());
|
||||||
ipt.attr('ref', $(this).attr('ref'))
|
ipt.attr('ref', $(this).attr('ref'))
|
||||||
.attr('tarif_ref', $(this).attr('tarif_ref'))
|
.attr('tarif_ref', $(this).attr('tarif_ref'))
|
||||||
|
|
@ -601,6 +618,7 @@ function modalFormLivraison_addPanierTypeCompoLegume(modal, panier, datas) {
|
||||||
val = $(this).html();
|
val = $(this).html();
|
||||||
unite = $(this).attr("unite");
|
unite = $(this).attr("unite");
|
||||||
if(unite in legumeTarifUnitesAccronymes) {
|
if(unite in legumeTarifUnitesAccronymes) {
|
||||||
|
$(this).parent().addClass("editing");
|
||||||
var ipt = $("<input class='editable quantite' type='number' step='0.1'>");
|
var ipt = $("<input class='editable quantite' type='number' step='0.1'>");
|
||||||
$(this).html("").append(ipt);
|
$(this).html("").append(ipt);
|
||||||
initFloatInput(ipt);
|
initFloatInput(ipt);
|
||||||
|
|
@ -609,7 +627,7 @@ function modalFormLivraison_addPanierTypeCompoLegume(modal, panier, datas) {
|
||||||
var td = $(this).parent();
|
var td = $(this).parent();
|
||||||
val = parseFloat( $(this).val() );
|
val = parseFloat( $(this).val() );
|
||||||
td.html( number_format(val, 3) );
|
td.html( number_format(val, 3) );
|
||||||
td.parent().updateCompoLegumeMontant();
|
td.parent().removeClass("editing").updateCompoLegumeMontant(true);
|
||||||
});
|
});
|
||||||
ipt.select();
|
ipt.select();
|
||||||
}
|
}
|
||||||
|
|
@ -640,7 +658,7 @@ function modalFormLivraison_loadPanierTypeCompoLegumeTarif(row, tarif_ref, tarif
|
||||||
|
|
||||||
row.find("td.quantite_unite").html(unite);
|
row.find("td.quantite_unite").html(unite);
|
||||||
|
|
||||||
row.updateCompoLegumeMontant();
|
row.updateCompoLegumeMontant(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function modalFormLivraison_refreshPanierTypeCompoLegumeTarif(modal, panier, row) {
|
function modalFormLivraison_refreshPanierTypeCompoLegumeTarif(modal, panier, row) {
|
||||||
|
|
@ -690,7 +708,7 @@ function modalFormLivraison_copyPanierTypeCompo(modal, panier, btn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$.fn.updateCompoLegumeMontant = function() {
|
$.fn.updateCompoLegumeMontant = function(focus) {
|
||||||
q = parseFloat($(this).find("td.quantite").html());
|
q = parseFloat($(this).find("td.quantite").html());
|
||||||
t = parseFloat($(this).find("td.tarif").html());
|
t = parseFloat($(this).find("td.tarif").html());
|
||||||
$(this).find("td.montant").html( number_format(q * t, 2)+" €" );
|
$(this).find("td.montant").html( number_format(q * t, 2)+" €" );
|
||||||
|
|
@ -698,7 +716,8 @@ $.fn.updateCompoLegumeMontant = function() {
|
||||||
// UPDATE TOTAL
|
// UPDATE TOTAL
|
||||||
panier = $(this).parent().parent();
|
panier = $(this).parent().parent();
|
||||||
modalFormLivraison_updateMontantTotalPanier(panier);
|
modalFormLivraison_updateMontantTotalPanier(panier);
|
||||||
panier.find(".btnAddLegume").focus();
|
|
||||||
|
if(focus) panier.find(".btnAddLegume").focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
function modalFormLivraison_updateMontantTotalPanier(panier) {
|
function modalFormLivraison_updateMontantTotalPanier(panier) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
<span class="nullChild">aucun panier</span>
|
<span class="nullChild">aucun panier</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab tabLegumes">
|
<div class="tab tabLegumes">
|
||||||
<table class="panier legumesTotal">
|
<table class="panier table-hover legumesTotal">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="title">
|
<tr class="title">
|
||||||
<th class="titre" colspan="2">TOTAL :</th>
|
<th class="titre" colspan="2">TOTAL :</th>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{foreach from=$lieux item=lieu}
|
{foreach from=$lieux item=lieu}
|
||||||
<table class="table panier">
|
<table class="table table-hover panier">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="lieuTitre" lieu_ref="{$lieu.ref}">
|
<tr class="lieuTitre" lieu_ref="{$lieu.ref}">
|
||||||
<th class="noselect" colspan="2">{$lieu.nom}</th>
|
<th class="noselect" colspan="2">{$lieu.nom}</th>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{foreach from=$infos.legumes item=p}
|
{foreach from=$infos.legumes item=p}
|
||||||
<table class="panier">
|
<table class="panier table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="title">
|
<tr class="title">
|
||||||
<th class="titre" colspan="2">{$p.nom} <small>(x{$p.nb})</small></th>
|
<th class="titre" colspan="2">{$p.nom} <small>(x{$p.nb})</small></th>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<table class="panier legumesTotal">
|
<table class="panier table-hover legumesTotal">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="title">
|
<tr class="title">
|
||||||
<th class="titre">TOTAL :</th>
|
<th class="titre">TOTAL :</th>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{foreach from=$infos.paniers_eligibles item=lieu}
|
{foreach from=$infos.paniers_eligibles item=lieu}
|
||||||
<table class="table panier">
|
<table class="table table-hover panier">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="lieuTitre">
|
<tr class="lieuTitre">
|
||||||
<th colspan="2">{$lieu.nom}</th>
|
<th colspan="2">{$lieu.nom}</th>
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,19 @@
|
||||||
<tr class="contrat{if !$c.present} absent{/if}">
|
<tr class="contrat{if !$c.present} absent{/if}">
|
||||||
<td class="nom">{$c.client_prenom} {$c.client_nom}</td>
|
<td class="nom">{$c.client_prenom} {$c.client_nom}</td>
|
||||||
<td class="tel center">{$c.client_tel}</td>
|
<td class="tel center">{$c.client_tel}</td>
|
||||||
<td class="type center">{$c.panier_type_nom}</td>
|
<td class="type center{if $c.paniers|@count>1} multi_paniers{/if}">
|
||||||
<td class="nb_paniers center">{$c.nb_paniers_livres} / {$c.nb_paniers}</td>
|
{foreach from=$c.paniers item=p name=paniers}
|
||||||
<td class="complement center">{$c.complement_du}</td>
|
{if !$smarty.foreach.paniers.first}<br/>+ {/if}{$p.panier_type_nom}
|
||||||
<td class="complement center">{$c.complement}</td>
|
{/foreach}
|
||||||
<td class="complement center">{$c.complement_regle}</td>
|
</td>
|
||||||
|
<td class="nb_paniers center multi_paniers{if $c.paniers|@count>1} multi_paniers{/if}">
|
||||||
|
{foreach from=$c.paniers item=p name=paniers}
|
||||||
|
{if !$smarty.foreach.paniers.first}<br/>{/if}{$p.nb_paniers_livres} / {$p.nb_paniers}
|
||||||
|
{/foreach}
|
||||||
|
</td>
|
||||||
|
<td class="complement center">{$c.complement_du_print}</td>
|
||||||
|
<td class="complement center">{$c.complement_print}</td>
|
||||||
|
<td class="complement center">{$c.complement_regle_print}</td>
|
||||||
<td class="signature center">{if !$c.present}ABSENT{/if}</td>
|
<td class="signature center">{if !$c.present}ABSENT{/if}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue