Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Pixel Humain
survey
Commits
fff33c76
Commit
fff33c76
authored
Jun 26, 2020
by
Raph El
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form : amélioration validation form
parent
6b9474f3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
69 deletions
+79
-69
controllers/answer/IndexAction.php
controllers/answer/IndexAction.php
+4
-1
controllers/answer/ValidateAction.php
controllers/answer/ValidateAction.php
+6
-33
models/Answer.php
models/Answer.php
+59
-31
views/tpls/forms/cplx/validationForm.php
views/tpls/forms/cplx/validationForm.php
+4
-3
views/tpls/forms/finish.php
views/tpls/forms/finish.php
+5
-0
views/tpls/forms/formWizard.php
views/tpls/forms/formWizard.php
+1
-1
No files found.
controllers/answer/IndexAction.php
View file @
fff33c76
...
@@ -40,7 +40,10 @@ class IndexAction extends CAction
...
@@ -40,7 +40,10 @@ class IndexAction extends CAction
$canEditAnswer
=
false
;
$canEditAnswer
=
false
;
$canSeeAnswer
=
false
;
$canSeeAnswer
=
false
;
if
(
empty
(
$mode
)
||
(
$mode
!=
"w"
&&
$mode
!=
"r"
)
)
if
(
empty
(
$mode
)
||
(
$mode
!=
"w"
&&
$mode
!=
"r"
)
||
(
!
empty
(
$answer
[
"validated"
])
&&
$answer
[
"validated"
]
==
true
)
)
$mode
=
"r"
;
$mode
=
"r"
;
if
(
!
empty
(
Yii
::
app
()
->
session
[
'userId'
])){
if
(
!
empty
(
Yii
::
app
()
->
session
[
'userId'
])){
...
...
controllers/answer/ValidateAction.php
View file @
fff33c76
<?php
<?php
class
ValidateAction
extends
CAction
class
ValidateAction
extends
CAction
{
{
public
function
run
(
$id
=
null
,
$type
=
null
,
$tpl
=
null
)
public
function
run
()
{
{
//$controller = $this->getController();
$params
=
$_POST
;
$res
=
Answer
::
validate
(
$_POST
);
$params
[
"controller"
]
=
$this
->
getController
();
Rest
::
json
(
$_POST
);
$res
=
Answer
::
validate
(
$params
);
Rest
::
json
(
$res
);
}
}
}
}
"organizations"
:
[
{
"from"
:
"aressForm1.multitextvalidationaressForm110"
,
"to"
:
"name"
},
{
"from"
:
"aressForm1.multitextvalidationaressForm111"
,
"to"
:
"sigle"
},
{
"from"
:
"aressForm1.multitextvalidationaressForm112"
,
"to"
:
"siren"
},
{
"from"
:
"aressForm1.multitextvalidationaressForm19"
,
"to"
:
"email"
},
{
"from"
:
"aressForm1.multitextvalidationaressForm113"
,
"to"
:
"WALDEC_RNA
"
},
{
"from"
:
"aressForm1.multitextvalidationaressForm113"
,
"to"
:
"siren"
}
]
\ No newline at end of file
models/Answer.php
View file @
fff33c76
...
@@ -368,45 +368,73 @@ class Answer{
...
@@ -368,45 +368,73 @@ class Answer{
public
static
function
validate
(
$params
){
public
static
function
validate
(
$params
){
$costum
=
CacheHelper
::
getCostum
();
$costum
=
CacheHelper
::
getCostum
();
$set
=
array
();
$set
=
array
();
$res
=
array
(
'result'
=>
false
,
"msg"
=>
"Erreur"
);
if
(
!
empty
(
$params
[
"
validated"
])
&&
$params
[
"validated"
]
===
true
)
if
(
!
empty
(
$params
[
"
answerId"
])
)
$
set
[
"validated"
]
=
true
;
$
answer
=
PHDB
::
findOneById
(
Answer
::
COLLECTION
,
$params
[
"answerId"
])
;
if
(
!
empty
(
$params
[
"input"
][
"generateElement"
])){
if
(
!
empty
(
$answer
)){
$mapping
=
array
();
if
(
!
empty
(
$params
[
"input"
][
"validated"
])
&&
(
$params
[
"input"
][
"validated"
]
===
true
||
$params
[
"input"
][
"validated"
]
===
"true"
)
)
$import
=
array
(
$set
[
"validated"
]
=
true
;
'file'
=>
array
(
json_encode
(
array
(
$params
[
"answer"
]))),
'nameFile'
=>
"test"
,
if
(
!
empty
(
$params
[
"input"
][
"generateElement"
])){
'typeFile'
=>
'json'
,
"warnings"
=>
"false"
);
foreach
(
$params
[
"input"
][
"generateElement"
]
as
$type
=>
$map
)
{
$mapping
=
array
();
$mapping
=
array
();
foreach
(
$map
as
$k
=>
$v
)
{
$import
=
array
(
$mapping
[]
=
array
(
'file'
=>
array
(
json_encode
(
array
(
$params
[
"answer"
]))),
'idHeadCSV'
=>
$v
[
"from"
],
'nameFile'
=>
"test"
,
'valueAttributeElt'
=>
$v
[
"to"
]
'typeFile'
=>
'json'
,
);
"warnings"
=>
"false"
);
foreach
(
$params
[
"input"
][
"generateElement"
]
as
$type
=>
$map
)
{
$mapping
=
array
();
foreach
(
$map
as
$k
=>
$v
)
{
$mapping
[]
=
array
(
'idHeadCSV'
=>
$v
[
"from"
],
'valueAttributeElt'
=>
$v
[
"to"
]
);
}
$import
[
'infoCreateData'
]
=
$mapping
;
$import
[
'typeElement'
]
=
$type
;
//Rest::json($import); exit;
$resImport
=
Import
::
previewData
(
$import
,
true
,
true
,
true
);
//Rest::json($resImport); exit;
foreach
(
$resImport
[
"elementsObj"
]
as
$keyElt
=>
$elt
)
{
$elt
=
Import
::
checkElement
(
$elt
,
$type
);
if
(
!
empty
(
$elt
[
"msgError"
]))
unset
(
$elt
[
"msgError"
]);
$elt
[
"collection"
]
=
$type
;
$elt
[
"key"
]
=
$type
;
if
(
Costum
::
isSameFunction
(
"generateElementBeforeSave"
)){
$elt
=
Costum
::
sameFunction
(
"generateElementBeforeSave"
,
$elt
);
}
$save
=
Element
::
save
(
$elt
);
//Rest::json($save); exit;
Link
::
connect
(
$save
[
"id"
],
$type
,
$params
[
"answerId"
],
Answer
::
COLLECTION
,
Yii
::
app
()
->
session
[
"userId"
],
"answers"
,
false
,
false
,
false
,
false
);
Link
::
connect
(
$params
[
"answerId"
],
Answer
::
COLLECTION
,
$save
[
"id"
],
$type
,
Yii
::
app
()
->
session
[
"userId"
],
$type
,
false
,
false
,
false
,
false
);
}
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
//Rest::json($resImport); exit;
}
}
$import
[
'infoCreateData'
]
=
$mapping
;
$import
[
'typeElement'
]
=
$type
;
$resImport
=
Import
::
previewData
(
$import
,
true
,
true
,
true
);
Rest
::
json
(
$resImport
);
exit
;
}
}
}
if
(
Costum
::
isSameFunction
(
"answerValidate"
)){
if
(
Costum
::
isSameFunction
(
"answerValidate"
)){
$paramBeforeValidate
=
Costum
::
sameFunction
(
"answerValidate"
,
$params
);
$paramBeforeValidate
=
Costum
::
sameFunction
(
"answerValidate"
,
$params
);
}
}
if
(
!
empty
(
$set
)){
PHDB
::
update
(
Answer
::
COLLECTION
,
array
(
"_id"
=>
new
MongoId
((
string
)
$params
[
"answerId"
])),
array
(
'$set'
=>
$set
)
);
if
(
!
empty
(
$set
)){
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
PHDB
::
update
(
Answer
::
COLLECTION
,
}
array
(
"_id"
=>
new
MongoId
((
string
)
$params
[
"answerId"
])),
array
(
'$set'
=>
$set
)
);
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
if
(
$res
[
"result"
]
===
true
){
$res
[
"html"
]
=
$params
[
"controller"
]
->
renderPartial
(
'survey.views.tpls.forms.finish'
,
$res
,
true
);
}
}
}
return
$res
;
return
$res
;
...
...
views/tpls/forms/cplx/validationForm.php
View file @
fff33c76
<?php
<?php
if
(
$mode
!=
"pdf"
){
if
(
$mode
!=
"pdf"
){
var_dump
(
$input
);
//
var_dump($input);
?>
?>
<div
class=
""
>
<div
class=
""
>
<label
for=
"validation
<?php
echo
$kunik
?>
"
><h4
style=
"color:
<?php
echo
(
$titleColor
)
?
$titleColor
:
"black"
;
?>
"
>
<?php
echo
$label
.
$editQuestionBtn
?>
</h4></label>
<label
for=
"validation
<?php
echo
$kunik
?>
"
><h4
style=
"color:
<?php
echo
(
$titleColor
)
?
$titleColor
:
"black"
;
?>
"
>
<?php
echo
$label
.
$editQuestionBtn
?>
</h4></label>
...
@@ -17,7 +17,6 @@ if($mode != "pdf"){
...
@@ -17,7 +17,6 @@ if($mode != "pdf"){
$
(
"
#question
<?php
echo
$key
?>
#validation
<?php
echo
$kunik
?>
"
).
off
().
click
(
function
(){
$
(
"
#question
<?php
echo
$key
?>
#validation
<?php
echo
$kunik
?>
"
).
off
().
click
(
function
(){
var
paramsValidate
=
{
var
paramsValidate
=
{
answerId
:
answerId
,
answerId
:
answerId
,
answer
:
answerObj
.
answers
,
input
:
paramsInput
input
:
paramsInput
};
};
...
@@ -26,7 +25,9 @@ if($mode != "pdf"){
...
@@ -26,7 +25,9 @@ if($mode != "pdf"){
baseUrl
+
"
/survey/answer/validate
"
,
baseUrl
+
"
/survey/answer/validate
"
,
paramsValidate
,
paramsValidate
,
function
(
data
){
function
(
data
){
toastr
.
success
(
"
Le formulaire à été soumis
"
);
toastr
.
success
(
"
Le formulaire à été soumis
"
);
if
(
typeof
data
.
html
!=
"
undefined
"
)
$
(
"
#customHeader
"
).
html
(
data
.
html
);
},
},
function
(
data
){
function
(
data
){
toastr
.
error
(
"
Un soucis est apparue. Contacter l'administrateur
"
);
toastr
.
error
(
"
Un soucis est apparue. Contacter l'administrateur
"
);
...
...
views/tpls/forms/finish.php
0 → 100644
View file @
fff33c76
<div
class=
"col-xs-12 text-center padding-20 margin-top-10"
>
<h4>
Félicitation!!! Vous avez terminé le formulaire.
</h4>
<br/>
<h4>
Celui-ci sera traité dans les plus bref délai.
</h4>
</div>
\ No newline at end of file
views/tpls/forms/formWizard.php
View file @
fff33c76
...
@@ -145,7 +145,7 @@ if(isset($this->costum["cms"]["color1"]))
...
@@ -145,7 +145,7 @@ if(isset($this->costum["cms"]["color1"]))
<div class="col-xs-12 margin-top-20">
<div class="col-xs-12 margin-top-20">
<?php
<?php
$wizardUid
=
(
String
)
$form
[
"_id"
];
$wizardUid
=
(
String
)
$form
[
"_id"
];
if
(
$canEdit
===
true
&&
$mode
!=
"fa"
){
if
(
$canEdit
===
true
&&
$mode
!=
"fa"
&&
empty
(
$answer
[
"validated"
])
){
$nameMode
=
"mode read"
;
$nameMode
=
"mode read"
;
if
(
$mode
==
"w"
)
if
(
$mode
==
"w"
)
$nameMode
=
"mode write"
;
$nameMode
=
"mode write"
;
...
...
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