/** * @name detailProduitMarche($pParam) * @param IdProduit * @desc Retourne le détail d'un produit */ public function detailProduitMarche($pParam) { $lVr = ProduitMarcheValid::validDelete($pParam); if ($lVr->getValid()) { $lMarcheService = new MarcheService(); $lReservationService = new ReservationService(); $lProduit = $lMarcheService->selectProduit($pParam["id"]); $lId = $lProduit->getIdNom(); $lModelesLot = ModeleLotViewManager::selectByIdNomProduit($lId); $lResponse = new DetailProduitResponse(); $lResponse->setModelesLot($lModelesLot); $lNvLots = array(); foreach ($lProduit->getLots() as $lLot) { $lReservation = $lReservationService->getReservationSurLot($lLot->getId()); $lNvLot = new DetailMarcheReservationVO(); $lNvLot->setId($lLot->getId()); $lNvLot->setTaille($lLot->getTaille()); $lNvLot->setPrix($lLot->getPrix()); if (!is_null($lReservation[0]->getStoId())) { $lNvLot->setReservation(true); } array_push($lNvLots, $lNvLot); } $lProduit->setLots($lNvLots); $lResponse->setProduit($lProduit); return $lResponse; } return $lVr; }
/** * @name supprimerProduit($pId) * @param integer * @desc Supprime un produit du marché */ public function supprimerProduit($pId) { $lProduit = ProduitManager::select($pId); // Suppression des lots $lLots = DetailCommandeManager::selectByIdProduit($pId); foreach ($lLots as $lLot) { $lLot->setEtat(1); DetailCommandeManager::update($lLot); } $lProduit->setEtat(1); ProduitManager::update($lProduit); // Modif des réservations $lReservationService = new ReservationService(); $lIdMarche = $lProduit->getIdCommande(); foreach ($lLots as $lLot) { // Chaque lot modifié $lListeDetailReservation = $lReservationService->getReservationSurLot($lLot->getId()); if (!is_null($lListeDetailReservation[0]->getDopeIdCompte())) { // Si il y a des réservations foreach ($lListeDetailReservation as $lDetailReservation) { // Chaque réservation de lot modifié $lIdReservationVO = new IdReservationVO(); $lIdReservationVO->setIdCompte($lDetailReservation->getDopeIdCompte()); $lIdReservationVO->setIdCommande($lIdMarche); $lReservationVO = $lReservationService->get($lIdReservationVO); $lNvDetailReservation = array(); foreach ($lReservationVO->getDetailReservation() as $lDetailReservationActuelle) { if ($lDetailReservationActuelle->getIdDetailCommande() != $lLot->getId()) { // Ne positionne que les autres produits array_push($lNvDetailReservation, $lDetailReservationActuelle); } } $lReservationVO->setDetailReservation($lNvDetailReservation); $lReservationService->set($lReservationVO); // Maj de la reservation } } } }