Commit dd56ce83 authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

Merge remote-tracking branch 'origin/development' into development

parents 7e008672 977736c9
......@@ -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"]);
......@@ -20,22 +19,16 @@ class DirectoryAction extends CAction
if(isset($answers["count"]))
$res["count"]=$answers["count"];
$res["results"] = $answerList ;
$res["what"] = (isset($params["form"]["what"])) ? $params["form"]["what"] : "réponses";
//$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);
}
}
......@@ -15,42 +15,28 @@ class DirectoryAction extends CAction
if(@$_POST["page"]){
$limitMin=$limitMin+(100*($_POST["page"]-1));
}
$search="";
if(!empty($_POST["name"])){
$search = trim(urldecode($_POST['name']));
$queryForm = array("parent.".$_POST["id"] => array('$exists' => 1 ) );
if(!empty($controller->costum) && !empty($controller->costum["slug"]))
$queryForm = array('$and' => array( $queryForm , array("source.key" => $controller->costum["slug"]) ) ) ;
$forms = PHDB::find(Form::COLLECTION, $queryForm , array("name", "mapping") );
$idFs = array();
foreach ($forms as $keyF => $valF) {
$idFs[] = $keyF;
}
$res = Form::getBySourceAndId($controller->costum["slug"]);
$searchParams = $_POST;
$searchParams["count"] = true;
$answers=Answer::globalAutocomplete($res["form"], $searchParams);
$answerList = Form::listForAdmin($answers["results"]) ;
$answerList = Answer::getDataAnswers($answerList, $res["forms"]);
$panelAdmin["context"] = array( "id" => $_POST["id"],
"collection" => $_POST["collection"],
"slug" => $_POST["slug"] );
$searchRegExp = Search::accentToRegex($search);
//$query=array("parentSlug"=>$slug);
$forms = PHDB::find(Form::COLLECTION, array("parent.".$_POST["id"] => array('$exists' => 1 ) ) , array("name") );
$idFs = array();
foreach ($forms as $keyF => $valF) {
$idFs[] = $keyF;
}
$query=array( "form"=>array('$in' => $idFs) );
//Rest::json($query); exit;
$querySearch = array();
if(!empty($querySearch))
$query = array('$and' => array( $query , $querySearch ) ) ;
if(!empty($panelAdmin['filters'])){
$query = Search::searchFilters($panelAdmin['filters'], $query);
}
$params["typeDirectory"]=[ Answer::COLLECTION ];
$params["results"] = array();
$answers = PHDB::findAndLimitAndIndex ( Answer::COLLECTION , $query, $stepLim, $limitMin);
$answerList = Form::listForAdmin($answers) ;
foreach ($answerList as $key => $value) {
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Answer::COLLECTION));
}
$params["results"]["count"][Answer::COLLECTION] = PHDB::count( Answer::COLLECTION , $query);
$params["results"]["count"] = $answers["count"];
$params["results"][Answer::COLLECTION] = $answerList ;
$params["panelAdmin"] = $panelAdmin;
$page = "groupAdmin";
......@@ -58,7 +44,5 @@ class DirectoryAction extends CAction
Rest::json( $params );
else if(Yii::app()->request->isAjaxRequest)
echo $controller->renderPartial("costum.views.custom.default.".$page,$params,true);
}
}
......@@ -116,6 +116,20 @@
"type" : "text",
"info" : ""
},
"deal111b" : {
"label" : "Sélectionner la nature des travaux",
"type" : "tpls.forms.select",
"options" : [
"Salle de bain",
"Toilettes",
"Cuisine",
"Toiture",
"Électricité",
"Chambre",
"Fenêtres",
"Autres"
]
},
"deal112" : {
"label" : "Description des travaux",
"type" : "textarea"
......
......@@ -172,13 +172,11 @@ class Answer{
}
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Form::ANSWER_COLLECTION));
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
// $imgAnsw=(isset($ans["profilMediumImageUrl"])) ? Yii::app()->createUrl($ans["profilMediumImageUrl"]) : Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()."/images/thumbnail-default.jpg";
if(!isset($ans["answers"])) {
$percent = 0;
} else {
......@@ -186,10 +184,8 @@ class Answer{
$answeredInputs = 0;
foreach ($forms as $fid => $f){
$totalInputs += count($f["inputs"]);
//echo "|".$f['id']."-fi=".count($f["inputs"]);
if( isset( $ans["answers"][$fid] ) ){
$answeredInputs += count( $ans["answers"][$fid] );
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
//todo lists are on depense for the moment
......@@ -211,7 +207,6 @@ class Answer{
$done++;
}
}
}
}
}
......@@ -223,16 +218,6 @@ class Answer{
if(!isset($globalLinks[$type]))
$globalLinks[$type] = [];
// if($type == "operators"){
// $lblstate = "Opérateur à valider";
// $statecol = "warning";
// foreach ($ls as $oid => $ov) {
// if($ov != "0"){
// $lblstate = "Opérateur OK";
// $statecol = "primary";
// }
// }
// }
foreach ($ls as $uid => $time) {
if(is_string($uid) && strlen($uid) == 24 && ctype_xdigit($uid)){
if(!in_array($uid, $localLinks[$type] ))
......@@ -255,10 +240,30 @@ class Answer{
$answerList[$key]["todo"] = $todo;
$answerList[$key]["done"] = $done;
$answerList[$key]["tasksPerson"] = $tasksPerson;
$answerList[$key]["canEdit"] = self::canEdit( $ans, null, Yii::app()->session["userId"]) ;
}
}
return $answerList;
}
public static function csv($elements, $idElt, $valElt, $forms ){
$elements[$idElt]["id"] = $idElt;
$elements[$idElt]["user"] = $valElt["user"];
$elements[$idElt]["created"] = date("d/m/Y", $valElt["created"]);
if(!empty($valElt["answers"])){
foreach ($forms as $keyF => $valF) {
if(!empty($valF["id"]) && !empty($valElt["answers"][$valF["id"]])){
foreach ($valElt["answers"][$valF["id"]] as $keyAns => $valAns) {
if(!empty($valF["inputs"]) && !empty($valF["inputs"][$keyAns]) && !empty($valF["inputs"][$keyAns]["label"])){
$elements[$idElt][$valF["inputs"][$keyAns]["label"]] = $valAns;
}
}
}
}
}
return $elements;
}
}
?>
\ No newline at end of file
......@@ -663,6 +663,7 @@ class Form {
$form = $params["form"] ;
else
$form = PHDB::findOneById( Form::COLLECTION, $_GET["form"] );
$params["parentForm"] = $form;
$communityLinks = array();
if(!empty($form["parent"])){
......
<div id="preview-elt-<?php echo $type ?>-<?php echo (string)$element["_id"] ?>">
<div class="col-xs-12 padding-10 toolsMenu">
<button class="btn btn-default pull-right btn-close-preview">
<i class="fa fa-times"></i>
</button>
</div>
<div class="col-xs-12 no-padding">
<?php
$params = array("answer"=>$element ,
"page" => "page",
"type" => $type,
"form"=> PHDB::findOneById( Form::COLLECTION , $element["form"]),
"canEdit"=>@$canEdit,
"canEditForm"=>false,
"controller" => $controller);
$params = Form::getDataForm($params);
$params["mode"]=(isset($_GET["mode"])) ? $_GET["mode"] : "rplus";
echo $this->renderPartial('survey.views.tpls.forms.formWizard', $params );
?>
</div>
\ No newline at end of file
......@@ -2,6 +2,7 @@
//check show btn use cases
// role is financer or operater
if( $mode != "pdf" ){
if(Form::canFormAccess(['roles'=>["Financeur","Opérateur"] ])){
$isFinanceur=false;
if(Authorisation::isInterfaceAdmin())
......@@ -23,7 +24,9 @@ if( $mode != "pdf" ){
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Intention opérateur</h4></td>
<?php $label=(@$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
$str = "";
......@@ -68,7 +71,7 @@ if( $mode != "pdf" ){
//if role operateurs
if(!$selectedOperator){
if($isOperator && !$alreadyCandidate){
if($isOperator && !$alreadyCandidate && $answer["step"]!="deal12"){
?>
<tr>
<td colspan='2' class="text-center" >
......@@ -95,21 +98,76 @@ if( $mode != "pdf" ){
</div>
<?php }
} else { ?>
<div class="col-xs-12 text-center margin-top-50 well">
<?php if(@$answer["step"] && $answer["step"]=="deal1"){ ?>
<span style="font-size: 22px;font-weight: 800;">Vous avez soumis votre dossier pour qu'un opérateur se positionne dessus.<br/>Il est en cours de validation.
Cette étape sera validé par un opérateur et les financeurs.</span>
<?php }else{ ?>
<span class="text-center" style="font-size: 22px;font-weight: 800;">
Une fois votre dossier estimé rempli, vous pouvez le valider afin qu'il soit mis sous étude des opérateurs et des financeurs<br/><br/>
<a href="javascript:;" class="validateForSubmit btn btn-success">
Soumettre votre dossier
</a>
</span>
<?php
if(@$answer["step"]){
if($answer["step"]=="deal1"){ ?>
<div class="col-xs-12 text-center margin-top-50 well">
<span style="font-size: 22px;font-weight: 800;">Vous avez soumis votre dossier.<br/>Votre candidature est en attente d'opérateur<br/> Une fois positionné, l'opérateur prendra en charge la suite de la canditature afin d'établir les financenements et le suivi des travaux.</span>
</div>
<?php }else{
foreach ($answer["links"]["operators"] as $oid => $state) {
$opId=$oid;
$operator=Element::getElementById($oid, Organization::COLLECTION, null, array("name","slug", "profilThumbImageUrl"));
$thumbOp=(isset($operator["profilThumbImageUrl"])) ? Yii::app()->createUrl($operator["profilThumbImageUrl"]) : Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()."/images/thumb/default_organizations.png";
} ?>
<div class="col-xs-12 well margin-top-50">
<?php if($answer["step"]=="deal12"){ ?>
<span style="font-size: 22px;font-weight: 800;">Votre dossier est en attente de validation d'un administrateur<br/>L'opérateur que vous avez sélectionné pour la prise en charge du dossier est </span>
<?php }else{ ?>
<?php $labelStep=array(
"deal2"=> "en cours de construction par l'opérateur",
"deal3"=> "en cours d'attribution des financements", "deal4"=>"est en phase d'échelonnage du planning", "deal5"=>"finalisé. Vous pouvez réaliser le suivi des travaux"); ?>
<span style="font-size: 22px;font-weight: 800;"> Votre dossier est <?php echo $label[$answer["step"]] ?>.<br/><br> L'opérateur en charge du dossier est </span>
<?php } ?>
<a href="#page.type.organizations.id.<?php echo $opId ?>" class="lbh-preview-element"><img src="<?php echo $thumbOp ?>" width=40 height=40 style="margin-right: 5px;border-radius: 20px"/><?php echo $operator["name"] ?></a>
</div>
<?php }
}else{ ?>
<div class="form-operator col-xs-12 no-padding">
<label for="<?php echo $kunik ?>">
<h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">
Avez-vous une préférences sur le choix du maître d'ouvrage ?</h4>
</label>
<select id="operators-selections" path="links.operators" style="width:100%;">
<?php if(isset($answer["links"]) && isset($answer["links"]["operators"])){
foreach($answer["links"]["operators"] as $k => $v){
$operator=Element::getElementById($k, Organization::COLLECTION, null, array("name", "profilThumbImageUrl"));
echo "<option class='optoper' value='".$k."'>".$elt["name"]."</option>";
$selectedOps=$k;
}
} ?>
<option value="<?php echo @$selectedOps ?>" data-action="unset" class='optoperunset' <?php echo (!isset($selectedOps)) ? "selected" : "" ?>>Pas de préférences sur le maitre d'oeuvre</option>
<?php
foreach ($parentForm["communityLinks"] as $v => $f) {
if($f["type"]==Organization::COLLECTION
&& isset($f["roles"]) && in_array("Opérateur", $f["roles"])){
$elt=Element::getElementById($v, $f["type"], null, array("name", "profilThumbImageUrl"));
//$thumb=$elt["thumbImg"]=(isset($elt["profilThumbImageUrl"])) ? Yii::app()->createUrl($elt["profilThumbImageUrl"]) : Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()."/images/thumb/default_organizations.jpg";
echo "<option class='optoper' value='".$v."' ".((isset($selectedOps) && $selectedOps==$v) ? "selected" : "").">".$elt["name"]."</option>";
}
} ?>
</select>
</div>
<div class="col-xs-12 text-center margin-top-50 well">
<span class="text-center" style="font-size: 22px;font-weight: 800;">
Une fois votre dossier estimé rempli, vous pouvez le valider afin qu'il soit mis sous étude des opérateurs et des financeurs<br/><br/>
<a href="javascript:;" class="validateForSubmit btn btn-success" data-step="<?php echo (isset($selectedOps)) ? "deal12" : "deal1" ?>">
Soumettre votre dossier
</a>
</span>
</div>
<?php } ?>
</div>
<?php }
} ?>
?>
<script type="text/javascript">
......@@ -132,25 +190,41 @@ if( $mode != "pdf" ){
};
$(this).fadeOut();
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal3" //pourrait etre un parametre element.costum.form.stepOperateur : deal3
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
} );
} );
validateForStep3();
});
$("#operators-selections").off().on("change", function(){
var oid = $(this).val();
if(notNull(oid)){
var valOp= 0;
submitVal="deal12";
$(".optoperunset").val(oid);
if(notNull($(this).find(":selected").data("action"))){
valOp=null;
submitVal="deal1";
}
$(".validateForSubmit").attr("data-step",submitVal);
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "links.operators."+oid,
value : valOp
};
// if(notNull($(this).data("action"))
// ctxTpl.action=$(this).data("action");
dataHelper.path2Value( ctxTpl, function(params) {
toastr.success("Votre préférence opérateur a bien été prise en compte");
//urlCtrl.loadByHash(location.hash);
});
}
});
$('.validateForSubmit').off().on("click", function() {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal1"
value : $(this).data("step")
};
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
......@@ -168,10 +242,49 @@ if( $mode != "pdf" ){
urlCtrl.loadByHash(location.hash);
} );
});
$('.selectOperator').off().on("click", function() {
var oid = $(this).data("oid");
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "links.operators."+oid,
value : "0"
};
dataHelper.path2Value( ctxTpl, function(params) {
/*ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal12"
};
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
});*/
urlCtrl.loadByHash(location.hash);
} );
});
});
function validateForStep3(){
dataHelper.path2Value( ctxTpl, function(params) {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal3" //pourrait etre un parametre element.costum.form.stepOperateur : deal3
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
} );
} );
}
</script>
<?php
}
?>
\ No newline at end of file
<?php
$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//var_dump($styleT);
$colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
?>
......@@ -16,125 +16,118 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
<?php echo $info ?>
<?php
} ?>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik ; ?>"
>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik ; ?>" >
<thead>
<?php
if( count($answers)>0 ){ ?>
<tr>
<?php
foreach ($properties as $i => $inp) {
echo "<th>".$inp["placeholder"]."</th>";
} ?>
<?php
if($mode != "r" && $mode != "pdf"){ ?>
<th></th>
<?php } ?>
</tr>
<?php } ?>
</thead>
<tbody class="directoryLines">
<?php
$ct = 0;
if(isset($answers)){
foreach ($answers as $q => $a) {
$tds = "";
<thead>
<?php
if( count($answers)>0 ){ ?>
<tr>
<?php
foreach ($properties as $i => $inp) {
$tds .= "<td>";
echo "<th>".$inp["placeholder"]."</th>";
} ?>
if( $i == "price" ) {
if(!empty($a["price"]))
$tds .= "<span id='price".$q."'>".$a["price"]."€</span>";
if( $paramsData["estimate"] )
{
$tds .= "<a href='javascript:;' data-id='".$answer["_id"]."' data-key='".$key."' data-form='".$form["id"]."' data-pos='".$q."' class='btn btn-xs btn-primary btnEstimate margin-left-5 padding-10'><i class='fa fa-plus'></i></a>";
if( isset($a["estimates"] ))
{
foreach ( $a["estimates"] as $uid => $esti )
<?php
if($mode != "r" && $mode != "pdf"){ ?>
<th></th>
<?php } ?>
</tr>
<?php } ?>
</thead>
<tbody class="directoryLines">
<?php
$ct = 0;
if(isset($answers)){
foreach ($answers as $q => $a) {
$tds = "";
foreach ($properties as $i => $inp) {
$tds .= "<td>";
if( $i == "price" ) {
if(!empty($a["price"]))
$tds .= "<span id='price".$q."'>".$a["price"]."€</span>";
if( $paramsData["estimate"] )
{
$tds .= "<a href='javascript:;' data-id='".$answer["_id"]."' data-key='".$key."' data-form='".$form["id"]."' data-pos='".$q."' class='btn btn-xs btn-primary btnEstimate margin-left-5 padding-10'><i class='fa fa-plus'></i></a>";
if( isset($a["estimates"] ))
{
$selected = ( isset($esti["selected"]) ) ? "success" : "default";