/** * @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 getListeAchat($pParam) * @return ListeAchatResponse * @desc Retourne la liste des Achats. */ public function getListeAchat($pParam) { $lVr = AchatValid::validRechercheListeAchat($pParam); if ($lVr->getValid()) { $lDateDebut = NULL; if (!empty($pParam['dateDebut'])) { $lDateDebut = $pParam['dateDebut']; } $lDateFin = NULL; if (!empty($pParam['dateFin'])) { $lDateFin = $pParam['dateFin']; } $lIdMarche = NULL; if (!empty($pParam['idMarche'])) { $lIdMarche = $pParam['idMarche']; } $lListeAchatResponse = new ListeAchatResponse(); $lAchatService = new AchatService(); $lListeAchatResponse->setListeAchat($lAchatService->rechercheListeAchat($lDateDebut, $lDateFin, $lIdMarche)); return $lListeAchatResponse; } return $lVr; }
/** * @name getListeAchatEtReservationExport($pParam) * @return array() * @desc Retourne la liste des achats et réservations pour une commande et la liste de produits demandés */ private function getListeAchatEtReservationExport($pParam) { $lIdProduits = $pParam['id_produits']; $lAchatService = new AchatService(); $lAchatsEtReservations = $lAchatService->getAchatEtReservationProduit($lIdProduits); // Mise en forme des données par produit $lTableauAR = array(); $lQuantiteAR = array(); foreach ($lAchatsEtReservations as $lReservation) { $lLigne = array(); $lLigne['compte'] = $lReservation->getCptLabel(); $lLigne['prenom'] = $lReservation->getAdhPrenom(); $lLigne['nom'] = $lReservation->getAdhNom(); $lLigne['telephonePrincipal'] = $lReservation->getAdhTelephonePrincipal(); if (isset($lTableauAR[$lReservation->getCptLabel()])) { if (!is_null($lReservation->getStoQuantiteReservation())) { $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['reservation'] = $lReservation->getStoQuantiteReservation() * -1; } if (!is_null($lReservation->getStoQuantiteAchat())) { $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['qteAchat'] = $lReservation->getStoQuantiteAchat() * -1; } if (!is_null($lReservation->getDopeMontantAchat())) { $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['prixAchat'] = $lReservation->getDopeMontantAchat() * -1; } if (!is_null($lReservation->getStoQuantiteSolidaire())) { $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['qteSolidaire'] = $lReservation->getStoQuantiteSolidaire() * -1; } if (!is_null($lReservation->getDopeMontantSolidaire())) { $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['prixSolidaire'] = $lReservation->getDopeMontantSolidaire() * -1; } $lTableauAR[$lLigne['compte']][$lReservation->getProId()]['unite'] = $lReservation->getProUniteMesure(); } else { foreach ($lIdProduits as $lIdProduit) { $lLigne[$lIdProduit] = array(); $lLigne[$lIdProduit]['reservation'] = ''; $lLigne[$lIdProduit]['qteAchat'] = ''; $lLigne[$lIdProduit]['prixAchat'] = ''; $lLigne[$lIdProduit]['qteSolidaire'] = ''; $lLigne[$lIdProduit]['prixSolidaire'] = ''; $lLigne[$lIdProduit]['unite'] = ''; if ($lReservation->getProId() == $lIdProduit) { if (!is_null($lReservation->getStoQuantiteReservation())) { $lLigne[$lIdProduit]['reservation'] = $lReservation->getStoQuantiteReservation() * -1; } if (!is_null($lReservation->getStoQuantiteAchat())) { $lLigne[$lIdProduit]['qteAchat'] = $lReservation->getStoQuantiteAchat() * -1; } if (!is_null($lReservation->getDopeMontantAchat())) { $lLigne[$lIdProduit]['prixAchat'] = $lReservation->getDopeMontantAchat() * -1; } if (!is_null($lReservation->getStoQuantiteSolidaire())) { $lLigne[$lIdProduit]['qteSolidaire'] = $lReservation->getStoQuantiteSolidaire() * -1; } if (!is_null($lReservation->getDopeMontantSolidaire())) { $lLigne[$lIdProduit]['prixSolidaire'] = $lReservation->getDopeMontantSolidaire() * -1; } $lLigne[$lIdProduit]['unite'] = $lReservation->getProUniteMesure(); } } $lTableauAR[$lLigne['compte']] = $lLigne; } // Calcul du total par produit if (isset($lQuantiteAR[$lReservation->getProId()])) { if (!is_null($lReservation->getStoQuantiteReservation())) { $lQuantiteAR[$lReservation->getProId()]['reservation'] += $lReservation->getStoQuantiteReservation() * -1; } if (!is_null($lReservation->getStoQuantiteAchat())) { $lQuantiteAR[$lReservation->getProId()]['qteAchat'] += $lReservation->getStoQuantiteAchat() * -1; } if (!is_null($lReservation->getDopeMontantAchat())) { $lQuantiteAR[$lReservation->getProId()]['prixAchat'] += $lReservation->getDopeMontantAchat() * -1; } if (!is_null($lReservation->getStoQuantiteSolidaire())) { $lQuantiteAR[$lReservation->getProId()]['qteSolidaire'] += $lReservation->getStoQuantiteSolidaire() * -1; } if (!is_null($lReservation->getDopeMontantSolidaire())) { $lQuantiteAR[$lReservation->getProId()]['prixSolidaire'] += $lReservation->getDopeMontantSolidaire() * -1; } } else { $lQuantiteAR[$lReservation->getProId()] = array(); $lQuantiteAR[$lReservation->getProId()]['reservation'] = ''; $lQuantiteAR[$lReservation->getProId()]['qteAchat'] = ''; $lQuantiteAR[$lReservation->getProId()]['prixAchat'] = ''; $lQuantiteAR[$lReservation->getProId()]['qteSolidaire'] = ''; $lQuantiteAR[$lReservation->getProId()]['prixSolidaire'] = ''; if (!is_null($lReservation->getStoQuantiteReservation())) { $lQuantiteAR[$lReservation->getProId()]['reservation'] = $lReservation->getStoQuantiteReservation() * -1; } if (!is_null($lReservation->getStoQuantiteAchat())) { $lQuantiteAR[$lReservation->getProId()]['qteAchat'] = $lReservation->getStoQuantiteAchat() * -1; } if (!is_null($lReservation->getDopeMontantAchat())) { $lQuantiteAR[$lReservation->getProId()]['prixAchat'] = $lReservation->getDopeMontantAchat() * -1; } if (!is_null($lReservation->getStoQuantiteSolidaire())) { $lQuantiteAR[$lReservation->getProId()]['qteSolidaire'] = $lReservation->getStoQuantiteSolidaire() * -1; } if (!is_null($lReservation->getDopeMontantSolidaire())) { $lQuantiteAR[$lReservation->getProId()]['prixSolidaire'] = $lReservation->getDopeMontantSolidaire() * -1; } } } return array('quantite' => $lQuantiteAR, 'detail' => $lTableauAR); }
/** * @name supprimerAchat($pParam) * @return AchatVR * @desc Supprime un achat */ public function supprimerAchat($pParam) { $lVr = AchatValid::validDelete($pParam); if ($lVr->getValid()) { $lAchatService = new AchatService(); $lAchatService->delete($pParam['id']); } return $lVr; }
/** * @name enregistrerAchat($pParam) * @return AchatVR * @desc Enregistre la commande d'un adhérent */ public function enregistrerAchat($pParam) { $lVr = MarcheValid::validEnregistrer($pParam); if ($lVr->getValid()) { $lAchatService = new AchatService(); $lIdAchat = $lAchatService->set(AchatToVO::convertFromArray($pParam)); return new AchatConfirmResponse($lIdAchat); } return $lVr; }
/** * @name supprimerAchat($pParam) * @return ListeReservationCommandeVR * @desc Met à jour une réservation */ public function supprimerAchat($pParam) { $lVr = AfficheAchatAdherentValid::validSupprimerAchat($pParam); if ($lVr->getValid()) { $lOperationService = new OperationService(); $lOperation = $lOperationService->get($pParam["idAchat"]); $lIdAchatVO = new IdAchatVO(); $lIdAchatVO->setIdCompte($lOperation->getIdCompte()); $lIdAchatVO->setIdCommande($lOperation->getIdCommande()); $lIdAchatVO->setIdAchat($lOperation->getId()); $lAchatService = new AchatService(); $lSupressionAchat = $lAchatService->delete($lIdAchatVO); } return $lVr; }
/** * @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; }