Commit 08414981 authored by lecluse's avatar lecluse
Browse files

#3930

v1.6.7
parent 276f4c99
......@@ -12,7 +12,7 @@ $settings = [
'app_infos' => [
'nom' => "OSE",
'desc' => "Organisation des Services d'Enseignement",
'version' => "1.6.6",
'version' => "1.6.7",
'date' => "18/11/2015",
'contact' => ['mail' => "Contactez votre composante.", /*'tel' => "01 02 03 04 05"*/],
'mentionsLegales' => "http://www.unicaen.fr/outils-portail-institutionnel/mentions-legales/",
......
......@@ -116,7 +116,7 @@ return [
],
'bjyauthorize' => [
'guards' => [
'Application\Guard\PrivilegeController' => [
Guard\PrivilegeController::class => [
[
'controller' => 'Application\Controller\Paiement',
'action' => ['demandeMiseEnPaiement'],
......@@ -152,12 +152,12 @@ return [
],
],
'resource_providers' => [
'BjyAuthorize\Provider\Resource\Config' => [
\BjyAuthorize\Provider\Resource\Config::class => [
'MiseEnPaiement' => [],
],
],
'rule_providers' => [
'Application\Provider\Rule\PrivilegeRuleProvider' => [
Provider\Rule\PrivilegeRuleProvider::class => [
'allow' => [
[
'privileges' => Privilege::MISE_EN_PAIEMENT_DEMANDE,
......@@ -170,31 +170,31 @@ return [
],
'service_manager' => [
'invokables' => [
'ApplicationServiceAPayer' => 'Application\Service\ServiceAPayer',
'ApplicationMiseEnPaiement' => 'Application\Service\MiseEnPaiement',
'ApplicationMiseEnPaiementIntervenantStructure' => 'Application\Service\MiseEnPaiementIntervenantStructure',
'ApplicationTypeHeures' => 'Application\Service\TypeHeures',
'ApplicationCentreCout' => 'Application\Service\CentreCout',
'ApplicationCentreCoutEp' => 'Application\Service\CentreCoutEp',
'MiseEnPaiementAssertion' => 'Application\Assertion\MiseEnPaiementAssertion',
'MiseEnPaiementExisteRule' => 'Application\Rule\Paiement\MiseEnPaiementExisteRule',
'ApplicationServiceAPayer' => Service\ServiceAPayer::class,
'ApplicationMiseEnPaiement' => Service\MiseEnPaiement::class,
'ApplicationMiseEnPaiementIntervenantStructure' => Service\MiseEnPaiementIntervenantStructure::class,
'ApplicationTypeHeures' => Service\TypeHeures::class,
'ApplicationCentreCout' => Service\CentreCout::class,
'ApplicationCentreCoutEp' => Service\CentreCoutEp::class,
'MiseEnPaiementAssertion' => Assertion\MiseEnPaiementAssertion::class,
'MiseEnPaiementExisteRule' => Rule\Paiement\MiseEnPaiementExisteRule::class,
],
],
'view_helpers' => [
'invokables' => [
'DemandeMiseEnPaiement' => 'Application\View\Helper\Paiement\DemandeMiseEnPaiementViewHelper',
'TypeHeures' => 'Application\View\Helper\Paiement\TypeHeuresViewHelper',
'DemandeMiseEnPaiement' => View\Helper\Paiement\DemandeMiseEnPaiementViewHelper::class,
'TypeHeures' => View\Helper\Paiement\TypeHeuresViewHelper::class,
],
],
'form_elements' => [
'invokables' => [
'PaiementMiseEnPaiementForm' => 'Application\Form\Paiement\MiseEnPaiementForm',
'PaiementMiseEnPaiementRechercheForm' => 'Application\Form\Paiement\MiseEnPaiementRechercheForm',
'PaiementMiseEnPaiementForm' => Form\Paiement\MiseEnPaiementForm::class,
'PaiementMiseEnPaiementRechercheForm' => Form\Paiement\MiseEnPaiementRechercheForm::class,
],
],
'controllers' => [
'invokables' => [
'Application\Controller\Paiement' => 'Application\Controller\PaiementController',
'Application\Controller\Paiement' => Controller\PaiementController::class,
],
],
];
\ No newline at end of file
......@@ -2,6 +2,22 @@
namespace Application\Controller;
use Application\Entity\Db\Service;
use Application\Entity\Db\ServiceReferentiel;
use Application\Entity\Db\Validation;
use Application\Entity\Db\VolumeHoraire;
use Application\Entity\Db\VolumeHoraireReferentiel;
use Application\Form\Paiement\Traits\MiseEnPaiementFormAwareTrait;
use Application\Form\Paiement\Traits\MiseEnPaiementRechercheFormAwareTrait;
use Application\Service\Traits\ContextAwareTrait;
use Application\Service\Traits\IntervenantAwareTrait;
use Application\Service\Traits\MiseEnPaiementAwareTrait;
use Application\Service\Traits\PeriodeAwareTrait;
use Application\Service\Traits\PersonnelAwareTrait;
use Application\Service\Traits\ServiceAPayerAwareTrait;
use Application\Service\Traits\ServiceAwareTrait;
use Application\Service\Traits\StructureAwareTrait;
use Application\Service\Traits\TypeIntervenantAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Json\Json;
use UnicaenApp\Exporter\Pdf;
......@@ -15,15 +31,17 @@ use Application\Entity\Db\Privilege;
*/
class PaiementController extends AbstractActionController
{
use \Application\Service\Traits\ContextAwareTrait,
\Application\Service\Traits\IntervenantAwareTrait,
\Application\Service\Traits\ServiceAwareTrait,
\Application\Service\Traits\StructureAwareTrait,
\Application\Service\Traits\PersonnelAwareTrait,
\Application\Service\Traits\PeriodeAwareTrait,
\Application\Service\Traits\MiseEnPaiementAwareTrait,
\Application\Service\Traits\ServiceAPayerAwareTrait,
\Application\Service\Traits\TypeIntervenantAwareTrait;
use ContextAwareTrait;
use IntervenantAwareTrait;
use ServiceAwareTrait;
use StructureAwareTrait;
use PersonnelAwareTrait;
use PeriodeAwareTrait;
use MiseEnPaiementAwareTrait;
use ServiceAPayerAwareTrait;
use TypeIntervenantAwareTrait;
use MiseEnPaiementFormAwareTrait;
use MiseEnPaiementRechercheFormAwareTrait;
......@@ -35,12 +53,12 @@ class PaiementController extends AbstractActionController
protected function initFilters()
{
$this->em()->getFilters()->enable('historique')->init([
'Application\Entity\Db\MiseEnPaiement',
'Application\Entity\Db\Service',
'Application\Entity\Db\VolumeHoraire',
'Application\Entity\Db\ServiceReferentiel',
'Application\Entity\Db\VolumeHoraireReferentiel',
'Application\Entity\Db\Validation',
MiseEnPaiement::class,
Service::class,
VolumeHoraire::class,
ServiceReferentiel::class,
VolumeHoraireReferentiel::class,
Validation::class,
]);
}
......@@ -94,7 +112,7 @@ class PaiementController extends AbstractActionController
$etat = $this->params()->fromRoute('etat');
$rechercheForm = $this->getFormMiseEnPaiementRecherche();
$rechercheForm = $this->getFormPaiementMiseEnPaiementRecherche();
$recherche = new MiseEnPaiementRecherche;
$recherche->setEtat($etat); // données à mettre en paiement uniquement
$rechercheForm->bind($recherche);
......@@ -324,23 +342,26 @@ class PaiementController extends AbstractActionController
{
$this->initFilters();
$title = 'Mise en paiement';
$structure = $this->context()->mandatory()->structureFromRoute();
$structure = $this->getEvent()->getParam('structure');
$intervenants = $this->params('intervenants');
$form = $this->getFormMiseEnPaiement();
$form = $this->getFormPaiementMiseEnPaiement();
$errors = [];
$request = $this->getRequest();
if ($request->isPost() && $this->isAllowed('privilege/' . Privilege::MISE_EN_PAIEMENT_MISE_EN_PAIEMENT)) {
$form->setData($request->getPost());
$form->isValid();
$periode = $form->get('periode')->getValue();
//$dateMiseEnPaiement = $form->get('date-mise-en-paiement')->getValue();
$periode = $this->getServicePeriode()->get($periode);
$periodeId = $form->get('periode')->getValue();
$periode = $this->getServicePeriode()->get($periodeId);
/* @var $periode \Application\Entity\Db\Periode */
$dateMiseEnPaiement = $periode->getDatePaiement($this->getServiceContext()->getAnnee()); // date forcée car plus de saisie possible!
//$dateMiseEnPaiement = \DateTime::createFromFormat('d/m/Y', $dateMiseEnPaiement);
$dateMiseEnPaiementValue = $form->get('date-mise-en-paiement')->getValue();
if ($dateMiseEnPaiementValue) {
$dateMiseEnPaiement = \DateTime::createFromFormat('d/m/Y', $dateMiseEnPaiementValue);
}else{
$dateMiseEnPaiement = $periode->getDatePaiement($this->getServiceContext()->getAnnee()); // à défaut
}
$intervenants = $this->getServiceIntervenant()->get(explode(',', $intervenants));
try {
......@@ -352,24 +373,4 @@ class PaiementController extends AbstractActionController
return compact('form', 'title', 'errors');
}
/**
* @return \Application\Form\Paiement\MiseEnPaiementForm
*/
protected function getFormMiseEnPaiement()
{
return $this->getServiceLocator()->get('FormElementManager')->get('PaiementMiseEnPaiementForm');
}
/**
* @return \Application\Form\Paiement\MiseEnPaiementRechercheForm
*/
protected function getFormMiseEnPaiementRecherche()
{
return $this->getServiceLocator()->get('FormElementManager')->get('PaiementMiseEnPaiementRechercheForm');
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ class Periode implements HistoriqueAwareInterface
use HistoriqueAwareTrait;
const SEMESTRE_1 = 'S1';
const SEMESTRE_2 = 'S2';
const PAIEMENT_TARDIF = 'PTD';
/**
* @var integer
......@@ -218,8 +219,12 @@ class Periode implements HistoriqueAwareInterface
*/
public function getLibelleAnnuel(Annee $annee)
{
$datePaiement = $this->getDatePaiement($annee);
return $this->getLibelleLong().' '.$datePaiement->format('Y');
if ($this->getCode() === self::PAIEMENT_TARDIF){
return $this->getLibelleLong();
}else{
$datePaiement = $this->getDatePaiement($annee);
return $this->getLibelleLong().' '.$datePaiement->format('Y');
}
}
......
......@@ -2,9 +2,9 @@
namespace Application\Form\Paiement;
use Application\Service\Traits\ContextAwareTrait;
use Application\Service\Traits\PeriodeAwareTrait;
use Zend\Form\Form;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
......@@ -16,28 +16,11 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait;
*/
class MiseEnPaiementForm extends Form implements InputFilterProviderInterface, ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait,
\Application\Service\Traits\ContextAwareTrait
;
use ServiceLocatorAwareTrait;
use ContextAwareTrait;
use PeriodeAwareTrait;
/**
*
* @var string
*/
private $id;
/**
* Retourne un identifiant unique de formulaire.
* Une fois ce dernier initialisé, il ne change plus pour l'instance en cours
*
* @return string
*/
public function getId()
{
if (null === $this->id) $this->id = uniqid();
return $this->id;
}
/**
*
......@@ -49,50 +32,52 @@ class MiseEnPaiementForm extends Form implements InputFilterProviderInterface, S
$annee = $this->getServiceContext()->getAnnee();
$periodes = $this->getServicePeriode()->getList( $this->getServicePeriode()->finderByPaiement(true) );
$periodes = $this->getServicePeriode()->getList($this->getServicePeriode()->finderByPaiement(true));
$datesMiseEnPaiement = [];
foreach( $periodes as $periode ){
$datesMiseEnPaiement[$periode->getId()] = $periode->getDatePaiement( $annee )->format('d/m/Y');
foreach ($periodes as $periode) {
$datesMiseEnPaiement[$periode->getId()] = $periode->getDatePaiement($annee)->format('d/m/Y');
}
$this ->setAttribute('method', 'post')
->setAttribute('class', 'paiement-mise-en-paiement-form')
->setAttribute('id', $this->getId())
->setAttribute('data-dates-mise-en-paiement', json_encode($datesMiseEnPaiement));
$this->setAttribute('method', 'post')
->setAttribute('class', 'paiement-mise-en-paiement-form')
->setAttribute('data-dates-mise-en-paiement', json_encode($datesMiseEnPaiement))
->setAttribute('data-periode-paiement-tardif-id', $this->getServicePeriode()->getPaiementTardif()->getId());
$defaultPeriode = $this->getServicePeriode()->getPeriodePaiement();
$this->add([
'type' => 'Select',
'name' => 'periode',
'options' => [
'label' => 'Période',
'value_options' => \UnicaenApp\Util::collectionAsOptions($periodes,false,function($p) use ($annee) { return $p->getLibelleAnnuel($annee); }),
'type' => 'Select',
'name' => 'periode',
'options' => [
'label' => 'Période',
'value_options' => \UnicaenApp\Util::collectionAsOptions($periodes, false, function ($p) use ($annee) {
return $p->getLibelleAnnuel($annee);
}),
],
'attributes' => [
'value' => $defaultPeriode ? $defaultPeriode->getId() : null,
],
]);
$defaultDateMiseEnPaiement = $defaultPeriode ? $defaultPeriode->getDatePaiement( $annee ) : null;
$defaultDateMiseEnPaiement = $defaultPeriode ? $defaultPeriode->getDatePaiement($annee) : null;
$this->add([
'type' => 'UnicaenApp\Form\Element\Date',
'name' => 'date-mise-en-paiement',
'options' => [
'label' => 'Date de mise en paiement',
'format' => 'd/m/Y'
'type' => 'UnicaenApp\Form\Element\Date',
'name' => 'date-mise-en-paiement',
'options' => [
'label' => 'Date de mise en paiement',
'format' => 'd/m/Y',
],
'attributes' => [
'step' => '1',
'step' => '1',
'disabled' => 'true',
'value' => $defaultPeriode ? $defaultDateMiseEnPaiement->format('d/m/Y') : null,
]
'value' => $defaultPeriode ? $defaultDateMiseEnPaiement->format('d/m/Y') : null,
],
]);
$this->add([
'name' => 'submit',
'type' => 'Submit',
'name' => 'submit',
'type' => 'Submit',
'attributes' => [
'value' => 'Effectuer la mise en paiement',
'class' => 'btn btn-primary',
......@@ -102,6 +87,8 @@ class MiseEnPaiementForm extends Form implements InputFilterProviderInterface, S
$this->setAttribute('action', $url(null, [], [], true));
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
......@@ -111,11 +98,11 @@ class MiseEnPaiementForm extends Form implements InputFilterProviderInterface, S
public function getInputFilterSpecification()
{
return [
'periode' => [
'required' => true
'periode' => [
'required' => true,
],
'date-mise-en-paiement' => [
'required' => false
'required' => false,
],
];
}
......
......@@ -3,6 +3,7 @@
namespace Application\Service;
use Application\Entity\Db\Structure as StructureEntity;
use Application\Entity\Db\Periode as PeriodeEntity;
use Doctrine\ORM\QueryBuilder;
......@@ -17,13 +18,12 @@ class Periode extends AbstractEntityService
/**
* Périodes d'enseignement
*
* @var \Application\Entity\Db\Periode[]
* @var PeriodeEntity[]
*/
protected $enseignement;
/**
* retourne la classe des entités
*
......@@ -32,52 +32,64 @@ class Periode extends AbstractEntityService
*/
public function getEntityClass()
{
return 'Application\Entity\Db\Periode';
return PeriodeEntity::class;
}
/**
* Retourne l'alias d'entité courante
*
* @return string
*/
public function getAlias(){
public function getAlias()
{
return 'per';
}
/**
*
* @param \DateTime $date
*
* @return PeriodeEntity
*/
public function getPeriodePaiement( \DateTime $date=null )
public function getPeriodePaiement(\DateTime $date = null)
{
$anneeDateDebut = $this->getServiceContext()->getAnnee()->getDateDebut();
$aY = (int)$anneeDateDebut->format('Y');
$aM = (int)$anneeDateDebut->format('n');
$aY = (int)$anneeDateDebut->format('Y');
$aM = (int)$anneeDateDebut->format('n');
if (empty($date)) $date = new \DateTime;
$dY = (int)$date->format('Y');
$dM = (int)$date->format('n');
$ecartMoisPaiement = ($dY-$aY)*12 + $dM - $aM;
$ecartMoisPaiement = ($dY - $aY) * 12 + $dM - $aM;
return $this->getRepo()->findOneBy(['paiement' => true, 'ecartMoisPaiement' => $ecartMoisPaiement]);
}
/**
* Retourne la liste des périodes d'enseignement
*
* @param QueryBuilder|null $queryBuilder
*
* @return QueryBuilder
*/
public function finderByEnseignement( QueryBuilder $qb=null, $alias=null )
public function finderByEnseignement(QueryBuilder $qb = null, $alias = null)
{
list($qb,$alias) = $this->initQuery($qb, $alias);
list($qb, $alias) = $this->initQuery($qb, $alias);
$qb->andWhere("$alias.enseignement = 1");
return $qb;
}
public function finderByMiseEnPaiement(StructureEntity $structure=null, QueryBuilder $qb=null, $alias=null)
public function finderByMiseEnPaiement(StructureEntity $structure = null, QueryBuilder $qb = null, $alias = null)
{
$serviceMIS = $this->getServiceLocator()->get('applicationMiseEnPaiementIntervenantStructure');
/* @var $serviceMIS MiseEnPaiementIntervenantStructure */
......@@ -88,64 +100,86 @@ class Periode extends AbstractEntityService
$serviceIntervenant = $this->getServiceLocator()->get('applicationIntervenant');
/* @var $serviceIntervenant Intervenant */
list($qb,$alias) = $this->initQuery($qb, $alias);
list($qb, $alias) = $this->initQuery($qb, $alias);
$this ->join( $serviceMIS , $qb, 'miseEnPaiementIntervenantStructure', false, $alias );
$serviceMIS ->join( $serviceMiseEnPaiement , $qb, 'miseEnPaiement' );
$serviceMIS ->join( $serviceIntervenant , $qb, 'intervenant', false );
$this->join($serviceMIS, $qb, 'miseEnPaiementIntervenantStructure', false, $alias);
$serviceMIS->join($serviceMiseEnPaiement, $qb, 'miseEnPaiement');
$serviceMIS->join($serviceIntervenant, $qb, 'intervenant', false);
if ($structure){
$serviceMIS->finderByStructure( $structure, $qb );
if ($structure) {
$serviceMIS->finderByStructure($structure, $qb);
}
$serviceIntervenant->finderByAnnee( $this->getServiceContext()->getAnnee(), $qb );
$serviceIntervenant->finderByAnnee($this->getServiceContext()->getAnnee(), $qb);
return $qb;
}
/**
* Retourne la liste des périodes
*
* @param QueryBuilder|null $queryBuilder
* @return Application\Entity\Db\Periode[]
* @param QueryBuilder|null $qb
* @param string|null $alias
*/
public function getList( QueryBuilder $qb=null, $alias=null )
public function orderBy(QueryBuilder $qb = null, $alias = null)
{
list($qb,$alias) = $this->initQuery($qb, $alias);
list($qb, $alias) = $this->initQuery($qb, $alias);
$qb->orderBy("$alias.ordre");
return parent::getList($qb, $alias);
return $qb;
}
/**
* Retourne la liste dezs périodes d'enseignement
* Retourne la liste des périodes d'enseignement
*
* @return \Application\Entity\Db\Periode[]
* @return PeriodeEntity[]
*/
public function getEnseignement()
{
if (! $this->enseignement){
$this->enseignement = $this->getList( $this->finderByEnseignement() );
if (!$this->enseignement) {
$this->enseignement = $this->getList($this->finderByEnseignement());
}
return $this->enseignement;
}
/**
* Retourne le semestre 1
*
* @return \Application\Entity\Db\Periode
* @return PeriodeEntity
*/
public function getSemestre1()
{
return $this->getRepo()->findOneBy(['code' => PeriodeEntity::SEMESTRE_1]);
}
/**
* Retourne le semestre 2
*
* @return \Application\Entity\Db\Periode
* @return PeriodeEntity
*/
public function getSemestre2()
{
return $this->getRepo()->findOneBy(['code' => PeriodeEntity::SEMESTRE_2]);
}
/**
* Retourne le paiement tardif
*
* @return PeriodeEntity
*/
public function getPaiementTardif()
{
return $this->getRepo()->findOneBy(['code' => PeriodeEntity::PAIEMENT_TARDIF]);
}
}
\ No newline at end of file
......@@ -13,10 +13,4 @@ echo $this->formRow($form->get('submit'));
echo $this->form()->closeTag();
echo $this->formErrors( $form );
?><script type="text/javascript">
$(function() {
PaiementMiseEnPaiementForm.get("<?php echo $form->getId(); ?>").init();
});