Ajout gestion complément et feuille d'émargement

This commit is contained in:
Adrien RENARD 2024-01-22 03:25:50 +01:00
parent ae14bfd662
commit ade7b3380e
20 changed files with 479 additions and 52 deletions

View File

@ -79,8 +79,12 @@ function getClientsTableSelectBaseSQL() {
.CLIENTS_TABLE.".`nom`," .CLIENTS_TABLE.".`nom`,"
.CLIENTS_TABLE.".`prenom`," .CLIENTS_TABLE.".`prenom`,"
.CLIENTS_TABLE.".`tel`," .CLIENTS_TABLE.".`tel`,"
.CLIENTS_TABLE.".`email`" .CLIENTS_TABLE.".`email`,"
." FROM ".CLIENTS_TABLE; .COMPLEMENTS_CLIENTS_STATUS_VIEW.".`complements`,"
.COMPLEMENTS_CLIENTS_STATUS_VIEW.".`complements_regles`,"
.COMPLEMENTS_CLIENTS_STATUS_VIEW.".`complements_dus`"
." FROM ".CLIENTS_TABLE
." LEFT JOIN ".COMPLEMENTS_CLIENTS_STATUS_VIEW." ON ".CLIENTS_TABLE.".`ref`=".COMPLEMENTS_CLIENTS_STATUS_VIEW.".`client`";
} }
function buildClientsListSearchSQL($search) { function buildClientsListSearchSQL($search) {
@ -186,6 +190,9 @@ function getContratsTableSelectBaseSQL() {
.CONTRATS_TABLE.".`np_paniers_distrib_avt_saisie`," .CONTRATS_TABLE.".`np_paniers_distrib_avt_saisie`,"
.CONTRATS_TABLE.".`force_eligible`," .CONTRATS_TABLE.".`force_eligible`,"
.CONTRATS_TABLE.".`archive`," .CONTRATS_TABLE.".`archive`,"
.COMPLEMENTS_CONTRATS_STATUS_VIEW.".`complements`,"
.COMPLEMENTS_CONTRATS_STATUS_VIEW.".`complements_regles`,"
.COMPLEMENTS_CONTRATS_STATUS_VIEW.".`complements_dus`,"
.CONTRATS_TABLE.".`del`" .CONTRATS_TABLE.".`del`"
." FROM ".CONTRATS_TABLE ." FROM ".CONTRATS_TABLE
." LEFT JOIN ".CLIENTS_TABLE." ON ".CONTRATS_TABLE.".`client`=".CLIENTS_TABLE.".`ref`" ." LEFT JOIN ".CLIENTS_TABLE." ON ".CONTRATS_TABLE.".`client`=".CLIENTS_TABLE.".`ref`"
@ -193,7 +200,8 @@ function getContratsTableSelectBaseSQL() {
." LEFT JOIN ".PANIERS_GROUPES_TABLE." ON ".CONTRATS_TABLE.".`groupe`=".PANIERS_GROUPES_TABLE.".`ref`" ." LEFT JOIN ".PANIERS_GROUPES_TABLE." ON ".CONTRATS_TABLE.".`groupe`=".PANIERS_GROUPES_TABLE.".`ref`"
." LEFT JOIN ".PANIERS_TYPES_TABLE." ON ".CONTRATS_TABLE.".`panier_type`=".PANIERS_TYPES_TABLE.".`ref`" ." LEFT JOIN ".PANIERS_TYPES_TABLE." ON ".CONTRATS_TABLE.".`panier_type`=".PANIERS_TYPES_TABLE.".`ref`"
." LEFT JOIN ".LIEUX_TABLE." ON ".CONTRATS_TABLE.".`lieu_depot`=".LIEUX_TABLE.".`ref`" ." LEFT JOIN ".LIEUX_TABLE." ON ".CONTRATS_TABLE.".`lieu_depot`=".LIEUX_TABLE.".`ref`"
." LEFT JOIN ".CONTRATS_PANIERS_STATUT." ON ".CONTRATS_TABLE.".`ref`=".CONTRATS_PANIERS_STATUT.".`ref`"; ." LEFT JOIN ".CONTRATS_PANIERS_STATUT." ON ".CONTRATS_TABLE.".`ref`=".CONTRATS_PANIERS_STATUT.".`ref`"
." LEFT JOIN ".COMPLEMENTS_CONTRATS_STATUS_VIEW." ON ".CONTRATS_TABLE.".`ref`=".COMPLEMENTS_CONTRATS_STATUS_VIEW.".`contrat`";
} }
function buildContratsListSearchSQL($search) { function buildContratsListSearchSQL($search) {
@ -409,6 +417,8 @@ define('LIVRAISONS_PANIERS_TABLE',"livraisons_paniers");
define('LIVRAISONS_PANIERS_TABLE_STRUCT', array( define('LIVRAISONS_PANIERS_TABLE_STRUCT', array(
"livraison" => array( "type" => "int", "min" => 1, "max" => NULL, "default" => NULL, "force_default_under_min" => true ), "livraison" => array( "type" => "int", "min" => 1, "max" => NULL, "default" => NULL, "force_default_under_min" => true ),
"contrat" => array( "type" => "int", "min" => 1, "max" => NULL, "default" => NULL, "force_default_under_min" => true ), "contrat" => array( "type" => "int", "min" => 1, "max" => NULL, "default" => NULL, "force_default_under_min" => true ),
"complement" => array( "type" => "float", "min" => 0, "max" => 999.99, "default" => 0, "force_default_under_min" => true ),
"complement_regle" => array( "type" => "float", "min" => 0, "max" => 999.99, "default" => 0, "force_default_under_min" => true ),
"del" => array( "type" => "bool", "default" => 0 ) "del" => array( "type" => "bool", "default" => 0 )
)); ));
@ -431,6 +441,8 @@ function getLivraisonsPaniersSelectBaseSQL() {
.PANIERS_TYPES_TABLE.".`nom` as 'panier_type_nom'," .PANIERS_TYPES_TABLE.".`nom` as 'panier_type_nom',"
.CONTRATS_TABLE.".`lieu_depot` as 'lieu_depot_ref'," .CONTRATS_TABLE.".`lieu_depot` as 'lieu_depot_ref',"
.LIEUX_TABLE.".`nom` as 'lieu_depot_nom'," .LIEUX_TABLE.".`nom` as 'lieu_depot_nom',"
.LIVRAISONS_PANIERS_TABLE.".`complement`,"
.LIVRAISONS_PANIERS_TABLE.".`complement_regle`,"
.LIVRAISONS_PANIERS_TABLE.".`del`" .LIVRAISONS_PANIERS_TABLE.".`del`"
." FROM ".LIVRAISONS_PANIERS_TABLE ." FROM ".LIVRAISONS_PANIERS_TABLE
." LEFT JOIN ".LIVRAISONS_TABLE." ON ".LIVRAISONS_PANIERS_TABLE.".`livraison`=".LIVRAISONS_TABLE.".`ref`" ." LEFT JOIN ".LIVRAISONS_TABLE." ON ".LIVRAISONS_PANIERS_TABLE.".`livraison`=".LIVRAISONS_TABLE.".`ref`"
@ -440,3 +452,11 @@ function getLivraisonsPaniersSelectBaseSQL() {
." LEFT JOIN ".LIEUX_TABLE." ON ".CONTRATS_TABLE.".`lieu_depot`=".LIEUX_TABLE.".`ref`" ." LEFT JOIN ".LIEUX_TABLE." ON ".CONTRATS_TABLE.".`lieu_depot`=".LIEUX_TABLE.".`ref`"
." LEFT JOIN ".CONTRATS_PANIERS_STATUT." ON ".CONTRATS_TABLE.".`ref`=".CONTRATS_PANIERS_STATUT.".`ref`"; ." LEFT JOIN ".CONTRATS_PANIERS_STATUT." ON ".CONTRATS_TABLE.".`ref`=".CONTRATS_PANIERS_STATUT.".`ref`";
} }
////////////////////////////////////////////////////////////////////////
// COMPLEMENTS STATUS VIEWS ////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
define('COMPLEMENTS_CONTRATS_STATUS_VIEW', "complements_contrats_status");
define('COMPLEMENTS_CLIENTS_STATUS_VIEW', "complements_clients_status");

View File

@ -138,6 +138,32 @@ function getClientDatas($id) {
function getClientContrats($id) { return getContratsList("date","DESC", array("client" => $id)); } function getClientContrats($id) { return getContratsList("date","DESC", array("client" => $id)); }
function getClientAbsences($id) { return getClientAbsencesList("fin", "DESC", $id); } function getClientAbsences($id) { return getClientAbsencesList("fin", "DESC", $id); }
function getClientComplementDuAtDate($id, $date) {
$val = 0;
$sql = "SELECT"
." CASE WHEN ISNULL( SUM(`complement`) - SUM(`complement_regle`) )"
." THEN 0.00"
." ELSE SUM(`complement`) - SUM(`complement_regle`)"
." END as 'complement_du'"
." FROM ".LIVRAISONS_PANIERS_TABLE
." LEFT JOIN ".LIVRAISONS_TABLE." ON ".LIVRAISONS_PANIERS_TABLE.".`livraison` = ".LIVRAISONS_TABLE.".`ref`"
." WHERE `contrat` IN ("
." SELECT `ref` FROM ".CONTRATS_TABLE." WHERE `client`=".intval($id)
.")"
." AND ".LIVRAISONS_TABLE.".date<'".$date."'";
$r = $GLOBALS['db_admin']['man']->select($sql,1);
if(!$r['erreur']) $val = $r['datas']['complement_du'];
else {
$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 $val;
}
// ADD / UPDATE DATAS // ADD / UPDATE DATAS
function getClientDatasFromRequest() { return getRequestTableDatas(CLIENTS_TABLE_STRUCT); } function getClientDatasFromRequest() { return getRequestTableDatas(CLIENTS_TABLE_STRUCT); }

View File

@ -117,11 +117,13 @@ function getLivraisonDatas($id) {
$i["lieux"] = getLivraisonLieux($id); $i["lieux"] = getLivraisonLieux($id);
$i["paniers"] = getLivraisonPaniers($id); $i["paniers"] = getLivraisonPaniers($id);
$i["paniers_contrats"] = getLivraisonPaniersContratsList($id); $i["paniers_contrats"] = getLivraisonPaniersContratsList($id);
$i["contrats_list"] = getLivraisonPaniersContratsList($id, $i["paniers_contrats"]);
$i["nb_paniers"] = getLivraisonNbPaniers($id); $i["nb_paniers"] = getLivraisonNbPaniers($id);
$i["legumes"] = getLivraisonLegumes($id, $i["nb_paniers"]); $i["legumes"] = getLivraisonLegumes($id, $i["nb_paniers"]);
$i["total_legumes"] = calcLivraisonTotalLegumes($i["legumes"]); $i["total_legumes"] = calcLivraisonTotalLegumes($i["legumes"]);
$i["paniers_eligibles"] = getLivraisonPaniersEligibles($i["paniers_groupe_ref"], $i["date"], $i["quinz_groupe"], $i["paniers_contrats"]); $i["paniers_eligibles"] = getLivraisonPaniersEligibles($i["paniers_groupe_ref"], $i["date"], $i["quinz_groupe"], $i['paniers']);
$i["emargement_list"] = getLivraisonEmargementList($i["paniers_eligibles"], $i["date"]);
} }
else { else {
$er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']); $er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']);
@ -131,6 +133,42 @@ function getLivraisonDatas($id) {
return $i; return $i;
} }
function getLivraisonEmargementList($paniers_eligibles, $date, $lieu=0) {
$list = array();
foreach($paniers_eligibles as $l) {
if($l["ref"] == $lieu || !$lieu>0) {
foreach($l["paniers"] as $pType) {
foreach($pType["paniers"] as $p) {
if($p["present"]) {
$du = getClientComplementDuAtDate($p["client_ref"], $date);
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"] .= "";
else $p["complement"] = "";
if((float)$p["complement_regle"]>0) $p["complement_regle"] .= "";
else $p["complement_regle"] = "";
}
else {
$p["complement_du"] = "/";
$p["complement"] = "/";
$p["complement_regle"] = "/";
}
$list[] = $p;
}
}
}
}
// ORDER
$list = orderListByKey($list, "client_prenom", "ASC");
return $list;
}
// ADD / UPDATE DATAS // ADD / UPDATE DATAS
function getLivraisonDatasFromRequest() { function getLivraisonDatasFromRequest() {
@ -261,7 +299,7 @@ function getLivraisonLieux($livraison) {
// LIVRAISONS - PANIERS //////////////////////////////////////////////// // LIVRAISONS - PANIERS ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $contrats_presents=array()) { function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $paniers = array()) {
$list = array(); $list = array();
$sql = "SELECT " $sql = "SELECT "
@ -269,6 +307,7 @@ function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $co
.CONTRATS_TABLE.".`client` as 'client_ref'," .CONTRATS_TABLE.".`client` as 'client_ref',"
.CLIENTS_TABLE.".`nom` as 'client_nom'," .CLIENTS_TABLE.".`nom` as 'client_nom',"
.CLIENTS_TABLE.".`prenom` as 'client_prenom'," .CLIENTS_TABLE.".`prenom` as 'client_prenom',"
.CLIENTS_TABLE.".`tel` as 'client_tel',"
.CONTRATS_TABLE.".`panier_type` as 'panier_type_ref'," .CONTRATS_TABLE.".`panier_type` as 'panier_type_ref',"
.PANIERS_TYPES_TABLE.".`nom` as 'panier_type_nom'," .PANIERS_TYPES_TABLE.".`nom` as 'panier_type_nom',"
.CONTRATS_TABLE.".`frequence`," .CONTRATS_TABLE.".`frequence`,"
@ -298,7 +337,18 @@ function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $co
if($i["frequence"] == "quinz") $i["frequence_print"] .= " <small>(groupe ".$i["quinz_groupe"].")</small>"; if($i["frequence"] == "quinz") $i["frequence_print"] .= " <small>(groupe ".$i["quinz_groupe"].")</small>";
$i["absence"] = getClientAbsenceAtDate($i["client_ref"], $date); $i["absence"] = getClientAbsenceAtDate($i["client_ref"], $date);
if($i["nb_paniers_restants"]>0 || (int)$i['force_eligible']>0) { if($i["nb_paniers_restants"]>0 || (int)$i['force_eligible']>0) {
// PRESENT
$i["present"] = array_key_exists(intval($i["contrat_ref"]), $paniers);
// COMPLEMENT
$i["complement"] = 0;
$i["complement_regle"] = 0;
if($i["present"]) {
$i["complement"] = $paniers[$i["contrat_ref"]]["complement"];
$i["complement_regle"] = $paniers[$i["contrat_ref"]]["complement_regle"];
}
// GROUP BY - LIEU & TYPE DE PANNIER // GROUP BY - LIEU & TYPE DE PANNIER
$lieu = intval($i['lieu_depot_ref']); $lieu = intval($i['lieu_depot_ref']);
$pType = intval($i['panier_type_ref']); $pType = intval($i['panier_type_ref']);
@ -324,12 +374,13 @@ function getLivraisonPaniersEligibles($paniers_groupe, $date, $quinz_groupe, $co
} }
// AJOUT // AJOUT
$i["present"] = in_array(intval($i["contrat_ref"]), $contrats_presents);
$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"]++;
$list[$lieu]["paniers"][$pType]["nb_paniers"]++; $list[$lieu]["paniers"][$pType]["nb_paniers"]++;
} }
} }
} }
} }
@ -365,7 +416,7 @@ function getNbLivraisonForContratAtDate($contrat, $date) {
} }
function getLivraisonPaniers($livraison, $lieu=0) { function getLivraisonPaniers($livraison, $lieu=0, $group_by_type=false) {
$list = array(); $list = array();
$sql = getLivraisonsPaniersSelectBaseSQL(); $sql = getLivraisonsPaniersSelectBaseSQL();
@ -381,14 +432,17 @@ function getLivraisonPaniers($livraison, $lieu=0) {
if($i["frequence"] == "quinz") $i["frequence_print"] .= " <small>(groupe ".$i["quinz_groupe"].')</small>'; if($i["frequence"] == "quinz") $i["frequence_print"] .= " <small>(groupe ".$i["quinz_groupe"].')</small>';
// GROUPE PAR TYPE DE PANIER // GROUPE PAR TYPE DE PANIER
if(!array_key_exists($i["panier_type_ref"], $list)) { if($group_by_type) {
$list[$i["panier_type_ref"]] = array( if(!array_key_exists($i["panier_type_ref"], $list)) {
"type_ref" => $i["panier_type_ref"], $list[$i["panier_type_ref"]] = array(
"type_nom" => $i["panier_type_nom"], "type_ref" => $i["panier_type_ref"],
"paniers" => array() "type_nom" => $i["panier_type_nom"],
); "paniers" => array()
);
}
$list[$i["panier_type_ref"]]["paniers"][] = $i;
} }
$list[$i["panier_type_ref"]]["paniers"][] = $i; else $list[$i["contrat_ref"]] = $i;
} }
} }
else { else {
@ -396,20 +450,33 @@ function getLivraisonPaniers($livraison, $lieu=0) {
$GLOBALS['errors'][] = "Une erreur est survenue durant la récupération de la liste des paniers de la livraison dans le base de données !".$er; $GLOBALS['errors'][] = "Une erreur est survenue durant la récupération de la liste des paniers de la livraison dans le base de données !".$er;
} }
$list = orderListByKey($list, "type_nom", "ASC"); if($group_by_type) $list = orderListByKey($list, "type_nom", "ASC");
return $list; return $list;
} }
function getLivraisonPaniersContratsList($livraison) { function getLivraisonPaniersContratsList($livraison, $ref_list = false) {
$list = array(); $list = array();
$sql = "SELECT `contrat` FROM ".LIVRAISONS_PANIERS_TABLE." WHERE `livraison`=".intval($livraison); if(!is_array($ref_list)) $sql = "SELECT `contrat` FROM ".LIVRAISONS_PANIERS_TABLE." WHERE `livraison`=".intval($livraison);
else {
$inList = "";
foreach($ref_list as $key => $ref) $inList .= $ref.(($key!==array_key_last($ref_list)) ? "," : "");
$sql = getContratsTableSelectBaseSQL()
." WHERE ".CONTRATS_TABLE.".`ref` IN ($inList)"
." ORDER BY ".CLIENTS_TABLE.".`prenom`, ".CLIENTS_TABLE.".`nom` ASC";
}
$r = $GLOBALS['db_admin']['man']->select($sql); $r = $GLOBALS['db_admin']['man']->select($sql);
if(!$r['erreur']) { if(!$r['erreur']) {
foreach($r['datas'] as $i) $list[] = intval($i['contrat']); foreach($r['datas'] as $i) {
if(!is_array($ref_list)) $list[] = intval($i['contrat']);
else {
$i["paniers_livres"] = getContratPaniersLivres($i['ref']);
$list[] = $i;
}
}
} }
else { else {
$er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']); $er = "</br>sql: ".$sql."</br>error: ".getReadableVar($r['erreur']);
@ -477,6 +544,33 @@ function clearLivraisonPaniers($livraison) {
); );
} }
////////////////////////////////////////////////////////////////////////
// LIVRAISONS - COMPLEMENT /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function getLivraisonComplementFromRequest() {
$datas = array();
if(!isset($_REQUEST["complement"]) && !isset($_REQUEST["complement_regle"])) return "ERREUR : aucune modification de complement tranmis !";
if(isset($_REQUEST["complement"])) $datas["complement"] = floatval($_REQUEST["complement"]);
if(isset($_REQUEST["complement_regle"])) $datas["complement_regle"] = floatval($_REQUEST["complement_regle"]);
return $datas;
}
function updateLivraisonComplement($livraison, $contrat, $datas) {
$condition = " WHERE livraison=$livraison AND contrat=$contrat";
return updateDatasInTableByCondition(
$GLOBALS['db_admin']['man'], // DB MANAGER
LIVRAISONS_PANIERS_TABLE, // TABLE NAME
LIVRAISONS_PANIERS_TABLE_STRUCT,// TABLE STRUCTURE
$condition, // CONDITION
$datas, // DATAS
"au complement", // NULL STRING
"du complement" // ERROR STRING
);
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// LIVRAISONS - LEGUMES //////////////////////////////////////////////// // LIVRAISONS - LEGUMES ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -575,7 +669,7 @@ function clearLivraisonLegumes($livraison) {
// PRINTS ////////////////////////////////////////////////////////////// // PRINTS //////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
function exportLivraisonTemplateToPDF($templateFile, $outputFileName) { function exportLivraisonTemplateToPDF($templateFile, $outputFileName, $orientation='portrait') {
$GLOBALS['smarty'] -> assign('logo', PUBLIC_HTML_ADMIN.'img/logo.png'); $GLOBALS['smarty'] -> assign('logo', PUBLIC_HTML_ADMIN.'img/logo.png');
$cssFiles = array( $cssFiles = array(
@ -583,13 +677,14 @@ function exportLivraisonTemplateToPDF($templateFile, $outputFileName) {
PUBLIC_HTML_ADMIN.'css/livraisons.css' PUBLIC_HTML_ADMIN.'css/livraisons.css'
); );
$GLOBALS['smarty'] -> assign('cssFiles',$cssFiles); $GLOBALS['smarty'] -> assign('cssFiles',$cssFiles);
$GLOBALS['smarty'] -> assign('orientation',$orientation);
$html = $GLOBALS['smarty']->fetch($templateFile); $html = $GLOBALS['smarty']->fetch($templateFile);
// die($html); // die($html);
$dompdf = new Dompdf\Dompdf(); $dompdf = new Dompdf\Dompdf();
$dompdf->loadHtml($html); $dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait'); $dompdf->setPaper('A4', $orientation);
$options = $dompdf->getOptions(); $options = $dompdf->getOptions();
$options->setIsRemoteEnabled(true); $options->setIsRemoteEnabled(true);
$dompdf->setOptions($options); $dompdf->setOptions($options);

View File

@ -227,8 +227,9 @@ DEFAULT CHARSET=utf8;
CREATE TABLE `livraisons_paniers` ( CREATE TABLE `livraisons_paniers` (
`livraison` smallint(5) UNSIGNED NOT NULL, `livraison` smallint(5) UNSIGNED NOT NULL,
`contrat` smallint(5) UNSIGNED NOT NULL, `contrat` smallint(5) UNSIGNED NOT NULL,
`force_not_archive` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `complement` float(5,2) UNSIGNED NOT NULL DEFAULT '0',
`del` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `complement_regle` float(5,2) UNSIGNED NOT NULL DEFAULT '0',
`del` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
UNIQUE (`livraison`, `contrat`), UNIQUE (`livraison`, `contrat`),
CONSTRAINT `livraisons_paniers_livraison_fk` FOREIGN KEY (`livraison`) REFERENCES `livraisons`(`ref`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `livraisons_paniers_livraison_fk` FOREIGN KEY (`livraison`) REFERENCES `livraisons`(`ref`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `livraisons_paniers_contrat_fk` FOREIGN KEY (`contrat`) REFERENCES `contrats`(`ref`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `livraisons_paniers_contrat_fk` FOREIGN KEY (`contrat`) REFERENCES `contrats`(`ref`) ON DELETE RESTRICT ON UPDATE RESTRICT,
@ -288,4 +289,32 @@ CREATE VIEW `livraisons_nb_paniers` AS
FROM `livraisons_paniers` FROM `livraisons_paniers`
GROUP BY `livraisons_paniers`.`livraison`; GROUP BY `livraisons_paniers`.`livraison`;
COMMIT; -- --------------------------------------------------------
-- STRUCTURE DE LA VIEW `complements_contrats_status`
-- --------------------------------------------------------
CREATE VIEW `complements_contrats_status` AS
SELECT
`contrats`.`client`,
`contrat`,
SUM(`complement`) as 'complements',
SUM(`complement_regle`) as 'complements_regles',
( SUM(`complement`) - SUM(`complement_regle`) ) as 'complements_dus'
FROM `livraisons_paniers`
LEFT JOIN `contrats` ON `livraisons_paniers`.`contrat` = `contrats`.`ref`
GROUP BY `contrat`;
-- --------------------------------------------------------
-- STRUCTURE DE LA VIEW `complements_clients_status`
-- --------------------------------------------------------
CREATE VIEW `complements_clients_status` AS
SELECT
`client`,
SUM(`complements`) as 'complements',
SUM(`complements_regles`) as 'complements_regles',
( SUM(`complements`) - SUM(`complements_regles`) ) as 'complements_dus'
FROM `complements_contrats_status`
GROUP BY `client`;
COMMIT;

View File

@ -42,6 +42,8 @@
border-collapse: collapse; border-collapse: collapse;
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
page-break-inside: avoid;
break-inside: avoid;
} }
.formLivraison table.panier { margin-top: 10px; } .formLivraison table.panier { margin-top: 10px; }
@ -85,6 +87,8 @@
.formLivraison table.panier tr.head > th.nom, .formLivraison table.panier tr.head > th.nom,
.formLivraison table.panier tr.head > th.frequence { width: 50%; } .formLivraison table.panier tr.head > th.frequence { width: 50%; }
.formLivraison table.panier tr.head > th.complement,
.formLivraison table.panier tr.head > th.complement_regle { min-width: 100px; }
.formLivraison table.panier tr.head > th.tarif, .formLivraison table.panier tr.head > th.tarif,
.formLivraison table.panier tr.head > th.quantite, .formLivraison table.panier tr.head > th.quantite,
.formLivraison table.panier tr.head > th.montant { text-align: center; min-width: 120px; } .formLivraison table.panier tr.head > th.montant { text-align: center; min-width: 120px; }
@ -104,6 +108,10 @@
.formLivraison table.panier input.editable.legume { width: 100%; text-align: left; } .formLivraison table.panier input.editable.legume { width: 100%; text-align: left; }
.formLivraison table.panier input.editable.quantite { width: 70px; text-align: right; } .formLivraison table.panier input.editable.quantite { width: 70px; text-align: right; }
.formLivraison table.panier input.editable.complement,
.formLivraison table.panier input.editable.complement_regle { width: 90px; text-align: center; }
.formLivraison table.panier td.editable { cursor: pointer; }
/* TAB PANIERS */ /* TAB PANIERS */
@ -133,10 +141,45 @@
#modalViewLivraison div.btnPrint { margin-right: 10px; } #modalViewLivraison div.btnPrint { margin-right: 10px; }
body.printLivraison { font-size: 8pt; } body.printLivraison { font-size: 8pt; }
body.printLivraison[orientation=landscape] { margin-top: -20px; }
table.printHeader { width: 100%; margin-bottom: 10px; } table.printHeader { width: 100%; margin-bottom: 10px; }
table.printHeader th.titre { width: 25%; font-size: 10pt; vertical-align: middle; } table.printHeader th.titre { width: 25%; font-size: 10pt; vertical-align: middle; }
table.printHeader th.page { width: 50%; font-size: 16pt; text-align: center; } table.printHeader th.page { width: 50%; font-size: 16pt; text-align: center; }
table.printHeader th.logo { width: 25%; text-align: right; padding: 10pt; } table.printHeader th.logo { width: 25%; text-align: right; padding: 10pt; }
table.printHeader th.logo > img { height: 50pt; } table.printHeader th.logo > img { height: 50pt; }
.page_break { page-break-before: always; } .page_break { page-break-before: always; }
table.emargement {
width: 100%;
border-collapse: true;
}
table.emargement thead tr { background-color: rgba(51, 122, 183, .1); }
table.emargement th, table.emargement td {
padding: 5px;
border: 1px dotted #333333;
}
table.emargement th {
font-weight: bold;
}
table.emargement tbody td {
padding-top: 15px;
padding-bottom: 15px;
}
table.emargement .center { text-align: center; }
table.emargement .tel { max-width: 40px; }
table.emargement .type { max-width: 30px; }
table.emargement .nb_paniers { max-width: 25px; }
table.emargement .complement { max-width: 40px; }
table.emargement .signature { max-width: 60px; }
table.emargement tr.absent { background-color: #F0F0F0; }
table.emargement tr.absent td.nom,
table.emargement tr.absent td.tel,
table.emargement tr.absent td.type,
table.emargement tr.absent td.nb_paniers { text-decoration: line-through; }

View File

@ -92,10 +92,23 @@ function modalViewClient_loadDatas(modal, id) {
modal.find("td.tel").html( (datas.tel!="" && datas.tel!=null) ? '<a href="tel:'+datas.tel+'">'+datas.tel+'</a>' : "." ); modal.find("td.tel").html( (datas.tel!="" && datas.tel!=null) ? '<a href="tel:'+datas.tel+'">'+datas.tel+'</a>' : "." );
modal.find("td.email").html( (datas.email!="" && datas.email!=null) ? '<a href="mailto:'+datas.email+'">'+datas.email+'</a>' : "."); modal.find("td.email").html( (datas.email!="" && datas.email!=null) ? '<a href="mailto:'+datas.email+'">'+datas.email+'</a>' : ".");
// COMPLEMENTS
comp = ".";
if(datas.complements>0 || datas.complements_regles>0 || datas.complements_dus>0) {
comp = number_format(datas.complements, 2)+" €";
if(datas.complements_regles>0) {
comp += " / "+number_format(datas.complements_regles, 2)+" € réglé";
comp += " => "+number_format(Math.abs(datas.complements_dus), 2)+((datas.complements_dus >= 0) ? " € à régler" : " € d'avoir");
}
else if(datas.complements_dus>0) comp += " => "+number_format(Math.abs(datas.complements_dus), 2)+((datas.complements_dus >= 0) ? " € à régler" : " € d'avoir");
}
modal.find("td.complements").html(comp);
// CONTRATS // CONTRATS
$.post(clientsConf.baseURL, { 'ref' : id, 'action' : 'modalView_getTab', 'tab' : 'contrats' }, function(result) { $.post(clientsConf.baseURL, { 'ref' : id, 'action' : 'modalView_getTab', 'tab' : 'contrats' }, function(result) {
modal.find("div.tabContrats").html(result); modal.find("div.tabContrats").html(result);
}).fail(function() { alert("ERREUR SERVEUR ! (client modal view - load tab contrats)"); }); }).fail(function() { alert("ERREUR SERVEUR ! (client modal view - load tab contrats)"); });
// ABSENCES // ABSENCES
modalViewClient_loadTabAbsences(); modalViewClient_loadTabAbsences();
@ -113,6 +126,7 @@ function modalViewClient_clear(modal) {
modal.find("td.nom").html(""); modal.find("td.nom").html("");
modal.find("td.tel").html(""); modal.find("td.tel").html("");
modal.find("td.email").html(""); modal.find("td.email").html("");
modal.find("td.complements").html("");
modal.find("div.tabContrats").html(""); modal.find("div.tabContrats").html("");
modal.find("div.tabAbsences").html(""); modal.find("div.tabAbsences").html("");

View File

@ -126,6 +126,18 @@ function modalViewContrat_loadDatas(modal, id) {
modal.find("td.nb_panier_livre").html(nb_panier_livre); modal.find("td.nb_panier_livre").html(nb_panier_livre);
modal.find("td.nb_panier_restant").html(datas.nb_paniers_restants + " / " + datas.nb_paniers); modal.find("td.nb_panier_restant").html(datas.nb_paniers_restants + " / " + datas.nb_paniers);
// COMPLEMENTS
comp = ".";
if(datas.complements>0 || datas.complements_regles>0 || datas.complements_dus>0) {
comp = number_format(datas.complements, 2)+" €";
if(datas.complements_regles>0) {
comp += " / "+number_format(datas.complements_regles, 2)+" € réglé";
comp += " => "+number_format(Math.abs(datas.complements_dus), 2)+((datas.complements_dus >= 0) ? " € à régler" : " € d'avoir");
}
else if(datas.complements_dus>0) comp += " => "+number_format(Math.abs(datas.complements_dus), 2)+((datas.complements_dus >= 0) ? " € à régler" : " € d'avoir");
}
modal.find("td.complements").html(comp);
// PANIERS // PANIERS
$.post(contratsConf.baseURL, { 'ref' : id, 'action' : 'modalView_getTab', 'tab' : 'paniers' }, function(result) { $.post(contratsConf.baseURL, { 'ref' : id, 'action' : 'modalView_getTab', 'tab' : 'paniers' }, function(result) {
modal.find("div.tabPaniers").html(result); modal.find("div.tabPaniers").html(result);
@ -160,6 +172,8 @@ function modalViewContrat_clear(modal) {
modal.find("td.nb_panier_livre").html(""); modal.find("td.nb_panier_livre").html("");
modal.find("td.nb_panier_restant").html(""); modal.find("td.nb_panier_restant").html("");
modal.find("td.complements").html("");
modal.find("div.tabPaniers").html(""); modal.find("div.tabPaniers").html("");
} }

View File

@ -718,7 +718,7 @@ function initFiltreInputNumber() {
function initIntInput(elem) { function initIntInput(elem) {
elem.unbind('keypress').keypress( function(event) { elem.unbind('keypress').keypress( function(event) {
keys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]; keys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57];
if(event.keyCode==13) $(this).blur(); if(event.keyCode==13) setTimeout(function() { elem.blur(); },50);
if(jQuery.inArray(event.keyCode,keys)==-1) event.preventDefault(); if(jQuery.inArray(event.keyCode,keys)==-1) event.preventDefault();
}); });
} }
@ -738,7 +738,7 @@ function initIntInputWithLimits(elem, min, max) {
function initFloatInput(elem) { function initFloatInput(elem) {
elem.unbind('keypress').unbind('keyup').keypress( function(event) { elem.unbind('keypress').unbind('keyup').keypress( function(event) {
keys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 46, 44]; keys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 46, 44];
if(event.keyCode==13) $(this).blur(); if(event.keyCode==13) setTimeout(function() { elem.blur(); },50);
if(jQuery.inArray(event.keyCode,keys)==-1) event.preventDefault(); if(jQuery.inArray(event.keyCode,keys)==-1) event.preventDefault();
if((event.keyCode==46 || event.keyCode==44) && $(this).val().indexOf('.')>0) event.preventDefault(); if((event.keyCode==46 || event.keyCode==44) && $(this).val().indexOf('.')>0) event.preventDefault();
}).keyup( function(event) { }).keyup( function(event) {

View File

@ -92,16 +92,15 @@ function initViewLivraison() {
modalForm_initTabs(modalViewLivraison); modalForm_initTabs(modalViewLivraison);
// BTN PRINT // BTN PRINT
modalViewLivraison.find("div.btnPrint a").click(function(e) { modalViewLivraison_initPrintBtn();
e.preventDefault(); $(this).blur();
id = parseInt( modalViewLivraison.attr("view_id") );
if(!id>0) return;
url = livraisonsConf.baseURL+"?ref="+id+"&action=getPDF&type="+$(this).attr("print_type");
window.open(url, '_blank');
});
// CANCEL // CANCEL
modalViewLivraison.on('hidden.bs.modal', function() { modalViewLivraison_clear(modalViewLivraison); }); modalViewLivraison.on('hidden.bs.modal', function(e) { modalViewLivraison_clear(modalViewLivraison); });
// EMPECHE LA FERMETURE SI ON EST ENTRAIN D'EDITER UN COMPLEMENT
modalViewLivraison.on('hide.bs.modal', function(e) {
if(modalViewLivraison.find("input.editable").length>0) e.preventDefault();
});
} }
function modalViewLivraison_loadDatas(modal, id) { function modalViewLivraison_loadDatas(modal, id) {
@ -109,15 +108,25 @@ function modalViewLivraison_loadDatas(modal, id) {
var datas = JSON.parse(jsonTxt); var datas = JSON.parse(jsonTxt);
modal.find("small.db_ref > span").html(datas.ref); modal.find("small.db_ref > span").html(datas.ref);
// PRINT EMARGEMENT PAR LIEU
if(Object.values(datas.lieux).length>1) {
for(l in datas.lieux) {
li = $('<li print_type="emargement" class="print_emargement_par_lieu"></li>');
a = $('<a href="#" target="_blank" print_type="emargement"></a></li>');
a.html("Emargement - "+datas.lieux[l].nom).attr("lieu", l);
li.append(a);
li.insertAfter(modal.find("#print_emargement"));
}
modalViewLivraison_initPrintBtn();
}
modal.find("td.groupe").html(datas.paniers_groupe_nom); modal.find("td.groupe").html(datas.paniers_groupe_nom);
modal.find("td.date").html(datas.date_print); modal.find("td.date").html(datas.date_print);
modal.find("td.quinz_groupe").html(datas.quinz_groupe); modal.find("td.quinz_groupe").html(datas.quinz_groupe);
if(datas.paniers_contrats.length>0) { if(datas.paniers_contrats.length>0) {
// PANIERS // PANIERS
$.post(livraisonsConf.baseURL, { 'ref' : id, 'action' : 'modalView_getTab', 'tab' : 'paniers' }, function(result) { modalViewLivraison_loadPaniers();
modal.find("div.tabPaniers").html(result);
}).fail(function() { alert("ERREUR SERVEUR (modal view livraison - load tab paniers)"); });
// COMPO // COMPO
if(datas.legumes.length>0) { if(datas.legumes.length>0) {
@ -156,6 +165,8 @@ function modalViewLivraison_clear(modal) {
modal.find("small.db_ref > span").html(""); modal.find("small.db_ref > span").html("");
modal.find(".print_emargement_par_lieu").remove();
modal.find("td.groupe").html(""); modal.find("td.groupe").html("");
modal.find("td.date").html(""); modal.find("td.date").html("");
modal.find("td.quinz_groupe").html(""); modal.find("td.quinz_groupe").html("");
@ -165,6 +176,85 @@ function modalViewLivraison_clear(modal) {
modal.find("div.tabLegumes").html("<span class='nullChild'>aucun légume</span>"); modal.find("div.tabLegumes").html("<span class='nullChild'>aucun légume</span>");
} }
function modalViewLivraison_loadPaniers() {
$.post(livraisonsConf.baseURL, { 'ref' : modalViewLivraison.attr("view_id"), 'action' : 'modalView_getTab', 'tab' : 'paniers', 'complements' : 1 }, function(result) {
modalViewLivraison.find("div.tabPaniers").html(result);
// COMPLEMENT
modalViewLivraison.find("div.tabPaniers td.complement").each(function(n,e) {
$(this).addClass("editable").dblclick(function(e) {
e.preventDefault();
val = parseFloat( $(this).html() );
var ipt = $("<input class='editable complement' type='text' old_value='0'>");
$(this).html("").append(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);
ipt.blur(function(e) {
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();
});
});
// COMPLEMENT REGLE
modalViewLivraison.find("div.tabPaniers td.complement_regle").each(function(n,e) {
$(this).addClass("editable").dblclick(function(e) {
e.preventDefault();
val = parseFloat( $(this).html() );
var ipt = $("<input class='editable complement_regle' type='text' old_value='0'>");
$(this).html("").append(ipt);
initFloatInput(ipt);
if(val>0) ipt.val(val).attr("old_value", val);
ipt.blur(function(e) { modalViewLivraison_saveComplement( $(this) ); });
ipt.select();
});
});
}).fail(function() { alert("ERREUR SERVEUR (modal view livraison - load tab paniers)"); });
}
function modalViewLivraison_saveComplement(ipt) {
var td = ipt.parent();
var tr = td.parent();
val = parseFloat( ipt.val() );
old_value = parseFloat( ipt.attr("old_value") );
if(val>0 || val!=old_value) {
var datas = {
action : "saveComplement",
livraison : parseInt( modalViewLivraison.attr("view_id") ),
contrat : parseInt( tr.attr("contrat") )
}
if(ipt.hasClass("complement")) datas.complement = val;
else datas.complement_regle = val;
$.post(livraisonsConf.baseURL, datas, function(result) {
if(parseInt(result)==1) modalViewLivraison_loadPaniers();
else { console.error(result); alert(result); }
}).fail(function() { alert("ERREUR SERVEUR (modal view livraison - save complement)"); });
}
else td.html(".");
}
function modalViewLivraison_initPrintBtn() {
modalViewLivraison.find("div.btnPrint a").unbind("click").click(function(e) {
e.preventDefault(); $(this).blur();
id = parseInt( modalViewLivraison.attr("view_id") );
if(!id>0) return;
url = livraisonsConf.baseURL+"?ref="+id+"&action=getPDF&type="+$(this).attr("print_type");
if(isDefined($(this).attr("lieu"))) url += "&lieu="+$(this).attr("lieu");
window.open(url, '_blank');
});
}
/***** MODAL FORM ADD/EDIT *****/ /***** MODAL FORM ADD/EDIT *****/
function modalFormLivraison_init(modal) { function modalFormLivraison_init(modal) {
modal.find("modal").on("submit", function(e) { e.preventDefault(); }); modal.find("modal").on("submit", function(e) { e.preventDefault(); });

View File

@ -25,6 +25,7 @@ require_once(FUNCTIONS_DIR_PATH.'functions_livraisons.php');
require_once(FUNCTIONS_DIR_PATH.'functions_legumes.php'); require_once(FUNCTIONS_DIR_PATH.'functions_legumes.php');
include_once(FUNCTIONS_DIR_PATH.'functions_paniers_groupes.php'); include_once(FUNCTIONS_DIR_PATH.'functions_paniers_groupes.php');
include_once(FUNCTIONS_DIR_PATH.'functions_clients.php'); include_once(FUNCTIONS_DIR_PATH.'functions_clients.php');
include_once(FUNCTIONS_DIR_PATH.'functions_contrats.php');
$action = false; $action = false;
if(isset($_REQUEST['action'])) $action = strval( $_REQUEST['action'] ); if(isset($_REQUEST['action'])) $action = strval( $_REQUEST['action'] );
@ -50,16 +51,29 @@ if(isset($_REQUEST["ref"]) && (int)$_REQUEST["ref"]>0 && $action) {
// GET PDF // GET PDF
case "getPDF": { case "getPDF": {
$GLOBALS['smarty'] -> assign('infos', $infos); $GLOBALS['smarty'] -> assign('infos', $infos);
$types = array( $types = array(
"full" => array("tpl" => "livraisons/prints/livraison_print_full.tpl", "fn" => ""), "full" => array("tpl" => "livraisons/prints/livraison_print_full.tpl", "fn" => "", "orientation" => "portrait"),
"paniers" => array("tpl" => "livraisons/prints/livraison_print_paniers.tpl", "fn" => "-liste_paniers_"), "paniers" => array("tpl" => "livraisons/prints/livraison_print_paniers.tpl", "fn" => "-liste_paniers_", "orientation" => "portrait"),
"compo" => array("tpl" => "livraisons/prints/livraison_print_compo.tpl", "fn" => "-compo_paniers_"), "compo" => array("tpl" => "livraisons/prints/livraison_print_compo.tpl", "fn" => "-compo_paniers_", "orientation" => "portrait"),
"legumes" => array("tpl" => "livraisons/prints/livraison_print_legumes.tpl", "fn" => "-total_legumes_") "legumes" => array("tpl" => "livraisons/prints/livraison_print_legumes.tpl", "fn" => "-total_legumes_", "orientation" => "portrait"),
"emargement" => array("tpl" => "livraisons/prints/livraison_print_emargement.tpl", "fn" => "-emargement_", "orientation" => "landscape")
); );
if(isset($_REQUEST['type']) && array_key_exists($_REQUEST['type'], $types)) { if(isset($_REQUEST['type']) && array_key_exists($_REQUEST['type'], $types)) {
$type = $types[$_REQUEST['type']]; $type = $types[$_REQUEST['type']];
if($_REQUEST['type'] == "emargement") {
$lieu_ref = 0;
$lieu_nom = "";
if(isset($_REQUEST["lieu"]) && (int)$_REQUEST["lieu"]>0 && array_key_exists(intval($_REQUEST["lieu"]), $infos["lieux"])) {
$lieu_ref = intval($_REQUEST["lieu"]);
$lieu_nom = $infos["lieux"][$lieu_ref]["nom"];
}
$GLOBALS['smarty'] -> assign('emargement_list', getLivraisonEmargementList($infos["paniers_eligibles"], $infos["date"], $lieu_ref));
$GLOBALS['smarty'] -> assign('lieu_ref', $lieu_ref);
$GLOBALS['smarty'] -> assign('lieu_nom', $lieu_nom);
}
$filename = "Livraison-".$infos["paniers_groupe_nom"].$type["fn"]."_".$infos["date"].".pdf"; $filename = "Livraison-".$infos["paniers_groupe_nom"].$type["fn"]."_".$infos["date"].".pdf";
exportLivraisonTemplateToPDF($type["tpl"], $filename); exportLivraisonTemplateToPDF($type["tpl"], $filename, $type["orientation"]);
} }
die("NO TYPE"); die("NO TYPE");
} break; } break;
@ -75,7 +89,12 @@ if(isset($_REQUEST["ref"]) && (int)$_REQUEST["ref"]>0 && $action) {
// ADD PANIERS // ADD PANIERS
foreach($datas['paniers'] as $i => $contrat) { foreach($datas['paniers'] as $i => $contrat) {
$r = addLivraisonPanier(array( 'livraison' => $id, 'contrat' => intval($contrat))); $datas = array( 'livraison' => $id, 'contrat' => intval($contrat) );
if(array_key_exists($contrat, $infos["paniers"])) {
$datas["complement"] = $infos["paniers"][$contrat]["complement"];
$datas["complement_regle"] = $infos["paniers"][$contrat]["complement_regle"];
}
$r = addLivraisonPanier($datas);
if($r!==true) die("ERREUR : une erreur est survenu durant l'enregistrement du panier de la livraison ($r)"); if($r!==true) die("ERREUR : une erreur est survenu durant l'enregistrement du panier de la livraison ($r)");
} }
@ -171,6 +190,18 @@ switch($action) {
$GLOBALS['smarty'] -> assign('lieux', $list); $GLOBALS['smarty'] -> assign('lieux', $list);
die( $GLOBALS['smarty']->fetch("livraisons/livraison_form_tab_paniers.tpl") ); die( $GLOBALS['smarty']->fetch("livraisons/livraison_form_tab_paniers.tpl") );
} break; } break;
// SAVE COMPLEMENT
case "saveComplement" : {
if(isset($_REQUEST["livraison"]) && (int)$_REQUEST["livraison"]>0) $livraison = intval($_REQUEST["livraison"]);
else die("ERREUR : aucune référence de livraison tranmis !");
if(isset($_REQUEST["contrat"]) && (int)$_REQUEST["contrat"]>0) $contrat = intval($_REQUEST["contrat"]);
else die("ERREUR : aucune référence de contrat tranmis !");
$datas = getLivraisonComplementFromRequest();
if(is_array($datas)) die( strval(updateLivraisonComplement($livraison, $contrat, $datas)) );
else die($datas);
} break;
// DEFAULT - LIST // DEFAULT - LIST
default: { default: {
// GROUPE // GROUPE

View File

@ -22,6 +22,7 @@
<tr><th>nom :</th><td class="nom"></td></tr> <tr><th>nom :</th><td class="nom"></td></tr>
<tr><th>téléphone :</th><td class="tel"></td></tr> <tr><th>téléphone :</th><td class="tel"></td></tr>
<tr><th>email :</th><td class="email"></td></tr> <tr><th>email :</th><td class="email"></td></tr>
<tr><th>compléments :</th><td class="complements"></td></tr>
</table> </table>
</div> </div>
<div class="tab tabContrats"> <div class="tab tabContrats">

View File

@ -25,6 +25,7 @@
<tr><th>nb. de chèque :</th><td class="nb_cheque"></td></tr> <tr><th>nb. de chèque :</th><td class="nb_cheque"></td></tr>
<tr><th>nb. de panier(s) livré(s) :</th><td class="nb_panier_livre"></td></tr> <tr><th>nb. de panier(s) livré(s) :</th><td class="nb_panier_livre"></td></tr>
<tr><th>nb. de panier(s) restant(s) :</th><td class="nb_panier_restant"></td></tr> <tr><th>nb. de panier(s) restant(s) :</th><td class="nb_panier_restant"></td></tr>
<tr><th>compléments :</th><td class="complements"></td></tr>
</table> </table>
</div> </div>
<div class="tab tabPaniers"> <div class="tab tabPaniers">

View File

@ -4,6 +4,8 @@
<th>date</th> <th>date</th>
<th>panier</th> <th>panier</th>
<th>lieu</th> <th>lieu</th>
<th class="center">complement</th>
<th class="center">réglé</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -12,6 +14,8 @@
<td>{$i.livraison_date_print}</td> <td>{$i.livraison_date_print}</td>
<td>{$i.panier_type_nom}</td> <td>{$i.panier_type_nom}</td>
<td>{$i.lieu_depot_nom}</td> <td>{$i.lieu_depot_nom}</td>
<td class="center">{$i.complement}</td>
<td class="center">{$i.complement_regle} €</td>
</tr> </tr>
{foreachelse} {foreachelse}
<tr> <tr>

View File

@ -13,12 +13,14 @@
<div class="modal-body formLivraison"> <div class="modal-body formLivraison">
<div class="btn-group btnPrint pull-right"> <div class="btn-group btnPrint pull-right">
<button type="button" class="btn btn-default glyphicon glyphicon-print dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button> <button type="button" class="btn btn-default glyphicon glyphicon-print dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
<ul class="dropdown-menu"> <ul class="dropdown-menu prints">
<li print_type="paniers"><a href="#" target="_blank" print_type="paniers">Paniers</a></li> <li print_type="paniers"><a href="#" target="_blank" print_type="paniers">Paniers</a></li>
<li print_type="compo"><a href="#" target="_blank" print_type="compo">Composition</a></li> <li print_type="compo"><a href="#" target="_blank" print_type="compo">Composition</a></li>
<li print_type="legumes"><a href="#" target="_blank" print_type="legumes">Total légumes</a></li> <li print_type="legumes"><a href="#" target="_blank" print_type="legumes">Total légumes</a></li>
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li print_type="full"><a href="#" target="_blank" print_type="full">Complet</a></li> <li print_type="full"><a href="#" target="_blank" print_type="full">Complet</a></li>
<li role="separator" class="divider"></li>
<li print_type="emargement" id="print_emargement"><a href="#" target="_blank" print_type="emargement">Feuille d'émargement</a></li>
</ul> </ul>
</div> </div>
<ul class="nav nav-tabs formTabsBtns"> <ul class="nav nav-tabs formTabsBtns">

View File

@ -3,24 +3,32 @@
<thead> <thead>
<tr class="lieuTitre"> <tr class="lieuTitre">
<th colspan="2">{$lieu.nom}</th> <th colspan="2">{$lieu.nom}</th>
<th>{$lieu.nb_paniers} paniers</th> <th{if $smarty.request.complements==1} colspan="3"{/if}>{$lieu.nb_paniers} paniers</th>
</tr> </tr>
<tr class="head"> <tr class="head">
<th class="nom">client</th> <th class="nom">client</th>
<th class="frequence">fréquence</th> <th class="frequence">fréquence</th>
<th class="nb_paniers_restants">nb. de paniers restant</th> <th class="nb_paniers_restants">nb. de paniers restant</th>
{if $smarty.request.complements==1}
<th class="complement center">complement</th>
<th class="complement_regle center">réglé</th>
{/if}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach from=$lieu.paniers item=pType} {foreach from=$lieu.paniers item=pType}
<tr class="panierTitre"> <tr class="panierTitre">
<th colspan="4">{$pType.type_nom} <small>(x{$pType.nb_paniers})</small></th> <th colspan="6">{$pType.type_nom} <small>(x{$pType.nb_paniers})</small></th>
</tr> </tr>
{foreach from=$pType.paniers item=p} {foreach from=$pType.paniers item=p}
<tr{if !$p.present} class="absent"{/if}> <tr{if !$p.present} class="absent"{/if} contrat="{$p.contrat_ref}">
<td class="nom">{$p.client_prenom} {$p.client_nom}</td> <td class="nom">{$p.client_prenom} {$p.client_nom}</td>
<td class="frequence">{if $p.present}{$p.frequence_print}{else}absent{/if}</td> <td class="frequence">{if $p.present}{$p.frequence_print}{else}absent{/if}</td>
<td class="nb_paniers_restants">{$p.nb_paniers_restants}</td> <td class="nb_paniers_restants">{$p.nb_paniers_restants}</td>
{if $smarty.request.complements==1}
<td class="complement center">{if $p.complement >0}{$p.complement}{else}.{/if}</td>
<td class="complement_regle center">{if $p.complement_regle >0}{$p.complement_regle}{else}.{/if}</td>
{/if}
</tr> </tr>
{/foreach} {/foreach}
{/foreach} {/foreach}

View File

@ -4,7 +4,7 @@
{/foreach} {/foreach}
</head> </head>
<body class="printLivraison"> <body class="printLivraison" orientation="{$orientation}">
<!-- COMPOSITION --> <!-- COMPOSITION -->
<div class="formLivraison"> <div class="formLivraison">
<table class="printHeader"> <table class="printHeader">

View File

@ -0,0 +1,49 @@
<head>
{foreach from=$cssFiles item=file}
<link href="{$file}" rel="stylesheet" media="all">
{/foreach}
</head>
<body class="printLivraison" orientation="{$orientation}">
<!-- PANIERS -->
<div class="formLivraison">
<table class="printHeader">
<tr>
<th class="titre">
LIVRAISON {$infos.paniers_groupe_nom|upper}<br/>
{$infos.date_long_print}
</th>
<th class="page">FEUILLE D'EMARGEMENT{if $lieu_ref>0}<br/>{$lieu_nom}{/if}</th>
<th class="logo"><img src="{$logo}"></th>
</tr>
</table>
<table class="emargement">
<thead>
<tr>
<th class="nom">NOM</th>
<th class="tel center">TELEPHONE</th>
<th class="type center">TYPE DE PANIER</th>
<th class="nb_paniers center">PANIERS DISTRIBUES</th>
<th class="complement center">COMPLEMENT<br/>A REGLER</th>
<th class="complement center">COMPLEMENT<br/>DU JOUR</th>
<th class="complement center">COMPLEMENT<br/>REGLE CE JOUR</th>
<th class="signature center">SIGNATURE</th>
</tr>
</thead>
<tbody>
{foreach from=$emargement_list item=c}
<tr class="contrat{if !$c.present} absent{/if}">
<td class="nom">{$c.client_prenom} {$c.client_nom}</td>
<td class="tel center">{$c.client_tel}</td>
<td class="type center">{$c.panier_type_nom}</td>
<td class="nb_paniers center">{$c.nb_paniers_livres} / {$c.nb_paniers}</td>
<td class="complement center">{$c.complement_du}</td>
<td class="complement center">{$c.complement}</td>
<td class="complement center">{$c.complement_regle}</td>
<td class="signature center">{if !$c.present}ABSENT{/if}</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</body>

View File

@ -4,7 +4,7 @@
{/foreach} {/foreach}
</head> </head>
<body class="printLivraison"> <body class="printLivraison" orientation="{$orientation}">
<!-- PANIERS --> <!-- PANIERS -->
<div class="formLivraison"> <div class="formLivraison">
<table class="printHeader"> <table class="printHeader">

View File

@ -4,7 +4,7 @@
{/foreach} {/foreach}
</head> </head>
<body class="printLivraison"> <body class="printLivraison" orientation="{$orientation}">
<!-- LEGUMES --> <!-- LEGUMES -->
<div class="formLivraison"> <div class="formLivraison">
<table class="printHeader"> <table class="printHeader">

View File

@ -4,7 +4,7 @@
{/foreach} {/foreach}
</head> </head>
<body class="printLivraison"> <body class="printLivraison" orientation="{$orientation}">
<!-- PANIERS --> <!-- PANIERS -->
<div class="formLivraison"> <div class="formLivraison">
<table class="printHeader"> <table class="printHeader">