/**
  * @name getInfoCompte()
  * @desc Donne les infos sur le compte du zeybu
  */
 public function getInfoCompte()
 {
     $lCompteService = new CompteService();
     $lOperationService = new OperationService();
     $lMarcheService = new MarcheService();
     $lSoldeSolidaire = $lCompteService->get(-2)->getSolde();
     $lSoldeTotal = $lCompteService->get(-1)->getSolde();
     $lSoldeCaisse = $lOperationService->getSoldeCaisse();
     $lSoldeBanque = $lOperationService->getSoldeBanque();
     return new InfoCompteZeybuResponse($lSoldeTotal, $lSoldeSolidaire, $lSoldeCaisse, $lSoldeBanque, $lMarcheService->get());
 }
 /**
  * @name supprimerAdherent($pParam)
  * @desc Passe l'adhérent en état supprimé
  */
 public function supprimerAdherent($pParam)
 {
     $lVr = AdherentValid::validDelete($pParam);
     if ($lVr->getValid()) {
         $lIdAdherent = $pParam['id'];
         $lAdherentService = new AdherentService();
         $lAdherentService->delete($lIdAdherent);
         // Gestion du compte
         $lCompteService = new CompteService();
         $lData = $lVr->getData();
         $lIdAncienCompte = $lData['adherent']->getAdhIdCompte();
         $lAdherentAncienCompte = $lCompteService->getAdherentCompte($lIdAncienCompte);
         // RAZ de l'adhérent principal
         $lIdAdherentPrincipalAncienCompte = 0;
         // Ou positionnement du nouvel
         if (!is_null($lAdherentAncienCompte[0]->getId()) && $pParam['idAdherentPrincipal'] != -1) {
             $lIdAdherentPrincipalAncienCompte = $pParam['idAdherentPrincipal'];
         }
         // Maj de l'ancien compte
         $lAncienCompte = $lCompteService->get($lIdAncienCompte);
         $lAncienCompte->setIdAdherentPrincipal($lIdAdherentPrincipalAncienCompte);
         $lCompteService->set($lAncienCompte);
         $lResponse = new AjoutAdherentResponse();
         $lResponse->setId($lIdAdherent);
         return $lResponse;
     }
     return $lVr;
 }
 /**
  * @name getAdherent()
  * @return ListeAdherentResponse
  * @desc Recherche la liste des adherents
  */
 public function getAdherent()
 {
     // Lancement de la recherche
     $lResponse = new ListeAdherentResponse();
     $lAdherentService = new AdherentService();
     $lResponse->setListeAdherent($lAdherentService->getAllResumeSansSolde());
     $lCompteService = new CompteService();
     $lResponse->setSolde($lCompteService->get(-2)->getSolde());
     return $lResponse;
 }
 /**
  * @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($pId)
  * @param integer
  * @desc Met à jour une opération
  */
 public function delete($pId)
 {
     $lOperationValid = new OperationValid();
     if ($lOperationValid->delete($pId)) {
         $lOperation = $this->getDetail($pId);
         // Maj du solde du compte
         $lTypeModificationSolde = array(1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14);
         if (in_array($lOperation->getTypePaiement(), $lTypeModificationSolde)) {
             $lCompteService = new CompteService();
             // Mise à jour du solde
             $lCompte = $lCompteService->get($lOperation->getIdCompte());
             $lCompte->setSolde($lCompte->getSolde() - $lOperation->getMontant());
             $lCompteService->set($lCompte);
         }
         // Si c'est un paiement de facture de producteur il faut mettre à jour les paiements associés
         $lOperationChampComplementaireFacture = OperationChampComplementaireManager::recherche(array(OperationChampComplementaireManager::CHAMP_OPERATIONCHAMPCOMPLEMENTAIRE_CHCP_ID, OperationChampComplementaireManager::CHAMP_OPERATIONCHAMPCOMPLEMENTAIRE_VALEUR), array('=', '='), array(9, $pId), array(), array());
         if (!is_null($lOperationChampComplementaireFacture[0]->getOpeId())) {
             // Suppression de l'operation de facture
             $lOperationFacture = $this->getDetail($lOperationChampComplementaireFacture[0]->getOpeId());
             $this->delete($lOperationFacture->getId());
             // Suppression de l'operation zeybu
             $lOpeFacChampComp = $lOperationFacture->getChampComplementaire();
             $this->delete($lOpeFacChampComp[10]->getValeur());
         }
         switch ($lOperation->getTypePaiement()) {
             case 0:
                 // Annulation de la reservation
             // Annulation de la reservation
             case 16:
             case 22:
                 $lOperation->setTypePaiement(16);
                 return $this->update($lOperation);
                 break;
             case 15:
                 // Réservation non récupérée
                 $lOperation->setTypePaiement(15);
                 return $this->update($lOperation);
                 break;
             case 1:
                 // Annulation achat/dépot
             // Annulation achat/dépot
             case 2:
             case 6:
                 $lOperation->setTypePaiement(18);
                 return $this->update($lOperation);
                 break;
             case 7:
                 $lOperation->setTypePaiement(18);
                 return $this->update($lOperation);
                 break;
             case 8:
                 $lOperation->setTypePaiement(20);
                 return $this->update($lOperation);
                 break;
             default:
                 $lOperation->setDate(StringUtils::dateTimeAujourdhuiDb());
                 $lOperation->setlibelle("Supression");
                 $this->insertHistorique($lOperation);
                 // Ajout historique
                 //$this->insertHistorique($lDetailOperation); // Ajout historique
                 return OperationManager::delete($pId);
                 // delete de l'opération
                 break;
         }
     } else {
         return false;
     }
 }
 /**
  * @name getInfoCompte()
  * @desc Donne les infos sur le compte association
  */
 public function getInfoCompte()
 {
     $lCompteService = new CompteService();
     return new InfoCompteResponse($lCompteService->get(-4)->getSolde());
 }
 /**
  * @name validUpdate($pData)
  * @return CompteSolidaireModifierVirementVR
  * @desc Test la validite de l'élément
  */
 public static function validUpdate($pData)
 {
     $lVr = new CompteSolidaireModifierVirementVR();
     //Tests inputs
     if (!isset($pData['id'])) {
         $lVr->setValid(false);
         $lVr->getId()->setValid(false);
         $lErreur = new VRerreur();
         $lErreur->setCode(MessagesErreurs::ERR_201_CODE);
         $lErreur->setMessage(MessagesErreurs::ERR_201_MSG);
         $lVr->getId()->addErreur($lErreur);
     }
     if (!isset($pData['montant'])) {
         $lVr->setValid(false);
         $lVr->getMontant()->setValid(false);
         $lErreur = new VRerreur();
         $lErreur->setCode(MessagesErreurs::ERR_201_CODE);
         $lErreur->setMessage(MessagesErreurs::ERR_201_MSG);
         $lVr->getMontant()->addErreur($lErreur);
     }
     if ($lVr->getValid()) {
         //Tests Techniques
         if (!TestFonction::checkLength($pData['id'], 0, 11)) {
             $lVr->setValid(false);
             $lVr->getId()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_101_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_101_MSG);
             $lVr->getId()->addErreur($lErreur);
         }
         if (!is_int((int) $pData['id'])) {
             $lVr->setValid(false);
             $lVr->getId()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_108_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_108_MSG);
             $lVr->getId()->addErreur($lErreur);
         }
         if (!TestFonction::checkLength($pData['montant'], 0, 12) || $pData['montant'] > 999999999.99) {
             $lVr->setValid(false);
             $lVr->getMontant()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_101_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_101_MSG);
             $lVr->getMontant()->addErreur($lErreur);
         }
         if (!is_float((double) $pData['montant'])) {
             $lVr->setValid(false);
             $lVr->getMontant()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_109_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_109_MSG);
             $lVr->getMontant()->addErreur($lErreur);
         }
         //Tests Fonctionnels
         if (empty($pData['id'])) {
             $lVr->setValid(false);
             $lVr->getId()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_201_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_201_MSG);
             $lVr->getId()->addErreur($lErreur);
         }
         if (empty($pData['montant'])) {
             $lVr->setValid(false);
             $lVr->getMontant()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_201_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_201_MSG);
             $lVr->getMontant()->addErreur($lErreur);
         }
         if ($pData['montant'] <= 0) {
             $lVr->setValid(false);
             $lVr->getMontant()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_215_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_215_MSG);
             $lVr->getMontant()->addErreur($lErreur);
         }
         if ($lVr->getValid()) {
             $lOperationService = new OperationService();
             $lOperation = $lOperationService->getDetail($pData['id']);
             $lOpeChampComp = $lOperation->getChampComplementaire();
             if ($lOperation->getTypePaiement() == 3 || $lOperation->getTypePaiement() == 9) {
                 $lOperationSoeur = $lOperationService->getDetail($lOpeChampComp[4]->getValeur());
             } else {
                 if ($lOperation->getTypePaiement() == 4 || $lOperation->getTypePaiement() == 10) {
                     $lOperationSoeur = $lOperationService->getDetail($lOpeChampComp[5]->getValeur());
                 }
             }
             $lCompteService = new CompteService();
             if (!$lCompteService->existe($lOperationSoeur->getIdCompte()) || !$lCompteService->existe($lOperation->getIdCompte())) {
                 $lVr->setValid(false);
                 $lVr->getId()->setValid(false);
                 $lErreur = new VRerreur();
                 $lErreur->setCode(MessagesErreurs::ERR_227_CODE);
                 $lErreur->setMessage(MessagesErreurs::ERR_227_MSG);
                 $lVr->getId()->addErreur($lErreur);
             }
             // Le Montant dans l'operation est négatif donc solde - montant
             if ($pData['montant'] > $lCompteService->get(-2)->getSolde() - $lOperation->getMontant()) {
                 $lVr->setValid(false);
                 $lVr->getMontant()->setValid(false);
                 $lErreur = new VRerreur();
                 $lErreur->setCode(MessagesErreurs::ERR_237_CODE);
                 $lErreur->setMessage(MessagesErreurs::ERR_237_MSG);
                 $lVr->getMontant()->addErreur($lErreur);
             }
         }
     }
     return $lVr;
 }
 /**
  * @name getDetailCompte($pParam)
  * @desc Retourne les informations sur un compte
  */
 public function getDetailCompte($pParam)
 {
     $lVr = NAMESPACE_CLASSE\NAMESPACE_VALIDATEUR\MOD_GESTION_ADHERENTS\CompteValid::validExiste($pParam);
     if ($lVr->getValid()) {
         $lResponse = new CompteResponse();
         $lCompteService = new CompteService();
         $lResponse->setCompte($lCompteService->get($pParam['id']));
         $lResponse->setAdherentCompte($lCompteService->getAdherentCompte($pParam['id']));
         return $lResponse;
     }
     return $lVr;
 }
Ejemplo n.º 9
0
 /**
  * @name insert($pAdherent)
  * @param AdherentVO
  * @return AdherentVO
  * @desc Ajoute un adherent
  */
 private function insert($pAdherent)
 {
     // Initialisation du Logger
     $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS);
     $lLogger->setMask(Log::MAX(LOG_LEVEL));
     // Si pas de liaison création d'un nouveau compte
     $lNvCompte = false;
     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
         $lNvCompte = true;
     }
     // Insertion de la première mise à jour
     $pAdherent->setDateMaj(StringUtils::dateTimeAujourdhuiDb());
     // 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);
     }
     // Enregistre l'adherent dans la BDD
     $lIdAdherent = AdherentManager::insert($pAdherent);
     if ($lNvCompte) {
         // Création d'un compte
         $lCompte = $lCompteService->get($lCompte->getId());
         $lCompte->setIdAdherentPrincipal($lIdAdherent);
         // Positionnement de l'adhérent en adhérent principal du compte
         $lCompteService->set($lCompte);
     } else {
         // Liaison avec un autre compte
         // Les adhérents du compte
         $lListeAdherent = $this->selectActifByIdCompte($pAdherent->getIdCompte());
         // Le premier adhérent
         $lAdherent = $lListeAdherent[0];
         $lAdhesionService = new AdhesionService();
         // Les adhésions sur le premier adhérent
         $lAdhesions = $lAdhesionService->getAdhesionSurAdherent($lAdherent->getId());
         // Positionne les mêmes adhésions
         foreach ($lAdhesions as $lAdhesion) {
             if (!is_null($lAdhesion->getAdadId())) {
                 $lAdhesionAdherentDetail = $lAdhesionService->getAdhesionAdherent($lAdhesion->getAdadId());
                 $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($lIdAdherent);
                     $lAdhesionService->setAdhesionAdherent($lAdhesionAdherent);
                 }
             }
         }
     }
     $pAdherent->setId($lIdAdherent);
     $pAdherent->setNumero('Z' . $lIdAdherent);
     // Mise à jour du numéro dans l'objet
     AdherentManager::update($pAdherent);
     // Mise à jour de la base
     // Ajout des autorisations de l'adherent
     $lModuleService = new ModuleService();
     $lModulesDefaut = $lModuleService->selectAllDefautVisible();
     $lAutorisations = array();
     foreach ($lModulesDefaut as $lModule) {
         $lAutorisation = new AutorisationVO();
         $lAutorisation->setIdAdherent($lIdAdherent);
         $lAutorisation->setIdModule($lModule->getId());
         //AutorisationManager::insert($lAutorisation);
         array_push($lAutorisations, $lAutorisation);
     }
     if (!empty($lAutorisations)) {
         AutorisationManager::insertByArray($lAutorisations);
     }
     //$lAdherent = AdherentManager::select($lIdAdherent);
     // Insertion des informations de connexion
     $lMdp = MotDePasseUtils::generer();
     $lIdentification = new IdentificationVO();
     $lIdentification->setIdLogin($lIdAdherent);
     $lIdentification->setLogin($pAdherent->getNumero());
     $lIdentification->setPass(md5($lMdp));
     $lIdentification->setType(1);
     $lIdentification->setAutorise(1);
     IdentificationManager::insert($lIdentification);
     // Ajout à la mailing liste
     $lMailingListeService = new MailingListeService();
     if ($pAdherent->getCourrielPrincipal() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielPrincipal());
     }
     if ($pAdherent->getCourrielSecondaire() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielSecondaire());
     }
     // Envoi du mail de confirmation
     if ($pAdherent->getCourrielPrincipal() != "") {
         $lTo = $pAdherent->getCourrielPrincipal();
     } else {
         if ($pAdherent->getCourrielSecondaire() != "") {
             $lTo = $pAdherent->getCourrielSecondaire();
         } else {
             // Pas de mail sur le compte : Envoi au gestionnaire
             $lTo = MAIL_SUPPORT;
         }
     }
     $lFrom = MAIL_SUPPORT;
     $jour = date("d-m-Y");
     $heure = date("H:i");
     $lSujet = "Votre Compte zeybux";
     $lContenu = file_get_contents(CHEMIN_TEMPLATE . MOD_GESTION_ADHERENTS . "/" . "MailAjoutAdherent.html");
     $lContenu = str_replace(array("{LOGIN}", "{MOT_PASSE}", "{PROP_NOM}", "{ZEYBUX_ADRESSE_SITE}"), array($pAdherent->getNumero(), $lMdp, PROP_NOM, ZEYBUX_ADRESSE_SITE), $lContenu);
     $lHeaders = file_get_contents(CHEMIN_TEMPLATE . COMMUN_TEMPLATE . "/" . "EnteteMail.html");
     $lHeaders = str_replace("{FROM}", $lFrom, $lHeaders);
     $VerifEnvoiMail = TRUE;
     $VerifEnvoiMail = @mail($lTo, $lSujet, $lContenu, $lHeaders);
     if ($VerifEnvoiMail === FALSE) {
         $lVr = new TemplateVR();
         $lVr->setValid(false);
         $lVr->getLog()->setValid(false);
         $lErreur = new VRerreur();
         $lErreur->setCode(MessagesErreurs::ERR_118_CODE);
         $lErreur->setMessage(MessagesErreurs::ERR_118_MSG);
         $lVr->getLog()->addErreur($lErreur);
         $lLogger->log("Erreur d'envoi du mail de création de l'adhérent " . $pAdherent->getNumero() . "par : " . $_SESSION[ID_CONNEXION] . ".", PEAR_LOG_INFO);
         // Maj des logs
         $lLogger->log($lVr->export(), PEAR_LOG_INFO);
         // Maj des logs
     } else {
         $lLogger->log("Envoi du mail de création de l'adhérent " . $pAdherent->getNumero() . "par : " . $_SESSION[ID_CONNEXION] . ".", PEAR_LOG_INFO);
         // Maj des logs
     }
     return $pAdherent;
 }