Commit 56474286 authored by Johnny Leveneur's avatar Johnny Leveneur
Browse files

fait

parent b0d38978
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -305,7 +305,11 @@ class InscriptionController extends AbstractActionController
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost();
            if ($data["reponse"] === "oui") {
//                $this->getInscriptionService()->
                if ($this->getInscriptionService()->deleteInscriptionPlace($inscription, $inscriptionPlace)) {
                    $this->flashMessenger()->addSuccessMessage("La place a été supprimé.");
                } else {
                    $this->flashMessenger()->addWarningMessage("La place n'a pas été supprimé.");
                }
            }
            exit();
        }
+16 −0
Original line number Diff line number Diff line
@@ -184,6 +184,22 @@ class InscriptionService
        return $place;
    }

    public function deleteInscriptionPlace(Inscription $inscription, InscriptionPlace $inscriptionPlace): bool
    {
        if($inscriptionPlace === null) return false ;

        $places = $inscription->getPlaces();

        if($places->removeElement($inscriptionPlace))
        {
            $inscription->setNombrePlacesDemandees($inscription->getNombrePlacesDemandees() - 1);
            $this->update($inscription);
            return true;
        }

        return false ;
    }

    /**
     * Get entities as options for a select input
     *