/** * @name getListeAchatEtReservation($pParam) * @param Id du marché * @desc Retourne la liste des adhérents un flag achat et réservation sur le marché */ public function getListeAchatEtReservation($pParam) { $lVr = EditerCommandeValid::validGetInfoCommande($pParam); if ($lVr->getValid()) { $lResponse = new ListeAchatEtReservationResponse(); // Les achats adhérents $lResponse->setListeAchatEtReservation(AdherentManager::selectListeAdherentAchatMarche($pParam["id_marche"])); // Les achats du compte invité $lAchatService = new AchatService(); $lResponse->setListeAchatInvite($lAchatService->selectOperationAchat(-3, $pParam["id_marche"])); return $lResponse; } return $lVr; }
/** * @name getInfoAchatMarche($pParam) * @return InfoAchatCommandeResponse * @desc Retourne les infos de réservation d'un adhérent */ public function getInfoAchatMarche($pParam) { $lVr = MarcheValid::validGetInfoAchatMarche($pParam); if ($lVr->getValid()) { $lResponse = new InfoAchatCommandeResponse(); if ($pParam["id_adherent"] != 0) { // Si ce n'est pas le compte invité $lAdherent = AdherentViewManager::select($pParam["id_adherent"]); $lResponse->setAdherent($lAdherent); } $lStockService = new StockService(); $lStockProduitsDisponible = $lStockService->getProduitsDisponible(); // Stock de produit disponible $lStock = array(); $lProduitsMarche = array(); $lProduitsReservation = array(); $lProduitsAchat = array(); if ($pParam["id_commande"] != -1) { // Si ce n'est pas la caisse permanente $lMarcheService = new MarcheService(); $lMarche = $lMarcheService->get($pParam["id_commande"]); $lProduitsMarche = $lMarche->getProduits(); $lResponse->setMarche($lMarche); // Les informations du marché if ($pParam["id_adherent"] != 0) { // Si ce n'est pas le compte invité $lReservationService = new ReservationService(); $lIdReservation = new IdReservationVO(); $lIdReservation->setIdCompte($lAdherent->getAdhIdCompte()); $lIdReservation->setIdCommande($pParam["id_commande"]); // Récupère les réservations actives $lProduitsReservation = $lReservationService->get($lIdReservation, true)->getDetailReservation(); $lResponse->setReservation($lProduitsReservation); // La réservation $lAchatService = new AchatService(); $lOperationsAchat = $lAchatService->selectOperationAchat($lAdherent->getAdhIdCompte(), $pParam["id_commande"]); $lAchat = new AchatVO(); if (!is_null($lOperationsAchat[0]->getId())) { $lAchat = $lAchatService->get($lOperationsAchat[0]->getId()); $lProduitsAchat = $lAchat->getProduits(); } else { $lOperationService = new OperationService(); $lOperationsRechargement = $lOperationService->getOperationRechargementSurMarche($lAdherent->getAdhIdCompte(), $pParam["id_commande"]); if (!is_null($lOperationsRechargement[0]->getId())) { $lAchat = $lAchatService->get($lOperationsRechargement[0]->getId()); } } $lResponse->setAchats($lAchat); // L'achat } } if ($pParam["id_adherent"] != 0) { // Si ce n'est pas le compte invité $lAdhesionService = new AdhesionService(); $lResponse->setNbAdhesionEnCours($lAdhesionService->getNbAdhesionEnCoursSurAdherent($pParam["id_adherent"])); } // Fusion des stocks $lLotsProduits = array(); foreach ($lStockProduitsDisponible as $lProduitStock) { if (!is_null($lProduitStock->getId())) { $lAjout = true; foreach ($lProduitsMarche as $lProduitMarche) { if ($lProduitStock->getIdNom() == $lProduitMarche->getIdNom() && $lProduitStock->getUnite() == $lProduitMarche->getUnite()) { $lAjout = false; } } if ($lAjout) { if (!isset($lStock[$lProduitStock->getCproNom()])) { $lStock[$lProduitStock->getCproNom()] = array("cproId" => $lProduitStock->getIdCategorie(), "cproNom" => $lProduitStock->getCproNom(), "produits" => array()); } $lUnite = $lProduitStock->getUnite(); $lStock[$lProduitStock->getCproNom()]["produits"][$lProduitStock->getNom() . $lProduitStock->getUnite()] = new ProduitDetailAchatAfficheVO($lProduitStock->getIdNom(), null, null, null, null, null, null, null, null, null, $lUnite, null, $lUnite, null, null, $lProduitStock->getIdCategorie(), $lProduitStock->getCproNom(), null, $lProduitStock->getNom()); $lLotsProduits[$lProduitStock->getIdNom() . $lProduitStock->getUnite()] = array("nom" => $lProduitStock->getNom(), "type" => "modele", "lots" => $lProduitStock->getLots()); } } } foreach ($lProduitsMarche as $lProduitMarche) { if (!isset($lStock[$lProduitMarche->getCproNom()])) { $lStock[$lProduitMarche->getCproNom()] = array("cproId" => $lProduitMarche->getIdCategorie(), "cproNom" => $lProduitMarche->getCproNom(), "produits" => array()); } $lUnite = !is_null($lProduitMarche->getUnite()) ? $lProduitMarche->getUnite() : $lProduitMarche->getUniteSolidaire(); $lMontant = NULL; $lQuantite = NULL; $lIdDetailCommande = NULL; // Ajout des réservations if (empty($lProduitsAchat)) { foreach ($lProduitsReservation as $lProduitReservation) { if ($lProduitReservation->getIdNomProduit() == $lProduitMarche->getIdNom() && $lProduitReservation->getUnite() == $lProduitMarche->getUnite()) { $lQuantite = $lProduitReservation->getQuantite(); $lMontant = $lProduitReservation->getMontant(); $lIdDetailCommande = $lProduitReservation->getIdDetailCommande(); } } } $lStock[$lProduitMarche->getCproNom()]["produits"][$lProduitMarche->getNom() . $lProduitMarche->getUnite()] = new ProduitDetailAchatAfficheVO($lProduitMarche->getIdNom(), null, null, null, null, $lIdDetailCommande, null, null, null, $lQuantite, $lUnite, null, $lUnite, $lMontant, null, $lProduitMarche->getIdCategorie(), $lProduitMarche->getCproNom(), null, $lProduitMarche->getNom()); $lLotsProduits[$lProduitMarche->getIdNom() . $lProduitMarche->getUnite()] = array("nom" => $lProduitMarche->getNom(), "type" => "marche", "lots" => $lProduitMarche->getLots()); } foreach ($lProduitsAchat as $lProduitAchat) { $lUnite = !is_null($lProduitAchat->getUnite()) ? $lProduitAchat->getUnite() : $lProduitAchat->getUniteSolidaire(); if (!is_null($lUnite)) { if (isset($lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite])) { $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdStock($lProduitAchat->getIdStock()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdStockSolidaire($lProduitAchat->getIdStockSolidaire()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdDetailCommande($lProduitAchat->getIdDetailCommande()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdModeleLot($lProduitAchat->getIdModeleLot()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdDetailCommandeSolidaire($lProduitAchat->getIdDetailCommandeSolidaire()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdModeleLotSolidaire($lProduitAchat->getIdModeleLotSolidaire()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setQuantite($lProduitAchat->getQuantite()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setQuantiteSolidaire($lProduitAchat->getQuantiteSolidaire()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setMontant($lProduitAchat->getMontant()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setMontantSolidaire($lProduitAchat->getMontantSolidaire()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdDetailOperation($lProduitAchat->getIdDetailOperation()); $lStock[$lProduitAchat->getCproNom()][$lProduitAchat->getNproNom()][$lUnite]->setIdDetailOperationSolidaire($lProduitAchat->getIdDetailOperationSolidaire()); } else { if (!isset($lStock[$lProduitAchat->getCproNom()])) { $lStock[$lProduitAchat->getCproNom()] = array("cproId" => $lProduitAchat->getCproId(), "cproNom" => $lProduitAchat->getCproNom(), "produits" => array()); } $lProduitAchat->setUnite($lUnite); $lProduitAchat->setUniteSolidaire($lUnite); $lStock[$lProduitAchat->getCproNom()]["produits"][$lProduitAchat->getNproNom() . $lUnite] = $lProduitAchat; // Ajout des lots $lModelesLot = ModeleLotManager::selectByIdNomProduit($lProduitAchat->getIdNomProduit()); // Récupère même les lots supprimés car il y a peut être eu un achat sur ce lot précédemment $lLots = array(); foreach ($lModelesLot as $lModeleLot) { $lLot = new DetailMarcheVO(); $lLot->setId($lModeleLot->getId()); $lLot->setTaille($lModeleLot->getQuantite()); $lLot->setPrix($lModeleLot->getPrix()); $lLots[$lModeleLot->getId()] = $lLot; } $lLotsProduits[$lProduitAchat->getIdNomProduit() . $lUnite] = array("nom" => $lProduitAchat->getNproNom(), "type" => "modele", "lots" => $lLots); } } } ksort($lStock); $lResponse->setStock($lStock); // Stock de produit disponible $lResponse->setLots($lLotsProduits); // Lots des produits $lBanqueService = new BanqueService(); $lTypePaiementService = new TypePaiementService(); $lResponse->setTypePaiement($lTypePaiementService->selectVisible()); // Type de paiment $lResponse->setBanques($lBanqueService->getAllActif()); // Liste des banques $lResponse->setIdRequete(uniqid()); return $lResponse; } return $lVr; }