Skip to content
Snippets Groups Projects
Commit e93cb4c0 authored by lecluse's avatar lecluse
Browse files
Saisie de la mise ne paiement par la DRH
parent ae3e499e
No related branches found
No related tags found
No related merge requests found
Showing with 342 additions and 66 deletions
...@@ -17,24 +17,37 @@ return [ ...@@ -17,24 +17,37 @@ return [
], ],
], ],
'child_routes' => [ 'child_routes' => [
'mise-en-paiement' => [ 'etat-demande-paiement' => [
'type' => 'Literal', 'type' => 'Literal',
'may_terminate' => false, 'may_terminate' => true,
'options' => [ 'options' => [
'route' => '/mise-en-paiement', 'route' => '/etat-demande-paiement',
'defaults' => [ 'defaults' => [
'action' => 'miseEnPaiement', 'action' => 'etatPaiement',
'etat' => Entity\Db\MiseEnPaiement::A_METTRE_EN_PAIEMENT, 'etat' => Entity\Db\MiseEnPaiement::A_METTRE_EN_PAIEMENT,
], ],
], ],
], ],
'mise-en-paiement' => [
'type' => 'Segment',
'may_terminate' => true,
'options' => [
'route' => '/mise-en-paiement/:structure/:intervenants',
'constraints' => [
'structure' => '[0-9]*'
],
'defaults' => [
'action' => 'MiseEnPaiement',
],
],
],
'etat-paiement' => [ 'etat-paiement' => [
'type' => 'Literal', 'type' => 'Literal',
'may_terminate' => false, 'may_terminate' => true,
'options' => [ 'options' => [
'route' => '/etat-paiement', 'route' => '/etat-paiement',
'defaults' => [ 'defaults' => [
'action' => 'miseEnPaiement', 'action' => 'etatPaiement',
'etat' => Entity\Db\MiseEnPaiement::MIS_EN_PAIEMENT, 'etat' => Entity\Db\MiseEnPaiement::MIS_EN_PAIEMENT,
], ],
], ],
...@@ -49,10 +62,10 @@ return [ ...@@ -49,10 +62,10 @@ return [
'pages' => array( 'pages' => array(
'gestion' => array( 'gestion' => array(
'pages' => array( 'pages' => array(
'mise-en-paiement' => array( 'etat-demande-paiement' => array(
'label' => "Mise en paiement", 'label' => "Mise en paiement",
'title' => "Mise en paiement", 'title' => "Mise en paiement",
'route' => 'paiement/mise-en-paiement', 'route' => 'paiement/etat-demande-paiement',
), ),
'etat-paiement' => array( 'etat-paiement' => array(
'label' => "État de paiement", 'label' => "État de paiement",
...@@ -70,9 +83,14 @@ return [ ...@@ -70,9 +83,14 @@ return [
'BjyAuthorize\Guard\Controller' => [ 'BjyAuthorize\Guard\Controller' => [
[ [
'controller' => 'Application\Controller\Paiement', 'controller' => 'Application\Controller\Paiement',
'action' => ['index','demandeMiseEnPaiement','miseEnPaiement'], 'action' => ['index','demandeMiseEnPaiement','etatPaiement'],
'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR, R_DRH], 'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR, R_DRH],
], ],
[
'controller' => 'Application\Controller\Paiement',
'action' => ['miseEnPaiement'],
'roles' => [R_ADMINISTRATEUR, R_DRH],
],
], ],
], ],
'resource_providers' => [ 'resource_providers' => [
...@@ -115,6 +133,7 @@ return [ ...@@ -115,6 +133,7 @@ return [
], ],
'form_elements' => [ 'form_elements' => [
'invokables' => [ 'invokables' => [
'PaiementMiseEnPaiementForm' => 'Application\Form\Paiement\MiseEnPaiementForm',
'PaiementMiseEnPaiementRechercheForm' => 'Application\Form\Paiement\MiseEnPaiementRechercheForm', 'PaiementMiseEnPaiementRechercheForm' => 'Application\Form\Paiement\MiseEnPaiementRechercheForm',
], ],
], ],
......
...@@ -49,7 +49,7 @@ class PaiementController extends AbstractActionController implements ContextProv ...@@ -49,7 +49,7 @@ class PaiementController extends AbstractActionController implements ContextProv
return compact('intervenant', 'servicesAPayer'); return compact('intervenant', 'servicesAPayer');
} }
public function miseEnPaiementAction() public function etatPaiementAction()
{ {
$this->initFilters(); $this->initFilters();
...@@ -104,6 +104,44 @@ class PaiementController extends AbstractActionController implements ContextProv ...@@ -104,6 +104,44 @@ class PaiementController extends AbstractActionController implements ContextProv
return compact( 'rechercheForm', 'etatPaiement', 'etat' ); return compact( 'rechercheForm', 'etatPaiement', 'etat' );
} }
public function miseEnPaiementAction()
{
$title = 'Mise en paiement';
$structure = $this->context()->mandatory()->structureFromRoute();
$intervenants = $this->params('intervenants');
$form = $this->getFormMiseEnPaiement();
$errors = [];
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($request->getPost());
$form->isValid();
$dateMiseEnPaiement = $form->get('date-mise-en-paiement')->getValue();
$periode = $form->get('periode')->getValue();
$dateMiseEnPaiement = \DateTime::createFromFormat('d/m/Y', $dateMiseEnPaiement);
$periode = $this->getServicePeriode()->get($periode);
$intervenants = $this->getServiceIntervenant()->get( explode(',',$intervenants) );
try{
$this->getServiceMiseEnPaiement()->mettreEnPaiement($structure, $intervenants, $periode, $dateMiseEnPaiement);
}catch(\Exception $e){
$errors[] = $e->getMessage();
}
}
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 * @return \Application\Form\Paiement\MiseEnPaiementRechercheForm
*/ */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<field name="libelleLong" type="string" column="LIBELLE_LONG" length="40" nullable="false"/> <field name="libelleLong" type="string" column="LIBELLE_LONG" length="40" nullable="false"/>
<field name="ordre" type="integer" column="ORDRE" nullable="false"/> <field name="ordre" type="integer" column="ORDRE" nullable="false"/>
<field name="paiement" type="boolean" column="PAIEMENT" nullable="true"/> <field name="paiement" type="boolean" column="PAIEMENT" nullable="true"/>
<field name="moisOriginePaiement" type="integer" column="MOIS_ORIGINE_PAIEMENT" nullable="true"/>
<many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur"> <many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur">
<join-columns> <join-columns>
<join-column name="HISTO_MODIFICATEUR_ID" referenced-column-name="ID"/> <join-column name="HISTO_MODIFICATEUR_ID" referenced-column-name="ID"/>
......
...@@ -87,6 +87,14 @@ class Periode ...@@ -87,6 +87,14 @@ class Periode
*/ */
protected $paiement; protected $paiement;
/**
* moisOriginePaiement
*
* @var integer
*/
protected $moisOriginePaiement;
/** /**
* miseEnPaiementIntervenantStructure * miseEnPaiementIntervenantStructure
* *
...@@ -370,6 +378,29 @@ class Periode ...@@ -370,6 +378,29 @@ class Periode
return $this->paiement; return $this->paiement;
} }
/**
* Set moisOriginePaiement
*
* @param boolean $moisOriginePaiement
* @return Periode
*/
public function setMoisOriginePaiement($moisOriginePaiement)
{
$this->moisOriginePaiement = $moisOriginePaiement;
return $this;
}
/**
* Get moisOriginePaiement
*
* @return boolean
*/
public function getMoisOriginePaiement()
{
return $this->moisOriginePaiement;
}
/** /**
* Get miseEnPaiementIntervenantStructure * Get miseEnPaiementIntervenantStructure
* *
......
<?php
namespace Application\Form\Paiement;
use Zend\Form\Form;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
/**
* Description of MiseEnPaiementForm
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class MiseEnPaiementForm extends Form implements InputFilterProviderInterface, ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
*
* @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;
}
/**
*
*/
public function init()
{
$url = $this->getServiceLocator()->getServiceLocator()->get('viewhelpermanager')->get('url');
/* @var $url Zend\View\Helper\Url */
$this ->setAttribute('method', 'post')
->setAttribute('class', 'paiement-mise-en-paiement-form')
->setAttribute('id', $this->getId());
$periodes = $this->getServicePeriode()->getList( $this->getServicePeriode()->finderByPaiement(true) );
$defaultPeriode = $this->getServicePeriode()->getDatePeriodePaiement();
$this->add([
'type' => 'Select',
'name' => 'periode',
'options' => [
'label' => 'Période',
'value_options' => \UnicaenApp\Util::collectionAsOptions($periodes),
],
'attributes' => [
'value' => $defaultPeriode ? $defaultPeriode->getId() : null,
],
]);
$defaultDateMiseEnPaiement = new \DateTime;
$this->add([
'type' => 'UnicaenApp\Form\Element\Date',
'name' => 'date-mise-en-paiement',
'options' => [
'label' => 'Date de mise en paiement',
'format' => 'd/m/Y'
],
'attributes' => [
'step' => '1',
'value' => $defaultDateMiseEnPaiement->format('d/m/Y')
]
]);
$this->add([
'name' => 'submit',
'type' => 'Submit',
'attributes' => [
'value' => 'Effectuer la mise en paiement',
'class' => 'btn btn-primary',
],
]);
$this->setAttribute('action', $url(null, [], [], true));
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
*
* @return array
*/
public function getInputFilterSpecification()
{
return [
'periode' => [
'required' => true
],
'date-mise-en-paiement' => [
'required' => true
],
];
}
/**
* @return \Application\Service\Periode
*/
protected function getServicePeriode()
{
return $this->getServiceLocator()->getServiceLocator()->get('applicationPeriode');
}
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ namespace Application\Service; ...@@ -5,6 +5,7 @@ namespace Application\Service;
use Application\Entity\Db\MiseEnPaiement as MiseEnPaiementEntity; use Application\Entity\Db\MiseEnPaiement as MiseEnPaiementEntity;
use Application\Entity\Paiement\MiseEnPaiementRecherche; use Application\Entity\Paiement\MiseEnPaiementRecherche;
use Application\Entity\Db\Structure as StructureEntity; use Application\Entity\Db\Structure as StructureEntity;
use Application\Entity\Db\Periode as PeriodeEntity;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
/** /**
...@@ -246,6 +247,28 @@ class MiseEnPaiement extends AbstractEntityService ...@@ -246,6 +247,28 @@ class MiseEnPaiement extends AbstractEntityService
} }
} }
/**
*
* @param StructureEntity $structure
* @param \Application\Entity\Db\Intervenant[] $intervenants
* @param PeriodeEntity $periodePaiement
* @param \DateTime $dateMiseEnPaiement
*/
public function mettreEnPaiement( StructureEntity $structure, $intervenants, PeriodeEntity $periodePaiement, \DateTime $dateMiseEnPaiement )
{
list($qb,$alias) = $this->initQuery();
$this->finderByEtat( MiseEnPaiementEntity::A_METTRE_EN_PAIEMENT, $qb );
$this->finderByStructure($structure, $qb);
$this->finderByIntervenants($intervenants, $qb);
$mepList = $this->getList( $qb );
foreach( $mepList as $mep ){
/* @var $mep MiseEnPaiementEntity */
$mep->setPeriodePaiement( $periodePaiement );
$mep->setDateMiseEnPaiement($dateMiseEnPaiement);
$this->save( $mep );
}
}
private function hydrateFromChangements( MiseEnPaiementEntity $object, $data ) private function hydrateFromChangements( MiseEnPaiementEntity $object, $data )
{ {
if (isset($data['heures'])){ if (isset($data['heures'])){
......
...@@ -44,6 +44,19 @@ class Periode extends AbstractEntityService ...@@ -44,6 +44,19 @@ class Periode extends AbstractEntityService
return 'per'; return 'per';
} }
/**
*
* @param \DateTime $date
* @return PeriodeEntity
*/
public function getDatePeriodePaiement( \DateTime $date=null )
{
if (empty($date)) $date = new \DateTime;
$mois = (int)$date->format('m');
if (0 == $mois) return null;
return $this->getRepo()->findOneBy(['moisOriginePaiement' => $mois]);
}
/** /**
* Retourne la liste des périodes d'enseignement * Retourne la liste des périodes d'enseignement
* *
......
<?php
use Application\Entity\Db\MiseEnPaiement;
/* @var $rechercheForm \Application\Form\Paiement\MiseEnPaiementRechercheForm */
/* @var $etatPaiement array */
/* @var $etat string */
/* @var $miseEnPaiementForm Application\Form\Paiement\MiseEnPaiementForm */
$title = 'Paiement';
switch( $etat ){
case MiseEnPaiement::A_VALIDER:
$title = 'Demandes de mise en paiement à valider';
break;
case MiseEnPaiement::A_METTRE_EN_PAIEMENT:
$title = 'Mise en paiement';
break;
case MiseEnPaiement::MIS_EN_PAIEMENT:
$title = 'État de paiement';
break;
}
$this->headTitle()->append($title);
?>
<h1><?php echo $title ?></h1>
<div class="panel panel-default filter" data-etat="<?php echo $etat ?>">
<div class="panel-heading">Filtres</div>
<div class="panel-body">
<?php echo $this->form()->openTag($rechercheForm->prepare()); ?>
<?php
echo $this->formControlGroup($rechercheForm->get('structure'));
if ($rechercheForm->get('structure')->getValue()){
if (MiseEnPaiement::MIS_EN_PAIEMENT === $etat){
echo $this->formControlGroup($rechercheForm->get('periode'));
if ($rechercheForm->get('periode')->getValue()){
echo $this->formControlGroup($rechercheForm->get('intervenants'));
}
}else{
echo $this->formControlGroup($rechercheForm->get('intervenants'));
}
}
echo $this->formRow($rechercheForm->get('submit'));
echo $this->form()->closeTag();
echo $this->formErrors( $rechercheForm );
?>
</div>
<script type="text/javascript">
$(function() {
PaiementMiseEnPaiementRechercheForm.get("<?php echo $rechercheForm->getId(); ?>").init();
});
</script>
</div>
<?php
if (! empty($etatPaiement)){
echo $this->partial('application/paiement/etat-paiement-html', compact('etatPaiement'));
if( $etat === MiseEnPaiement::A_METTRE_EN_PAIEMENT && $this->isAllowed('controller/Application\Controller\Paiement:miseenpaiement')){
$url = $this->url('paiement/mise-en-paiement', [
'structure' => $rechercheForm->get('structure')->getValue(),
'intervenants'=> implode( ',', $rechercheForm->get('intervenants')->getValue() )
]);
?><a href="<?php echo $url ?>" data-event="mise-en-paiement-form-submit" data-url-redirect="<?php echo $this->url(null, [], [], true) ?>" class="btn btn-primary ajax-modal">Mise en paiement</a><?php
}
}
\ No newline at end of file
<?php <?php
use Application\Entity\Db\MiseEnPaiement; /* @var $form Application\Form\Paiement\MiseEnPaiementForm */
/* @var $errors string[] */
/* @var $rechercheForm \Application\Form\Paiement\MiseEnPaiementRechercheForm */ echo $this->form()->openTag($form->prepare());
/* @var $etatPaiement array */
/* @var $etat string */
$title = 'Paiement';
switch( $etat ){
case MiseEnPaiement::A_VALIDER:
$title = 'Demandes de mise en paiement à valider';
break;
case MiseEnPaiement::A_METTRE_EN_PAIEMENT:
$title = 'Mise en paiement';
break;
case MiseEnPaiement::MIS_EN_PAIEMENT:
$title = 'État de paiement';
break;
}
?> echo $this->formControlGroup($form->get('periode'));
<h1><?php echo $title ?></h1> echo $this->formControlGroup($form->get('date-mise-en-paiement'));
<div class="panel panel-default filter" data-etat="<?php echo $etat ?>">
<div class="panel-heading">Filtres</div> echo $this->formRow($form->get('submit'));
<div class="panel-body">
<?php echo $this->form()->openTag($rechercheForm->prepare()); ?>
<?php
echo $this->formControlGroup($rechercheForm->get('structure'));
if ($rechercheForm->get('structure')->getValue()){
if (MiseEnPaiement::MIS_EN_PAIEMENT === $etat){
echo $this->formControlGroup($rechercheForm->get('periode'));
if ($rechercheForm->get('periode')->getValue()){
echo $this->formControlGroup($rechercheForm->get('intervenants'));
}
}else{
echo $this->formControlGroup($rechercheForm->get('intervenants'));
}
}
echo $this->formRow($rechercheForm->get('submit'));
echo $this->form()->closeTag(); echo $this->form()->closeTag();
echo $this->formErrors( $rechercheForm ); echo $this->formErrors( $form );
?>
</div>
<script type="text/javascript">
$(function() {
PaiementMiseEnPaiementRechercheForm.get("<?php echo $rechercheForm->getId(); ?>").init();
});
</script>
</div>
<?php
if (! empty($etatPaiement)) if ($errors) echo $this->messenger()->setMessages(array(UnicaenApp\View\Helper\Messenger::ERROR => $errors));
echo $this->partial('application/paiement/etat-paiement-html', compact('etatPaiement')); \ No newline at end of file
...@@ -531,7 +531,7 @@ function PaiementMiseEnPaiementRechercheForm( id ) ...@@ -531,7 +531,7 @@ function PaiementMiseEnPaiementRechercheForm( id )
submitElement.show(); submitElement.show();
} }
}else{ }else{
submitElement.attr( 'value', 'Sélectionner ou rechercher les intervenants correspondants'); submitElement.attr( 'value', 'Suite...');
submitElement.show(); submitElement.show();
} }
} }
...@@ -562,6 +562,13 @@ function PaiementMiseEnPaiementRechercheForm( id ) ...@@ -562,6 +562,13 @@ function PaiementMiseEnPaiementRechercheForm( id )
); );
iediv.find(".select-all").click( function(){ that.intervenantsSelectAll() } ); iediv.find(".select-all").click( function(){ that.intervenantsSelectAll() } );
iediv.find(".select-none").click( function(){ that.intervenantsSelectNone() } ); iediv.find(".select-none").click( function(){ that.intervenantsSelectNone() } );
$("body").on("mise-en-paiement-form-submit", function(event, data) {
if ($("div .messenger, div .alert", event.div).length ? false : true){
document.location.href = event.a.data('url-redirect');
}
});
this.onIntervenantsChange(); this.onIntervenantsChange();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment