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
9f944568
Commit
9f944568
authored
Apr 15, 2020
by
Raph El
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form : update for co
parent
553ea577
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
44 deletions
+92
-44
assets/js/form.js
assets/js/form.js
+50
-23
controllers/answer/GetAction.php
controllers/answer/GetAction.php
+7
-14
views/tpls/forms/cplx/decideFromBudget.php
views/tpls/forms/cplx/decideFromBudget.php
+10
-3
views/tpls/forms/cplx/financement.php
views/tpls/forms/cplx/financement.php
+8
-1
views/tpls/forms/cplx/financementFromBudget.php
views/tpls/forms/cplx/financementFromBudget.php
+8
-1
views/tpls/forms/cplx/suiviFromBudget.php
views/tpls/forms/cplx/suiviFromBudget.php
+8
-1
views/tpls/forms/formWizard.php
views/tpls/forms/formWizard.php
+1
-1
No files found.
assets/js/form.js
View file @
9f944568
...
...
@@ -55,10 +55,11 @@ var formObj = {
},
"
html
"
);
},
answer
:
function
(
fObj
,
id
,
form
){
mylog
.
log
(
"
fObj.urls.answer
"
,
fObj
,
id
,
form
);
var
url
=
'
/survey/answer/index/id/
'
+
id
;
if
(
typeof
form
!=
"
undefined
"
&&
form
!=
null
)
url
+=
'
/form/
'
+
form
;
ajaxPost
(
fObj
.
container
,
baseUrl
+
'
/survey/answer/index/id/
'
+
id
,
ajaxPost
(
fObj
.
container
,
baseUrl
+
url
,
null
,
function
(){
history
.
replaceState
(
location
.
hash
,
""
,
hashUrlPage
+
"
.view.forms.answer.
"
+
id
);
...
...
@@ -196,26 +197,30 @@ formObj.views.form = function(id, form){
else
str
+=
'
<span class="label label-danger">Pas activé</span>
'
;
str
+=
"
<br/>
"
;
if
(
typeof
form
.
active
!=
"
undefined
"
&&
form
.
active
===
true
){
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class=" apply btn btn-xs btn-primary col-sm-12 bold">
'
+
'
<i class="fa fa-file-text-o"></i> Apply
'
+
str
+=
'
<div class="col-xs-12">
'
;
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class="myAnswers btn btn-xs btn-primary col-sm-12 bold">
'
+
'
<i class="fa fa-pencil"></i> My answers
'
+
'
</a>
'
;
if
(
typeof
form
.
active
!=
"
undefined
"
&&
form
.
active
===
true
){
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class=" application btn btn-xs btn-primary col-sm-12 bold">
'
+
'
<i class="fa fa-file-text-o"></i> Application Form
'
+
'
</a>
'
;
if
(
typeof
form
.
canEditForm
!=
"
undefined
"
&&
form
.
canEditForm
===
true
){
str
+=
'
<a href="#form.edit.id.
'
+
id
+
'
" class="btn btn-xs btn-primary col-sm-12 bold">
'
+
'
<i class="fa fa-pencil"></i> Answers
'
+
'
</a>
'
;
}
}
else
{
if
(
typeof
form
.
canEditForm
!=
"
undefined
"
&&
form
.
canEditForm
===
true
){
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class="btn btn-xs btn-primary config col-sm-12 bold">
'
+
'
<i class="fa fa-pencil"></i> CONSTRUIRE
'
+
'
</a>
'
;
if
(
typeof
form
.
canEditForm
!=
"
undefined
"
&&
form
.
canEditForm
===
true
){
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class="allAnswers btn btn-xs btn-primary col-sm-12 bold">
'
+
'
<i class="fa fa-pencil"></i> All Answers
'
+
'
</a>
'
;
}
}
else
{
if
(
typeof
form
.
canEditForm
!=
"
undefined
"
&&
form
.
canEditForm
===
true
){
str
+=
'
<a href="javascript:;" data-id="
'
+
id
+
'
" class="btn btn-xs btn-primary config col-sm-12 bold">
'
+
'
<i class="fa fa-pencil"></i> Build
'
+
'
</a>
'
;
}
}
}
str
+=
'
</div>
'
+
str
+=
'
</div>
'
+
'
</div>
'
+
'
</div>
'
+
'
</div>
'
;
return
str
;
...
...
@@ -230,15 +235,37 @@ formObj.events.add = function(fObj){
};
formObj
.
events
.
form
=
function
(
fObj
){
$
(
fObj
.
container
+
'
.appl
y
'
).
off
().
on
(
"
click
"
,
function
(){
$
(
fObj
.
container
+
'
.appl
ication
'
).
off
().
on
(
"
click
"
,
function
(){
fObj
.
urls
.
answer
(
fObj
,
"
new
"
,
$
(
this
).
data
(
"
id
"
));
// ajaxPost(fObj.container, baseUrl+'/survey/answer/index/id/new/form/'+$(this).data("id"),
// null,
});
$
(
fObj
.
container
+
'
.allAnswers
'
).
off
().
on
(
"
click
"
,
function
(){
getAjax
(
fObj
.
container
,
baseUrl
+
"
/survey/answer/get/form/
"
+
$
(
this
).
data
(
"
id
"
),
function
(){
},
"
html
"
);
});
$
(
fObj
.
container
+
'
.myAnswers
'
).
off
().
on
(
"
click
"
,
function
(){
// ajaxPost(fObj.results.dom, baseUrl+"/survey/answer/views/",
// data,
// function(){
// },"html");
// fObj.results.events(fObj);
// });
// var data{
// allAnswers=results
// }
// if(Object.keys(results).length > 0){
// ajaxPost(fObj.results.dom, baseUrl+"/survey/answer/views/",
// data,
// function(){
// fObj.results.events(fObj);
// });
// }
});
$
(
fObj
.
container
+
'
.config
'
).
off
().
on
(
"
click
"
,
function
(){
var
idForm
=
$
(
this
).
data
(
"
id
"
);
fObj
.
urls
.
form
(
fObj
,
idForm
);
...
...
controllers/answer/GetAction.php
View file @
9f944568
...
...
@@ -3,30 +3,20 @@ class GetAction extends CTKAction
{
//if $slug : getd all the forms for an element.slug
//if $id : opens the forms
public
function
run
(
$form
)
public
function
run
(
$form
=
null
,
$userId
=
null
)
{
$controller
=
$this
->
getController
();
$controller
->
layout
=
"//layouts/empty"
;
$tpl
=
(
!
empty
(
$params
[
"parentForm"
][
"answersTpl"
]))
?
$params
[
"parentForm"
][
"answersTpl"
]
:
'survey.views.tpls.forms.cplx.answers'
;
$controller
->
layout
=
"//layouts/empty"
;
$params
=
[];
$params
[
"form"
]
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"_id"
=>
new
MongoId
(
$form
)
]
);
//var_dump($params["form"]);exit;
$params
[
"forms"
]
=
[];
foreach
(
$params
[
"form
List
"
]
as
$ix
=>
$formId
)
{
foreach
(
$params
[
"form
"
][
"subForms
"
]
as
$ix
=>
$formId
)
{
$f
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
[
"id"
=>
$formId
]);
$params
[
"forms"
][
$formId
]
=
$f
;
}
$params
[
"what"
]
=
(
isset
(
$params
[
"form"
][
"what"
]))
?
$params
[
"form"
][
"what"
]
:
"réponses"
;
$el
=
Slug
::
getElementBySlug
(
$params
[
"form"
][
"parentSlug"
]
);
$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"]["subForms"]) , "parentSlug" => $params["form"]["parentSlug"]] );
$params
[
'el'
]
=
Form
::
getFirstParentForm
(
$params
[
"form"
]);
$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"
])
...
...
@@ -34,6 +24,9 @@ class GetAction extends CTKAction
$params
[
"wizid"
]
=
$form
;
$tpl
=
(
!
empty
(
$params
[
"form"
][
"answersTpl"
]))
?
$params
[
"form"
][
"answersTpl"
]
:
'survey.views.tpls.forms.cplx.answers'
;
if
(
Yii
::
app
()
->
request
->
isAjaxRequest
)
echo
$controller
->
renderPartial
(
$tpl
,
$params
,
true
);
else
...
...
views/tpls/forms/cplx/decideFromBudget.php
View file @
9f944568
...
...
@@ -51,7 +51,14 @@ if( isset($parentForm["params"][$kunik]) ) {
$paramsData
[
"amounts"
]
=
$parentForm
[
"params"
][
$kunik
][
"amounts"
];
}
$communityLinks
=
Element
::
getCommunityByTypeAndId
(
$this
->
costum
[
"contextType"
],
$this
->
costum
[
"contextId"
]);
$communityLinks
=
array
();
if
(
!
empty
(
$form
[
"parent"
])){
foreach
(
$form
[
"parent"
]
as
$key
=>
$value
)
{
$cl
=
Element
::
getCommunityByTypeAndId
(
$key
,
$value
[
"type"
]);
if
(
!
empty
(
$cl
))
$communityLinks
=
array_merge
(
$communityLinks
,
$cl
);
}
}
$organizations
=
Link
::
groupFindByType
(
Organization
::
COLLECTION
,
$communityLinks
,[
"name"
,
"links"
]
);
$orgs
=
[];
...
...
@@ -288,9 +295,9 @@ if( isset($parentForm["params"]["financement"]["tpl"])){
?>
<script
type=
"text/javascript"
>
if
(
typeof
costum
.
lists
==
"
undefined
"
)
if
(
typeof
costum
!=
"
undefined
"
&&
costum
!=
null
&&
typeof
costum
.
lists
==
"
undefined
"
)
costum
.
lists
=
{};
if
(
typeof
costum
.
lists
==
"
undefined
"
)
if
(
typeof
costum
!=
"
undefined
"
&&
costum
!=
null
&&
typeof
costum
.
lists
==
"
undefined
"
)
costum
.
lists
.
budgetInputList
=
<?php
echo
json_encode
(
Yii
::
app
()
->
session
[
"budgetInputList"
]
);
?>
;
//costum.lists.financerTypeList =
<?php
//echo json_encode(Ctenat::$financerTypeList); ?>;
costum
.
lists
.
workerList
=
<?
php
echo
json_encode
(
$orgs
);
?>
;
...
...
views/tpls/forms/cplx/financement.php
View file @
9f944568
...
...
@@ -8,7 +8,14 @@
$editParamsBtn
=
(
$canEdit
)
?
" <a href='javascript:;' data-id='"
.
$el
[
"_id"
]
.
"' data-collection='"
.
$this
->
costum
[
"contextType"
]
.
"' data-path='costum.form.params."
.
$kunik
.
"' class='previewTpl edit"
.
$kunik
.
"Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>"
:
""
;
$communityLinks
=
Element
::
getCommunityByTypeAndId
(
$this
->
costum
[
"contextType"
],
$this
->
costum
[
"contextId"
]);
$communityLinks
=
array
();
if
(
!
empty
(
$form
[
"parent"
])){
foreach
(
$form
[
"parent"
]
as
$key
=>
$value
)
{
$cl
=
Element
::
getCommunityByTypeAndId
(
$key
,
$value
[
"type"
]);
if
(
!
empty
(
$cl
))
$communityLinks
=
array_merge
(
$communityLinks
,
$cl
);
}
}
$persons
=
Link
::
groupFindByType
(
Person
::
COLLECTION
,
$communityLinks
,[
"name"
,
"links"
]
);
$organizations
=
Link
::
groupFindByType
(
Organization
::
COLLECTION
,
$communityLinks
,[
"name"
,
"links"
]
);
$financers
=
array_merge
(
$persons
,
$organizations
);
...
...
views/tpls/forms/cplx/financementFromBudget.php
View file @
9f944568
...
...
@@ -49,8 +49,15 @@ if( isset($parentForm["params"][$kunik]) ) {
if
(
isset
(
$parentForm
[
"params"
][
$kunik
][
"openFinancing"
])
)
$paramsData
[
"openFinancing"
]
=
$parentForm
[
"params"
][
$kunik
][
"openFinancing"
];
}
$communityLinks
=
array
();
if
(
!
empty
(
$form
[
"parent"
])){
foreach
(
$form
[
"parent"
]
as
$key
=>
$value
)
{
$cl
=
Element
::
getCommunityByTypeAndId
(
$key
,
$value
[
"type"
]);
if
(
!
empty
(
$cl
))
$communityLinks
=
array_merge
(
$communityLinks
,
$cl
);
}
}
$communityLinks
=
Element
::
getCommunityByTypeAndId
(
$this
->
costum
[
"contextType"
],
$this
->
costum
[
"contextId"
]);
$organizations
=
Link
::
groupFindByType
(
Organization
::
COLLECTION
,
$communityLinks
,[
"name"
,
"links"
]
);
$orgs
=
[];
...
...
views/tpls/forms/cplx/suiviFromBudget.php
View file @
9f944568
...
...
@@ -66,7 +66,14 @@ if( isset($parentForm["params"][$kunik]["limitRoles"]) )
if
(
isset
(
$parentForm
[
"params"
][
$kunik
][
"budgetCopy"
])
)
$paramsData
[
"budgetCopy"
]
=
$parentForm
[
"params"
][
$kunik
][
"budgetCopy"
];
$communityLinks
=
Element
::
getCommunityByTypeAndId
(
$this
->
costum
[
"contextType"
],
$this
->
costum
[
"contextId"
]);
$communityLinks
=
array
();
if
(
!
empty
(
$form
[
"parent"
])){
foreach
(
$form
[
"parent"
]
as
$key
=>
$value
)
{
$cl
=
Element
::
getCommunityByTypeAndId
(
$key
,
$value
[
"type"
]);
if
(
!
empty
(
$cl
))
$communityLinks
=
array_merge
(
$communityLinks
,
$cl
);
}
}
$organizations
=
Link
::
groupFindByType
(
Organization
::
COLLECTION
,
$communityLinks
,[
"name"
,
"links"
]
);
$orgs
=
[];
...
...
views/tpls/forms/formWizard.php
View file @
9f944568
...
...
@@ -158,7 +158,7 @@ if(isset($this->costum["cms"]["color1"]))
"what"
=>
"dossiers"
,
"wizid"
=>
$wizardUid
];
echo
$this
->
renderPartial
(
$
this
->
costum
[
"f
orm
"
]
[
"answersTpl"
],
$params
);
echo
$this
->
renderPartial
(
$
parentF
orm
[
"answersTpl"
],
$params
);
}
if
(
$mode
==
"fa"
&&
$canEditForm
===
true
){
...
...
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