Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web-DPO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libriciel
web-DPO
Commits
b22017cf
Commit
b22017cf
authored
Dec 10, 2018
by
tguillon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Amélioration : Possibilité de définir le préfix d'enregistrement du
numéro du traitement au registre
parent
ae18ca18
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
9 deletions
+131
-9
app/Config/Schema/CreationBase/patchs/1.0.0_to_1.0.1.sql
app/Config/Schema/CreationBase/patchs/1.0.0_to_1.0.1.sql
+4
-0
app/Controller/EtatFichesController.php
app/Controller/EtatFichesController.php
+32
-7
app/Controller/OrganisationsController.php
app/Controller/OrganisationsController.php
+1
-1
app/Locale/fra/LC_MESSAGES/organisation.po
app/Locale/fra/LC_MESSAGES/organisation.po
+6
-0
app/Model/AppModel.php
app/Model/AppModel.php
+58
-0
app/Model/Fiche.php
app/Model/Fiche.php
+15
-0
app/View/Organisations/edit.ctp
app/View/Organisations/edit.ctp
+15
-1
No files found.
app/Config/Schema/CreationBase/patchs/1.0.0_to_1.0.1.sql
View file @
b22017cf
...
...
@@ -20,4 +20,8 @@ INSERT INTO crons(organisation_id, nom, action, active, lock, created, modified)
CREATE
UNIQUE
INDEX
fichiers_url_idx
ON
fichiers
(
url
);
ALTER
TABLE
organisations
ADD
COLUMN
prefixenumero
VARCHAR
(
50
)
NOT
NULL
DEFAULT
'DPO-'
;
ALTER
TABLE
organisations
ADD
COLUMN
numeroregistre
INTEGER
NOT
NULL
DEFAULT
(
0
);
CREATE
UNIQUE
INDEX
fiches_organisation_id_numero_idx
ON
fiches
(
organisation_id
,
numero
);
COMMIT
;
\ No newline at end of file
app/Controller/EtatFichesController.php
View file @
b22017cf
...
...
@@ -930,9 +930,22 @@ class EtatFichesController extends AppController {
}
if
(
$numero
==
null
||
$numero
===
'null'
)
{
$numero
=
'DPO'
.
$id
;
$organisation
=
$this
->
Organisation
->
find
(
'first'
,
[
'conditions'
=>
[
'Organisation.id'
=>
$this
->
Session
->
read
(
'Organisation.id'
)
],
'fields'
=>
[
'Organisation.id'
,
'Organisation.prefixenumero'
,
'Organisation.numeroregistre'
]
]);
$numeroregistre
=
$organisation
[
'Organisation'
][
'numeroregistre'
]
+
1
;
$numero
=
$organisation
[
'Organisation'
][
'prefixenumero'
]
.
$numeroregistre
;
}
$messageError
=
__d
(
'default'
,
'default.flasherrorEnregistrementErreur'
);
$success
=
true
;
$this
->
EtatFiche
->
begin
();
...
...
@@ -1000,9 +1013,18 @@ class EtatFichesController extends AppController {
]);
$success
=
$success
&&
false
!==
$this
->
Historique
->
save
();
}
if
(
$success
==
true
)
{
$this
->
Organisation
->
id
=
$organisation
[
'Organisation'
][
'id'
];
$success
=
$success
&&
$this
->
Organisation
->
save
([
'numeroregistre'
=>
$numeroregistre
])
!==
false
;
}
}
}
}
}
else
{
$messageError
=
sprintf
(
"Le numéro d'enregistrement %s est déja présent au registre. Merci de modifier le numéro d'enregistrement."
,
$numero
);
}
if
(
$success
==
true
)
{
...
...
@@ -1014,15 +1036,18 @@ class EtatFichesController extends AppController {
'action'
=>
'supprimerLaNotif'
,
$idEncoursValid
[
'Fiche'
][
'id'
]
]);
$this
->
redirect
([
'controller'
=>
'registres'
,
'action'
=>
'index'
]);
}
else
{
$this
->
EtatFiche
->
rollback
();
$this
->
Session
->
setFlash
(
__d
(
'default'
,
'default.flasherrorEnregistrementErreur'
),
'flasherror'
);
}
$this
->
Session
->
setFlash
(
$messageError
,
'flasherror'
);
$this
->
redirect
([
'controller'
=>
'registres'
,
'action'
=>
'index'
]);
$this
->
redirect
(
$this
->
Referers
->
get
());
}
}
}
app/Controller/OrganisationsController.php
View file @
b22017cf
...
...
@@ -80,7 +80,7 @@ class OrganisationsController extends AppController {
if
(
'Cancel'
===
Hash
::
get
(
$this
->
request
->
data
,
'submit'
))
{
$this
->
redirect
(
$this
->
Referers
->
get
());
}
$success
=
true
;
$this
->
Organisation
->
begin
();
...
...
app/Locale/fra/LC_MESSAGES/organisation.po
View file @
b22017cf
...
...
@@ -228,6 +228,12 @@ msgstr "Registre : "
msgid "organisation.champRegistreVerrou"
msgstr "Voulez-vous utiliser le système de verrouillage du registre ?"
msgid "organisation.champPrefixenumero"
msgstr "Préfixe du numéro d'enregistrement d'un traitement au registre"
msgid "organisation.placeholderChampPrefixenumero"
msgstr "Préfixe du numéro d'enregistrement d'un traitement au registre"
###############################################################################
###################: View/Organisation/politiquepassword.ctp ###################
...
...
app/Model/AppModel.php
View file @
b22017cf
...
...
@@ -119,6 +119,8 @@ class AppModel extends Model {
* colonnes (comme lorsdqu'une table possède un INDEX UNIQUE sur plusieurs
* colonnes).
*
* @deprecated
*
* @param array $data Les données du champ envoyées à la validation
* @param array $fieldNames La liste des champs à contrôler
* @return type
...
...
@@ -163,6 +165,8 @@ class AppModel extends Model {
/**
* Règle de validation équivalent à un index unique sur plusieurs colonnes.
*
* @deprecated voir la méthode areUnique
*
* public $validate = array(
* 'name' => array(
* array(
...
...
@@ -241,4 +245,58 @@ class AppModel extends Model {
return
$success
;
}
/**
* Règle de validation équivalent à un index unique sur plusieurs colonnes.
*
* @fixme: il faudrait remplacer les méthodes `checkUnique` et `isUniqueMultiple`
*
* @param array $check
* @param array $fields
* @return boolean
*/
public
function
areUnique
(
$check
,
$fields
)
{
if
(
!
is_array
(
$check
)
||
empty
(
$fields
)
)
{
return
false
;
}
$data
=
$this
->
data
;
$fields
=
(
array
)
$fields
;
$available
=
array_keys
(
$data
[
$this
->
alias
]
);
$primaryKey
=
null
;
if
(
!
empty
(
$this
->
{
$this
->
primaryKey
}))
{
$primaryKey
=
$this
->
{
$this
->
primaryKey
};
}
elseif
(
isset
(
$data
[
$this
->
alias
][
$this
->
primaryKey
]
)
&&
!
empty
(
$data
[
$this
->
alias
][
$this
->
primaryKey
]
)
)
{
$primaryKey
=
$data
[
$this
->
alias
][
$this
->
primaryKey
];
}
// S'il manque des champs pour un enregistrement existant, on va les récupérer
if
(
!
empty
(
$primaryKey
)
&&
array_intersect
(
$fields
,
$available
)
!==
$fields
)
{
$query
=
[
'fields'
=>
array_diff
(
$fields
,
$available
),
'contain'
=>
false
,
'conditions'
=>
[
"
{
$this
->
alias
}
.
{
$this
->
primaryKey
}
"
=>
$primaryKey
]
];
$record
=
$this
->
find
(
'first'
,
$query
);
$data
[
$this
->
alias
]
=
array_merge
(
$record
[
$this
->
alias
],
$data
[
$this
->
alias
]);
$data
[
$this
->
alias
][
$this
->
primaryKey
]
=
$primaryKey
;
}
$querydata
=
array
(
'conditions'
=>
array
(),
'recursive'
=>
-
1
,
'contain'
=>
false
);
foreach
(
$fields
as
$field
)
{
$querydata
[
'conditions'
][
"
{
$this
->
alias
}
.
{
$field
}
"
]
=
$data
[
$this
->
alias
][
$field
];
}
// 1°) Pas l'id -> SELECT COUNT(*) FROM table WHERE name = XXX and modeletypecourrierpcg66_id = XXXX == 0
// 2°) On a l'id
if
(
isset
(
$data
[
$this
->
alias
][
$this
->
primaryKey
]
)
&&
!
empty
(
$data
[
$this
->
alias
][
$this
->
primaryKey
]
)
)
{
// SELECT COUNT(*) FROM table WHERE name = XXX and modeletypecourrierpcg66_id = XXXX AND id <> XXXX == 0
$querydata
[
'conditions'
][
"
{
$this
->
alias
}
.
{
$this
->
primaryKey
}
<>"
]
=
$data
[
$this
->
alias
][
$this
->
primaryKey
];
}
$found
=
$this
->
find
(
'first'
,
$querydata
);
return
empty
(
$found
);
}
}
app/Model/Fiche.php
View file @
b22017cf
...
...
@@ -33,6 +33,21 @@ class Fiche extends AppModel {
public
$name
=
'Fiche'
;
public
$validate
=
[
'organisation_id'
=>
[
'areUnique'
=>
[
'rule'
=>
array
(
'areUnique'
,
array
(
'organisation_id'
,
'numero'
),
false
),
'message'
=>
'... est déjà utilisée.'
]
],
'numero'
=>
[
'areUnique'
=>
[
'rule'
=>
array
(
'areUnique'
,
array
(
'organisation_id'
,
'numero'
),
false
),
'message'
=>
'... est déjà utilisée.'
]
],
];
/**
* hasOne associations
*
...
...
app/View/Organisations/edit.ctp
View file @
b22017cf
...
...
@@ -247,7 +247,7 @@
?>
</h2>
<div
class=
"row
radio
"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?php
echo
$this
->
WebcilForm
->
input
(
'verrouiller'
,
[
...
...
@@ -266,6 +266,20 @@
]);
?>
</div>
<div
class=
"col-md-6"
>
<?php
echo
$this
->
WebcilForm
->
input
(
'prefixenumero'
,
[
'id'
=>
'prefixenumero'
,
'required'
=>
true
]);
echo
$this
->
WebcilForm
->
input
(
'numeroregistre'
,
[
'id'
=>
'numeroregistre'
,
'type'
=>
'hidden'
,
'required'
=>
true
]);
?>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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