Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open-source
OSE
Commits
b8dde0e1
Commit
b8dde0e1
authored
Apr 12, 2019
by
Laurent Lécluse
Browse files
#20381
parent
c8a940b4
Changes
6
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
b8dde0e1
...
...
@@ -18,6 +18,7 @@ dans le détail des services.
*
Procédures d'installation et de mise à jour intégrées directement au projet dans Gitlab.
*
Certains dossiers intervenants pouvaient être validés plusieurs fois.
Un mécanisme contrôle désormais que le dossier n'est pas déjà validé avant de valider à nouveau.
*
Le contrôle de cohérence des données personnelles prend maintenant en compte le cas des français nés dans un ex-département français d'Algérie.
## Nouveautés
...
...
code/test1.php
View file @
b8dde0e1
...
...
@@ -7,10 +7,9 @@
* @var $sl \Zend\ServiceManager\ServiceLocatorInterface
*/
$command
=
'unoconv -f pdf -o /app/test.pdf /app/test.odt'
;
//$command = 'systemctl list-units';
//$command = 'ls';
$sp
=
$sl
->
get
(
\
Application\Service\PaysService
::
class
);
exec
(
$command
,
$output
,
$return
);
var_dump
(
$output
);
var_dump
(
$return
);
\ No newline at end of file
$france
=
$sp
->
getIdByLibelle
(
'Algérie'
);
var_dump
(
$france
);
\ No newline at end of file
module/Application/src/Application/Form/Intervenant/DossierFieldset.php
View file @
b8dde0e1
...
...
@@ -3,8 +3,6 @@
namespace
Application\Form\Intervenant
;
use
Application\Entity\Db\Dossier
as
Dossier
;
use
Application\Entity\Db\Pays
as
PaysEntity
;
use
Application\Entity\Db\Pays
;
use
Application\Entity\Db\StatutIntervenant
;
use
Application\Form\AbstractFieldset
;
use
Application\Service\Traits\CiviliteServiceAwareTrait
;
...
...
@@ -370,7 +368,7 @@ class DossierFieldset extends AbstractFieldset
'departementNaissance'
=>
[
'required'
=>
$departementRequired
,
'validators'
=>
[
new
DepartementNaissanceValidator
(
[
'france_id'
=>
self
::
$franceId
]
),
new
DepartementNaissanceValidator
(),
],
],
'villeNaissance'
=>
[
...
...
module/Application/src/Application/Service/PaysService.php
View file @
b8dde0e1
...
...
@@ -5,12 +5,17 @@ namespace Application\Service;
use
Application\Entity\Db\Pays
;
use
Application\Service\Traits\ParametresServiceAwareTrait
;
use
Doctrine\ORM\QueryBuilder
;
use
UnicaenApp\Util
;
/**
* Description of Pays
*/
class
PaysService
extends
AbstractEntityService
{
CONST
PAYS_FRANCE
=
'france '
;
CONST
PAYS_ALGERIE
=
'algerie'
;
use
ParametresServiceAwareTrait
;
...
...
@@ -40,13 +45,19 @@ class PaysService extends AbstractEntityService
/**
* @return
Pays
* @return
int|null
*/
public
function
get
France
():
Pays
public
function
get
IdByLibelle
(
string
$libelle
)
{
$franceId
=
$this
->
getServiceParametres
()
->
get
(
'pays_france'
);
$sql
=
'SELECT id FROM pays WHERE ose_divers.str_reduce(libelle_court) = :pays'
;
$res
=
$this
->
getEntityManager
()
->
getConnection
()
->
fetchAll
(
$sql
,
[
'pays'
=>
Util
::
reduce
(
$libelle
)]);
if
(
isset
(
$res
[
0
][
'ID'
])){
return
(
int
)
$res
[
0
][
'ID'
];
}
return
$this
->
get
(
$franceId
)
;
return
null
;
}
...
...
@@ -58,7 +69,7 @@ class PaysService extends AbstractEntityService
*/
public
function
isFrance
(
Pays
$pays
):
bool
{
return
$pays
==
$this
->
get
France
(
);
return
$pays
->
getId
()
==
$this
->
get
IdByLibelle
(
self
::
PAYS_FRANCE
);
}
...
...
module/Application/src/Application/Validator/DepartementNaissanceValidator.php
View file @
b8dde0e1
...
...
@@ -2,11 +2,13 @@
namespace
Application\Validator
;
use
LogicException
;
use
Application\Service\Traits\PaysServiceAwareTrait
;
use
Zend\Validator\AbstractValidator
;
class
DepartementNaissanceValidator
extends
AbstractValidator
{
use
PaysServiceAwareTrait
;
const
MSG_NOT_REQUIRED
=
'msgNotRequired'
;
const
MSG_REQUIRED
=
'msgRequired'
;
...
...
@@ -20,12 +22,8 @@ class DepartementNaissanceValidator extends AbstractValidator
public
function
__construct
(
$options
=
null
)
{
parent
::
__construct
(
$options
);
if
(
!
isset
(
$options
[
'france_id'
]))
{
throw
new
LogicException
(
"Paramètre 'france_id' introuvable."
);
}
$this
->
franceId
=
$options
[
'france_id'
];
$this
->
franceId
=
$this
->
getServicePays
()
->
getIdByLibelle
(
$this
->
getServicePays
()
::
PAYS_FRANCE
);
}
public
function
isValid
(
$value
,
$context
=
null
)
...
...
module/Application/src/Application/Validator/NumeroINSEEValidator.php
View file @
b8dde0e1
...
...
@@ -4,6 +4,7 @@ namespace Application\Validator;
use
Application\Service\Traits\CiviliteServiceAwareTrait
;
use
Application\Service\Traits\DepartementServiceAwareTrait
;
use
Application\Service\Traits\PaysServiceAwareTrait
;
use
LogicException
;
use
UnicaenApp\Validator\NumeroINSEE
;
...
...
@@ -21,12 +22,21 @@ class NumeroINSEEValidator extends NumeroINSEE
{
use
DepartementServiceAwareTrait
;
use
CiviliteServiceAwareTrait
;
use
PaysServiceAwareTrait
;
const
MSG_CIVILITE
=
'msgCivilite'
;
const
MSG_ANNEE
=
'msgAnnee'
;
const
MSG_MOIS
=
'msgMois'
;
const
MSG_DEPT
=
'msgDepartement'
;
/**
* @var ?int
*/
protected
$algerieId
;
/**
* @var ?int
*/
protected
$franceId
;
...
...
@@ -40,11 +50,8 @@ class NumeroINSEEValidator extends NumeroINSEE
self
::
MSG_DEPT
=>
"Le numéro n'est pas cohérent avec le pays et l'éventuel département de naissance saisi"
,
]);
if
(
!
isset
(
$options
[
'france_id'
]))
{
throw
new
LogicException
(
"Paramètre 'france_id' introuvable."
);
}
$this
->
franceId
=
(
int
)
$options
[
'france_id'
];
$this
->
franceId
=
$this
->
getServicePays
()
->
getIdByLibelle
(
'FRANCE'
);
$this
->
algerieId
=
$this
->
getServicePays
()
->
getIdByLibelle
(
'ALGERIE'
);
if
(
!
isset
(
$options
[
'serviceDepartement'
]))
{
throw
new
LogicException
(
"Service Département non fourni."
);
...
...
@@ -167,14 +174,21 @@ class NumeroINSEEValidator extends NumeroINSEE
return
true
;
}
$paysNaissance
=
(
int
)
$context
[
'paysNaissance'
];
$estNeEnFrance
=
$paysNaissance
===
$this
->
franceId
;
$paysNaissance
=
(
int
)
$context
[
'paysNaissance'
];
$estNeEnFrance
=
$paysNaissance
===
$this
->
franceId
;
$estNeEnAlgerie
=
$paysNaissance
===
$this
->
algerieId
;
if
(
$estNeEnFrance
)
{
// on doit avoir un code département français valide
if
(
!
$this
->
isValidDepartementFrance
(
$value
,
$context
))
{
return
false
;
}
}
if
(
$estNeEnAlgerie
)
{
// on doit avoir un code département français valide
if
(
!
$this
->
isValidDepartementAlgerie
(
$value
,
$context
))
{
return
false
;
}
}
else
{
// on doit avoir un code pays étranger valide
if
(
!
$this
->
isValidDepartementHorsFrance
(
$value
))
{
...
...
@@ -280,6 +294,22 @@ class NumeroINSEEValidator extends NumeroINSEE
private
function
isValidDepartementAlgerie
(
$value
,
$context
)
{
$departement
=
substr
(
$value
,
5
,
2
);
if
(
is_numeric
(
$departement
))
{
$d
=
(
int
)
$departement
;
if
(
in_array
(
$d
,
[
91
,
92
,
93
,
94
,
99
]))
{
return
'0'
.
(
string
)
$departement
;
}
}
return
null
;
}
/**
* Teste si un numéro INSEE possède le code département de naissance associé à un pays étranger.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment