Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open-source
OSE
Commits
24e4059a
Commit
24e4059a
authored
Apr 11, 2014
by
lecluse
Browse files
Saisie des volumes horaires (non finalisée) et des services (encore buggée)
parent
b3eaa101
Changes
17
Hide whitespace changes
Inline
Side-by-side
module/Application/config/module.config.php
View file @
24e4059a
...
...
@@ -161,6 +161,6 @@ return array_merge_recursive(
include
'demo.config.php'
,
include
'recherche.config.php'
,
include
'service.config.php'
,
include
'volume
_
horaire.config.php'
,
include
'volume
-
horaire.config.php'
,
include
'offre-formation.config.php'
);
module/Application/config/service.config.php
View file @
24e4059a
...
...
@@ -38,6 +38,20 @@ return array(
),
),
),
'voirLigne'
=>
array
(
'type'
=>
'Segment'
,
'options'
=>
array
(
'route'
=>
'/voirLigne[/:id][?only-content=:only-content]'
,
'constraints'
=>
array
(
'action'
=>
'[a-zA-Z][a-zA-Z0-9_-]*'
,
'id'
=>
'[0-9]*'
,
),
'defaults'
=>
array
(
'action'
=>
'voirLigne'
,
'only-content'
=>
0
),
),
),
'default'
=>
array
(
'type'
=>
'Segment'
,
'options'
=>
array
(
...
...
@@ -97,7 +111,9 @@ return array(
),
'service_manager'
=>
array
(
'invokables'
=>
array
(
'ApplicationService'
=>
'Application\\Service\\Service'
,
'ApplicationService'
=>
'Application\\Service\\Service'
,
'ApplicationPeriode'
=>
'Application\\Service\\Periode'
,
'ApplicationMotifNonPaiement'
=>
'Application\\Service\\MotifNonPaiement'
,
)
),
'view_helpers'
=>
array
(
...
...
module/Application/config/volume
_
horaire.config.php
→
module/Application/config/volume
-
horaire.config.php
View file @
24e4059a
...
...
@@ -5,7 +5,7 @@ namespace Application;
return
array
(
'router'
=>
array
(
'routes'
=>
array
(
'volume
_
horaire'
=>
array
(
'volume
-
horaire'
=>
array
(
'type'
=>
'Literal'
,
'options'
=>
array
(
'route'
=>
'/volume-horaire'
,
...
...
@@ -50,7 +50,7 @@ return array(
'default'
=>
array
(
'home'
=>
array
(
'pages'
=>
array
(
'volume
_
horaire'
=>
array
(
'volume
-
horaire'
=>
array
(
'label'
=>
'Volumes horaires'
,
'title'
=>
"Gestion des volumes horaires"
,
'visible'
=>
false
,
...
...
@@ -95,8 +95,7 @@ return array(
'view_helpers'
=>
array
(
'invokables'
=>
array
(
'volumeHoraireDl'
=>
'Application\View\Helper\VolumeHoraire\Dl'
,
'volumeHoraireListe'
=>
'Application\View\Helper\VolumeHoraire\Liste'
,
'volumeHoraireLigne'
=>
'Application\View\Helper\VolumeHoraire\Ligne'
,
'volumeHoraireListe'
=>
'Application\View\Helper\VolumeHoraire\Liste'
),
),
);
module/Application/src/Application/Controller/VolumeHoraireController.php
View file @
24e4059a
...
...
@@ -5,13 +5,14 @@ namespace Application\Controller;
use
Zend\Mvc\Controller\AbstractActionController
;
use
Common\Exception\RuntimeException
;
use
Common\Exception\LogicException
;
use
Application\Form\VolumeHoraire\Saisie
;
use
Application\Entity\Db\VolumeHoraire
;
use
Application\Exception\DbException
;
/**
* Description of VolumeHoraireController
*
* @method \Doctrine\ORM\EntityManager em() Description
* @method \Application\Controller\Plugin\Context context() Description
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class
VolumeHoraireController
extends
AbstractActionController
...
...
@@ -24,26 +25,6 @@ class VolumeHoraireController extends AbstractActionController
return
$this
->
getServiceLocator
()
->
get
(
'ApplicationVolumeHoraire'
);
}
/**
*
* @param integer $serviceId
* @return array
*/
protected
function
getContext
(
$service
)
{
$this
->
getServiceLocator
()
->
get
(
'ApplicationService'
)
->
getRepo
()
->
find
(
$service
);
/** @todo à modifier! ! ! */
return
array
(
// 'service' => $service,
);
}
public
function
indexAction
()
{
$context
=
$this
->
getContext
(
1
);
$volumeHoraires
=
$this
->
getServiceVolumeHoraire
()
->
finderByContext
(
$context
)
->
getQuery
()
->
execute
();
return
compact
(
'volumeHoraires'
,
'context'
);
}
public
function
voirAction
()
{
if
(
!
(
$id
=
$this
->
params
()
->
fromRoute
(
'id'
,
$this
->
params
()
->
fromPost
(
'id'
))))
{
...
...
@@ -56,25 +37,74 @@ class VolumeHoraireController extends AbstractActionController
return
compact
(
'volumeHoraire'
);
}
public
function
ajou
te
r
Action
()
public
function
lis
teAction
()
{
if
(
!
(
$serviceId
=
(
int
)
$this
->
params
()
->
fromRoute
(
'id'
)))
{
throw
new
LogicException
(
"Aucun identifiant de service spécifié."
);
}
if
(
!
(
$service
=
$this
->
getServiceLocator
()
->
get
(
'ApplicationService'
)
->
getRepo
()
->
find
(
$serviceId
)))
{
throw
new
RuntimeException
(
"Service '
$serviceId
' spécifié introuvable."
);
}
$volumeHoraires
=
$service
->
getVolumeHoraire
();
return
compact
(
'service'
,
'volumeHoraires'
);
}
public
function
modif
ie
r
Action
()
public
function
sais
ieAction
()
{
$vh
=
$this
->
context
()
->
mandatory
()
->
volumeHoraireFromQuery
();
/* @var $vh \Application\Entity\Db\VolumeHoraire */
$form
=
new
\
Application\Form\VolumeHoraire\Saisie
(
'vh'
);
var_dump
(
'avant'
,
$vh
->
getId
(),
$vh
->
getHeures
());
if
(
$this
->
getRequest
()
->
isPost
())
{
$data
=
$this
->
getRequest
()
->
getPost
();
if
(
$form
->
isValid
())
{
var_dump
(
$data
);
$vh
->
setHeures
(
floatval
(
$data
[
'heures'
]));
$this
->
em
()
->
flush
(
$vh
);
var_dump
(
'apres'
,
$vh
->
getId
(),
$vh
->
getHeures
());
$id
=
(
int
)
$this
->
params
()
->
fromRoute
(
'id'
,
0
);
$svh
=
$this
->
getServiceVolumeHoraire
();
$serviceId
=
(
int
)
$this
->
params
()
->
fromQuery
(
'service'
);
$periodeId
=
(
int
)
$this
->
params
()
->
fromQuery
(
'periode'
);
$motifNonPaiementId
=
(
int
)
$this
->
params
()
->
fromQuery
(
'motifNonPaiement'
,
0
);
$typeInterventionId
=
(
int
)
$this
->
params
()
->
fromQuery
(
'typeIntervention'
,
0
);
$form
=
new
Saisie
(
$this
->
getServiceLocator
()
);
$form
->
setAttribute
(
'action'
,
$this
->
url
()
->
fromRoute
(
null
,
array
(),
array
(),
true
));
if
(
0
!=
$id
){
/* Initialisation des valeurs */
$entity
=
$svh
->
getRepo
()
->
find
(
$id
);
/* @var $entity \Application\Entity\Db\VolumeHoraire */
$form
->
get
(
'heures'
)
->
setValue
(
$entity
->
getHeures
());
$form
->
get
(
'motifNonPaiement'
)
->
setValue
(
$entity
->
getMotifNonPaiement
()
?
$entity
->
getMotifNonPaiement
()
->
getId
()
:
0
);
}
else
{
$form
->
get
(
'motifNonPaiement'
)
->
setValue
(
$motifNonPaiementId
);
}
$form
->
get
(
'id'
)
->
setValue
(
$id
===
0
?
null
:
$id
);
$form
->
get
(
'service'
)
->
setValue
(
$serviceId
);
$form
->
get
(
'periode'
)
->
setValue
(
$periodeId
);
$form
->
get
(
'typeIntervention'
)
->
setValue
(
$typeInterventionId
);
$request
=
$this
->
getRequest
();
if
(
$request
->
isPost
()){
$post
=
$request
->
getPost
();
if
(
0
==
$post
[
'motifNonPaiement'
])
$post
[
'motifNonPaiement'
]
=
null
;
$form
->
setData
(
$post
);
if
(
$form
->
isValid
()){
if
(
!
isset
(
$entity
)){
$entity
=
new
VolumeHoraire
;
$entity
->
setService
(
$this
->
em
()
->
find
(
'Application\Entity\Db\Service'
,
$serviceId
));
$entity
->
setPeriode
(
$this
->
em
()
->
find
(
'Application\Entity\Db\Periode'
,
$periodeId
));
$entity
->
setTypeIntervention
(
$this
->
em
()
->
find
(
'Application\Entity\Db\TypeIntervention'
,
$typeInterventionId
));
}
$entity
->
setHeures
(
$post
[
'heures'
]);
if
(
null
!==
$post
[
'motifNonPaiement'
])
$entity
->
setMotifNonPaiement
(
$this
->
em
()
->
find
(
'Application\Entity\Db\MotifNonPaiement'
,
$post
[
'motifNonPaiement'
])
);
else
$entity
->
setMotifNonPaiement
(
null
);
try
{
$this
->
em
()
->
persist
(
$entity
);
$this
->
em
()
->
flush
();
$form
->
get
(
'id'
)
->
setValue
(
$entity
->
getId
()
);
// transmet le nouvel ID
}
catch
(
\
Exception
$e
){
$e
=
DbException
::
translate
(
$e
);
$errors
[]
=
$e
->
getMessage
();
}
}
else
{
$errors
[]
=
'La validation du formulaire a échoué. L\'enregistrement des données n\'a donc pas été fait.'
;
}
}
//<a onclick="$('#bsm5345063f12817').popover('hide');" class="close">×</a>
die
;
}
$errors
=
array
();
return
compact
(
'form'
,
'errors'
);
}
}
\ No newline at end of file
module/Application/src/Application/Entity/Db/MotifNonPaiement.php
View file @
24e4059a
...
...
@@ -332,4 +332,21 @@ class MotifNonPaiement
{
return
$this
->
histoCreateur
;
}
/**************************************************************************************************
* Début ajout
**************************************************************************************************/
/**
* Retourne la représentation littérale de cet objet.
*
* @return string
*/
public
function
__toString
()
{
return
$this
->
getLibelleLong
();
}
}
module/Application/src/Application/Form/VolumeHoraire/Saisie.php
View file @
24e4059a
...
...
@@ -6,17 +6,19 @@ use Zend\Form\Form;
use
Zend\InputFilter\InputFilter
;
use
Zend\Form\Element\Csrf
;
use
Zend\Stdlib\Hydrator\ClassMethods
;
use
Zend\Form\Element\Hidden
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
/**
* Description of Saisie
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class
Saisie
extends
Form
class
Saisie
extends
Form
implements
\
Zend\InputFilter\InputFilterProviderInterface
{
public
function
__construct
(
$name
=
null
,
$options
=
array
()
)
public
function
__construct
(
ServiceLocatorInterface
$serviceLocator
)
{
parent
::
__construct
(
$name
,
$options
);
parent
::
__construct
(
'volume-horaire'
);
$this
->
setAttribute
(
'method'
,
'post'
)
->
setAttribute
(
'class'
,
'volume-horaire'
)
...
...
@@ -24,7 +26,7 @@ class Saisie extends Form
// ->setInputFilter(new InputFilter())
// ->setPreferFormInputFilter(false)
;
$this
->
add
(
array
(
'name'
=>
'heures'
,
'options'
=>
array
(
...
...
@@ -37,16 +39,40 @@ class Saisie extends Form
),
'type'
=>
'Text'
,
));
$this
->
add
(
new
Csrf
(
'security'
));
$this
->
add
(
array
(
'name'
=>
'motifNonPaiement'
,
'options'
=>
array
(
'label'
=>
"Motif de non paiement :"
,
),
'attributes'
=>
array
(
'value'
=>
""
,
'title'
=>
"Motif de non paiement"
,
'class'
=>
'volume-horaire volume-horaire-motif-non-paiement input-sm'
),
'type'
=>
'Select'
));
$motifsNonPaiement
=
$serviceLocator
->
get
(
'ApplicationMotifNonPaiement'
)
->
getMotifsNonPaiement
();
foreach
(
$motifsNonPaiement
as
$id
=>
$motifNonPaiement
){
$motifsNonPaiement
[
$id
]
=
(
string
)
$motifNonPaiement
;
}
$motifsNonPaiement
[
0
]
=
'Aucun motif : paiement prévu'
;
$this
->
get
(
'motifNonPaiement'
)
->
setValueOptions
(
$motifsNonPaiement
);
$this
->
add
(
new
Hidden
(
'id'
)
);
$this
->
add
(
new
Hidden
(
'service'
)
);
$this
->
add
(
new
Hidden
(
'periode'
)
);
$this
->
add
(
new
Hidden
(
'typeIntervention'
)
);
$this
->
add
(
new
Csrf
(
'security'
)
);
$this
->
add
(
array
(
'name'
=>
'submit'
,
'type'
=>
'Submit'
,
'attributes'
=>
array
(
'value'
=>
'Enregistrer'
,
'title'
=>
"Enregistrer
ce volume horaire
"
,
'class'
=>
'volume-horaire volume-horaire-enregistrer btn btn-primary
btn-xs
'
'title'
=>
"Enregistrer"
,
'class'
=>
'volume-horaire volume-horaire-enregistrer btn btn-primary'
),
));
...
...
@@ -54,15 +80,28 @@ class Saisie extends Form
'name'
=>
'annuler'
,
'type'
=>
'Button'
,
'options'
=>
array
(
'label'
=>
'
Annul
er'
,
'label'
=>
'
Ferm
er'
,
),
'attributes'
=>
array
(
'title'
=>
"Abandonner cette saisie"
,
'class'
=>
'volume-horaire volume-horaire-annuler btn btn-
primary btn-xs
'
'class'
=>
'volume-horaire volume-horaire-annuler btn btn-
default fermer
'
),
));
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
*
* @return array
*/
public
function
getInputFilterSpecification
(){
return
array
(
'motifNonPaiement'
=>
array
(
'required'
=>
false
)
);
}
}
\ No newline at end of file
module/Application/src/Application/Service/MotifNonPaiement.php
0 → 100644
View file @
24e4059a
<?php
namespace
Application\Service
;
use
Application\Service\AbstractService
;
use
Doctrine\ORM\EntityRepository
;
use
Doctrine\ORM\QueryBuilder
;
use
Application\Entity\Db\MotifNonPaiement
as
Entity
;
/**
* Description of MotifNonPaiement
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class
MotifNonPaiement
extends
AbstractService
{
/**
* Repository
*
* @var Repository
*/
protected
$repo
;
/**
* Liste des motifs de non paiement
*
* @var Entity[]
*/
protected
$motifsNonPaiement
;
/**
* Retourne la liste des motifs de non paiement
*
* @param QueryBuilder|null $queryBuilder
* @return QueryBuilder
*/
public
function
finderByAll
(
QueryBuilder
$qb
=
null
)
{
if
(
empty
(
$qb
))
$qb
=
$this
->
getRepo
()
->
createQueryBuilder
(
'mnp'
);
$qb
->
addOrderBy
(
'mnp.libelleLong'
);
return
$qb
;
}
/**
*
* @return EntityRepository
*/
public
function
getRepo
()
{
if
(
empty
(
$this
->
repo
)
){
$this
->
getEntityManager
()
->
getFilters
()
->
enable
(
"historique"
);
$this
->
repo
=
$this
->
getEntityManager
()
->
getRepository
(
'Application\Entity\Db\MotifNonPaiement'
);
}
return
$this
->
repo
;
}
/**
* Liste des motifs de non paiement
*
* @return Entity[]
*/
public
function
getMotifsNonPaiement
()
{
if
(
!
$this
->
motifsNonPaiement
){
$mnps
=
$this
->
finderByAll
()
->
getQuery
()
->
execute
();
$this
->
motifsNonPaiement
=
array
();
foreach
(
$mnps
as
$mnp
){
$this
->
motifsNonPaiement
[
$mnp
->
getId
()]
=
$mnp
;
}
}
return
$this
->
motifsNonPaiement
;
}
}
\ No newline at end of file
module/Application/src/Application/Service/Periode.php
0 → 100644
View file @
24e4059a
<?php
namespace
Application\Service
;
use
Application\Service\AbstractService
;
use
Doctrine\ORM\EntityRepository
;
use
Doctrine\ORM\QueryBuilder
;
use
Application\Entity\Db\TypeIntervenant
as
EntityTypeIntervenant
;
/**
* Description of Periode
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class
Periode
extends
AbstractService
{
/**
* Repository
*
* @var Repository
*/
protected
$repo
;
/**
* Périodes par types d'intervenants
*
* @var array[]
*/
protected
$periodesByTypeIntervenant
;
/**
* Retourne la liste des périodes pour un type d'intervenant donné
*
* @param EntityTypeIntervenant $typeIntervenant
* @param QueryBuilder|null $queryBuilder
* @return QueryBuilder
*/
public
function
finderByTypeIntervenant
(
EntityTypeIntervenant
$typeIntervenant
,
QueryBuilder
$qb
=
null
)
{
if
(
empty
(
$qb
))
$qb
=
$this
->
getRepo
()
->
createQueryBuilder
(
'p'
);
$qb
->
andWhere
(
'p.typeIntervenant = :type'
)
->
setParameter
(
'type'
,
$typeIntervenant
);
$qb
->
orderBy
(
'p.ordre'
);
return
$qb
;
}
/**
*
* @param EntityTypeIntervenant $typeIntervenant
* @return type
*/
public
function
getByTypeIntervenant
(
EntityTypeIntervenant
$typeIntervenant
)
{
if
(
!
isset
(
$this
->
periodesByTypeIntervenant
[
$typeIntervenant
->
getId
()])){
$periodes
=
$this
->
finderByTypeIntervenant
(
$typeIntervenant
)
->
getQuery
()
->
execute
();
$this
->
periodesByTypeIntervenant
[
$typeIntervenant
->
getId
()]
=
array
();
foreach
(
$periodes
as
$periode
){
$this
->
periodesByTypeIntervenant
[
$typeIntervenant
->
getId
()][
$periode
->
getId
()]
=
$periode
;
}
}
return
$this
->
periodesByTypeIntervenant
[
$typeIntervenant
->
getId
()];
}
/**
*
* @return EntityRepository
*/
public
function
getRepo
()
{
if
(
empty
(
$this
->
repo
)
){
$this
->
getEntityManager
()
->
getFilters
()
->
enable
(
"historique"
);
$this
->
repo
=
$this
->
getEntityManager
()
->
getRepository
(
'Application\Entity\Db\Periode'
);
}
return
$this
->
repo
;
}
}
\ No newline at end of file
module/Application/src/Application/View/Helper/Service/Liste.php
View file @
24e4059a
...
...
@@ -72,14 +72,7 @@ class Liste extends AbstractHelper implements ServiceLocatorAwareInterface
$out
.
=
"<th> </th>
\n
"
;
$out
.
=
"</tr>
\n
"
;
foreach
(
$this
->
services
as
$service
){
$out
.
=
'<tr id="service-'
.
$service
->
getId
()
.
'-ligne">'
;
$out
.
=
$this
->
getView
()
->
serviceLigne
(
$service
,
$this
->
context
)
->
render
(
$details
);
$out
.
=
'</tr>'
;
$out
.
=
'<tr class="volume-horaire" id="service-'
.
$service
->
getId
()
.
'-volume-horaire-tr"'
.
(
$details
?
''
:
' style="display:none"'
)
.
'>'
.
'<td class="volume-horaire" id="service-'
.
$service
->
getId
()
.
'-volume-horaire-td" colspan="'
.
$colspan
.
'">'
.
$this
->
getView
()
->
volumeHoraireListe
(
$service
->
getVolumeHoraire
(),
array
(
'service'
=>
$service
)
)
->
render
()
.
'</td>'
.
'</tr>'
;
$out
.
=
$this
->
renderLigne
(
$service
,
$details
);
}
$out
.
=
'</table>'
.
"
\n
"
;
$out
.
=
$this
->
renderShowHide
();
...
...
@@ -93,6 +86,22 @@ class Liste extends AbstractHelper implements ServiceLocatorAwareInterface
return
$out
;
}
public
function
renderLigne
(
Service
$service
,
$details
=
false
)
{
$url
=
$this
->
getView
()
->
url
(
'service/voirLigne'
,
array
(
'id'
=>
$service
->
getId
(),
'only-content'
=>
1
));
$detailsUrl
=
$this
->
getView
()
->
url
(
'volume-horaire/default'
,
array
(
'action'
=>
'liste'
,
'id'
=>
$service
->
getId
()));
$out
=
'<tr id="service-'
.
$service
->
getId
()
.
'-ligne" data-url="'
.
$url
.
'">'
;
$out
.
=
$this
->
getView
()
->
serviceLigne
(
$service
,
$this
->
context
)
->
render
(
$details
);
$out
.
=
'</tr>'
;
$out
.
=
'<tr class="volume-horaire" id="service-'
.
$service
->
getId
()
.
'-volume-horaire-tr"'
.
(
$details
?
''
:
' style="display:none"'
)
.
'>'
.
'<td class="volume-horaire" id="service-'
.
$service
->
getId
()
.
'-volume-horaire-td" data-url="'
.
$detailsUrl
.
'" colspan="999">'
.
$this
->
getView
()
->
volumeHoraireListe
(
$service
->
getVolumeHoraire
(),
$service
)
->
render
()
.
'</td>'
.
'</tr>'
;
return
$out
;
}
public
function
renderShowHide
()
{
return
...
...
module/Application/src/Application/View/Helper/VolumeHoraire/Ligne.php
deleted
100644 → 0
View file @
b3eaa101
<?php
namespace
Application\View\Helper\VolumeHoraire
;
use
Zend\View\Helper\AbstractHelper
;
use
Application\Entity\Db\VolumeHoraire
;
/**
* Aide de vue permettant d'afficher une ligne de volume horaire
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class
Ligne
extends
AbstractHelper
{
/**
* @var VolumeHoraire
*/
protected
$volumeHoraire
;
/**
* Contexte
*
* @var array
*/
protected
$context
;
/**
* Helper entry point.
*
* @param VolumeHoraire $volumeHoraire
* @return self
*/
final
public
function
__invoke
(
VolumeHoraire
$volumeHoraire
,
array
$context
=
array
()
)
{
$this
->
volumeHoraire
=
$volumeHoraire
;
$this
->
context
=
$context
;
return
$this
;
}
/**
* Retourne le code HTML généré par cette aide de vue.
*
* @return string