/** * @name getDetail($pParam) * @return AchatAdherentResponse * @desc Retourne les détails des achats du marché */ public function getDetail($pParam) { $lVr = AfficheAchatAdherentValid::validGetAchat($pParam); if ($lVr->getValid()) { $lResponse = new AchatAdherentResponse(); // Récupère les achats $lAchatService = new AchatService(); $lAchat = $lAchatService->get($pParam["idAchat"]); $lResponse->setAchats($lAchat); return $lResponse; } return $lVr; }
/** * @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; }