/** * @name set($pAchat) * @param AchatVO * @return integer * @desc Ajoute ou modifie une réservation */ public function set($pAchat) { $lAchatValid = new NAMESPACE_CLASSE\NAMESPACE_VALIDATEUR\MOD_SERVICE\AchatValid(); if ($lAchatValid->input($pAchat)) { if ($lAchatValid->insert($pAchat)) { $lIdRequete = 0; $lOperationAchat = $pAchat->getOperationAchat()->getMontant(); $lOperationAchatSolidaire = $pAchat->getOperationAchatSolidaire()->getMontant(); $lOperationRechargement = $pAchat->getRechargement()->getMontant(); if (!is_null($lOperationAchat) && !empty($lOperationAchat)) { $lOperationAchatChampComp = $pAchat->getOperationAchat()->getChampComplementaire(); $lIdRequete = $lOperationAchatChampComp[15]->getValeur(); } if (!is_null($lOperationAchatSolidaire) && !empty($lOperationAchatSolidaire)) { $lOperationAchatSolidaireChampComp = $pAchat->getOperationAchatSolidaire()->getChampComplementaire(); $lIdRequete = $lOperationAchatSolidaireChampComp[15]->getValeur(); } if (!is_null($lOperationRechargement) && !empty($lOperationRechargement)) { $lOperationRechargementChampComp = $pAchat->getRechargement()->getChampComplementaire(); $lIdRequete = $lOperationRechargementChampComp[15]->getValeur(); } $lOperationService = new OperationService(); $lOperations = $lOperationService->getByIdrequete($lIdRequete); $lIdOperation = $lOperations[0]->getId(); if (is_null($lIdOperation) && empty($lIdOperation)) { return $this->insert($pAchat); } else { // C'est un doublon il faut passer en maj $lAchatActuel = $this->select($lIdOperation); // Récupération des Id if (!is_null($lAchatActuel->getOperationAchat())) { $pAchat->getOperationAchat()->setId($lAchatActuel->getOperationAchat()->getId()); } if (!is_null($lAchatActuel->getOperationAchatSolidaire())) { $pAchat->getOperationAchatSolidaire()->setId($lAchatActuel->getOperationAchatSolidaire()->getId()); } if (!is_null($lAchatActuel->getRechargement())) { $pAchat->getRechargement()->setId($lAchatActuel->getRechargement()->getId()); } return $this->update($pAchat); } } else { if ($lAchatValid->update($pAchat)) { return $this->update($pAchat); } } } return false; }