Commit 66b541fa authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Plus de formulaire à l'intérieur de la saisie de nouveaux enseignements en calendaire

parent 01c539f3
......@@ -343,6 +343,7 @@ class ServiceController extends AbstractController
}
$service = $this->getServiceService();
$form = $this->getFormServiceSaisie();
$form->setTypeVolumeHoraire($typeVolumeHoraire);
$element = $this->context()->elementPedagogiqueFromPost('element');
$etablissement = $this->context()->etablissementFromPost();
......@@ -464,6 +465,7 @@ class ServiceController extends AbstractController
}
$service = $this->getServiceService();
$form = $this->getFormServiceSaisie();
$form->setTypeVolumeHoraire($typeVolumeHoraire);
$intervenant = $this->getServiceLocalContext()->getIntervenant();
......
......@@ -29,101 +29,106 @@ class VolumeHoraireController extends AbstractController
use WorkflowServiceAwareTrait;
use PlafondProcessusAwareTrait;
public function listeAction()
{
$this->em()->getFilters()->enable('historique')->init([
\Application\Entity\Db\VolumeHoraire::class
\Application\Entity\Db\VolumeHoraire::class,
]);
$service = $this->getEvent()->getParam('service');
/* @var $service Service */
if (! $service) throw new RuntimeException("Service non spécifié ou introuvable.");
/* @var $service Service */
if (!$service) throw new RuntimeException("Service non spécifié ou introuvable.");
$typeVolumeHoraire = $this->context()->typeVolumeHoraireFromQueryPost('type-volume-horaire');
$service->setTypeVolumeHoraire($typeVolumeHoraire);
$readOnly = 1 == (int)$this->params()->fromQuery('read-only', 0);
$readOnly = 1 == (int)$this->params()->fromQuery('read-only', 0);
$volumeHoraireListe = $service->getVolumeHoraireListe()->setTypeVolumehoraire($typeVolumeHoraire);
$semestriel = $this->getServiceContext()->isModaliteServicesSemestriel($typeVolumeHoraire);
$volumeHoraireListe = $service->getVolumeHoraireListe()->setTypeVolumehoraire( $typeVolumeHoraire );
$semestriel = $this->getServiceContext()->isModaliteServicesSemestriel();
return compact('volumeHoraireListe', 'readOnly', 'semestriel');
}
public function saisieAction()
{
$this->em()->getFilters()->enable('historique')->init([
\Application\Entity\Db\VolumeHoraire::class,
\Application\Entity\Db\MotifNonPaiement::class
\Application\Entity\Db\MotifNonPaiement::class,
]);
$service = $this->context()->serviceFromRoute();
$typeVolumehoraire = $this->context()->typeVolumeHoraireFromQueryPost('type-volume-horaire');
$periode = $this->context()->periodeFromQueryPost();
$typeIntervention = $this->context()->typeInterventionFromQueryPost('type-intervention');
$errors = [];
$service = $this->context()->serviceFromRoute();
$typeVolumehoraire = $this->context()->typeVolumeHoraireFromQueryPost('type-volume-horaire');
$periode = $this->context()->periodeFromQueryPost();
$typeIntervention = $this->context()->typeInterventionFromQueryPost('type-intervention');
$errors = [];
$canViewMNP = $this->isAllowed($service->getIntervenant(), Privileges::MOTIF_NON_PAIEMENT_VISUALISATION);
$canEditMNP = $this->isAllowed($service->getIntervenant(), Privileges::MOTIF_NON_PAIEMENT_EDITION);
if ($canViewMNP){
if ($canViewMNP) {
$tousMotifsNonPaiement = $this->params()->fromQuery('tous-motifs-non-paiement');
if ($tousMotifsNonPaiement == '1'){
$motifNonPaiement = false;
}else{
$motifNonPaiement = $this->context()->motifNonPaiementFromQueryPost('motif-non-paiement');
if ($tousMotifsNonPaiement == '1') {
$motifNonPaiement = false;
} else {
$motifNonPaiement = $this->context()->motifNonPaiementFromQueryPost('motif-non-paiement');
}
$ancienMotifNonPaiement = $this->context()->motifNonPaiementFromQueryPost('ancien-motif-non-paiement', $motifNonPaiement);
}else{
$motifNonPaiement = false;
} else {
$motifNonPaiement = false;
$ancienMotifNonPaiement = false;
}
/* @var $service \Application\Entity\Db\Service */
$service->setTypeVolumeHoraire( $typeVolumehoraire );
$service->setTypeVolumeHoraire($typeVolumehoraire);
$volumeHoraireList = $service->getVolumeHoraireListe($periode, $typeIntervention);
$volumeHoraireList->setMotifNonPaiement($motifNonPaiement);
$form = $this->getFormVolumeHoraireSaisie();
$form->setViewMNP( $canViewMNP );
$form->setEditMNP( $canEditMNP );
$form->setViewMNP($canViewMNP);
$form->setEditMNP($canEditMNP);
$request = $this->getRequest();
if ($request->isPost()){
if ($request->isPost()) {
$heures = StringFromFloat::run($request->getPost()['heures']);
try{
try {
$volumeHoraireList->setHeures($heures, $motifNonPaiement, $ancienMotifNonPaiement);
}catch(\Exception $e){
} catch (\Exception $e) {
$errors[] = $e->getMessage();
}
}
$form->bind( $volumeHoraireList );
if ($request->isPost()){
if ($form->isValid()){
try{
$form->bind($volumeHoraireList);
if ($request->isPost()) {
if ($form->isValid()) {
try {
$this->getProcessusPlafond()->beginTransaction();
$this->getServiceService()->save($service);
$this->updateTableauxBord($service->getIntervenant());
$this->getProcessusPlafond()->endTransaction($service->getIntervenant(), $typeVolumehoraire);
}catch(\Exception $e){
$e = DbException::translate($e);
} catch (\Exception $e) {
$e = DbException::translate($e);
$errors[] = $e->getMessage();
}
}else{
} else {
$errors[] = 'La validation du formulaire a échoué. L\'enregistrement des données n\'a donc pas été fait.';
}
}
$terminal = $this->getRequest()->isXmlHttpRequest();
$terminal = $this->getRequest()->isXmlHttpRequest();
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel
->setTemplate('application/volume-horaire/saisie')
->setVariables(compact('form', 'errors', 'ancienMotifNonPaiement'));
->setTemplate('application/volume-horaire/saisie')
->setVariables(compact('form', 'errors', 'ancienMotifNonPaiement'));
if ($terminal) {
return $this->popoverInnerViewModel($viewModel, "Saisie d'heures d'enseignement", false);
}
return $viewModel;
}
......@@ -132,7 +137,7 @@ class VolumeHoraireController extends AbstractController
private function updateTableauxBord(Intervenant $intervenant)
{
$this->getServiceWorkflow()->calculerTableauxBord([
'formule','validation_enseignement','service','service_saisie','piece_jointe_fournie'
'formule', 'validation_enseignement', 'service', 'service_saisie', 'piece_jointe_fournie',
], $intervenant);
}
......
......@@ -4,6 +4,7 @@ namespace Application\Form\Service;
use Application\Entity\Db\Periode;
use Application\Entity\Db\Service;
use Application\Entity\Db\Traits\TypeVolumeHoraireAwareTrait;
use Application\Form\AbstractForm;
use Application\Form\Service\Traits\SaisieFieldsetAwareTrait;
use Application\Form\VolumeHoraire\Traits\SaisieMultipleFieldsetAwareTrait;
......@@ -20,6 +21,7 @@ use Zend\Stdlib\Hydrator\HydratorInterface;
*/
class Saisie extends AbstractForm
{
use TypeVolumeHoraireAwareTrait;
use PeriodeServiceAwareTrait;
use SaisieFieldsetAwareTrait;
use SaisieMultipleFieldsetAwareTrait;
......
......@@ -187,7 +187,7 @@ class ContextService extends AbstractService
*/
public function isModaliteServicesSemestriel($typeVolumeHoraire = TypeVolumeHoraire::CODE_PREVU): bool
{
return $this->getModaliteServices() == Parametre::SERVICES_MODALITE_SEMESTRIEL;
return $this->getModaliteServices($typeVolumeHoraire) == Parametre::SERVICES_MODALITE_SEMESTRIEL;
}
......
......@@ -296,7 +296,7 @@ class Liste extends AbstractViewHelper
{
$ligneView = $this->getView()->serviceLigne($this, $service);
if ($this->getServiceContext()->isModaliteServicesSemestriel()){
if ($this->getServiceContext()->isModaliteServicesSemestriel($this->getTypeVolumeHoraire())){
$volumeHoraireListe = $this->getView()->volumeHoraireListe($service->getVolumeHoraireListe());
/* @var $volumeHoraireListe \Application\View\Helper\VolumeHoraire\Liste */
}else{
......
......@@ -2,7 +2,6 @@
namespace Application\View\Helper\Service;
use Application\Entity\Db\Parametre;
use Application\Entity\Db\Periode;
use Application\Entity\Db\Service;
use Application\Entity\Db\TypeVolumeHoraire;
......@@ -130,7 +129,7 @@ class SaisieForm extends AbstractViewHelper
public function renderVolumesHoraires()
{
if (!$this->getServiceContext()->isModaliteServicesSemestriel()){
if (!$this->getServiceContext()->isModaliteServicesSemestriel($this->form->getTypeVolumeHoraire())){
return null;
}
$res = '';
......
<?php
/**
* @var $this \Application\View\Renderer\PhpRenderer
*/
echo $this->serviceSaisieForm( $form )->renderVolumesHoraires();
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment