/** * @name modifierInformation($pParam) * @return VR * @desc Modification des informations de l'adhérent. */ public function modifierInformation($pParam) { $lVr = InfoAdherentValid::validUpdateInformation($pParam); if ($lVr->getValid()) { // Chargement de l'adherent $lAdherentActuel = AdherentManager::select($pParam['id_adherent']); //Mise à jour des inscriptions de mailing liste $lMailingListeService = new MailingListeService(); if ($lAdherentActuel->getCourrielPrincipal() != "") { $lMailingListeService->delete($lAdherentActuel->getCourrielPrincipal()); } if ($lAdherentActuel->getCourrielSecondaire() != "") { $lMailingListeService->delete($lAdherentActuel->getCourrielSecondaire()); } if ($pParam['courrielPrincipal'] != "") { $lMailingListeService->insert($pParam['courrielPrincipal']); } if ($pParam['courrielSecondaire'] != "") { $lMailingListeService->insert($pParam['courrielSecondaire']); } $lAdherentActuel->setNom($pParam['nom']); $lAdherentActuel->setPrenom($pParam['prenom']); $lAdherentActuel->setCourrielPrincipal($pParam['courrielPrincipal']); $lAdherentActuel->setCourrielSecondaire($pParam['courrielSecondaire']); $lAdherentActuel->setTelephonePrincipal($pParam['telephonePrincipal']); $lAdherentActuel->setTelephoneSecondaire($pParam['telephoneSecondaire']); $lAdherentActuel->setAdresse($pParam['adresse']); $lAdherentActuel->setCodePostal($pParam['codePostal']); $lAdherentActuel->setVille($pParam['ville']); $lAdherentActuel->setDateNaissance($pParam['dateNaissance']); $lAdherentActuel->setCommentaire($pParam['commentaire']); // Insertion de la première mise à jour $lAdherentActuel->setDateMaj(StringUtils::dateTimeAujourdhuiDb()); // Maj de l'adherent dans la BDD AdherentManager::update($lAdherentActuel); $lCompteService = new CompteService(); $lCompte = $lCompteService->get($lAdherentActuel->getIdCompte()); $lCompte->setIdAdherentPrincipal($pParam['idAdherentPrincipal']); $lCompteService->set($lCompte); } return $lVr; }
/** * @name delete($pIdAdherent) * @param integer * @return AdherentVO * @desc Supprime un adherent */ public function delete($pIdAdherent) { $lAdherentValid = new NAMESPACE_CLASSE\NAMESPACE_VALIDATEUR\MOD_SERVICE\AdherentValid(); if ($lAdherentValid->delete($pIdAdherent)) { $lAdherent = AdherentManager::select($pIdAdherent); $lCompteService = new CompteService(); $lNbAdherentSurCompte = $lCompteService->getNombreAdherentSurCompte($lAdherent->getIdCompte()); $lAdhesionService = new AdhesionService(); // Suppression des adhésions $lAdhesionService->deleteAdhesionAdherentByIdAdherent($pIdAdherent); // Change l'état à supprimé $lAdherent->setEtat(2); AdherentManager::update($lAdherent); // Désactive l'identification $lIdentification = IdentificationManager::selectByIdType($lAdherent->getId(), 1); $lIdentification = $lIdentification[0]; $lIdentification->setAutorise(0); IdentificationManager::update($lIdentification); //Désinscription de la mailing liste $lMailingListeService = new MailingListeService(); if ($lAdherent->getCourrielPrincipal() != "") { $lMailingListeService->delete($lAdherent->getCourrielPrincipal()); } if ($lAdherent->getCourrielSecondaire() != "") { $lMailingListeService->delete($lAdherent->getCourrielSecondaire()); } // Si c'est le dernier adhérent du compte : suppression des réservations et abonnements if ($lNbAdherentSurCompte < 2) { // Suppression des réservations en cours $lMarcheService = new MarcheService(); $lReservations = $lMarcheService->getNonAchatParCompte($lAdherent->getIdCompte()); if (!is_null($lReservations[0]->getId())) { $lReservationService = new ReservationService(); foreach ($lReservations as $lReservation) { $lIdReservation = new IdReservationVO(); $lIdReservation->setIdCompte($lAdherent->getIdCompte()); $lIdReservation->setIdCommande($lReservation->getId()); $lReservationService->delete($lIdReservation); } } // Suppression des abonnements $lAbonnementService = new AbonnementService(); $lProduits = $lAbonnementService->getProduitsAbonne($lAdherent->getIdCompte()); foreach ($lProduits as $lProduit) { $lAbonnementService->deleteAbonnement($lProduit->getCptAboId()); } } return true; } else { return false; } }