/**
  * @name getAchatEtReservation($pParam)
  * @return AchatAdherentResponse
  * @desc Retourne les détails d'une réservation et des achats du marché
  */
 public function getAchatEtReservation($pParam)
 {
     $lVr = AfficheAchatAdherentValid::validGetAchatEtReservation($pParam);
     if ($lVr->getValid()) {
         $lIdAdherent = $pParam["id_adherent"];
         $lIdMarche = $pParam["id_marche"];
         $lIdOperation = $pParam["idOperation"];
         $lResponse = new AchatAdherentResponse();
         $lAdherent = AdherentViewManager::select($lIdAdherent);
         $lResponse->setAdherent($lAdherent);
         // Tableau pour rechercher le détail des produits achetés
         $lIdProduits = array();
         // Si achat sur marché recherche si il y a une réservation et le détail des achats
         if (!empty($lIdMarche) && empty($lIdOperation)) {
             $lReservationService = new ReservationService();
             $lIdReservation = new IdReservationVO();
             $lIdReservation->setIdCompte($lAdherent->getAdhIdCompte());
             $lIdReservation->setIdCommande($lIdMarche);
             $lReservation = $lReservationService->get($lIdReservation);
             $lResponse->setReservation($lReservation);
             if (!empty($lReservation)) {
                 // Récupère les informations sur les produits achetés
                 foreach ($lReservation->getDetailReservation() as $lDetailReservation) {
                     array_push($lIdProduits, $lDetailReservation->getIdProduit());
                 }
             }
             $lAchatService = new AchatService();
             $lIdAchat = new IdAchatVO();
             $lIdAchat->setIdCompte($lAdherent->getAdhIdCompte());
             $lIdAchat->setIdCommande($lIdMarche);
             $lAchats = $lAchatService->getAll($lIdAchat);
             $lResponse->setAchats($lAchats);
             if (is_array($lAchats)) {
                 foreach ($lAchats as $lAchat) {
                     foreach ($lAchat->getDetailAchat() as $lDetailAchat) {
                         array_push($lIdProduits, $lDetailAchat->getIdProduit());
                     }
                     foreach ($lAchat->getDetailAchatSolidaire() as $lDetailAchat) {
                         array_push($lIdProduits, $lDetailAchat->getIdProduit());
                     }
                 }
             }
         }
         // Récupère l'achat si il il y une operation
         if (!empty($lIdOperation)) {
             $lAchatService = new AchatService();
             $lIdAchat = new IdAchatVO();
             $lIdAchat->setIdAchat($lIdOperation);
             $lAchat = $lAchatService->get($lIdAchat);
             $lResponse->setAchats($lAchat);
             foreach ($lAchat->getDetailAchat() as $lDetailAchat) {
                 array_push($lIdProduits, $lDetailAchat->getIdProduit());
             }
             foreach ($lAchat->getDetailAchatSolidaire() as $lDetailAchat) {
                 array_push($lIdProduits, $lDetailAchat->getIdProduit());
             }
         }
         $lProduitService = new ProduitService();
         $lResponse->setDetailProduit($lProduitService->selectDetailProduits($lIdProduits));
         return $lResponse;
     }
     return $lVr;
 }
Exemplo n.º 2
0
 /**
  * @name validAjout($pData)
  * @return AchatCommandeVR
  * @desc Test la validite de l'élément
  */
 public static function validAjout($pData)
 {
     $lVr = new AchatCommandeVR();
     // Pour les adhents non compte invité et achat marché on vérifie si il n'y a pas déjà un achat
     if ($pData['idCompte'] != -3 && $pData['id'] != -1) {
         $lIdAchat = new IdAchatVO();
         $lIdAchat->setIdCompte($pData['idCompte']);
         $lIdAchat->setIdCommande($pData['id']);
         $lAchatService = new AchatService();
         $lAchat = $lAchatService->getAll($lIdAchat);
         if (isset($lAchat[0]) && is_object($lAchat[0]) && !is_null($lAchat[0]->getId()->getIdCompte())) {
             $lVr->setValid(false);
             $lVr->getLog()->setValid(false);
             $lErreur = new VRerreur();
             $lErreur->setCode(MessagesErreurs::ERR_263_CODE);
             $lErreur->setMessage(MessagesErreurs::ERR_263_MSG);
             $lVr->getLog()->addErreur($lErreur);
         }
     }
     return $lVr;
 }