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
47a41982
Commit
47a41982
authored
Jul 07, 2020
by
Anatole Rakotoson
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/qa' into qa
parents
650083b4
2e68bb95
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
122 additions
and
93 deletions
+122
-93
controllers/answer/IndexAction.php
controllers/answer/IndexAction.php
+4
-1
controllers/answer/ValidateAction.php
controllers/answer/ValidateAction.php
+7
-6
controllers/answer/admin/DirectoryAction.php
controllers/answer/admin/DirectoryAction.php
+0
-1
models/Answer.php
models/Answer.php
+62
-31
models/Form.php
models/Form.php
+6
-4
views/tpls/forms/costum/community/emailist.php
views/tpls/forms/costum/community/emailist.php
+1
-1
views/tpls/forms/costum/community/wizard.php
views/tpls/forms/costum/community/wizard.php
+25
-35
views/tpls/forms/cplx/multitextvalidation.php
views/tpls/forms/cplx/multitextvalidation.php
+1
-1
views/tpls/forms/cplx/validationForm.php
views/tpls/forms/cplx/validationForm.php
+10
-12
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 @
47a41982
...
...
@@ -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 @
47a41982
<?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
);
}
}
\ No newline at end of file
}
controllers/answer/admin/DirectoryAction.php
View file @
47a41982
...
...
@@ -24,7 +24,6 @@ class DirectoryAction extends CAction
$idFs
[]
=
$keyF
;
}
$res
=
Form
::
getBySourceAndId
(
$controller
->
costum
[
"slug"
]);
//Rest::json($res); exit;
$searchParams
=
$_POST
;
$searchParams
[
"count"
]
=
true
;
$answers
=
Answer
::
globalAutocomplete
(
$res
[
"form"
],
$searchParams
);
...
...
models/Answer.php
View file @
47a41982
...
...
@@ -108,6 +108,7 @@ class Answer{
}
public
static
function
globalAutocomplete
(
$form
,
$searchParams
){
//var_dump($form);
$searchParams
[
"indexMin"
]
=
(
isset
(
$searchParams
[
"indexMin"
]))
?
$searchParams
[
"indexMin"
]
:
0
;
$searchParams
[
"indexStep"
]
=
(
isset
(
$searchParams
[
"indexStep"
]))
?
$searchParams
[
"indexStep"
]
:
100
;
$mappingData
=
(
isset
(
$form
[
"mapping"
]))
?
$form
[
"mapping"
]
:
array
(
"name"
=>
"name"
,
"address"
=>
"address"
);
...
...
@@ -149,7 +150,7 @@ class Answer{
$query
=
Search
::
searchFilters
(
$searchParams
[
'filters'
],
$query
);
}
$res
=
array
();
//
var_dump
($query);exit;
//
Rest::json
($query);exit;
$res
[
"results"
]
=
PHDB
::
findAndLimitAndIndex
(
self
::
COLLECTION
,
$query
,
$searchParams
[
"indexStep"
],
$searchParams
[
"indexMin"
]);
if
(
isset
(
$searchParams
[
"count"
]))
$res
[
"count"
][
self
::
COLLECTION
]
=
PHDB
::
count
(
self
::
COLLECTION
,
$query
);
...
...
@@ -365,47 +366,77 @@ class Answer{
}
public
static
function
validate
(
$params
){
//Rest::json($params); exit;
$costum
=
CacheHelper
::
getCostum
();
$set
=
array
();
if
(
!
empty
(
$params
[
"
validated"
])
&&
$params
[
"validated"
]
===
true
)
$
set
[
"validated"
]
=
true
;
$res
=
array
(
'result'
=>
false
,
"msg"
=>
"Erreur"
);
if
(
!
empty
(
$params
[
"
answerId"
])
)
$
answer
=
PHDB
::
findOneById
(
Answer
::
COLLECTION
,
$params
[
"answerId"
])
;
if
(
!
empty
(
$params
[
"input"
][
"generateElement"
])){
$mapping
=
array
();
$import
=
array
(
'file'
=>
array
(
json_encode
(
array
(
$params
[
"answer"
]))),
'nameFile'
=>
"test"
,
'typeFile'
=>
'json'
,
"warnings"
=>
"false"
);
if
(
!
empty
(
$answer
)){
//Rest::json($answer); exit;
if
(
!
empty
(
$params
[
"input"
][
"validated"
])
&&
(
$params
[
"input"
][
"validated"
]
===
true
||
$params
[
"input"
][
"validated"
]
===
"true"
)
)
$set
[
"validated"
]
=
true
;
foreach
(
$params
[
"input"
][
"generateElement"
]
as
$type
=>
$map
)
{
if
(
!
empty
(
$params
[
"input"
][
"generateElement"
]
))
{
$mapping
=
array
();
foreach
(
$map
as
$k
=>
$v
)
{
$mapping
[]
=
array
(
'idHeadCSV'
=>
$v
[
"from"
],
'valueAttributeElt'
=>
$v
[
"to"
]
);
$import
=
array
(
'file'
=>
array
(
json_encode
(
array
(
$answer
))),
'nameFile'
=>
"test"
,
'typeFile'
=>
'json'
,
"warnings"
=>
"false"
);
//Rest::json($import); exit;
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"
)){
$paramBeforeValidate
=
Costum
::
sameFunction
(
"answerValidate"
,
$params
);
}
if
(
Costum
::
isSameFunction
(
"answerValidate"
)){
$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
)){
PHDB
::
update
(
Answer
::
COLLECTION
,
array
(
"_id"
=>
new
MongoId
((
string
)
$params
[
"answerId"
])),
array
(
'$set'
=>
$set
)
);
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
}
$res
=
array
(
'result'
=>
true
,
"msg"
=>
"Valider"
);
if
(
$res
[
"result"
]
===
true
){
$res
[
"html"
]
=
$params
[
"controller"
]
->
renderPartial
(
'survey.views.tpls.forms.finish'
,
$res
,
true
);
}
}
return
$res
;
...
...
models/Form.php
View file @
47a41982
...
...
@@ -184,10 +184,12 @@ class Form {
}
$res
[
"form"
]
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
$queryForm
);
$res
[
"forms"
]
=
[];
foreach
(
$res
[
"form"
][
"subForms"
]
as
$ix
=>
$formId
)
{
$f
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"id"
=>
$formId
]);
$res
[
"forms"
][
$formId
]
=
$f
;
}
if
(
!
empty
(
$res
[
"form"
][
"subForms"
])){
foreach
(
$res
[
"form"
][
"subForms"
]
as
$ix
=>
$formId
)
{
$f
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"id"
=>
$formId
]);
$res
[
"forms"
][
$formId
]
=
$f
;
}
}
return
$res
;
}
public
static
function
getById
(
$parentForm
,
$fields
=
array
()){
...
...
views/tpls/forms/costum/community/emailist.php
View file @
47a41982
...
...
@@ -127,7 +127,7 @@
inputType
:
"
text
"
,
label
:
"
Sujet
"
,
values
:
sectionDyf
.
<?php
echo
$kunik
?>
ParamsData
.
mail_type
}
}
,
mail_type
:
{
inputType
:
"
textarea
"
,
label
:
"
Mail type
"
,
...
...
views/tpls/forms/costum/community/wizard.php
View file @
47a41982
...
...
@@ -44,20 +44,20 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
foreach
(
$formList
as
$k
=>
$v
)
{
?>
<div
id=
'
<?php
echo
$v
?>
'
class=
'col-sm-offset-1 col-sm-10 sectionStep '
style=
"padding-bottom:40px"
>
<div
id=
'
<?php
echo
$v
?>
xx
'
class=
'col-sm-offset-1 col-sm-10 sectionStep '
style=
"padding-bottom:40px"
>
<?php
$form
=
PHDB
::
findOne
(
Form
::
COLLECTION
,[
"id"
=>
$v
]
);
?>
$form
=
PHDB
::
findOne
(
Form
::
COLLECTION
,[
"id"
=>
$v
]
);
?>
<script
type=
"text/javascript"
>
formInputs
[
"
<?php
echo
$v
?>
"
]
=
<?php
echo
json_encode
(
$form
[
'inputs'
]
);
?>
;
var
formInputsHere
=
formInputs
;
</script>
<?php
if
(
!
empty
(
$form
)
)
{
echo
'<h1 class="text-center" style="color:'
.
$color1
.
'" >'
.
@
$form
[
"name"
]
.
'</h1>'
;
<?php
if
(
!
empty
(
$form
)
)
{
echo
'<h1 class="text-center" style="color:'
.
$color1
.
'" >'
.
@
$form
[
"name"
]
.
'</h1>'
;
echo
"<div class='text-center'>"
;
if
(
isset
(
$this
->
costum
[
"cms"
][
$form
[
"id"
]
.
"desc"
]))
echo
htmlentities
(
$this
->
costum
[
"cms"
][
$form
[
"id"
]
.
"desc"
]);
...
...
@@ -67,24 +67,24 @@ var formInputsHere = formInputs;
echo
"<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='"
.
@
$form
[
"id"
]
.
"desc' data-type='textarea' data-markdown='1' data-path='costum.cms."
.
@
$form
[
"id"
]
.
"desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>"
;
echo
"</div>"
;
//echo "<div class='markdown'>";
//echo "<div class='markdown'>";
echo
"<div class=''>"
;
echo
$this
->
renderPartial
(
"survey.views.tpls.forms.formSection"
,
[
"formId"
=>
$v
,
"form"
=>
$form
,
"wizard"
=>
false
,
"answer"
=>
$answer
,
echo
$this
->
renderPartial
(
"survey.views.tpls.forms.formSection"
,
[
"formId"
=>
$v
,
"form"
=>
$form
,
"wizard"
=>
false
,
"answer"
=>
$answer
,
"mode"
=>
"w"
,
"showForm"
=>
$showForm
,
"canEdit"
=>
$canEdit
,
"el"
=>
$el
]
,
true
);
echo
"</div>"
;
}
else
{
echo
""
;
}
?>
"showForm"
=>
$showForm
,
"canEdit"
=>
$canEdit
,
"el"
=>
$el
]
,
true
);
echo
"</div>"
;
}
else
{
echo
""
;
}
?>
</div>
<?php
}
...
...
@@ -99,23 +99,13 @@ jQuery(document).ready(function() {
descHtml
=
dataHelper
.
markdownToHtml
(
$
(
v
).
html
());
$
(
v
).
html
(
descHtml
);
});
// Todo BUG en nav private
if
(
localStorage
!==
null
&&
localStorage
.
wizardStep
!==
null
)
showStepForm
(
localStorage
.
wizardStep
);
});
function
showStepForm
(
id
){
mylog
.
log
(
"
showStepForm
"
,
id
);
$
(
"
.sectionStep
"
).
addClass
(
"
hide
"
);
$
(
id
).
removeClass
(
"
hide
"
);
localStorage
.
setItem
(
"
wizardStep
"
,
id
);
}
</script>
</div>
</div>
\ No newline at end of file
</div>
views/tpls/forms/cplx/multitextvalidation.php
View file @
47a41982
...
...
@@ -171,7 +171,7 @@ $paramsData = [
"email"
=>
"adresse mail"
,
"unique"
=>
"Siret"
]
];
];
if
(
$saveOneByOne
)
...
...
views/tpls/forms/cplx/validationForm.php
View file @
47a41982
<?php
var_dump
(
$input
);
if
(
$mode
!=
"pdf"
){
//var_dump($input);
?>
<div
class=
""
>
<label
for=
"
<?php
echo
$k
ey
?>
"
><h4
style=
"color:
<?php
echo
(
$titleColor
)
?
$titleColor
:
"black"
;
?>
"
>
<?php
echo
$label
.
$editQuestionBtn
?>
</h4></label>
<label
for=
"
validation
<?php
echo
$k
unik
?>
"
><h4
style=
"color:
<?php
echo
(
$titleColor
)
?
$titleColor
:
"black"
;
?>
"
>
<?php
echo
$label
.
$editQuestionBtn
?>
</h4></label>
<div
class=
"text-center"
>
<
button
class=
"btn btn-primary"
id=
"validation
<?php
echo
$kunik
?>
"
>
Validation
</
button
>
<
a
href=
"javascript:;"
class=
"btn btn-primary"
id=
"validation
<?php
echo
$kunik
?>
"
>
Validation
</
a
>
</div>
</div>
...
...
@@ -13,19 +14,20 @@ if($mode != "pdf"){
var
paramsInput
=
<?php
echo
json_encode
(
$input
);
?>
;
jQuery
(
document
).
ready
(
function
()
{
mylog
.
log
(
"
render form input
"
,
"
/modules/costum/views/tpls/forms/cplx/validate.php
"
);
$
(
"
#validation
<?php
echo
$kunik
?>
"
).
click
(
function
(){
var
params
=
{
$
(
"
#question
<?php
echo
$key
?>
#validation
<?php
echo
$kunik
?>
"
).
off
().
click
(
function
(){
var
params
Validate
=
{
answerId
:
answerId
,
answer
:
answerObj
.
answers
,
input
:
paramsInput
};
ajaxPost
(
null
,
baseUrl
+
"
/survey/answer/validate
"
,
params
,
params
Validate
,
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
){
toastr
.
error
(
"
Un soucis est apparue. Contacter l'administrateur
"
);
...
...
@@ -34,9 +36,5 @@ if($mode != "pdf"){
});
});
</script>
<?php
}
?>
\ No newline at end of file
views/tpls/forms/finish.php
0 → 100644
View file @
47a41982
<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 @
47a41982
...
...
@@ -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