/** * @name exportOperation($pParam) * @desc Donne les opérations sur le compte du zeybu */ public function exportOperation($pParam) { $lVr = CompteAssociationValid::validRecherche($pParam); if ($lVr->getValid()) { $lDateDebut = NULL; if (!empty($pParam['dateDebut'])) { $lDateDebut = $pParam['dateDebut']; } $lDateFin = NULL; if (!empty($pParam['dateFin'])) { $lDateFin = $pParam['dateFin']; } $lCSV = new CSV(); $lCSV->setNom('CompteAssociation.csv'); // Le Nom // L'entete $lEntete = array("Date", "Compte", "Libelle", "Paiement", "N°", "Debit", "", "Credit", ""); $lCSV->setEntete($lEntete); // Les données $lOperationService = new OperationService(); $lOperations = $lOperationService->rechercheOperationAssociation($lDateDebut, $lDateFin); $lContenuTableau = array(); foreach ($lOperations as $lOperation) { $lDate = StringUtils::extractDate($lOperation->getOpeDate()); $lPaiement = ''; if (!is_null($lOperation->getTppType())) { $lPaiement = $lOperation->getTppType(); } $lCheque = ''; if (!is_null($lOperation->getNumeroCheque())) { $lCheque = $lOperation->getNumeroCheque(); } $lDebit = ''; $lCredit = ''; if ($lOperation->getOpeMontant() < 0) { $lDebit = $lOperation->getOpeMontant() * -1; } else { $lCredit = $lOperation->getOpeMontant(); } $lLignecontenu = array($lDate, $lOperation->getCptLabel(), $lOperation->getOpeLibelle(), $lPaiement, $lCheque, $lDebit, SIGLE_MONETAIRE, $lCredit, SIGLE_MONETAIRE); array_push($lContenuTableau, $lLignecontenu); } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name getListePaiementExport($pParam) * @return InfoMarcheVR * @desc Retourne la liste des adhérents qui ont réservé sur cette commande et les infos sur la commande. */ public function getListePaiementExport($pParam) { $lVr = MarcheValid::validGetMarche($pParam); if ($lVr->getValid()) { $lIdMarche = $pParam["id"]; $lTypePaiement = $pParam["type"]; $lCSV = new CSV(); $lCSV->setNom('Caisse.csv'); // Le Nom // L'entete $lEntete = array("Date", "N°", "Compte", "Nom", "Prénom", "Montant", ""); $lOperationService = new OperationService(); if ($lTypePaiement == 1) { $lOperations = $lOperationService->getListeEspeceCaisse($lIdMarche); } else { array_push($lEntete, "N°"); $lOperations = $lOperationService->getListeChequeCaisse($lIdMarche); } $lCSV->setEntete($lEntete); // Les données $lContenuTableau = array(); foreach ($lOperations as $lOperation) { if (!is_null($lOperation->getCptLabel())) { $lDate = StringUtils::extractDate($lOperation->getOpeDate()); if (is_null($lOperation->getAdhNumero())) { $lAdhNumero = ''; $lAdhNom = ''; $lAdhPrenom = ''; } else { $lAdhNumero = $lOperation->getAdhNumero(); $lAdhNom = $lOperation->getAdhNom(); $lAdhPrenom = $lOperation->getAdhPrenom(); } $lLignecontenu = array($lDate, $lAdhNumero, $lOperation->getCptLabel(), $lAdhNom, $lAdhPrenom, $lOperation->getOpeMontant(), SIGLE_MONETAIRE); if ($lTypePaiement == 2) { $lChampComplementaire = $lOperation->getOpeTypePaiementChampComplementaire(); array_push($lLignecontenu, $lChampComplementaire[3]->getValeur()); } array_push($lContenuTableau, $lLignecontenu); } } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name exportProduitCategorie($pParam) * @return CSV * @desc Retourne la liste des produits liés à la catégorie */ public function exportProduitCategorie($pParam) { $lVr = CategorieProduitValid::validDelete($pParam); if ($lVr->getValid()) { $lCategorie = CategorieProduitManager::select($pParam['id']); $lProduits = CatalogueFermeControleur::listeProduitCategorie($pParam['id']); $lCSV = new CSV(); $lCSV->setNom($lCategorie->getNom() . '_:_Liste_des_produits.csv'); // Le Nom // L'entete $lEntete = array("Nom du Produit"); $lCSV->setEntete($lEntete); $lContenuTableau = array(); foreach ($lProduits as $lProduit) { array_push($lContenuTableau, array($lProduit->getNom())); } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } return $lVr; }
/** * @name getListeAchatEtReservationCSV($pParam) * @return Un Fichier CSV * @desc Retourne la liste des achats et réservations pour une commande et la liste de produits demandés */ public function getListeAchatEtReservationCSV($pParam) { $lVr = ExportListeAchatEtReservationValid::validAjout($pParam); if ($lVr->getValid()) { $lIdProduits = $pParam['id_produits']; $lInfoAR = $this->getListeAchatEtReservationExport($pParam); $lQuantiteAR = $lInfoAR['quantite']; $lTableauAR = $lInfoAR['detail']; $lCSV = new CSV(); $lCSV->setNom('AchatEtRéservations.csv'); // Le Nom // L'entete $lEntete = array("Compte", "Nom", "Prénom", "Tel."); $lLigne2 = array("", "", "", ""); $lLigne3 = array("", "", "", "Total"); foreach ($lIdProduits as $lIdProduit) { $lProduit = ProduitManager::select($lIdProduit); $lNomProduit = NomProduitManager::select($lProduit->getIdNomProduit()); $lLabelNomProduit = htmlspecialchars_decode($lNomProduit->getNom(), ENT_QUOTES); if ($lProduit->getType() == 2) { $lLabelNomProduit .= " (Abonnement)"; } array_push($lEntete, $lLabelNomProduit, "", "", "", "", "", "", "", "", ""); array_push($lLigne2, "Réservation", "", "Achat", "", "", "", "Solidaire", "", "", ""); $lQuantiteReservation = ''; $lUniteReservation = ''; if (isset($lQuantiteAR[$lIdProduit]['reservation']) && !empty($lQuantiteAR[$lIdProduit]['reservation'])) { $lQuantiteReservation = $lQuantiteAR[$lIdProduit]['reservation']; $lUniteReservation = $lProduit->getUniteMesure(); } $lQuantiteAchat = ''; $lUniteAchat = ''; if (isset($lQuantiteAR[$lIdProduit]['qteAchat']) && !empty($lQuantiteAR[$lIdProduit]['qteAchat'])) { $lQuantiteAchat = $lQuantiteAR[$lIdProduit]['qteAchat']; $lUniteAchat = $lProduit->getUniteMesure(); } $lPrixAchat = ''; $lSiglePrixAchat = ''; if (isset($lQuantiteAR[$lIdProduit]['prixAchat']) && !empty($lQuantiteAR[$lIdProduit]['prixAchat'])) { $lPrixAchat = $lQuantiteAR[$lIdProduit]['prixAchat']; $lSiglePrixAchat = SIGLE_MONETAIRE; } $lQuantiteSolidaire = ''; $lUniteSolidaire = ''; if (isset($lQuantiteAR[$lIdProduit]['qteSolidaire']) && !empty($lQuantiteAR[$lIdProduit]['qteSolidaire'])) { $lQuantiteSolidaire = $lQuantiteAR[$lIdProduit]['qteSolidaire']; $lUniteSolidaire = $lProduit->getUniteMesure(); } $lPrixSolidaire = ''; $lSiglePrixSolidaire = ''; if (isset($lQuantiteAR[$lIdProduit]['prixSolidaire']) && !empty($lQuantiteAR[$lIdProduit]['prixSolidaire'])) { $lPrixSolidaire = $lQuantiteAR[$lIdProduit]['prixSolidaire']; $lSiglePrixSolidaire = SIGLE_MONETAIRE; } array_push($lLigne3, $lQuantiteReservation, $lUniteReservation, $lQuantiteAchat, $lUniteAchat, $lPrixAchat, $lSiglePrixAchat, $lQuantiteSolidaire, $lUniteSolidaire, $lPrixSolidaire, $lSiglePrixSolidaire); } $lCSV->setEntete($lEntete); // Les données $contenuTableau = array(); array_push($contenuTableau, $lLigne2); array_push($contenuTableau, $lLigne3); foreach ($lTableauAR as $lVal) { $lLigne = array(); array_push($lLigne, $lVal['compte']); array_push($lLigne, $lVal['nom']); array_push($lLigne, $lVal['prenom']); array_push($lLigne, $lVal['telephonePrincipal']); foreach ($lIdProduits as $lIdProduit) { $lQuantiteReservation = ''; $lUniteReservation = ''; if (isset($lVal[$lIdProduit]['reservation']) && !empty($lVal[$lIdProduit]['reservation'])) { $lQuantiteReservation = $lVal[$lIdProduit]['reservation']; $lUniteReservation = $lVal[$lIdProduit]['unite']; } $lQuantiteAchat = ''; $lUniteAchat = ''; if (isset($lVal[$lIdProduit]['qteAchat']) && !empty($lVal[$lIdProduit]['qteAchat'])) { $lQuantiteAchat = $lVal[$lIdProduit]['qteAchat']; $lUniteAchat = $lVal[$lIdProduit]['unite']; } $lPrixAchat = ''; $lSiglePrixAchat = ''; if (isset($lVal[$lIdProduit]['prixAchat']) && !empty($lVal[$lIdProduit]['prixAchat'])) { $lPrixAchat = $lVal[$lIdProduit]['prixAchat']; $lSiglePrixAchat = SIGLE_MONETAIRE; } $lQuantiteSolidaire = ''; $lUniteSolidaire = ''; if (isset($lVal[$lIdProduit]['qteSolidaire']) && !empty($lVal[$lIdProduit]['qteSolidaire'])) { $lQuantiteSolidaire = $lVal[$lIdProduit]['qteSolidaire']; $lUniteSolidaire = $lVal[$lIdProduit]['unite']; } $lPrixSolidaire = ''; $lSiglePrixSolidaire = ''; if (isset($lVal[$lIdProduit]['prixSolidaire']) && !empty($lVal[$lIdProduit]['prixSolidaire'])) { $lPrixSolidaire = $lVal[$lIdProduit]['prixSolidaire']; $lSiglePrixSolidaire = SIGLE_MONETAIRE; } array_push($lLigne, $lQuantiteReservation, $lUniteReservation, $lQuantiteAchat, $lUniteAchat, $lPrixAchat, $lSiglePrixAchat, $lQuantiteSolidaire, $lUniteSolidaire, $lPrixSolidaire, $lSiglePrixSolidaire); } array_push($contenuTableau, $lLigne); } $lCSV->setData($contenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name exportProduitCaracteristique($pParam) * @return CSV * @desc Retourne la liste des produits liés à la caracteristique */ public function exportProduitCaracteristique($pParam) { $lVr = CaracteristiqueValid::validDelete($pParam); if ($lVr->getValid()) { $lCaracteristique = CaracteristiqueManager::select($pParam['id']); $lProduits = ListeProduitCaracteristiqueViewManager::select($pParam['id']); $lCSV = new CSV(); $lTitre = str_replace(" ", "_", $lCaracteristique->getNom()); $lCSV->setNom($lTitre . '_:_Liste_des_produits.csv'); // Le Nom // L'entete $lEntete = array("Nom du Produit"); $lCSV->setEntete($lEntete); $lContenuTableau = array(); foreach ($lProduits as $lProduit) { array_push($lContenuTableau, array($lProduit->getNproNom())); } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } return $lVr; }
/** * @name getListeReservationCSV($pParam) * @return Un Fichier CSV * @desc Retourne la liste des réservations pour une commande et la liste de produits demandés */ public function getListeReservationCSV($pParam) { $lVr = ExportListeReservationValid::validAjout($pParam); if ($lVr->getValid()) { $lIdProduits = $pParam['id_produits']; $lInfoReservation = $this->getListeReservationExport($pParam); $lQuantiteReservation = $lInfoReservation['quantite']; $lTableauReservation = $lInfoReservation['detail']; $lCSV = new CSV(); $lCSV->setNom('Réservations.csv'); // Le Nom // L'entete $lEntete = array("Compte", "Nom", "Prénom", "Tel."); $lLigne2 = array("", "", "", ""); $lLigne3 = array("", "", "", ""); foreach ($lIdProduits as $lIdProduit) { $lProduit = ProduitManager::select($lIdProduit); $lNomProduit = NomProduitManager::select($lProduit->getIdNomProduit()); $lLabelNomProduit = htmlspecialchars_decode($lNomProduit->getNom(), ENT_QUOTES); if ($lProduit->getType() == 2) { $lLabelNomProduit .= " (Abonnement)"; } array_push($lEntete, $lLabelNomProduit, ""); array_push($lLigne2, "Prévu", "Réel"); $lQuantite = ''; if (isset($lQuantiteReservation[$lIdProduit])) { $lQuantite = $lQuantiteReservation[$lIdProduit]; } array_push($lLigne3, $lQuantite, ""); } $lCSV->setEntete($lEntete); // Les données $contenuTableau = array(); array_push($contenuTableau, $lLigne2); array_push($contenuTableau, $lLigne3); foreach ($lTableauReservation as $lVal) { $lLigne = array(); array_push($lLigne, $lVal['compte']); array_push($lLigne, $lVal['nom']); array_push($lLigne, $lVal['prenom']); array_push($lLigne, $lVal['telephonePrincipal']); foreach ($lIdProduits as $lIdProduit) { array_push($lLigne, $lVal[$lIdProduit], ""); } array_push($contenuTableau, $lLigne); } $lCSV->setData($contenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name exportListeAbonneSurProduit($pParam) * @desc Exporte la liste des abonnés du produit */ public function exportListeAbonneSurProduit($pParam) { $lVr = ListeProduitValid::validGetDetailProduit($pParam); if ($lVr->getValid()) { $lAbonnementService = new AbonnementService(); $lListeAbonne = $lAbonnementService->getAbonnesProduit($pParam["id"]); $lCSV = new CSV(); $lCSV->setNom('Liste_Abonne.csv'); // Le Nom // L'entete $lEntete = array("N°", "Compte", "Nom", "Prénom", "Quantité", ""); $lCSV->setEntete($lEntete); $lContenuTableau = array(); foreach ($lListeAbonne as $lAbonne) { array_push($lContenuTableau, array($lAbonne->getAdhNumero(), $lAbonne->getCptLabel(), $lAbonne->getAdhNom(), $lAbonne->getAdhPrenom(), $lAbonne->getCptAboQuantite(), $lAbonne->getProAboUnite())); } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name getFactureCSV($pParam) * @return Un Fichier CSV * @desc Retournela facture en format CSV */ public function getFactureCSV($pParam) { $lVr = FactureValid::validDelete($pParam); if ($lVr->getValid()) { $lCSV = new CSV(); $lCSV->setNom('BonDeLivraison.csv'); // Le Nom // L'entete $lEntete = array("Ferme", "Ref.", "Produit", "Quantite", "", "Prix", "", "Solidaire", ""); $lCSV->setEntete($lEntete); // Les données $lData = $lVr->getData(); $lFacture = $lData['facture']; $lFermeService = new FermeService(); $lFermes = $lFermeService->getByIdCompte($lFacture->getId()->getIdCompte()); $lFerme = $lFermes[0]; $lContenuTableau = array(); $lId = 0; foreach ($lFacture->getProduits() as $lProduit) { $lQuantite = ''; $lUnite = ''; $lMontant = 0; $lSigleMontant = SIGLE_MONETAIRE; $lQteTest = $lProduit->getQuantite(); if (!is_null($lProduit->getQuantite()) && !empty($lQteTest)) { $lQuantite = $lQteTest; $lUnite = $lProduit->getUnite(); $lMontant = $lProduit->getMontant(); } $lQuantiteSolidaire = ''; $lUniteSolidaire = ''; $lQteSolTest = $lProduit->getQuantiteSolidaire(); if (!is_null($lProduit->getQuantiteSolidaire()) && !empty($lQteSolTest)) { $lQuantiteSolidaire = $lQteSolTest; $lUniteSolidaire = $lProduit->getUniteSolidaire(); } $lNomFerme = ''; if ($lId == 0) { $lNomFerme = $lFerme->getNom(); $lId++; } $lLignecontenu = array($lNomFerme, $lProduit->getNproNumero(), $lProduit->getNproNom(), $lQuantite, $lUnite, $lMontant, $lSigleMontant, $lQuantiteSolidaire, $lUniteSolidaire); array_push($lContenuTableau, $lLignecontenu); } $lLignecontenu = array("", "", "", "", "Total : ", $lFacture->getId()->getMontant(), SIGLE_MONETAIRE, "", ""); array_push($lContenuTableau, $lLignecontenu); $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name exportListeAdherentAdhesion($pParam) * @return CSV * @desc Retourne le statut des adhésion d'adhérent sur un adhésion en CSV */ public function exportListeAdherentAdhesion($pParam) { $lVr = AdhesionValid::validDelete($pParam); if ($lVr->getValid()) { $lAdhesionService = new AdhesionService(); $lCSV = new CSV(); $lCSV->setNom('Liste_Adherent.csv'); // Le Nom // L'entete $lCSV->setEntete(array("N°", "Compte", "Nom", "Prénom", "Adhésion")); $lListeAdherent = $lAdhesionService->selectListeAdherentAdhesion($pParam['id']); $lContenuTableau = array(); foreach ($lListeAdherent as $lAdherent) { $lStatut = 'NON'; if (!is_null($lAdherent->getIdAdhesionAdherent())) { $lStatut = 'OUI'; } array_push($lContenuTableau, array($lAdherent->getAdhNumero(), $lAdherent->getCptLabel(), $lAdherent->getAdhNom(), $lAdherent->getAdhPrenom(), $lStatut)); } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
/** * @name getBComCSV($pParam) * @return Un Fichier CSV * @desc Retourne le bon de commande en format CSV */ public function getBComCSV($pParam) { $lVr = ExportBonCommandeValid::validAjout($pParam); if ($lVr->getValid()) { $lLignesBonCommande = $this->getBonCommandeExport($pParam); $lCSV = new CSV(); $lCSV->setNom('Bon_de_Commande.csv'); // Le Nom // L'entete $lEntete = array("Ferme", $lLignesBonCommande[0]->getFerNom()); $lCSV->setEntete($lEntete); // Préparation pour afficher le lot sir 2 fois le produit $lProduit = array(); foreach ($lLignesBonCommande as $lLigne) { if (isset($lProduit[$lLigne->getProId()])) { $lProduit[$lLigne->getProId()] = 2; } else { $lProduit[$lLigne->getProId()] = 1; } } // Les données $lContenuTableau = array(); array_push($lContenuTableau, array("Ref.", "Produit", "Commande", "", "Prix", "")); $lIdPrdt = 0; foreach ($lLignesBonCommande as $lLigne) { // if($lLigne->getProIdCompteFerme() != NULL) { // évite les lignes vides if ($lLigne->getProType() == 1) { $lNomProduit = $lLigne->getNproNom() . " (Solidaire)"; } else { if ($lLigne->getProType() == 2) { $lNomProduit = $lLigne->getNproNom() . " (Abonnement)"; } else { $lNomProduit = $lLigne->getNproNom(); } } if (isset($lProduit[$lLigne->getProId()]) && $lProduit[$lLigne->getProId()] == 2) { $lNomProduit .= " (" . number_format($lLigne->getDcomTaille(), 2, ',', ' ') . " " . $lLigne->getProUniteMesure() . ")"; } $lLignecontenu = array($lLigne->getNproNumero(), $lNomProduit, $lLigne->getStoQuantite(), $lLigne->getProUniteMesure(), $lLigne->getDopeMontant(), SIGLE_MONETAIRE); array_push($lContenuTableau, $lLignecontenu); $lIdPrdt = $lLigne->getProIdCompteFerme(); // } } $lCSV->setData($lContenuTableau); // Export en CSV $lCSV->output(); } else { return $lVr; } }
include_once CHEMIN_CONFIGURATION . "Titre.php"; // Définition des constantes de titre include_once CHEMIN_CLASSES_UTILS . "Log.php"; // La classe de Log // Définition du level de log define("LOG_LEVEL", PEAR_LOG_DEBUG); 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);