if ($lAdh->getId() == $lAdherent->getCptIdAdherentPrincipal()) {
                     $lSelected = 'selected="selected"';
                 } else {
                     $lSelected = '';
                 }
                 $lTemplate->assign_block_vars('adherent', array('id' => $lAdh->getId(), 'numero' => $lAdh->getNumero(), 'nom' => $lAdh->getNom(), 'prenom' => $lAdh->getPrenom(), 'selected' => $lSelected));
             }
         }
     }
     $lTemplate->assign_var_from_handle('ADHERENT_PRINCIPAL', 'listeAdherent');
     $lTemplate->assign_vars(array('nom' => $lAdherent->getAdhNom(), 'prenom' => $lAdherent->getAdhPrenom(), 'courrielPrincipal' => $lAdherent->getAdhCourrielPrincipal(), 'courrielSecondaire' => $lAdherent->getAdhCourrielSecondaire(), 'telephonePrincipal' => $lAdherent->getAdhTelephonePrincipal(), 'telephoneSecondaire' => $lAdherent->getAdhTelephoneSecondaire(), 'adresse' => $lAdherent->getAdhAdresse(), 'codePostal' => $lAdherent->getAdhCodePostal(), 'ville' => $lAdherent->getAdhVille(), 'commentaire' => $lAdherent->getAdhCommentaire()));
     InfobullesUtils::generer($lTemplate);
     // Messages d'erreur
     // Affichage des dates si elles ne sont pas nulle
     if (!StringUtils::dateEstNulle($lAdherent->getAdhDateNaissance())) {
         $lTemplate->assign_vars(array('dateNaissance' => StringUtils::dateDbToFr($lAdherent->getAdhDateNaissance())));
     }
     // Pied de Page
     $lTemplate->set_filenames(array('piedPage' => COMMUN_TEMPLATE . 'PiedPage.html'));
     $lTemplate->assign_vars(array('PROP_NOM' => PROP_NOM, 'PROP_ADRESSE' => PROP_ADRESSE, 'PROP_CODE_POSTAL' => PROP_CODE_POSTAL, 'PROP_VILLE' => PROP_VILLE, 'PROP_TEL' => PROP_TEL, 'PROP_MEL' => PROP_MEL, 'ZEYBUX_TITRE_SITE' => ZEYBUX_TITRE_SITE));
     $lTemplate->assign_var_from_handle('PIED_PAGE', 'piedPage');
     // Affichage
     $lTemplate->pparse('body');
     break;
 case "information":
     if (isset($_POST['idAdherentPrincipal']) && isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['date_naissance']) && isset($_POST['commentaire']) && isset($_POST['courriel_principal']) && isset($_POST['courriel_secondaire']) && isset($_POST['telephone_principal']) && isset($_POST['telephone_secondaire']) && isset($_POST['adresse']) && isset($_POST['code_postal']) && isset($_POST['ville'])) {
         $lParam = array("id_adherent" => $_SESSION[DROIT_ID], "idAdherentPrincipal" => $_POST['idAdherentPrincipal'], "nom" => $_POST['nom'], "prenom" => $_POST['prenom'], "dateNaissance" => StringUtils::dateFrToDb($_POST['date_naissance']), "commentaire" => $_POST['commentaire'], "courrielPrincipal" => $_POST['courriel_principal'], "courrielSecondaire" => $_POST['courriel_secondaire'], "telephonePrincipal" => $_POST['telephone_principal'], "telephoneSecondaire" => $_POST['telephone_secondaire'], "adresse" => $_POST['adresse'], "codePostal" => $_POST['code_postal'], "ville" => $_POST['ville']);
         $lVr = $lControleur->modifierInformation($lParam);
         $lLogger->log("Modification des informations du compte de l'Adhérent : " . $_SESSION[ID_CONNEXION], PEAR_LOG_INFO);
         // Maj des logs
         InfobullesUtils::init();
 					$lData["totalSolidaire"] += $lDetailAchatSolidaire->getMontant() * -1;
 				}
 			}
 			
 			if(!isset($lData["categories"][$lProduit->getCproNom()])) {
 				$lData["categories"][$lProduit->getCproNom()] = array("nom" => $lProduit->getCproNom(), "achat" => array());
 			}
 			array_push($lData["categories"][$lProduit->getCproNom()]["achat"], $lLigneAchat);
 		}*/
 if (!is_null($lPage->getAchats()->getOperationAchat())) {
     $lData["total"] = $lPage->getAchats()->getOperationAchat()->getMontant() * -1;
     $lData["dateAchat"] = StringUtils::dateDbToFr($lPage->getAchats()->getOperationAchat()->getDate());
 }
 if (!is_null($lPage->getAchats()->getOperationAchatSolidaire())) {
     $lData["totalSolidaire"] = $lPage->getAchats()->getOperationAchatSolidaire()->getMontant() * -1;
     $lData["dateAchat"] = StringUtils::dateDbToFr($lPage->getAchats()->getOperationAchatSolidaire()->getDate());
 }
 $lData["totalMarche"] = $lData["total"] + $lData["totalSolidaire"];
 $lData["total"] = StringUtils::affichageMonetaireFr($lData["total"]);
 $lData["totalSolidaire"] = StringUtils::affichageMonetaireFr($lData["totalSolidaire"]);
 $lData["totalMarche"] = StringUtils::affichageMonetaireFr($lData["totalMarche"]);
 $lTemplate->assign_vars(array('sigleMonetaire' => SIGLE_MONETAIRE, "dateAchat" => $lData["dateAchat"], "totalMarche" => $lData["totalMarche"], "total" => $lData["total"], "totalSolidaire" => $lData["totalSolidaire"]));
 foreach ($lData["categories"] as $lCategorie) {
     $lTemplate->assign_block_vars('categories', array('nom' => $lCategorie["nom"]));
     foreach ($lCategorie["achat"] as $lAchat) {
         $lTemplate->assign_block_vars('categories.achat', $lAchat);
     }
 }
 // Pied de Page
 $lTemplate->set_filenames(array('piedPage' => COMMUN_TEMPLATE . 'PiedPage.html'));
 $lTemplate->assign_vars(array('PROP_NOM' => PROP_NOM, 'PROP_ADRESSE' => PROP_ADRESSE, 'PROP_CODE_POSTAL' => PROP_CODE_POSTAL, 'PROP_VILLE' => PROP_VILLE, 'PROP_TEL' => PROP_TEL, 'PROP_MEL' => PROP_MEL, 'ZEYBUX_TITRE_SITE' => ZEYBUX_TITRE_SITE));
        $i++;
    }
    $lListeOperationAvenir = $lCompte->getOperationAvenir();
    if (!is_null($lListeOperationAvenir[0]->getOpeIdCompte())) {
        $lTemplate->set_filenames(array('listeOperationfuture' => MOD_MON_COMPTE . '/ListeOperationFuture.html'));
        //if(count($lListeOperationAvenir))
        $lSolde = $lAdherent->getCptSolde();
        $lRechargementPrecedent = 0;
        foreach ($lListeOperationAvenir as $lOperationAvenir) {
            $lSolde += $lOperationAvenir->getOpeMontant();
            $lRechargement = 0;
            if ($lSolde < SOLDE_CIBLE) {
                $lRechargement = ceil((SOLDE_CIBLE - $lSolde) / SOLDE_CIBLE) * SOLDE_CIBLE - $lRechargementPrecedent;
            }
            $lRechargementPrecedent += $lRechargement;
            $lTemplate->assign_block_vars('operationAvenir', array('opeLibelle' => $lOperationAvenir->getOpeLibelle(), 'opeDate' => StringUtils::dateDbToFr($lOperationAvenir->getOpeDate()), 'comDateMarche' => StringUtils::dateDbToFr($lOperationAvenir->getComDateMarche()), 'opeMontant' => StringUtils::affichageMonetaireFr($lOperationAvenir->getOpeMontant() * -1), 'nouveauSolde' => StringUtils::affichageMonetaireFr($lSolde), 'rechargement' => StringUtils::affichageMonetaireFr($lRechargement)));
        }
        $lTemplate->assign_var_from_handle('LISTE_OPERATION_FUTURE', 'listeOperationfuture');
    }
    $lTemplate->assign_var_from_handle('LISTE_OPERATION_ADHERENT', 'listeOperationAdherent');
    // Pied de Page
    $lTemplate->set_filenames(array('piedPage' => COMMUN_TEMPLATE . 'PiedPage.html'));
    $lTemplate->assign_vars(array('PROP_NOM' => PROP_NOM, 'PROP_ADRESSE' => PROP_ADRESSE, 'PROP_CODE_POSTAL' => PROP_CODE_POSTAL, 'PROP_VILLE' => PROP_VILLE, 'PROP_TEL' => PROP_TEL, 'PROP_MEL' => PROP_MEL, 'ZEYBUX_TITRE_SITE' => ZEYBUX_TITRE_SITE));
    $lTemplate->assign_var_from_handle('PIED_PAGE', 'piedPage');
    // Affichage
    $lTemplate->pparse('body');
} else {
    $lLogger->log("Demande d'affichage sans autorisation du compte de l'Adhérent", PEAR_LOG_INFO);
    // Maj des logs
    header('location:./index.php?cx=2');
}
echo date('d/m/Y');
?>
</td>
        </tr>
    </table>
    <br>
    <i>
        <b><u>Objet </u>: &laquo; Bon de Commande &raquo;</b><br><br>
    </i>
    <div>
    Madame, Monsieur,<br>
    L'association "<?php 
echo PROP_NOM;
?>
" souhaite commander les produits suivants pour le <?php 
echo StringUtils::dateDbToFr($lMarche->getDateMarcheDebut());
?>
.<br><br>
    </div>
    <table cellspacing="0" style="width: 100%; text-align: center; font-size: 10pt;">
        <tr>
            <th style="width: 10%; border: solid 1px black;">Produit</th>
            <th style="width: 37%; border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;">Désignation</th>
            <th style="width: 20%; border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;">Prix Unitaire</th>
            <th style="width: 20%; border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;">Quantité</th>
            <th style="width: 13%; border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;">Prix Net</th>
        </tr>
    </table>
<?php 
$lTotal = 0;
foreach ($lLignesBonCommande as $lLigne) {
    include_once CHEMIN_CLASSES_VIEW_MANAGER . "AdherentViewManager.php";
    include_once CHEMIN_CLASSES_UTILS . "CSV.php";
    include_once CHEMIN_CLASSES_UTILS . "StringUtils.php";
    $lAdherents = AdherentViewManager::selectAll();
    $lCSV = new CSV();
    $lCSV->setNom('Adherents.csv');
    // Le Nom
    // L'entete
    $lEntete = array("N°", "Nom", "Prénom", "Courriel 1", "Courriel 2", "Téléphone 1", "Téléphone 2", "Adresse", "Code Postal", "Ville", "Date de Naissance", "Date d'Adhésion", "Commentaire", "Compte", "Solde");
    $lCSV->setEntete($lEntete);
    // Les données
    $lContenuTableau = array();
    foreach ($lAdherents as $lAdh) {
        if ($lAdh->getAdhId() != NULL && $lAdh->getAdhEtat() == 1) {
            // Pas de ligne Vide ni d'adhérent supprimé
            $lDateNaissance = StringUtils::dateDbToFr(htmlspecialchars_decode($lAdh->getAdhDateNaissance(), ENT_QUOTES));
            if ($lDateNaissance == "00/00/0000") {
                $lDateNaissance = "";
            }
            $lDateAdhesion = StringUtils::dateDbToFr(htmlspecialchars_decode($lAdh->getAdhDateAdhesion(), ENT_QUOTES));
            if ($lDateAdhesion == "00/00/0000") {
                $lDateAdhesion = "";
            }
            $lLignecontenu = array(htmlspecialchars_decode($lAdh->getAdhNumero(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhNom(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhPrenom(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhCourrielPrincipal(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhCourrielSecondaire(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhTelephonePrincipal(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhTelephoneSecondaire(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhAdresse(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhCodePostal(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getAdhVille(), ENT_QUOTES), $lDateNaissance, $lDateAdhesion, htmlspecialchars_decode($lAdh->getAdhCommentaire(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getCptLabel(), ENT_QUOTES), htmlspecialchars_decode($lAdh->getCptSolde(), ENT_QUOTES));
            array_push($lContenuTableau, $lLignecontenu);
        }
    }
    $lCSV->setData($lContenuTableau);
    // Export en CSV
    $lCSV->output();
}