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
0e7ea975
Commit
0e7ea975
authored
Apr 12, 2020
by
Tibor Katelbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor ids to subForms
parent
5e1cbf65
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
78 additions
and
57 deletions
+78
-57
controllers/answer/GetAction.php
controllers/answer/GetAction.php
+1
-2
controllers/form/DeleteAction.php
controllers/form/DeleteAction.php
+3
-3
controllers/form/GetAction.php
controllers/form/GetAction.php
+2
-2
models/Answer.php
models/Answer.php
+2
-2
models/Form.php
models/Form.php
+3
-4
views/tpls/answers/index.php
views/tpls/answers/index.php
+2
-1
views/tpls/forms/config.php
views/tpls/forms/config.php
+7
-5
views/tpls/forms/cplx/stepValidation.php
views/tpls/forms/cplx/stepValidation.php
+3
-3
views/tpls/forms/formWizard.php
views/tpls/forms/formWizard.php
+2
-1
views/tpls/forms/oforms.php
views/tpls/forms/oforms.php
+5
-5
views/tpls/forms/wizard.php
views/tpls/forms/wizard.php
+46
-28
views/tpls/views/index.php
views/tpls/views/index.php
+2
-1
No files found.
controllers/answer/GetAction.php
View file @
0e7ea975
...
...
@@ -16,7 +16,6 @@ class GetAction extends CTKAction
$params
=
[];
$params
[
"form"
]
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"_id"
=>
new
MongoId
(
$form
)
]
);
//var_dump($params["form"]);exit;
$params
[
"formList"
]
=
$params
[
"form"
][
"ids"
];
$params
[
"forms"
]
=
[];
foreach
(
$params
[
"formList"
]
as
$ix
=>
$formId
)
{
$f
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"id"
=>
$formId
]);
...
...
@@ -27,7 +26,7 @@ class GetAction extends CTKAction
$params
[
'el'
]
=
$el
[
"el"
];
//ce code ne marchera pas pour deux formulaire identaique , d'un meme slug
//TODO utiliser le parntForm Id en plus
// $params["allAnswers"] = PHDB::find( Form::ANSWER_COLLECTION, ["formId"=>implode('|', $params["form"]["
id
s"]) , "parentSlug" => $params["form"]["parentSlug"]] );
// $params["allAnswers"] = PHDB::find( Form::ANSWER_COLLECTION, ["formId"=>implode('|', $params["form"]["
subForm
s"]) , "parentSlug" => $params["form"]["parentSlug"]] );
$params
[
"allAnswers"
]
=
PHDB
::
find
(
Answer
::
COLLECTION
,
[
"form"
=>
$form
]
);
$params
[
'canEdit'
]
=
(
isset
(
Yii
::
app
()
->
session
[
"userId"
])
&&
isset
(
$el
[
"type"
])
&&
isset
(
$el
[
"id"
])
)
?
Authorisation
::
canEditItem
(
Yii
::
app
()
->
session
[
"userId"
],
$el
[
"type"
],
$el
[
"id"
])
...
...
controllers/form/DeleteAction.php
View file @
0e7ea975
...
...
@@ -12,10 +12,10 @@ class DeleteAction extends CAction
{
// if( Authorisation::isElementAdmin($id, Form::ANSWER_COLLECTION, Yii::app()->session["userId"], false)) {
if
(
isset
(
$form
[
"
id
s"
]))
if
(
isset
(
$form
[
"
subForm
s"
]))
{
PHDB
::
remove
(
Form
::
ANSWER_COLLECTION
,
[
"formId"
=>
implode
(
"|"
,
$form
[
"
id
s"
])
]);
foreach
(
$form
[
"
id
s"
]
as
$ix
=>
$fid
)
{
PHDB
::
remove
(
Form
::
ANSWER_COLLECTION
,
[
"formId"
=>
implode
(
"|"
,
$form
[
"
subForm
s"
])
]);
foreach
(
$form
[
"
subForm
s"
]
as
$ix
=>
$fid
)
{
PHDB
::
remove
(
Form
::
COLLECTION
,
[
"id"
=>
$fid
]);
}
}
...
...
controllers/form/GetAction.php
View file @
0e7ea975
...
...
@@ -25,8 +25,8 @@ class GetAction extends CTKAction
{
$formId
=
""
;
if
(
isset
(
$f
[
'
id
s'
])){
foreach
(
$f
[
'
id
s'
]
as
$ix
=>
$fid
)
if
(
isset
(
$f
[
'
subForm
s'
])){
foreach
(
$f
[
'
subForm
s'
]
as
$ix
=>
$fid
)
{
if
(
$formId
!=
""
)
$formId
.
=
"|"
;
...
...
models/Answer.php
View file @
0e7ea975
...
...
@@ -28,8 +28,8 @@ class Answer{
$formList
=
null
;
if
(
!
empty
(
$form
)
){
$ans
[
"form"
]
=
(
String
)
$form
[
"_id"
];
if
(
!
empty
(
$form
[
"
id
s"
])){
$formList
=
$form
[
"
id
s"
];
if
(
!
empty
(
$form
[
"
subForm
s"
])){
$formList
=
$form
[
"
subForm
s"
];
$ans
[
"formId"
]
=
implode
(
"|"
,
$formList
);
$ans
[
"formList"
]
=
count
(
$formList
);
}
...
...
models/Form.php
View file @
0e7ea975
...
...
@@ -167,9 +167,8 @@ class Form {
$queryForm
=
array
(
"_id"
=>
new
MongoId
(
$form
));
}
$res
[
"form"
]
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
$queryForm
);
$res
[
"formList"
]
=
$res
[
"form"
][
"ids"
];
$res
[
"forms"
]
=
[];
foreach
(
$res
[
"form
List
"
]
as
$ix
=>
$formId
)
{
foreach
(
$res
[
"form
"
][
"subForms
"
]
as
$ix
=>
$formId
)
{
$f
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"id"
=>
$formId
]);
$res
[
"forms"
][
$formId
]
=
$f
;
}
...
...
@@ -773,8 +772,8 @@ class Form {
$params
[
"formList"
]
=
explode
(
"|"
,
$answer
[
"formId"
]);
$params
[
"formId"
]
=
$answer
[
"formId"
];
}
else
if
(
isset
(
$form
)
&&
!
empty
(
$form
[
"
id
s"
])
){
$params
[
"formList"
]
=
$form
[
"
id
s"
];
}
else
if
(
isset
(
$form
)
&&
!
empty
(
$form
[
"
subForm
s"
])
){
$params
[
"formList"
]
=
$form
[
"
subForm
s"
];
$params
[
"formId"
]
=
implode
(
"|"
,
$params
[
"formList"
]);
}
$params
=
self
::
getFormData
(
$params
);
...
...
views/tpls/answers/index.php
View file @
0e7ea975
...
...
@@ -311,7 +311,8 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
if
(
$showForm
){
$params
=
[
"formList"
=>
$formList
,
"parentForm"
=>
$parentForm
,
"form"
=>
$form
,
"el"
=>
$el
,
"active"
=>
"all"
,
"color1"
=>
$color1
,
...
...
views/tpls/forms/config.php
View file @
0e7ea975
<?php
if
(
$canEditForm
===
true
){
$subFormIds
=
[];
if
(
isset
(
$form
[
"
id
s"
]))
$subFormIds
=
array_merge
(
$subFormIds
,
$form
[
"
id
s"
]
);
if
(
isset
(
$form
[
"
subForm
s"
]))
$subFormIds
=
array_merge
(
$subFormIds
,
$form
[
"
subForm
s"
]
);
?>
<div
class=
"col-xs-12 padding-10 text-center bg-info"
>
<h4>
Admin Form
</h4>
...
...
@@ -42,7 +42,7 @@ var oformParams = {
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Activé
"
},
checked
:
false
},
id
s
:
{
subForm
s
:
{
inputType
:
"
array
"
,
label
:
"
Nommé chaque étape de votre questionnaire
"
,
//subLabel : "Vous remplirez les question de chaques étapes par la suite",
...
...
@@ -107,14 +107,16 @@ var oformParams = {
tplCtx
.
value
[
k
]
=
getPairsObj
(
'
.
'
+
k
+
val
.
inputType
);
else
if
(
val
.
inputType
==
"
array
"
){
tplCtx
.
value
[
k
]
=
getArray
(
'
.
'
+
k
+
val
.
inputType
);
if
(
k
==
"
id
s
"
){
if
(
k
==
"
subForm
s
"
){
var
cx
=
subForms
.
length
;
$
.
each
(
tplCtx
.
value
[
k
],
function
(
ix
,
fName
)
{
mylog
.
log
(
"
check sub Form
"
,
fName
,
"
<?php
echo
$el
[
"slug"
]
?>
"
+
cx
);
if
(
$
.
inArray
(
fName
,
subForms
)
<
0
){
var
newFormId
=
"
<?php
echo
$el
[
"slug"
]
?>
"
+
cx
;
tplCtx
.
value
[
k
][
ix
]
=
newFormId
;
var
newForm
=
{
var
newForm
=
{
collection
:
"
forms
"
,
value
:
{
id
:
newFormId
,
...
...
views/tpls/forms/cplx/stepValidation.php
View file @
0e7ea975
...
...
@@ -182,7 +182,7 @@ if( $mode != "pdf" ){
user
:
userId
}
};
if
(
costum
.
form
.
id
s
.
length
==
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
id
s
)
+
1
&&
formData
.
valid
==
"
valid
"
)
if
(
costum
.
form
.
subForm
s
.
length
==
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
subForm
s
)
+
1
&&
formData
.
valid
==
"
valid
"
)
ctxTpl
.
value
.
finished
=
true
;
mylog
.
log
(
"
validation save
"
,
ctxTpl
);
...
...
@@ -192,10 +192,10 @@ if( $mode != "pdf" ){
//only increment step form to next step if step valid
if
(
ctxTpl
.
value
.
valid
==
"
valid
"
||
ctxTpl
.
value
.
valid
==
"
validReserve
"
){
step
=
0
;
if
(
costum
.
form
.
id
s
.
length
==
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
id
s
)
+
1
)
if
(
costum
.
form
.
subForm
s
.
length
==
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
subForm
s
)
+
1
)
step
=
"
all
"
;
else
step
=
costum
.
form
.
id
s
[
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
id
s
)
+
1
];
step
=
costum
.
form
.
subForm
s
[
$
.
inArray
(
"
<?php
echo
$form
[
'id'
]
?>
"
,
costum
.
form
.
subForm
s
)
+
1
];
ctxTpl
=
{
id
:
"
<?php
echo
$answer
[
'_id'
]
?>
"
,
...
...
views/tpls/forms/formWizard.php
View file @
0e7ea975
...
...
@@ -288,7 +288,8 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
}
if
(
!
empty
(
$showForm
))
{
$params
=
[
"formList"
=>
$formList
,
"parentForm"
=>
$parentForm
,
"form"
=>
$form
,
"el"
=>
$el
,
"active"
=>
"all"
,
"color1"
=>
$color1
,
...
...
views/tpls/forms/oforms.php
View file @
0e7ea975
...
...
@@ -8,8 +8,8 @@
$ct
=
0
;
$subFormIds
=
[];
foreach
(
$forms
as
$fix
=>
$f
)
{
if
(
isset
(
$f
[
"
id
s"
])){
foreach
(
$f
[
"
id
s"
]
as
$ix
=>
$sfid
)
{
if
(
isset
(
$f
[
"
subForm
s"
])){
foreach
(
$f
[
"
subForm
s"
]
as
$ix
=>
$sfid
)
{
if
(
!
in_array
(
$sfid
,
$subFormIds
))
$subFormIds
[]
=
$sfid
;
}
...
...
@@ -36,8 +36,8 @@ foreach ($forms as $fix => $f) {
steps :
<br/>
<?php
if
(
isset
(
$f
[
'
id
s'
])){
foreach
(
$f
[
"
id
s"
]
as
$ix
=>
$i
)
{
if
(
isset
(
$f
[
'
subForm
s'
])){
foreach
(
$f
[
"
subForm
s"
]
as
$ix
=>
$i
)
{
$countQ
=
(
isset
(
$f
[
$i
][
"inputs"
])
)
?
count
(
$f
[
$i
][
"inputs"
])
:
0
;
echo
'<i class="fa fa-file-text-o"></i> '
.
$f
[
$i
][
'name'
]
.
" ("
.
$countQ
.
" inputs)<br/>"
;
}
...
...
@@ -193,7 +193,7 @@ var oform = {
// params : { onText : "Oui", offText : "Non", onLabel : "Oui", offLabel : "Non",
// labelText : "Activé"},
// checked : false },
//
id
s : {
//
subForm
s : {
// inputType : "array",
// label : "Nommé chaque étape de votre questionnaire",
// //subLabel : "Vous remplirez les question de chaques étapes par la suite",
...
...
views/tpls/forms/wizard.php
View file @
0e7ea975
...
...
@@ -19,6 +19,7 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
}
}
if
(
isset
(
$form
[
"subForms"
])
&&
count
(
$form
[
"subForms"
])
>
1
)
{
?>
<div
class=
"col-xs-12 margin-top-20"
>
<div
id=
"
<?php
echo
$wizid
?>
"
class=
"swMain"
>
...
...
@@ -44,15 +45,12 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
// var_dump($listSteps); exit;
$activeStep
=
0
;
$nextStepValid
=
true
;
foreach
(
$formList
as
$k
=>
$v
)
{
foreach
(
$form
[
"subForms"
]
as
$k
=>
$v
)
{
$n
=
"todo"
;
$p
=
null
;
$form
=
PHDB
::
findOne
(
Form
::
COLLECTION
,[
"id"
=>
$v
]
);
if
(
!
empty
(
$form
)
)
$n
=
$form
[
"name"
];
if
(
!
empty
(
$form
s
[
$v
]
)
)
$n
=
$form
s
[
$v
]
[
"name"
];
echo
"<li>"
;
...
...
@@ -65,7 +63,7 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
$k
==
0
||
(
isset
(
$answer
[
"step"
])
&&
$answer
[
"step"
]
==
"all"
)
||
(
isset
(
$parentForm
[
"hasStepValidations"
])
&&
isset
(
$answer
[
"step"
])
&&
$k
<=
array_search
(
$answer
[
"step"
],
$form
List
)
)
||
(
isset
(
$parentForm
[
"hasStepValidations"
])
&&
isset
(
$answer
[
"step"
])
&&
$k
<=
array_search
(
$answer
[
"step"
],
$form
[
"subForms"
]
)
)
||
(
isset
(
$parentForm
[
"hasStepValidations"
])
&&
!
isset
(
$answer
[
"step"
])
&&
$k
<=
$parentForm
[
"hasStepValidations"
]
)
)
{
$d
=
'class="done"'
;
...
...
@@ -85,18 +83,14 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
<?php
foreach
(
$form
List
as
$k
=>
$v
)
{
foreach
(
$form
[
"subForms"
]
as
$k
=>
$v
)
{
$hide
=
(
$k
==
$activeStep
)
?
""
:
"hide"
;
?>
<div
id=
'
<?php
echo
$v
;
?>
'
class=
'col-sm-offset-1 col-sm-10 sectionStep
<?php
echo
$hide
;
?>
'
style=
"padding-bottom:40px"
>
<?php
$form
=
PHDB
::
findOne
(
Form
::
COLLECTION
,[
"id"
=>
$v
]
);
?>
<script
type=
"text/javascript"
>
formInputs
[
"
<?php
echo
$v
?>
"
]
=
<?php
echo
(
!
empty
(
$form
[
'inputs'
])
?
json_encode
(
$form
[
'inputs'
]
)
:
json_encode
([])
)
?>
;
formInputs
[
"
<?php
echo
$v
?>
"
]
=
<?php
echo
(
!
empty
(
$form
s
[
$v
]
[
'inputs'
])
?
json_encode
(
$form
s
[
$v
]
[
'inputs'
]
)
:
json_encode
([])
)
?>
;
var
formInputsHere
=
formInputs
;
jQuery
(
document
).
ready
(
function
()
{
mylog
.
log
(
"
render
"
,
"
survey.views.tpls.forms.wizard
"
);
...
...
@@ -119,23 +113,23 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
</script>
<?php
if
(
!
empty
(
$form
)
)
if
(
!
empty
(
$form
s
[
$v
]
)
)
{
echo
'<h1 class="text-center" style="color:'
.
$color1
.
'" >'
.
@
$form
[
"name"
]
.
'</h1>'
;
echo
'<h1 class="text-center" style="color:'
.
$color1
.
'" >'
.
@
$form
s
[
$v
]
[
"name"
]
.
'</h1>'
;
echo
"<div class='text-center'>"
;
if
(
isset
(
$this
->
costum
[
"cms"
][
$form
[
"id"
]
.
"desc"
]))
echo
htmlentities
(
$this
->
costum
[
"cms"
][
$form
[
"id"
]
.
"desc"
]);
if
(
isset
(
$this
->
costum
[
"cms"
][
$form
s
[
$v
]
[
"id"
]
.
"desc"
]))
echo
htmlentities
(
$this
->
costum
[
"cms"
][
$form
s
[
$v
]
[
"id"
]
.
"desc"
]);
else
echo
"<span style='color:#aaa'>* section description</span>"
;
if
(
@
$canEditForm
)
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
"<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='"
.
@
$form
s
[
$v
]
[
"id"
]
.
"desc' data-type='textarea' data-markdown='1' data-path='costum.cms."
.
@
$form
s
[
$v
]
[
"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=''>"
;
echo
$this
->
renderPartial
(
"survey.views.tpls.forms.formSection"
,
[
"formId"
=>
$v
,
"form"
=>
$form
,
"form"
=>
$form
s
[
$v
]
,
"wizard"
=>
true
,
"answer"
=>
$answer
,
"mode"
=>
@
$mode
,
...
...
@@ -157,13 +151,37 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
?>
<script
type=
"text/javascript"
>
</script>
</div>
<?php
}
else
if
(
isset
(
$form
[
"subForms"
])
&&
count
(
$form
[
"subForms"
])
==
1
)
{
echo
"<div class='col-xs-12'>"
;
echo
'<h1 class="text-center" style="color:'
.
$color1
.
'" >'
.
@
$forms
[
$v
][
"name"
]
.
'</h1>'
;
echo
"<div class='text-center'>"
;
if
(
isset
(
$this
->
costum
[
"cms"
][
$forms
[
$v
][
"id"
]
.
"desc"
]))
echo
htmlentities
(
$this
->
costum
[
"cms"
][
$forms
[
$v
][
"id"
]
.
"desc"
]);
else
echo
"<span style='color:#aaa'>* section description</span>"
;
if
(
@
$canEditForm
)
echo
"<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='"
.
@
$forms
[
$v
][
"id"
]
.
"desc' data-type='textarea' data-markdown='1' data-path='costum.cms."
.
@
$forms
[
$v
][
"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=''>"
;
echo
$this
->
renderPartial
(
"survey.views.tpls.forms.formSection"
,
[
"formId"
=>
$form
[
"subForms"
][
0
],
"form"
=>
$forms
[
$form
[
"subForms"
][
0
]],
"wizard"
=>
true
,
"answer"
=>
$answer
,
"mode"
=>
@
$mode
,
"showForm"
=>
$showForm
,
"canEdit"
=>
$canEdit
,
"canEditForm"
=>
@
$canEditForm
,
"el"
=>
$el
]
,
true
);
echo
"</div>"
;
echo
"</div>"
;
}
else
{
echo
"<div class='col-xs-12 text-center'>"
;
echo
'<br/><h4 class="text-red text-center">ce formulaire est encore vide</h4>'
;
echo
"<a href='javascript:;' data-id='"
.
(
String
)
$form
[
"_id"
]
.
"' class='configBtn btn btn-danger bold'> <i class='fa fa-cogs'></i> CONFIGUREZ LE ICI </a>"
;
echo
"</div>"
;
}
?>
</div>
\ No newline at end of file
views/tpls/views/index.php
View file @
0e7ea975
...
...
@@ -157,7 +157,8 @@ if(isset($this->costum["cms"]["color1"]))
if
(
$showForm
){
$params
=
[
"formList"
=>
$formList
,
"parentForm"
=>
$parentForm
,
"form"
=>
$form
,
"el"
=>
$el
,
"active"
=>
"all"
,
"color1"
=>
$color1
,
...
...
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