Commit 1ad6a153 authored by Anatole Rakotoson's avatar Anatole Rakotoson
Browse files

sommom

parent 90c96c3f
......@@ -197,9 +197,9 @@
sectionDyf.<?php echo $kunik ?> = {
"jsonSchema" : {
"title" : "Plans de conservation",
"title" : "Aire marine protégée",
"icon" : "fa-globe",
"text" : "Décrire ici les principaux postes de dépenses : à quoi correspondent les coûts ? <br/>Préciser ce qui relève des dépenses de fonctionnement et des dépenses d’investissement.<br/>Les coûts doivent être en <b>hors taxe</b>.",
"text" : "",
"properties" : <?php echo json_encode( $properties ); ?>,
save : function () {
var today = new Date();
......
<?php if($answer){
?>
<div class="form-group">
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>">
<?php
$editBtnL = ($canAnswer) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a> <a href='javascript:;' data-id='5e5e2470681c3376298b456b' data-collection='answers' data-path='answers.sommomForm1.sommomForm122.' class='addorganismesommomForm122 btn btn-default'><i class='fa fa-plus'></i> Ajouter un organisme </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["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>" : "";
$paramsData = [
"type" => [
"Poster" => "Poster",
"Présentation orale" => "Présentation orale"
]
];
$a=[];
if(isset($answer["answers"]["sommomForm1"])){
foreach ($answer["answers"]["sommomForm1"] as $k => $v) {
if(is_array($v)){
foreach ($v as $key => $value) {
if(isset($value["intitule"])) {
$a += array($value["intitule"] => $value["intitule"]);
}
}
}
}
}
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["ocean"]) )
$paramsData["ocean"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["ocean"];
$properties = [
"Type" => [
"label" => "Type",
"placeholder" => "Sélectionner le type",
"noOrder" => true,
"options" => $paramsData["type"],
"rules" => [ "required" => true ]
],
"intitule" => [
"label" => "Intitulé de la contribution",
"placeholder" => "Nom",
"inputType" => "text",
"rules" => [ "required" => true ]
],
"annee" => [
"label" => "Année de participation",
"placeholder" => "Année",
"inputType" => "text",
"rules" => [ "required" => true ]
],
"lien" => [
"label" => "Lien de la conférence",
"placeholder" => "lien de consultation",
"inputType" => "text",
"rules" => [ "required" => false ]
]
];
$propertiesParams = [
"labels"=>[],
"placeholders"=>[],
];
foreach ($properties as $k => $v) {
if( isset($v["label"])){
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["labels"][$k]) )
$properties[$k]["label"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["labels"][$k];
$propertiesParams["labels"][$k] = $properties[$k]["label"];
}
if( isset($v["placeholder"])){
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholders"][$k]) )
$properties[$k]["placeholder"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholders"][$k];
$propertiesParams["placeholders"][$k] = $properties[$k]["placeholder"];
}
}
?>
<thead>
<tr>
<td colspan='<?php echo count( $properties)+2?>' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn.$editParamsBtn.$editBtnL?></h4>
<?php echo $info ?>
</td>
</tr>
<?php
if( count($answers)>0 ){ ?>
<tr>
</th>
<?php
foreach ($properties as $i => $inp) {
echo "<th>".$inp["placeholder"]."</th>";
} ?>
<th></th>
</tr>
<tr></tr>
<?php } ?>
</thead>
<tbody class="directoryLines">
<?php
$ct = 0;
if(isset($answers)){
foreach ($answers as $q => $a) {
echo "<tr id='".$kunik.$q."' class='".$kunik."Line'>";
foreach ($properties as $i => $inp) {
echo "<td>";
if(isset($a[$i])) {
if(is_array($a[$i])){
echo implode(",", $a["ocean"]);
}
else {
if($i == "lien")
{
echo "<a href='".$a[$i]."'>".$a[$i]."</a>";
}
else
{
echo $a[$i];
}
}
}
echo "</td>";
}
?>
<td style="white-space: normal;">
<?php
$this->renderPartial( "survey.views.tpls.forms.cplx.editDeleteLineBtn" , [
"canEdit"=>($canEdit || $canAnswer),
"id" => $answer["_id"],
"collection" => Form::ANSWER_COLLECTION,
"q" => $q,
"path" => $answerPath.$q,
"keyTpl"=>$kunik
] ); ?>
<a href="javascript:;" class="btn btn-xs btn-primary openAnswersComment" onclick="commentObj.openPreview('answers','<?php echo $answer["_id"]?>','<?php echo $answer["_id"].$key.$q ?>', '<?php echo @$a['step'] ?>')"><?php echo PHDB::count(Comment::COLLECTION, array("contextId"=>$answer["_id"],"contextType"=>"answers", "path"=>$answer["_id"].$key.$q))?> <i class='fa fa-commenting'></i></a>
</td>
<?php
$ct++;
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
<script type="text/javascript">
var <?php echo $kunik ?>Data = <?php echo json_encode( (isset($answers)) ? $answers : null ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsProperty = {
labels : <?php echo json_encode( $propertiesParams["labels"] ); ?>,
placeholders : <?php echo json_encode( $propertiesParams["placeholders"] ); ?>
};
$(document).ready(function() {
sectionDyf.<?php echo $kunik ?> = {
"jsonSchema" : {
"title" : "Contribution à la communauté scientifique",
"icon" : "fa-globe",
"text" : "",
"properties" : <?php echo json_encode( $properties ); ?>,
save : function () {
var today = new Date();
tplCtx.value = { date : today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear() };
$.each( sectionDyf.<?php echo $kunik ?>.jsonSchema.properties , function(k,val) {
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"description" : "Liste de question possible",
"icon" : "fa-cog",
"properties" : {
labels : {
inputType : "properties",
labelKey : "Clef",
labelValue : "Libellé du champs",
label : "Modifier les libélés des Questions",
values : sectionDyf.<?php echo $kunik ?>ParamsProperty.labels
},
placeholders : {
inputType : "properties",
labelKey : "Clef",
labelValue : "Texte dans le champs",
label : "Modifier les textes à l'interieur du champs de saisie",
values : sectionDyf.<?php echo $kunik ?>ParamsProperty.placeholders
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value[k] = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
mylog.log("value",'.'+k+val.inputType,tplCtx.value[k]);
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
} );
}
}
}
};
mylog.log("render","/modules/costum/views/tpls/forms/<?php echo $kunik ?>.php");
//adds a line into answer
$(".add<?php echo $kunik ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+((notNull(<?php echo $kunik ?>Data) ? <?php echo $kunik ?>Data.length : "0"));
dyFObj.openForm( sectionDyf.<?php echo $kunik ?> );
});
$(".edit<?php echo $kunik ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>,null, <?php echo $kunik ?>Data[$(this).data("key")]);
});
$(".edit<?php echo $kunik ?>Params").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//if no params config on the element.costum.form.params.<?php echo $kunik ?>
//then we load default values available in forms.inputs.<?php echo $kunik ?>xxx.params
//mylog.log(".editParams",sectionDyf.<?php echo $kunik ?>Params,calData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
});
</script>
<?php } else {
//echo "<h4 class='text-red'>CALENDAR works with existing answers</h4>";
} ?>
\ No newline at end of file
......@@ -8,7 +8,14 @@
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["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>" : "";
$paramsData = [];
$paramsData = [
"type" => [
"Publication" => "Publication",
"Etude" => "Etude",
"Ouvrage" => "Ouvrage",
"Autre" => "Autre"
]
];
$a=[];
......@@ -29,6 +36,13 @@
$paramsData["ocean"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["ocean"];
$properties = [
"Type" => [
"label" => "Type",
"placeholder" => "Sélectionner le type",
"noOrder" => true,
"options" => $paramsData["type"],
"rules" => [ "required" => true ]
],
"intitule" => [
"label" => "Référence",
"placeholder" => "Référence",
......
......@@ -107,11 +107,46 @@
<th rowspan="2"></th>
</tr>
<tr>
<th><?php $mn = 1; foreach ($properties as $k => $v) { if( $mn < 2) { echo $v["label"]; $mn++ ;} } ?></th>
<th><?php $mn = 2; foreach ($properties as $k => $v) { if( $mn < 3) { echo $v["label"]; $mn++ ;} } ?></th>
<th><?php $mn = 3; foreach ($properties as $k => $v) { if( $mn < 4) { echo $v["label"]; $mn++ ;} } ?></th>
<th><?php $mn = 4; foreach ($properties as $k => $v) { if( $mn < 5) { echo $v["label"]; $mn++ ;} } ?></th>
<th><?php $mn = 5; foreach ($properties as $k => $v) { if( $mn < 6) { echo $v["label"]; $mn++ ;} } ?></th>
<th><?php
$mn = 1;
foreach ($properties as $k => $v) {
if( $mn ==2) {
echo $v["label"];
}
$mn++ ;
} ?></th>
<th><?php
$mn = 1;
foreach ($properties as $k => $v) {
if( $mn ==3) {
echo $v["label"];
}
$mn++ ;
} ?></th>
<th><?php
$mn = 1;
foreach ($properties as $k => $v) {
if( $mn ==5) {
echo $v["label"];
}
$mn++ ;
} ?></th>
<th><?php
$mn = 1;
foreach ($properties as $k => $v) {
if( $mn ==6) {
echo $v["label"];
}
$mn++ ;
} ?></th>
<th><?php
$mn = 1;
foreach ($properties as $k => $v) {
if( $mn ==7) {
echo $v["label"];
}
$mn++ ;
} ?></th>
</tr>
</thead>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment