Commit d66fd40c authored by Raph El's avatar Raph El
Browse files

Hoyfix step + canEdit answer for directory

parent 61b11208
......@@ -64,11 +64,14 @@ var formObj = {
history.replaceState(location.hash, "", hashUrlPage+".view.forms.dir.form."+id);
},"html");
},
answer : function(fObj, id, form){
answer : function(fObj, id, form, mode){
mylog.log("fObj.urls.answer", fObj, id, form);
var url = '/survey/answer/index/id/'+id;
if(typeof form != "undefined" && form != null)
url += '/form/'+form;
if(typeof mode != "undefined" && mode != null)
url += '/mode/'+mode;
ajaxPost(fObj.container, baseUrl+url,
null,
function(){
......@@ -202,7 +205,6 @@ var formObj = {
'</div>'+
'</div>';
return str ;
},
answers : function(fObj, answers){
//mylog.log("formProfil.views.answers");
......@@ -290,10 +292,16 @@ var formObj = {
}
}
str += '<div class="col-xs-12 no-padding">'+
'<a href="javascript:;" data-id="'+id+'" class="btnAnswer lbh margin-top-5 btn btn-open-answer">'+
'<i class="fa fa-sign-in"></i> Ouvrir'+
'</a>'+
'</div>'+
'<a href="javascript:;" data-id="'+id+'" data-mode="r" class="btnAnswer lbh margin-top-5 btn btn-open-answer">'+
'<i class="fa fa-sign-in"></i> Lire'+
'</a>';
if(typeof ans.canEdit == "boolean" && ans.canEdit === true){
str += '<a href="javascript:;" data-id="'+id+'" data-mode="w" class="btnAnswer lbh margin-top-5 btn btn-open-answer">'+
'<i class="fa fa-sign-in"></i> Modifer'+
'</a>';
}
str += '</div>'+
'</div>'+
'</div>';
});
......@@ -311,7 +319,7 @@ var formObj = {
},
answers : function(fObj){
$(fObj.container+' .btnAnswer').off().on("click",function(){
fObj.urls.answer(fObj, $(this).data("id"));
fObj.urls.answer(fObj, $(this).data("id"), null, $(this).data("mode"));
});
},
......
......@@ -12,7 +12,6 @@ class DirectoryAction extends CAction
$res=array();
$searchParams = $_POST;
$res = Form::getBySourceAndId($source, $form);
//var_dump($params["form"]);exit;
$answers=Answer::globalAutocomplete($res["form"], $searchParams);
$answerList = Form::listForAdmin($answers["results"]) ;
$answerList = Answer::getDataAnswers($answerList, $res["forms"]);
......@@ -23,19 +22,13 @@ class DirectoryAction extends CAction
$res["what"] = (isset($params["form"]["what"])) ? $params["form"]["what"] : "réponses";
//$el = Slug::getElementBySlug( $res["form"]["parentSlug"] );
//$el=Form::getFirstParentForm($res["form"]);
$res['el'] = Form::getFirstParentForm($res["form"]);
//$res['el'] = Form::getFirstParentForm($res["form"]);
//ce code ne marchera pas pour deux formulaire identaique , d'un meme slug
//TODO utiliser le parntForm Id en plus
$res['canEdit'] = ( isset(Yii::app()->session["userId"]) && isset($el["type"]) && isset($el["id"]) ) ?
Authorisation::canEditItem(Yii::app()->session["userId"],$el["type"], $el["id"])
: false ;
// if($tpl=="json")
Rest::json( $res );
//else if(Yii::app()->request->isAjaxRequest)
// echo $controller->renderPartial("costum.views.custom.default.".$page,$params,true);
}
}
......@@ -255,6 +255,7 @@ class Answer{
$answerList[$key]["todo"] = $todo;
$answerList[$key]["done"] = $done;
$answerList[$key]["tasksPerson"] = $tasksPerson;
$answerList[$key]["canEdit"] = self::canEdit( $ans, $ans["form"], Yii::app()->session["userId"]) ;
}
}
return $answerList;
......
......@@ -24,7 +24,7 @@ if( $mode != "pdf" ){
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<?php $label=($answer["step"]=="deal12") ? "Opérateur sélectionner par le ménage" : "Intention opérateur"; ?>
<?php $label=(!empty($answer["step"]) && $answer["step"]=="deal12") ? "Opérateur sélectionner par le ménage" : "Intention opérateur"; ?>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></td>
</tr>
<?php
......
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