Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
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
Show 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
$canEditAnswer
=
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"
;
if
(
!
empty
(
Yii
::
app
()
->
session
[
'userId'
])){
...
...
controllers/answer/ValidateAction.php
View file @
fff33c76
<?php
class
ValidateAction
extends
CAction
{
public
function
run
(
$id
=
null
,
$type
=
null
,
$tpl
=
null
)
public
function
run
()
{
$res
=
Answer
::
validate
(
$_POST
);
Rest
::
json
(
$_POST
);
//$controller = $this->getController();
$params
=
$_POST
;
$params
[
"controller"
]
=
$this
->
getController
();
$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,8 +368,12 @@ class Answer{
public
static
function
validate
(
$params
){
$costum
=
CacheHelper
::
getCostum
();
$set
=
array
();
$res
=
array
(
'result'
=>
false
,
"msg"
=>
"Erreur"
);
if
(
!
empty
(
$params
[
"answerId"
]))
$answer
=
PHDB
::
findOneById
(
Answer
::
COLLECTION
,
$params
[
"answerId"
]);
if
(
!
empty
(
$params
[
"validated"
])
&&
$params
[
"validated"
]
===
true
)
if
(
!
empty
(
$answer
)){
if
(
!
empty
(
$params
[
"input"
][
"validated"
])
&&
(
$params
[
"input"
][
"validated"
]
===
true
||
$params
[
"input"
][
"validated"
]
===
"true"
)
)
$set
[
"validated"
]
=
true
;
if
(
!
empty
(
$params
[
"input"
][
"generateElement"
])){
...
...
@@ -391,8 +395,26 @@ class Answer{
}
$import
[
'infoCreateData'
]
=
$mapping
;
$import
[
'typeElement'
]
=
$type
;
//Rest::json($import); exit;
$resImport
=
Import
::
previewData
(
$import
,
true
,
true
,
true
);
Rest
::
json
(
$resImport
);
exit
;
//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;
}
}
...
...
@@ -409,6 +431,12 @@ class Answer{
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
}
if
(
$res
[
"result"
]
===
true
){
$res
[
"html"
]
=
$params
[
"controller"
]
->
renderPartial
(
'survey.views.tpls.forms.finish'
,
$res
,
true
);
}
}
return
$res
;
}
...
...
views/tpls/forms/cplx/validationForm.php
View file @
fff33c76
<?php
if
(
$mode
!=
"pdf"
){
var_dump
(
$input
);
//
var_dump($input);
?>
<div
class=
""
>
<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"){
$
(
"
#question
<?php
echo
$key
?>
#validation
<?php
echo
$kunik
?>
"
).
off
().
click
(
function
(){
var
paramsValidate
=
{
answerId
:
answerId
,
answer
:
answerObj
.
answers
,
input
:
paramsInput
};
...
...
@@ -27,6 +26,8 @@ if($mode != "pdf"){
paramsValidate
,
function
(
data
){
toastr
.
success
(
"
Le formulaire à été soumis
"
);
if
(
typeof
data
.
html
!=
"
undefined
"
)
$
(
"
#customHeader
"
).
html
(
data
.
html
);
},
function
(
data
){
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"]))
<div class="col-xs-12 margin-top-20">
<?php
$wizardUid
=
(
String
)
$form
[
"_id"
];
if
(
$canEdit
===
true
&&
$mode
!=
"fa"
){
if
(
$canEdit
===
true
&&
$mode
!=
"fa"
&&
empty
(
$answer
[
"validated"
])
){
$nameMode
=
"mode read"
;
if
(
$mode
==
"w"
)
$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