Commit 7cbc3e03 authored by Raph El's avatar Raph El
Browse files

Hotfix answer view mode

parent 4729bf00
......@@ -4,16 +4,36 @@ class IndexAction extends CAction
public function run($id=null, $answer=null, $tpl=null, $mode=null)
{
$this->getController()->layout = "//layouts/empty";
$params = ["canEdit" => true];
if(!empty($id)){
$params["answerId"]=$id;
}
$params["mode"] = (!empty($mode) ? $mode : "r");
//echo $params["mode"] ; exit;
$params = Form::getDataForAnswer($params);
//$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.views.index";
echo $this->getController()->renderPartial($tpl,$params );
// $answer = PHDB::findOne( Form::ANSWER_COLLECTION, array("_id"=>new MongoId($id)));
$form = PHDB::findOne( Form::COLLECTION , array("id"=>$answer["formId"]));
$parentForm = Slug::getElementBySlug($form["id"]);
$canEditAnswer = false;
$canSeeAnswer = false;
if(!empty(Yii::app()->session['userId'])){
$canEditAnswer = Form::canEditAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if(empty($canEditAnswer)){
$canSeeAnswer = Form::canSeeAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if($canSeeAnswer === true && !empty($mode) && ($mode == "w" || $mode == "rplus") )
$mode = "r";
}
}
if($canEditAnswer === true || $canSeeAnswer === true){
$params["canEdit"] = $canEditAnswer;
$params["mode"] = (!empty($mode) ? $mode : "r");
//Rest::json($params); exit;
//$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.views.index";
echo $this->getController()->renderPartial($tpl,$params );
} else {
echo "Erreur";
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
//contains all dynform definitions for complexe inputs
//it also carries sub dynforms, when an input needs extra parameters to
var sectionDyf = {};
//var sectionDyf = {};
var tplCtx = {};
var DFdata = {
......
......@@ -22,7 +22,7 @@
<li class="answerLi col-xs-12 ansline<?php echo $k ?>" >
<div class="col-xs-3 text-center">
<a href="#answer.index.id.<?php echo $ans["_id"] ?>" class="lbh"> <?php echo $lbl." ".$ct ?></a>
<a href="#answer.index.id.<?php echo $ans["_id"] ?>.mode.w" class="lbh"> <?php echo $lbl." ".$ct ?></a>
</div>
<?php
$lblp = "";
......
......@@ -100,13 +100,20 @@ if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->sess
}
</style>
<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 = {};
</script>
<?php
$params = [ "tpl" => Yii::app()->session["costum"]["slug"],
"slug"=>$el["slug"],
"canEdit"=>$canEdit,
"el"=>$el ];
echo $this->renderPartial("survey.views.tpls.acceptAndAdmin", $params, true );
// $params = [ "tpl" => Yii::app()->session["costum"]["slug"],
// "slug"=>$el["slug"],
// "canEdit"=>$canEdit,
// "el"=>$el ];
// echo $this->renderPartial("survey.views.tpls.acceptAndAdmin", $params, true );
?>
<div class="col-xs-12 no-padding" id="customHeader" style="background-color: white">
......@@ -118,97 +125,98 @@ if(isset(Yii::app()->session["costum"]["cms"]["color1"]))
// echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='color1' data-type='color' data-path='costum.cms.color1' data-label='Couleur Principale '><i class='fa fa-pencil'></i></a>";
?>
<div class="col-sm-12 col-md-12 col-xs-12 no-padding" style="background-color:<?php echo Yii::app()->session["costum"]["colors"]["grey"]; ?>; max-width:100%;">
<div class="col-xs-12 no-padding" style="">
<style type="text/css">
.monTitle{
border-top: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
border-bottom: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
margin-top: -20px;
}
</style>
<?php $formSmallSize = 12; ?>
<div class="col-md-12 col-lg-<?php echo $formSmallSize?> no-padding "><br/>
<div class="row margin-top-20 padding-20" style="background-color: white; ">
<div class="col-xs-12">
<script type="text/javascript">
var formInputs = {};
var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null"; ?>;
</script>
<div class="col-xs-12 margin-top-20">
<?php
$wizardUid = "wizardForm";
// $params = [
// "el" => $el,
// "color1" => $color1,
// "canEdit" => $canEdit,
// "allAnswers"=>@$allAnswers,
// "what" => "dossiers"
// ];
// echo $this->renderPartial("survey.views.tpls.answers.allAnswers",$params);
if($showForm){
$params = [
"formList"=>$formList,
"el" => $el,
"active" => "all",
"color1" => $color1,
"canEdit" => false,
"answer"=>$answer,
"showForm" => $showForm,
"mode" => $mode,
"wizid"=> $wizardUid
];
echo $this->renderPartial("survey.views.tpls.forms.wizard",$params);
} else {
echo "<h4 class='text-center' style='color:".$color1."'><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>";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 no-padding" >
<!-- style="background-color:<?php //echo Yii::app()->session["costum"]["colors"]["grey"]; ?>; max-width:100%;"> -->
<div class="col-xs-12 no-padding" style="">
<style type="text/css">
.monTitle{
border-top: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
border-bottom: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
margin-top: -20px;
}
</style>
<?php $formSmallSize = 12; ?>
<div class="col-md-12 col-lg-<?php echo $formSmallSize?> no-padding "><br/>
<div class="col-xs-12 no-padding" style="background-color: white; ">
<div class="col-xs-12 no-padding">
<script type="text/javascript">
var formInputs = {};
var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null"; ?>;
</script>
<div class="col-xs-12 margin-top-20">
<?php
$wizardUid = "wizardForm";
$params = [
"el" => $el,
"color1" => $color1,
"canEdit" => $canEdit,
"allAnswers"=>@$allAnswers,
"what" => "dossiers"
];
echo $this->renderPartial("survey.views.tpls.answers.allAnswers",$params);
if($showForm){
$params = [
"formList"=>$formList,
"el" => $el,
"active" => "all",
"color1" => $color1,
"canEdit" => false,
"answer"=>$answer,
"showForm" => $showForm,
"mode" => $mode,
"wizid"=> $wizardUid
];
echo $this->renderPartial("survey.views.tpls.forms.wizard",$params);
} else {
echo "<h4 class='text-center' style='color:".$color1."'><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>";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<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(Yii::app()->session['costum']['dynForm']); ?>;
//information and structure of the form in this page
var tplCtx = {};
jQuery(document).ready(function() {
mylog.log("render","/modules/costum/views/custom/co/formWizard.php");
contextData = {
id : "<?php echo Yii::app()->session["costum"]["contextId"] ?>",
type : "<?php echo Yii::app()->session["costum"]["contextType"] ?>",
name : '<?php echo htmlentities($el['name']) ?>',
profilThumbImageUrl : "http://127.0.0.1/ph/themes/CO2/assets/img/LOGOS/CO2/logo-min.png"
};
getAjax("community", baseUrl+"/"+moduleId+"/element/getdatadetail/type/"+costum.contextType+"/id/"+costum.contextId+"/dataName/members",
function(data){
//displayInTheContainer(data,"members","group",null,true);
mylog.log("#community",data);
},
"html");
$('#showAnswerBtn').on("click",function() {
$("#allAnswersContainer").toggleClass("hide");
$('#<?php echo "wizardForm" ?>').toggleClass("hide");
//getAjax(".pageContent", baseUrl+"/costum/co/index/slug/<?php echo $el['slug'] ?>/page/answerList",null,"html");
})
mylog.log("render","/modules/costum/views/custom/co/formWizard.php");
contextData = {
id : "<?php echo Yii::app()->session["costum"]["contextId"] ?>",
type : "<?php echo Yii::app()->session["costum"]["contextType"] ?>",
name : '<?php echo htmlentities($el['name']) ?>',
profilThumbImageUrl : "http://127.0.0.1/ph/themes/CO2/assets/img/LOGOS/CO2/logo-min.png"
};
getAjax("community",
baseUrl+"/"+moduleId+"/element/getdatadetail/type/"+costum.contextType+"/id/"+costum.contextId+"/dataName/members",
function(data){
//displayInTheContainer(data,"members","group",null,true);
mylog.log("#community",data);
},
"html");
$('#showAnswerBtn').on("click",function() {
$("#allAnswersContainer").toggleClass("hide");
$('#<?php echo "wizardForm" ?>').toggleClass("hide");
//getAjax(".pageContent", baseUrl+"/costum/co/index/slug/<?php //echo $el['slug'] ?>/page/answerList",null,"html");
});
});
......
Markdown is supported
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