Commit c21b29e5 authored by thomas craipeau's avatar thomas craipeau
Browse files

refactor costum session change

parent afc94b48
......@@ -12,8 +12,8 @@
costum.col = "<?php echo $this->costum["contextType"] ?>";
costum.ctrl = "<?php echo Element::getControlerByCollection($this->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); ?>;
var configDynForm = <?php echo json_encode($this->costum['dynForm']); ?>;
var tplsList = <?php echo json_encode((isset($this->costum['tpls'])) ? $this->costum['tpls']:null); ?>;
</script>
<?php
......@@ -236,7 +236,7 @@ jQuery(document).ready(function() {
<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"])) {
<?php } else if(isset($this->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>
......
......@@ -379,7 +379,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
<script type="text/javascript">
//to edit costum page pieces
var configDynForm = <?php echo json_encode(Yii::app()->session['costum']['dynForm']); ?>;
var configDynForm = <?php echo json_encode($this->costum['dynForm']); ?>;
//information and structure of the form in this page
var tplCtx = {};
......
......@@ -121,8 +121,8 @@
<div class="formFund" style="display:none;">
<form class="inputFund" role="form">
<?php
if(isset(Yii::app()->session["costum"]["cms"]["fundMsg"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["fundMsg"]);
if(isset($this->costum["cms"]["fundMsg"])){
echo htmlentities($this->costum["cms"]["fundMsg"]);
} else { ?>
Ceci n'est qu'une promesse pour l'instant <br>
Si le montant est atteint, nous vous recontacterons, pour passer à la caisse <br/>
......
......@@ -21,9 +21,9 @@
foreach ($allAnswers as $k => $ans) {
$ct++;
$lbl = $what." ".$ct;
if(isset(Yii::app()->session["costum"]["form"]["title"]))
if(isset($this->costum["form"]["title"]))
{
$titlePath = explode( ".", Yii::app()->session["costum"]["form"]["title"] );
$titlePath = explode( ".", $this->costum["form"]["title"] );
if(isset($ans["answers"][$titlePath[0]][$titlePath[1]]))
$lbl = $ans["answers"][$titlePath[0]][$titlePath[1]];
}
......
......@@ -2,7 +2,7 @@
$debug = false;
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <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>" : "";
$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>" : "";
$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>" : "";
$paramsData = [
"group" => [
......@@ -22,14 +22,14 @@ $paramsData = [
"estimate" => false
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["group"]) )
$paramsData["group"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["group"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["nature"]) )
$paramsData["nature"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["nature"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["amounts"]) )
$paramsData["amounts"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["amounts"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["estimate"]) )
$paramsData["estimate"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["estimate"];
if( isset($this->costum["form"]["params"][$kunik]["group"]) )
$paramsData["group"] = $this->costum["form"]["params"][$kunik]["group"];
if( isset($this->costum["form"]["params"][$kunik]["nature"]) )
$paramsData["nature"] = $this->costum["form"]["params"][$kunik]["nature"];
if( isset($this->costum["form"]["params"][$kunik]["amounts"]) )
$paramsData["amounts"] = $this->costum["form"]["params"][$kunik]["amounts"];
if( isset($this->costum["form"]["params"][$kunik]["estimate"]) )
$paramsData["estimate"] = $this->costum["form"]["params"][$kunik]["estimate"];
// if(isset($answers)){
// foreach ($answers as $q => $a) {
......
......@@ -30,11 +30,11 @@
"01/07/2022",
"01/01/2023"
]];
$dateSections = (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["dateSections"])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]["dateSections"] : $paramsData["dateSections"] ;
$dateSections = (isset($this->costum["form"]["params"][$kunik]["dateSections"])) ? $this->costum["form"]["params"][$kunik]["dateSections"] : $paramsData["dateSections"] ;
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <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>" : "";
$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>" : "";
$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>" : "";
?>
<thead>
<tr>
......@@ -47,7 +47,7 @@
<th>Actions<br/>
</th>
<?php
$sectionTitles = (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["sectionTitles"])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]["sectionTitles"] : $paramsData["sectionTitles"];
$sectionTitles = (isset($this->costum["form"]["params"][$kunik]["sectionTitles"])) ? $this->costum["form"]["params"][$kunik]["sectionTitles"] : $paramsData["sectionTitles"];
foreach ($sectionTitles as $i => $lbl) {
echo "<th>".$lbl."</th>";
} ?>
......@@ -193,7 +193,7 @@ $(document).ready(function() {
}
};
sectionDyf.<?php echo $kunik?>ParamsData = <?php echo json_encode( ( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) ? Yii::app()->session["costum"]["form"]["params"][$kunik] : $paramsData); ?>;
sectionDyf.<?php echo $kunik?>ParamsData = <?php echo json_encode( ( isset($this->costum["form"]["params"][$kunik]) ) ? $this->costum["form"]["params"][$kunik] : $paramsData); ?>;
mylog.log("render","/modules/costum/views/tpls/forms/<?php echo $kunik ?>.php");
......
<?php if($answer){
$copy = "opalProcess1.depense";
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"]) )
$copy = Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"];
if( isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
$copy = $this->costum["form"]["params"][$kunik]["budgetCopy"];
//var_dump($copy);
$copyT = explode(".", $copy);
$copyF = $copyT[0];
......@@ -25,7 +25,7 @@
$editBtnL = "";
$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>" : "";
$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>" : "";
$paramsData = [
......@@ -39,22 +39,22 @@ $paramsData = [
]
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$budgetKey]["group"]) )
$paramsData["group"] = Yii::app()->session["costum"]["form"]["params"][$budgetKey]["group"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$budgetKey]["nature"]) )
$paramsData["nature"] = Yii::app()->session["costum"]["form"]["params"][$budgetKey]["nature"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$budgetKey]["amounts"]) )
$paramsData["amounts"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["amounts"];
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$budgetKey]["group"]) )
$paramsData["group"] = $this->costum["form"]["params"][$budgetKey]["group"];
if( isset($this->costum["form"]["params"][$budgetKey]["nature"]) )
$paramsData["nature"] = $this->costum["form"]["params"][$budgetKey]["nature"];
if( isset($this->costum["form"]["params"][$budgetKey]["amounts"]) )
$paramsData["amounts"] = $this->costum["form"]["params"][$kunik]["amounts"];
}
$communityLinks = Element::getCommunityByTypeAndId(Yii::app()->session["costum"]["contextType"],Yii::app()->session["costum"]["contextId"]);
$communityLinks = Element::getCommunityByTypeAndId($this->costum["contextType"],$this->costum["contextId"]);
$organizations = Link::groupFindByType( Organization::COLLECTION,$communityLinks,["name","links"] );
$orgs = [];
foreach ($organizations as $id => $or) {
$roles = $or["links"]["memberOf"][Yii::app()->session["costum"]["contextId"]]["roles"];
$roles = $or["links"]["memberOf"][$this->costum["contextId"]]["roles"];
if( $paramsData["limitRoles"] && !empty($roles))
{
foreach ($roles as $i => $r) {
......@@ -98,7 +98,7 @@ $properties["votes"] = [
<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;
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"]) )
if( !isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>"; ?>
</td>
</tr>
......@@ -274,13 +274,13 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Décision Gl
<?php
if( isset(Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"])){
//if( Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] ,
if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
//if( $this->costum["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"] ,
[ "totalFin" => $total,
"totalBudg" => Yii::app()->session["totalBudget"]["totalBudget"] ] );
// else
// $this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"]);
// $this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"]);
}
?>
......
......@@ -8,15 +8,15 @@
<?php
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='answers.".$kunik.".' class='add".$keyTpl." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$keyTpl."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$keyTpl."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [ "nature" => [
"investissement" => "Investissement",
"fonctionnement" => "Fonctionnement"
] ];
if( isset(Yii::app()->session["costum"]["form"]["params"][$keyTpl]) )
$paramsData = Yii::app()->session["costum"]["form"]["params"][$keyTpl];
if( isset($this->costum["form"]["params"][$keyTpl]) )
$paramsData = $this->costum["form"]["params"][$keyTpl];
$properties = [
"nature" => [
......
......@@ -33,9 +33,9 @@
],
"limit" => 0 ];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["limit"]) )
$paramsData["limit"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["limit"];
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$kunik]["limit"]) )
$paramsData["limit"] = $this->costum["form"]["params"][$kunik]["limit"];
}
$properties = [
......@@ -50,20 +50,20 @@
];
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]
&& isset(Yii::app()->session["costum"]["form"]["params"][$kunik])
&& isset($this->costum["form"]["params"][$kunik])
&& ( $paramsData["limit"] == 0 ||
!isset($answer["answers"][$kunik]) ||
( isset($answer["answers"][$kunik]) && $paramsData["limit"] > count($answer["answers"][$kunik]) )))
? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='answers.".$kunik.".' class='add".$keyTpl." btn btn-default'><i class='fa fa-plus'></i> Ajouter un élément </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".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
?>
<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;
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['type']) )
if( !isset($this->costum["form"]["params"][$kunik]['type']) )
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>";
?>
......@@ -142,7 +142,7 @@ $(document).ready(function() {
connectToAnswer : function ( data ) {
mylog.log("costum.<?php echo $kunik ?>.connectToAnswer",data)
tplCtx.value = {
type : (data.type) ? data.type : "<?php echo (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['type'])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]['type'] : ''; ?>",
type : (data.type) ? data.type : "<?php echo (isset($this->costum["form"]["params"][$kunik]['type'])) ? $this->costum["form"]["params"][$kunik]['type'] : ''; ?>",
id : data.id,
slug : data.map.slug
};
......@@ -186,11 +186,11 @@ $(document).ready(function() {
inputType : "select",
label : "Définir un type d'élément",
options : sectionDyf.<?php echo $kunik ?>ParamsData.type,
value : "<?php echo (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['type'])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]['type'] : ''; ?>"
value : "<?php echo (isset($this->costum["form"]["params"][$kunik]['type'])) ? $this->costum["form"]["params"][$kunik]['type'] : ''; ?>"
},
limit : {
label : "Combien d'éléments peuvent être ajoutés (0 si pas de limite)",
value : "<?php echo (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['limit'])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]['limit'] : ''; ?>"
value : "<?php echo (isset($this->costum["form"]["params"][$kunik]['limit'])) ? $this->costum["form"]["params"][$kunik]['limit'] : ''; ?>"
}
},
save : function () {
......@@ -218,19 +218,19 @@ $(document).ready(function() {
//adds a line into answer
<?php if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['type']) ) { ?>
<?php if( isset($this->costum["form"]["params"][$kunik]['type']) ) { ?>
$(".add<?php echo $keyTpl ?>").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( "<?php echo Element::getControlerByCollection(Yii::app()->session["costum"]["form"]["params"][$kunik]['type']); ?>",null,null,null,costum.<?php echo $kunik ?> );
dyFObj.openForm( "<?php echo Element::getControlerByCollection($this->costum["form"]["params"][$kunik]['type']); ?>",null,null,null,costum.<?php echo $kunik ?> );
});
$(".edit<?php echo $keyTpl ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
dyFObj.openForm( "<?php echo Yii::app()->session["costum"]["form"]["params"][$kunik]['type']; ?>",null, <?php echo $keyTpl ?>Data[$(this).data("key")]);
dyFObj.openForm( "<?php echo $this->costum["form"]["params"][$kunik]['type']; ?>",null, <?php echo $keyTpl ?>Data[$(this).data("key")]);
});
<?php } ?>
......
......@@ -5,9 +5,9 @@
<?php
$editBtnL = (Yii::app()->session["userId"] == $answer["user"] && isset(Yii::app()->session["costum"]["form"]["params"][$keyTpl.$key]) ) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='answers.".$keyTpl.$key.".' class='add".$keyTpl." btn btn-default'><i class='fa fa-plus'></i> Ajouter un élément </a>" : "";
$editBtnL = (Yii::app()->session["userId"] == $answer["user"] && isset($this->costum["form"]["params"][$keyTpl.$key]) ) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='answers.".$keyTpl.$key.".' class='add".$keyTpl." btn btn-default'><i class='fa fa-plus'></i> Ajouter un élément </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$keyTpl.$key."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$keyTpl.$key."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [ "type" => [
Organization::COLLECTION => "Organization",
......@@ -51,7 +51,7 @@
<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;
if( !isset(Yii::app()->session["costum"]["form"]["params"][$keyTpl.$key]['type']) )
if( !isset($this->costum["form"]["params"][$keyTpl.$key]['type']) )
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>";
?>
......@@ -150,19 +150,19 @@ $(document).ready(function() {
//adds a line into answer
<?php if( isset(Yii::app()->session["costum"]["form"]["params"][$keyTpl.$key]['type']) ) { ?>
<?php if( isset($this->costum["form"]["params"][$keyTpl.$key]['type']) ) { ?>
$(".add<?php echo $keyTpl ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+((notNull(<?php echo $keyTpl ?>Data) ? <?php echo $keyTpl ?>Data.length : "0"));
dyFObj.openForm( "<?php echo Yii::app()->session["costum"]["form"]["params"][$keyTpl.$key]['type']; ?>" );
dyFObj.openForm( "<?php echo $this->costum["form"]["params"][$keyTpl.$key]['type']; ?>" );
});
$(".edit<?php echo $keyTpl ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
dyFObj.openForm( "<?php echo Yii::app()->session["costum"]["form"]["params"][$keyTpl.$key]['type']; ?>",null, <?php echo $keyTpl ?>Data[$(this).data("key")]);
dyFObj.openForm( "<?php echo $this->costum["form"]["params"][$keyTpl.$key]['type']; ?>",null, <?php echo $keyTpl ?>Data[$(this).data("key")]);
});
<?php } ?>
......
......@@ -6,21 +6,21 @@
<?php
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <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>" : "";
$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>" : "";
$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(Yii::app()->session["costum"]["contextType"],Yii::app()->session["costum"]["contextId"]);
$communityLinks = Element::getCommunityByTypeAndId($this->costum["contextType"],$this->costum["contextId"]);
$persons = Link::groupFindByType( Person::COLLECTION,$communityLinks,["name","links"] );
$organizations = Link::groupFindByType( Organization::COLLECTION,$communityLinks,["name","links"] );
$financers = array_merge( $persons, $organizations );
$orgs = [];
if( !empty($or["links"]["memberOf"][Yii::app()->session["costum"]["contextId"]]["roles"]) ) {
if( !empty($or["links"]["memberOf"][$this->costum["contextId"]]["roles"]) ) {
foreach ($financers as $id => $or) {
$roles = $or["links"]["memberOf"][Yii::app()->session["costum"]["contextId"]]["roles"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"]) && !empty($roles))
$roles = $or["links"]["memberOf"][$this->costum["contextId"]]["roles"];
if( isset($this->costum["form"]["params"][$kunik]["limitRoles"]) && !empty($roles))
{
foreach ($roles as $i => $r) {
if( in_array($r, Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"]) )
if( in_array($r, $this->costum["form"]["params"][$kunik]["limitRoles"]) )
$orgs[$id] = $or["name"];
}
}
......@@ -34,13 +34,13 @@
"limitRoles" =>["Financeur"]
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["tpl"]) )
$paramsData["tpl"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["tpl"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["financerTypeList"]) )
$paramsData["financerTypeList"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["financerTypeList"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["financersList"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"];
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$kunik]["tpl"]) )
$paramsData["tpl"] = $this->costum["form"]["params"][$kunik]["tpl"];
if( isset($this->costum["form"]["params"][$kunik]["financerTypeList"]) )
$paramsData["financerTypeList"] = $this->costum["form"]["params"][$kunik]["financerTypeList"];
if( isset($this->costum["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["financersList"] = $this->costum["form"]["params"][$kunik]["limitRoles"];
}
$properties = [
......@@ -197,13 +197,13 @@ if($total > 0){
</div>
<?php
if( isset(Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"])){
//if( Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] ,
if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
//if( $this->costum["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"] ,
[ "totalFin" => $total,
"totalBudg" => Yii::app()->session["totalBudget"]["totalBudget"] ] );
// else
// $this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"]);
// $this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"]);
}
?>
......
......@@ -2,8 +2,8 @@
$copy = "opalProcess1.depense";
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"]) )
$copy = Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"];
if( isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
$copy = $this->costum["form"]["params"][$kunik]["budgetCopy"];
//var_dump($copy);
$copyT = explode(".", $copy);
$copyF = $copyT[0];
......@@ -25,7 +25,7 @@ if($wizard){
$editBtnL = "";
$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>" : "";
$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>" : "";
......@@ -35,26 +35,26 @@ $paramsData = [
"openFinancing" => true
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["tpl"]) )
$paramsData["tpl"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["tpl"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"]) )
$paramsData["budgetCopy"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["financerTypeList"]) )
$paramsData["financerTypeList"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["financerTypeList"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["limitRoles"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["limitRoles"];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["openFinancing"]) )
$paramsData["openFinancing"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["openFinancing"];
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$kunik]["tpl"]) )
$paramsData["tpl"] = $this->costum["form"]["params"][$kunik]["tpl"];
if( isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
$paramsData["budgetCopy"] = $this->costum["form"]["params"][$kunik]["budgetCopy"];
if( isset($this->costum["form"]["params"][$kunik]["financerTypeList"]) )
$paramsData["financerTypeList"] = $this->costum["form"]["params"][$kunik]["financerTypeList"];
if( isset($this->costum["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["limitRoles"] = $this->costum["form"]["params"][$kunik]["limitRoles"];
if( isset($this->costum["form"]["params"][$kunik]["openFinancing"]) )
$paramsData["openFinancing"] = $this->costum["form"]["params"][$kunik]["openFinancing"];
}
$communityLinks = Element::getCommunityByTypeAndId(Yii::app()->session["costum"]["contextType"],Yii::app()->session["costum"]["contextId"]);
$communityLinks = Element::getCommunityByTypeAndId($this->costum["contextType"],$this->costum["contextId"]);
$organizations = Link::groupFindByType( Organization::COLLECTION,$communityLinks,["name","links"] );
$orgs = [];
foreach ($organizations as $id => $or) {
$roles = $or["links"]["memberOf"][Yii::app()->session["costum"]["contextId"]]["roles"];
$roles = $or["links"]["memberOf"][$this->costum["contextId"]]["roles"];
if( $paramsData["limitRoles"] && !empty($roles))
{
foreach ($roles as $i => $r) {
......@@ -90,7 +90,7 @@ $properties = [
"size" => 6,
]
];
$amounts = (isset(Yii::app()->session["costum"]["form"]["params"][$budgetKey]["amounts"])) ? Yii::app()->session["costum"]["form"]["params"][$budgetKey]["amounts"] : ["price" => "Price"] ;
$amounts = (isset($this->costum["form"]["params"][$budgetKey]["amounts"])) ? $this->costum["form"]["params"][$budgetKey]["amounts"] : ["price" => "Price"] ;
foreach ( $amounts as $k => $l) {
$properties[$k] = [ "inputType" => "text",
"label" => $l,
......@@ -107,7 +107,7 @@ foreach ( $amounts as $k => $l) {
<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;
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["budgetCopy"]) )
if( !isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>";?>
</td>
</tr>
......@@ -385,13 +385,13 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Pourcentage
<?php
if( isset(Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"])){
//if( Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"] ,
if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
//if( $this->costum["form"]["params"]["financement"]["tpl"] == "tpls.forms.equibudget" )
$this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"] ,
[ "totalFin" => $total,
"totalBudg" => Yii::app()->session["totalBudget"]["totalBudget"] ] );
// else
// $this->renderPartial( "costum.views.".Yii::app()->session["costum"]["form"]["params"]["financement"]["tpl"]);
// $this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"]);
}
?>
......
......@@ -8,7 +8,7 @@
<?php
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='answers.".$kunik.".' class='add".$keyTpl." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$keyTpl."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$keyTpl."' class='previewTpl edit".$keyTpl."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [ "titles" => [ "Indicateur",
"Objectif / Réalisé",
......@@ -22,8 +22,8 @@ $paramsData = [ "titles" => [ "Indicateur",
//temporaire car specific au CTE
$indicateurs = Ctenat::getIndicator();
if( isset(Yii::app