Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pixel Humain
survey
Commits
7734212a
Commit
7734212a
authored
Mar 05, 2020
by
Tibor Katelbach
Browse files
Merge remote-tracking branch 'origin/qa' into qa
parents
a4b000be
e227b42a
Changes
49
Hide whitespace changes
Inline
Side-by-side
controllers/AnswerController.php
0 → 100644
View file @
7734212a
<?php
class
AnswerController
extends
CommunecterController
{
protected
function
beforeAction
(
$action
)
{
//parent::initPage();
return
parent
::
beforeAction
(
$action
);
}
public
function
actions
()
{
return
array
(
'new'
=>
'survey.controllers.answer.NewAction'
,
'index'
=>
'survey.controllers.answer.IndexAction'
,
'all'
=>
'survey.controllers.answer.AllAction'
);
}
}
controllers/CoController.php
View file @
7734212a
...
...
@@ -18,8 +18,9 @@ class CoController extends CommunecterController {
public
function
actions
()
{
return
array
(
'init'
=>
'survey.controllers.actions.openForm.InitAction'
,
'index'
=>
'survey.controllers.actions.IndexAction'
,
'init'
=>
'survey.controllers.actions.InitAction'
,
'form'
=>
'survey.controllers.actions.FormAction'
,
'forms'
=>
'survey.controllers.actions.FormsAction'
,
...
...
controllers/FormController.php
0 → 100644
View file @
7734212a
<?php
class
FormController
extends
CommunecterController
{
protected
function
beforeAction
(
$action
)
{
//parent::initPage();
return
parent
::
beforeAction
(
$action
);
}
public
function
actions
()
{
return
array
(
'create'
=>
'survey.controllers.openForm.CreateAction'
,
'edit'
=>
'survey.controllers.openForm.EditAction'
,
);
}
}
controllers/answer/IndexAction.php
0 → 100644
View file @
7734212a
<?php
class
IndexAction
extends
CAction
{
public
function
run
(
$id
=
null
,
$answer
=
null
,
$tpl
=
null
)
{
$this
->
getController
()
->
layout
=
"//layouts/empty"
;
$params
=
[
"canEdit"
=>
true
];
// if( isset($test) ){
// $params["tpl"]=$id;
//}
if
(
!
empty
(
$id
)){
$params
[
"answerId"
]
=
$id
;
}
$params
=
Form
::
getDataForAnswer
(
$params
);
$tpl
=
(
!
empty
(
$tpl
))
?
$tpl
:
"survey.views.tpls.forms.formWizard"
;
echo
$this
->
getController
()
->
renderPartial
(
$tpl
,
$params
);
}
}
\ No newline at end of file
controllers/a
ctions/Init
Action.php
→
controllers/a
nswer/New
Action.php
View file @
7734212a
<?php
class
Init
Action
extends
CAction
class
New
Action
extends
CAction
{
public
function
run
(
$id
=
null
,
$tpl
=
null
)
{
$this
->
getController
()
->
layout
=
"//layouts/empty"
;
$params
=
[
"canEdit"
=>
true
];
if
(
isset
(
$test
)
){
$params
[
"tpl"
]
=
$id
;
// $params["test"]=$test;
}
$params
=
array
(
"canEdit"
=>
true
,
"answerId"
=>
"new"
);
if
(
isset
(
$test
)
){
$params
[
"tpl"
]
=
$id
;
}
$params
=
Form
::
getDataForAnswer
(
$params
);
$tpl
=
(
!
empty
(
$tpl
))
?
$tpl
:
"survey.views.tpls.forms.formWizard"
;
echo
$this
->
getController
()
->
renderPartial
(
$tpl
,
$params
);
}
...
...
controllers/openForm/CreateAction.php
0 → 100644
View file @
7734212a
controllers/openForm/EditAction.php
0 → 100644
View file @
7734212a
<?php
class
InitAction
extends
CAction
{
public
function
run
(
$id
=
null
,
$answer
=
null
,
$tpl
=
null
)
{
$this
->
getController
()
->
layout
=
"//layouts/empty"
;
$params
=
[
"canEdit"
=>
true
];
if
(
isset
(
$test
)
){
$params
[
"tpl"
]
=
$id
;
}
if
(
!
empty
(
$anwserId
)){
$params
[
"answerId"
]
=
$answer
;
}
$params
=
Form
::
getDataForAnswer
(
$params
);
$tpl
=
(
!
empty
(
$tpl
))
?
$tpl
:
"costum.views.custom.co.formWizard"
;
echo
$this
->
getController
()
->
renderPartial
(
$tpl
,
$params
);
}
}
\ No newline at end of file
models/Form.php
View file @
7734212a
...
...
@@ -636,11 +636,27 @@ class Form {
if
(
isset
(
Yii
::
app
()
->
session
[
'costum'
][
"hasOpenForm"
])){
if
(
isset
(
Yii
::
app
()
->
session
[
'costum'
][
"isMultiForms"
])){
$params
[
"formList"
]
=
Yii
::
app
()
->
session
[
"costum"
][
"form"
][
"ids"
];
$params
[
"formId"
]
=
implode
(
"|"
,
$params
[
"formList"
]);
$answerId
=
null
;
$answer
=
null
;
$generateAnswer
=
false
;
if
(
isset
(
$_GET
[
'answer'
]))
$answerId
=
$_GET
[
'answer'
];
else
if
(
isset
(
$params
[
"answerId"
]))
$answerId
=
$params
[
"answerId"
];
//var_dump($answerId);
if
(
!
empty
(
$answerId
)
&&
$answerId
!=
"new"
)
$answer
=
self
::
getAnswerById
(
$answerId
);
//var_dump($answer);exit;
if
(
!
empty
(
$answer
)){
$params
[
"formList"
]
=
explode
(
"|"
,
$answer
[
"formId"
]);
$params
[
"formId"
]
=
$answer
[
"formId"
];
}
else
if
(
isset
(
Yii
::
app
()
->
session
[
"costum"
][
"form"
])){
$params
[
"formList"
]
=
Yii
::
app
()
->
session
[
"costum"
][
"form"
][
"ids"
];
$params
[
"formId"
]
=
implode
(
"|"
,
$params
[
"formList"
]);
}
//when inputs are interdependant on other inputs
$budgetInputList
=
[];
$allforms
=
[];
...
...
@@ -676,9 +692,11 @@ class Form {
// $answer = ( isset(Yii::app()->session["costum"]["form"]["canModifyAnswer"]) && isset($_GET['answer'])) ? PHDB::findOne( Form::ANSWER_COLLECTION,[ "_id" => new MongoId($_GET['answer']) ] ) : null;
$answer
=
(
isset
(
$_GET
[
'answer'
])
&&
$_GET
[
'answer'
]
!=
"new"
)
?
PHDB
::
findOne
(
Form
::
ANSWER_COLLECTION
,[
"_id"
=>
new
MongoId
(
$_GET
[
'answer'
])
]
)
:
null
;
if
(
!
isset
(
$params
[
"el"
])
&&
!
empty
(
$answer
)
&&
isset
(
$answer
[
"parentSlug"
]))
$params
[
"el"
]
=
Slug
::
getElementBySlug
(
$answer
[
"parentSlug"
])[
"el"
];
$showForm
=
true
;
$generateAnswer
=
false
;
$myAnswers
=
PHDB
::
find
(
Form
::
ANSWER_COLLECTION
,[
"formId"
=>
$params
[
"formId"
],
"parentSlug"
=>
$params
[
"el"
][
"slug"
],
...
...
@@ -686,48 +704,44 @@ class Form {
if
(
!
isset
(
Yii
::
app
()
->
session
[
"costum"
][
"form"
][
"oneAnswerPerPerson"
])
||
count
(
$myAnswers
)
==
0
)
{
//si ya qu'une réponse et on la charge directe
/*if(count($myAnswers) == 1 )
$answer = $myAnswers[ array_keys($myAnswers)[0] ];
else {
//sinon on cherche la reponse incomplete
foreach ($myAnswers as $id => $ans)
{
//chercher les reponse incomplete
//var_dump(isset( $ans["answers"] ) );
if(!isset( $ans["answers"]) && $answer == null )
$answer = $ans;
}
}*/
if
(
$answer
==
null
&&
count
(
$myAnswers
)
>
1
&&
!
$params
[
"canEdit"
]
)
$showForm
=
false
;
//si aucune reponse existe
//et qu'on a des input complexe alors on génere une answer
if
(
!
isset
(
$_GET
[
'answer'
])
&&
$answer
==
null
)
{
if
(
isset
(
$params
[
"formList"
])){
$generateAnswer
=
true
;
}
else
if
(
isset
(
$form
[
"inputs"
])){
foreach
(
$form
[
"inputs"
]
as
$key
=>
$inp
)
{
if
(
stripos
(
$inp
[
"type"
]
,
"tpls.forms.cplx"
)
!==
false
)
$generateAnswer
=
true
;
}
}
}
if
(
isset
(
$_GET
[
'answer'
])
&&
$_GET
[
'answer'
]
==
"new"
)
$generateAnswer
=
true
;
if
(
!
isset
(
Yii
::
app
()
->
session
[
"costum"
][
"form"
][
"oneAnswerPerPerson"
])
||
count
(
$myAnswers
)
==
0
){
//si ya qu'une réponse et on la charge directe
if
(
count
(
$myAnswers
)
==
1
)
$answer
=
$myAnswers
[
array_keys
(
$myAnswers
)[
0
]
];
else
{
//sinon on cherche la reponse incomplete
foreach
(
$myAnswers
as
$id
=>
$ans
)
{
//chercher les reponse incomplete
if
(
!
isset
(
$ans
[
"answers"
])
&&
$answer
==
null
)
$answer
=
$ans
;
}
}
if
(
$answer
==
null
&&
count
(
$myAnswers
)
>
1
&&
!
$canEdit
)
$showForm
=
false
;
//si aucune reponse existe
//et qu'on a des input complexe alors on génere une answer
if
(
!
isset
(
$_GET
[
'answer'
])
&&
$answer
==
null
){
if
(
isset
(
$params
[
"formList"
])){
$generateAnswer
=
true
;
}
else
if
(
isset
(
$form
[
"inputs"
])){
foreach
(
$form
[
"inputs"
]
as
$key
=>
$inp
)
{
if
(
stripos
(
$inp
[
"type"
]
,
"tpls.forms.cplx"
)
!==
false
)
$generateAnswer
=
true
;
}
}
}
if
(
isset
(
$answerId
)
&&
$answerId
==
"new"
)
$generateAnswer
=
true
;
//on pré genere un anwser que quand il n'y en pas
//pour permettre le save onBlur , ou s'il y a des cplx forms
//il ne peut y avoir qu'un seul answer en cours simultanement
//on pré genere un anwser que quand il n'y en pas
//pour permettre le save onBlur , ou s'il y a des cplx forms
...
...
@@ -772,9 +786,7 @@ class Form {
echo
"<h4 class='text-center text-red'><i class='fa fa-warning'></i> Une seul réponse n'est possible.</h4>"
;
echo
"<a class='btn btn-primary' href='/costum/co/index/slug/"
.
$el
[
"slug"
]
.
"/answer/"
.
$myAnswers
[
0
]
.
"'>Votre réponse</a>"
;
}
}
return
$params
;
}
...
...
views/tpls/acceptAndAdmin.php
0 → 100644
View file @
7734212a
<?php
if
(
!
isset
(
$el
[
"costum"
][
"slug"
]
)
||
(
isset
(
$el
[
"costum"
][
"slug"
])
&&
$el
[
"costum"
][
"slug"
]
!=
$tpl
)
)
$test
=
$tpl
;
if
(
isset
(
$test
)
||
$canEdit
)
{
?>
<script
type=
"text/javascript"
>
//contains all dynform definitions for complexe inputs
//it also carries sub dynforms, when an input needs extra parameters to
var
sectionDyf
=
{};
var
tplCtx
=
{};
var
DFdata
=
{
'
tpl
'
:
'
<?php
echo
$tpl
?>
'
,
"
id
"
:
"
<?php
echo
Yii
::
app
()
->
session
[
"costum"
][
"contextId"
]
?>
"
};
costum
.
col
=
"
<?php
echo
Yii
::
app
()
->
session
[
"costum"
][
"contextType"
]
?>
"
;
costum
.
ctrl
=
"
<?php
echo
Element
::
getControlerByCollection
(
Yii
::
app
()
->
session
[
"costum"
][
"contextType"
])
?>
"
;
var
configDynForm
=
<?php
echo
json_encode
(
Yii
::
app
()
->
session
[
'costum'
][
'dynForm'
]);
?>
;
var
tplsList
=
<?php
echo
json_encode
((
isset
(
Yii
::
app
()
->
session
[
'costum'
][
'tpls'
]))
?
Yii
::
app
()
->
session
[
'costum'
][
'tpls'
]
:
null
);
?>
;
function
saveThisTpl
(
slug
)
{
data
=
{
collection
:
costum
.
contextType
,
id
:
costum
.
contextId
,
path
:
"
costum.slug
"
,
value
:
'
<?php
echo
$tpl
?>
'
}
mylog
.
log
(
"
.saveThisTpl
"
,
"
data
"
,
data
);
// http://127.0.0.1/costum/co/index/slug/administration-opal/test/campagne#
dataHelper
.
path2Value
(
data
,
function
(
params
)
{
var
s
=
location
.
href
;
var
a
=
s
.
split
(
'
/
'
);
s
=
s
.
replace
(
a
[
a
.
length
-
2
]
+
'
/
'
,
''
);
s
=
s
.
replace
(
a
[
a
.
length
-
1
],
''
);
location
.
href
=
s
;
}
);
}
function
previewTpl
()
{
$
(
'
#acceptAndAdmin,.editBtn,.editQuestion,.addQuestion,.deleteLine, .previewTpl
'
).
fadeOut
();
}
jQuery
(
document
).
ready
(
function
()
{
mylog
.
log
(
"
render
"
,
"
/modules/costum/views/tpls/acceptAndAdmin.php
"
);
$
(
"
.editBtn
"
).
off
().
on
(
"
click
"
,
function
()
{
var
activeForm
=
{
"
jsonSchema
"
:
{
"
title
"
:
"
Template config
"
,
"
type
"
:
"
object
"
,
"
properties
"
:
{
}
}
};
if
(
configDynForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
])
activeForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
]
=
configDynForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
];
else
activeForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
]
=
{
label
:
$
(
this
).
data
(
"
label
"
)
};
if
(
$
(
this
).
data
(
"
label
"
))
activeForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
].
label
=
$
(
this
).
data
(
"
label
"
);
if
(
$
(
this
).
data
(
"
type
"
)){
activeForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
].
inputType
=
$
(
this
).
data
(
"
type
"
);
if
(
$
(
this
).
data
(
"
type
"
)
==
"
textarea
"
&&
$
(
this
).
data
(
"
markdown
"
)
)
activeForm
.
jsonSchema
.
properties
[
$
(
this
).
data
(
"
key
"
)
].
markdown
=
true
;
}
tplCtx
.
id
=
contextData
.
id
;
tplCtx
.
collection
=
contextData
.
type
;
tplCtx
.
key
=
$
(
this
).
data
(
"
key
"
);
tplCtx
.
path
=
$
(
this
).
data
(
"
path
"
);
activeForm
.
jsonSchema
.
save
=
function
()
{
tplCtx
.
value
=
$
(
"
#
"
+
tplCtx
.
key
).
val
();
//alert("#"+tplCtx.key+" : "+$( "#"+tplCtx.key ).val());
console
.
log
(
"
activeForm save tplCtx
"
,
tplCtx
);
if
(
typeof
tplCtx
.
value
==
"
undefined
"
)
toastr
.
error
(
'
value cannot be empty!
'
);
else
{
dataHelper
.
path2Value
(
tplCtx
,
function
(
params
)
{
$
(
"
#ajax-modal
"
).
modal
(
'
hide
'
);
location
.
reload
();
}
);
}
}
dyFObj
.
openForm
(
activeForm
);
});
$
(
'
.deleteLine
'
).
off
().
click
(
function
(){
formId
=
$
(
this
).
data
(
"
id
"
);
key
=
$
(
this
).
data
(
"
key
"
);
pathLine
=
$
(
this
).
data
(
"
path
"
);
collection
=
$
(
this
).
data
(
"
collection
"
);
bootbox
.
dialog
({
title
:
"
Confirmez la suppression
"
,
message
:
"
<span class='text-red bold'><i class='fa fa-warning'></i> Cette action sera irréversible</span>
"
,
buttons
:
[
{
label
:
"
Ok
"
,
className
:
"
btn btn-primary pull-left
"
,
callback
:
function
()
{
var
formQ
=
{
value
:
null
,
collection
:
collection
,
id
:
formId
,
path
:
pathLine
};
dataHelper
.
path2Value
(
formQ
,
function
(
params
)
{
$
(
"
#
"
+
key
).
remove
();
//location.reload();
}
);
}
},
{
label
:
"
Annuler
"
,
className
:
"
btn btn-default pull-left
"
,
callback
:
function
()
{}
}
]
});
});
$
(
"
.editTpl
"
).
off
().
on
(
"
click
"
,
function
()
{
var
activeForm
=
{
"
jsonSchema
"
:
{
"
title
"
:
"
Edit Question config
"
,
"
type
"
:
"
object
"
,
"
properties
"
:
{}
}
};
$
.
each
(
formTpls
[
$
(
this
).
data
(
"
key
"
)
]
,
function
(
k
,
val
)
{
console
.
log
(
"
formTpls
"
,
k
,
val
);
activeForm
.
jsonSchema
.
properties
[
k
]
=
{
label
:
k
,
value
:
val
};
});
console
.
log
(
"
formTpls activeForm.jsonSchema.properties
"
,
activeForm
.
jsonSchema
.
properties
);
tplCtx
.
id
=
$
(
this
).
data
(
"
id
"
);
tplCtx
.
key
=
$
(
this
).
data
(
"
key
"
);
tplCtx
.
collection
=
$
(
this
).
data
(
"
collection
"
);
tplCtx
.
path
=
$
(
this
).
data
(
"
path
"
);
activeForm
.
jsonSchema
.
save
=
function
()
{
tplCtx
.
value
=
{};
$
.
each
(
formTpls
[
tplCtx
.
key
]
,
function
(
k
,
val
)
{
tplCtx
.
value
[
k
]
=
$
(
"
#
"
+
k
).
val
();
});
//alert("#"+tplCtx.key+" : "+$( "#"+tplCtx.key ).val());
console
.
log
(
"
save tplCtx
"
,
tplCtx
);
if
(
typeof
tplCtx
.
value
==
"
undefined
"
)
toastr
.
error
(
'
value cannot be empty!
'
);
else
{
dataHelper
.
path2Value
(
tplCtx
,
function
(
params
)
{
$
(
"
#ajax-modal
"
).
modal
(
'
hide
'
);
location
.
reload
();
}
);
}
}
dyFObj
.
openForm
(
activeForm
);
});
$
(
"
.addTpl
"
).
off
().
on
(
"
click
"
,
function
()
{
var
tplCtx
=
{};
var
activeForm
=
{
"
jsonSchema
"
:
{
"
title
"
:
"
Ajouter une section
"
,
"
type
"
:
"
object
"
,
"
properties
"
:
{
type
:
{
label
:
"
Choisir le template
"
,
inputType
:
"
select
"
,
options
:
{
"
blockevent
"
:
"
Les blocs d'évènements
"
,
"
eventCarousel
"
:
"
Les évènements en carousel
"
,
"
blockwithimg
"
:
"
Un bloc avec un texte et une image
"
,
"
communityblock
"
:
"
Les blocs communautés
"
,
"
communityCaroussel
"
:
"
Communauté en carousel
"
,
"
news
"
:
"
L'actualité
"
},
value
:
"
text
"
}
}
}
};
tplCtx
.
id
=
$
(
this
).
data
(
"
id
"
);
tplCtx
.
key
=
$
(
this
).
data
(
"
key
"
);
tplCtx
.
collection
=
$
(
this
).
data
(
"
collection
"
);
activeForm
.
jsonSchema
.
save
=
function
()
{
tplCtx
.
path
=
"
costum.tpls.
"
+
$
(
"
#type
"
).
val
();
tplCtx
.
value
=
{
defaultcolor
:
"
white
"
};
console
.
log
(
"
activeForm save tplCtx
"
,
tplCtx
);
if
(
typeof
tplCtx
.
value
==
"
undefined
"
)
toastr
.
error
(
'
value cannot be empty!
'
);
else
{
dataHelper
.
path2Value
(
tplCtx
,
function
(
params
)
{
$
(
"
#ajax-modal
"
).
modal
(
'
hide
'
);
location
.
reload
();
}
);
}
}
dyFObj
.
openForm
(
activeForm
);
});
});
</script>
<div
class=
"alert alert-danger text-center"
id=
"acceptAndAdmin"
>
<?php
//echo Yii::app()->session["costum"]["contextId"]."<br/>" ?>
<?
php
//echo Yii::app()->session["costum"]["contextType"]."<br/>" ?>
<?
php
//echo Yii::app()->session["costum"]["contextSlug"]."<br/>" ?>
<?
php
//var_dump(Yii::app()->session["costum"]) ?>
<?
php
if
(
isset
(
$test
)
){
?>
<strong>
Hey!
</strong>
Is this what you want ?
<a
href=
"javascript:;"
onclick=
" saveThisTpl('
<?php
echo
$tpl
?>
') "
class=
"btn btn-danger"
>
Save This Template
</a>
<a
href=
"/costum/co/index/slug/
<?php
echo
$slug
?>
/test/costumBuilder"
class=
"btn btn-default"
>
Try another Template
</a>
<?php
}
else
if
(
isset
(
Yii
::
app
()
->
session
[
'costum'
][
"dynForm"
]))
{
?>
<!-- <strong>Configure</strong> your Costum Template <a href="/costum/co/config/slug/
<?php
//echo $slug ?>" class="btn btn-danger"><i class="fa fa-pencil"></i> here </a> -->
<
a
class
=
"btn btn-default"
href
=
"javascript:previewTpl();"
><
i
class
=
"fa fa-eye"
></
i
>
Preview
</
a
>
<
a
class
=
"btn btn-default"
href
=
"#@<?= Yii::app()->session["
costum
"]["
contextSlug
"] ?>"
data
-
hash
=
"#page.type.<?= Yii::app()->session["
costum
"]["
contextType
"] ?>.id.<?= Yii::app()->session["
costum
"]["
contextId
"] ?>"
target
=
"_blank"
><
i
class
=
"fa fa-id-card-o"
aria
-
hidden
=
"true"
></
i
>
Element
</
a
>
<?
php
echo
$this
->
renderPartial
(
"costum.views.tpls.blocCss"
,
array
(
"canEdit"
=>
$canEdit
));
?>
<?php
echo
$this
->
renderPartial
(
"costum.views.tpls.blocApp"
,
array
(
"canEdit"
=>
$canEdit
));
?>
<?php
}
else
{
?>
<strong>hey petit pixel</strong> rajoute une balise dynform sur ton template pour le rendre editable.
<?php
}
?>
</div>
<?php
}
?>
\ No newline at end of file
views/tpls/answers/allAnswers.php
0 → 100644
View file @
7734212a
<style
type=
"text/css"
>
#allAnswersList
{
list-style
:
none
}
#allAnswersList
li
{
padding
:
5px
;
border-bottom
:
1px
solid
#ccc
;
}
</style>
<div
class=
"col-xs-12 text-center"
>
<a
href=
"javascript:;"
class=
'btn btn- btn-default'
id=
"showAnswerBtn"
><i
class=
"fa fa-bars"
></i>
Les
<?php
echo
$what
?>
</a>
<a
href=
"#dashboard"
class=
'lbh btn btn-default'
><i
class=
"fa fa-area-chart"
></i>
Observatoire Global
</a>
<a
href=
"#community"
class=
'lbh btn btn-default'
><i
class=
"fa fa-group"
></i>
Communauté
</a>
<a
href=
"/costum/co/index/slug/
<?php
echo
$el
[
"slug"
]
?>
/answer/new"
class=
'btn btn-primary'
id=
"showAnswerBtn"
><i
class=
"fa fa-plus"
></i>
Ajouter
<?php
echo
$what
?>
</a>
</div>
<div
id=
"allAnswersContainer"
class=
"hide col-xs-12 col-lg-offset-2 col-lg-8 margin-top-20"
>
<ul
id=
"allAnswersList"
>
<?php
$lbl
=
$what
.
" "
;
$ct
=
0
;
if
(
!
empty
(
$allAnswers
)){
foreach
(
$allAnswers
as
$k
=>
$ans
)
{
$ct
++
;
?>
<li
class=
"answerLi col-xs-12"
>
<div
class=
"col-xs-3 text-center"
>
<a
href=
"#answer.index.id.
<?php
echo
$ans
[
"_id"
]
?>
"
class=
"lbh"
>
<?php
echo
$lbl
.
" "
.
$ct
?>
</a>
</div>
<?php
$lblp
=
""
;
$percol
=
"danger"
;
if
(
!
isset
(
$ans
[
"answers"
]))
{
$lblp
=
"no answers"
;
$percent
=
0
;
}
else
{
$totalInputs
=
0
;
$answeredInputs
=
0
;
foreach
(
Yii
::
app
()
->
session
[
"forms"
]
as
$ix
=>
$f
)
{
$totalInputs
+=
count
(
$f
[
"inputs"
]);
//echo "|".$f['id']."-fi=".count($f["inputs"]);
if
(
isset
(
$ans
[
"answers"
][
$f
[
'id'
]]
)
){
$answeredInputs
+=
count
(
$ans
[
"answers"
][
$f
[
'id'
]]
);
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
}
//echo "tot".$totalInputs."-ans".$answeredInputs;
$percent
=
floor
(
$answeredInputs
*
100
/
$totalInputs
);
$percol
=
"primary"
;
$lblp
=
$percent
.
"%"
;
}
if
(
$percent
>
50
)
$percol
=
"warning"
;
if
(
$percent
>
75
)
$percol
=
"success"
;
?>
<div
class=
"col-xs-8"
>
<span
class=
"margin-5"
style=
"font-size:0.8em"
>
<i
class=
"fa fa-calendar"
></i>
<?php
echo
date
(
"d/m/y H:i"
,
$ans
[
"created"
]);
?>
</span>
<?php
$step
=
"instruction"
;
$icon
=
"folder-open-o"
;
if
(
$percent
!=
0
&&
isset
(
$ans
[
"validation"
])
)
{
if
(
isset
(
$ans
[
"validation"
][
"deal2"
][
"valid"
])
&&
in_array
(
$ans
[
"validation"
][
"deal2"
][
"valid"
],
[
"valid"
,
"validReserve"
]
)
)
{
$step
=
"financement"
;
$icon
=
"money"
;
}
if
(
isset
(
$ans
[
"validation"
][
"deal3"
][
"valid"
])
&&
in_array
(
$ans
[
"validation"
][
"deal3"
][
"valid"
],
[
"valid"
,
"validReserve"
]
)
){
$step
=
"suivi"
;
$icon
=
"cogs"
;
}
}
?>
<span
class=
"margin-5 "
style=
"font-size:0.8em"
>
<i
class=
"fa fa-
<?php
echo
$icon
;
?>
"
></i>
<?php
echo
$step
;
?>
</span>
<br/>
<span
class=
"margin-5 label label-
<?php
echo
$percol
?>
"
>
<i
class=
"fa fa-pencil-square-o"
></i>
<?php
echo
$lblp
?>
</span>
<br/>
<?php
if
(
$percent
!=
0
)
{
?>
<a
href=
"#dashboard.answer.
<?php
echo
$ans
[
"_id"
]
?>
"
class=
'margin-5 lbh btn btn-default '
>
<i
class=
"fa fa-group "
></i>
Communauté
<span
class=
"margin-5 label label-primary"
>
3
</span></a>
<a
href=
"#dashboard.answer.
<?php
echo
$ans
[
"_id"
]
?>
"
class=
'margin-5 lbh btn btn-default '
>
<i
class=
"fa fa-pie-chart "
></i>
Observatoire Local
</a>