/**
  * @name update($pVo)
  * @param ProducteurVO
  * @desc Met à jour la ligne de la table, correspondant à l'id du ProducteurVO, avec les informations du ProducteurVO
  */
 public static function update($pVo)
 {
     // Initialisation du Logger
     $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS);
     $lLogger->setMask(Log::MAX(LOG_LEVEL));
     // Mise en forme des données
     $pVo->setNom(StringUtils::formaterNom(trim($pVo->getNom())));
     $pVo->setPrenom(StringUtils::formaterPrenom(trim($pVo->getPrenom())));
     $pVo->setCourrielPrincipal(trim($pVo->getCourrielPrincipal()));
     $pVo->setCourrielSecondaire(trim($pVo->getCourrielSecondaire()));
     $pVo->setTelephonePrincipal(trim($pVo->getTelephonePrincipal()));
     $pVo->setTelephoneSecondaire(trim($pVo->getTelephoneSecondaire()));
     $pVo->setAdresse(trim($pVo->getAdresse()));
     $pVo->setCodePostal(trim($pVo->getCodePostal()));
     $pVo->setVille(StringUtils::formaterVille(trim($pVo->getVille())));
     $pVo->setCommentaire(trim($pVo->getCommentaire()));
     // Protection des dates vides
     if ($pVo->getDateNaissance() == '') {
         $pVo->setDateNaissance(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pVo->getDateCreation() == '') {
         $pVo->setDateCreation(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pVo->getDateMaj() == '') {
         $pVo->getDateMaj(StringUtils::FORMAT_DATE_NULLE);
     }
     $lRequete = "UPDATE " . ProducteurManager::TABLE_PRODUCTEUR . "\n\t\t\t SET\n\t\t\t\t " . ProducteurManager::CHAMP_PRODUCTEUR_ID_FERME . " = '" . StringUtils::securiser($pVo->getIdFerme()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_NUMERO . " = '" . StringUtils::securiser($pVo->getNumero()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_NOM . " = '" . StringUtils::securiser($pVo->getNom()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_PRENOM . " = '" . StringUtils::securiser($pVo->getPrenom()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_COURRIEL_PRINCIPAL . " = '" . StringUtils::securiser($pVo->getCourrielPrincipal()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_COURRIEL_SECONDAIRE . " = '" . StringUtils::securiser($pVo->getCourrielSecondaire()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_TELEPHONE_PRINCIPAL . " = '" . StringUtils::securiser($pVo->getTelephonePrincipal()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_TELEPHONE_SECONDAIRE . " = '" . StringUtils::securiser($pVo->getTelephoneSecondaire()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_ADRESSE . " = '" . StringUtils::securiser($pVo->getAdresse()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_CODE_POSTAL . " = '" . StringUtils::securiser($pVo->getCodePostal()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_VILLE . " = '" . StringUtils::securiser($pVo->getVille()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_DATE_NAISSANCE . " = '" . StringUtils::securiser($pVo->getDateNaissance()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_DATE_CREATION . " = '" . StringUtils::securiser($pVo->getDateCreation()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_DATE_MAJ . " = '" . StringUtils::securiser($pVo->getDateMaj()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_COMMENTAIRE . " = '" . StringUtils::securiser($pVo->getCommentaire()) . "'\n\t\t\t\t," . ProducteurManager::CHAMP_PRODUCTEUR_ETAT . " = '" . StringUtils::securiser($pVo->getEtat()) . "'\n\t\t\t WHERE " . ProducteurManager::CHAMP_PRODUCTEUR_ID . " = '" . StringUtils::securiser($pVo->getId()) . "'";
     $lLogger->log("Execution de la requete : " . $lRequete, PEAR_LOG_DEBUG);
     // Maj des logs
     return Dbutils::executerRequeteInsertRetourId($lRequete);
 }
Exemplo n.º 2
0
     $lOperation = new OperationVO();
     $lOperation->setIdCompte($lIdCompte);
     $lOperation->setMontant($lSolde);
     $lOperation->setLibelle("Création du compte");
     $lOperation->setDate(StringUtils::dateAujourdhuiDb());
     //$lOperation->setType(1);
     $lOperation->setIdCommande(0);
     $lOperation->setTypePaiement(-1);
     OperationManager::insert($lOperation);
 }
 //L'adhérent
 $lAdherent = new AdherentVO();
 $lAdherent->setIdCompte($lIdCompte);
 $lAdherent->setNumero($lNumero);
 $lAdherent->setNom(StringUtils::formaterNom(trim($lNom)));
 $lAdherent->setPrenom(StringUtils::formaterPrenom(trim($lPrenom)));
 $lAdherent->setCourrielPrincipal(trim($lCourrielP));
 $lAdherent->setCourrielSecondaire(trim($lCourrielS));
 $lAdherent->setTelephonePrincipal(trim($lTelephoneP));
 $lAdherent->setTelephoneSecondaire(trim($lTelephoneS));
 $lAdherent->setAdresse(trim($lAdresse));
 $lAdherent->setCodePostal(trim($lCodePostal));
 $lAdherent->setVille(StringUtils::formaterVille(trim($lVille)));
 $lAdherent->setDateNaissance($lDateNaissance);
 $lAdherent->setDateAdhesion($lDateAdhesion);
 $lAdherent->setDateMaj(StringUtils::dateTimeAujourdhuiDb());
 $lAdherent->setCommentaire(trim($lCommentaire));
 $lAdherent->setEtat(1);
 // Protection des dates vides
 if ($lAdherent->getDateNaissance() == '') {
     $lAdherent->setDateNaissance(StringUtils::FORMAT_DATE_NULLE);
 /**
  * @name update($pAdherent)
  * @param AdherentVO
  * @return AdherentVO
  * @desc Modifie un adherent
  */
 private function update($pAdherent)
 {
     $lAdherentActuel = AdherentManager::select($pAdherent->getId());
     // Si pas de liaison création d'un nouveau compte
     if ($pAdherent->getIdCompte() == 0) {
         // Création d'un nouveau compte
         $lCompte = new CompteVO();
         $lCompteService = new CompteService();
         $lCompte = $lCompteService->set($lCompte);
         $pAdherent->setIdCompte($lCompte->getId());
         // Laision avec l'adhérent
         $lCompte->setIdAdherentPrincipal($pAdherent->getId());
         // Positionnement de l'adhérent en adhérent principal du compte
         $lCompteService->set($lCompte);
     } else {
         if ($pAdherent->getIdCompte() != $lAdherentActuel->getIdCompte()) {
             // Liaison avec un autre compte
             $lAdhesionService = new AdhesionService();
             // Suppression des adhésions actuelles
             $lAdhesionService->deleteAdhesionAdherentByIdAdherent($pAdherent->getId());
             // Les adhérents du compte
             $lListeAdherent = $this->selectActifByIdCompte($pAdherent->getIdCompte());
             // Le premier adhérent
             $lAdherent = $lListeAdherent[0];
             // Les adhésions sur le premier adhérent
             $lAdhesions = $lAdhesionService->getAdhesionSurAdherent($lAdherent->getId());
             // Positionne les mêmes adhésions si elles existent
             foreach ($lAdhesions as $lAdhesion) {
                 $lAdhesionAdherentDetail = $lAdhesionService->getAdhesionAdherent($lAdhesion->getAdadId());
                 if ($lAdhesionAdherentDetail) {
                     $lAdhesionAdherent = $lAdhesionAdherentDetail->getAdhesionAdherent();
                     $lTypeAdhesion = $lAdhesionService->getTypeAdhesion($lAdhesionAdherent->getIdTypeAdhesion());
                     if ($lTypeAdhesion->getIdPerimetre() == 2) {
                         // Si type d'adhésion sur périmètre compte
                         $lAdhesionAdherent->setId('');
                         $lAdhesionAdherent->setIdAdherent($pAdherent->getId());
                         $lAdhesionService->setAdhesionAdherent($lAdhesionAdherent);
                     }
                 }
             }
         }
     }
     // Insertion de la date de mise à jour
     $pAdherent->setDateMaj(StringUtils::dateTimeAujourdhuiDb());
     // On reporte le numero dans la maj
     $pAdherent->setNumero($lAdherentActuel->getNumero());
     // L'adherent n'est pas supprimé
     $pAdherent->setEtat(1);
     // Mise en forme des données
     $pAdherent->setNom(StringUtils::formaterNom(trim($pAdherent->getNom())));
     $pAdherent->setPrenom(StringUtils::formaterPrenom(trim($pAdherent->getPrenom())));
     $pAdherent->setCourrielPrincipal(trim($pAdherent->getCourrielPrincipal()));
     $pAdherent->setCourrielSecondaire(trim($pAdherent->getCourrielSecondaire()));
     $pAdherent->setTelephonePrincipal(trim($pAdherent->getTelephonePrincipal()));
     $pAdherent->setTelephoneSecondaire(trim($pAdherent->getTelephoneSecondaire()));
     $pAdherent->setAdresse(trim($pAdherent->getAdresse()));
     $pAdherent->setCodePostal(trim($pAdherent->getCodePostal()));
     $pAdherent->setVille(StringUtils::formaterVille(trim($pAdherent->getVille())));
     $pAdherent->setCommentaire(trim($pAdherent->getCommentaire()));
     // Protection des dates vides
     if ($pAdherent->getDateNaissance() == '') {
         $pAdherent->setDateNaissance(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pAdherent->getDateAdhesion() == '') {
         $pAdherent->setDateAdhesion(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pAdherent->getDateMaj() == '') {
         $pAdherent->setDateMaj(StringUtils::FORMAT_DATE_NULLE);
     }
     // Maj de l'adherent dans la BDD
     $lRetour = AdherentManager::update($pAdherent);
     // Récupération des autorisations acutelles
     $lAutorisationsActuelles = AutorisationManager::selectByIdAdherent($pAdherent->getId());
     $lModuleService = new ModuleService();
     $lModulesDefaut = $lModuleService->selectAllDefautVisible();
     $lIdModuleDefaut = array();
     foreach ($lModulesDefaut as $lModule) {
         array_push($lIdModuleDefaut, $lModule->getId());
     }
     // Suppression des autorisations
     $lIdSuppAutorisation = array();
     foreach ($lAutorisationsActuelles as $lAutorisationActu) {
         // Suppression si ce n'est pas un module par defaut
         if (!in_array($lAutorisationActu->getIdModule(), $lIdModuleDefaut)) {
             $lSupp = true;
             foreach ($pAdherent->getListeModule() as $lIdModule) {
                 if ($lAutorisationActu->getIdModule() == $lIdModule) {
                     $lSupp = false;
                 }
             }
             if ($lSupp) {
                 array_push($lIdSuppAutorisation, $lAutorisationActu->getId());
             }
         }
     }
     if (!empty($lIdSuppAutorisation)) {
         AutorisationManager::deleteByArray($lIdSuppAutorisation);
     }
     // Ajout des nouvelles autorisations du compte
     $lAutorisations = array();
     foreach ($pAdherent->getListeModule() as $lIdModule) {
         $lAjout = true;
         foreach ($lAutorisationsActuelles as $lAutorisationActu) {
             if ($lAutorisationActu->getIdModule() == $lIdModule) {
                 $lAjout = false;
             }
         }
         if ($lAjout) {
             $lAutorisation = new AutorisationVO();
             $lAutorisation->setIdAdherent($pAdherent->getId());
             $lAutorisation->setIdModule($lIdModule);
             array_push($lAutorisations, $lAutorisation);
         }
     }
     if (!empty($lAutorisations)) {
         AutorisationManager::insertByArray($lAutorisations);
     }
     //Mise à jour des inscriptions de mailing liste
     $lMailingListeService = new MailingListeService();
     // Suppression des anciens mails
     if ($lAdherentActuel->getCourrielPrincipal() != "") {
         $lMailingListeService->delete($lAdherentActuel->getCourrielPrincipal());
     }
     if ($lAdherentActuel->getCourrielSecondaire() != "") {
         $lMailingListeService->delete($lAdherentActuel->getCourrielSecondaire());
     }
     // Ajout des nouveaux mails
     if ($pAdherent->getCourrielPrincipal() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielPrincipal());
     }
     if ($pAdherent->getCourrielSecondaire() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielSecondaire());
     }
     return $lRetour;
 }