Commit ea1e45e6 authored by Clément Damiens's avatar Clément Damiens
Browse files

Merge branch 'FlorentBen' into 'master'

Debugs et amelio DEAL

See merge request !31
parents 2f99a9b3 8d546635
......@@ -54,6 +54,7 @@
},
"deal4" : {
"roles" : [
"Opérateur",
"Financeur"
]
}
......@@ -216,19 +217,6 @@
"Oui" : ": Entrez ici l'année"
}
},
"multiRadiodeal143" : {
"global" : {
"list" : [
"Légère",
"Lourde"
],
"width" : ""
},
"tofill" : {
"Légère" : "simple",
"Lourde" : "simple"
}
},
"multiRadiodeal142" : {
"global" : {
"list" : [
......@@ -249,8 +237,8 @@
"multiRadiodeal149" : {
"global" : {
"list" : [
"Petit travaux",
"Grand travaux"
"Petits travaux",
"Grands travaux"
],
"width" : ""
},
......@@ -318,7 +306,6 @@
"deal140",
"deal123",
"deal121",
"deal125",
"deal128",
"deal135b",
"deal137",
......@@ -483,7 +470,7 @@
"position" : "7"
},
"deal130" : {
"label" : "N° Allocataire RSA",
"label" : "N° Allocataire CAF",
"type" : "text",
"position" : "8"
},
......@@ -541,11 +528,6 @@
"type" : "tpls.forms.cplx.multiRadio",
"position" : "16"
},
"deal136" : {
"label" : "Cochez selon le dossier (la présente plate-forme ne concerne que l'amélioration)",
"type" : "tpls.forms.cplx.multiCheckboxPlus",
"position" : "17"
},
"deal135b" : {
"label" : "Personnes occupant le logement",
"type" : "tpls.forms.costum.deal.totalRevenu",
......@@ -598,11 +580,6 @@
"type" : "tpls.forms.cplx.multiRadio",
"position" : "26"
},
"deal143" : {
"label" : "Type d’amélioration",
"type" : "tpls.forms.cplx.multiRadio",
"position" : "27"
},
"deal111b" : {
"label" : "Nature des travaux",
"type" : "tpls.forms.cplx.multiCheckboxPlus",
......@@ -801,19 +778,33 @@
"docType" : "file",
"paste" : "false",
"restricted" : "true",
"itemLimit" : "1"
}
"itemLimit" : "10"
},
"showUpdateDate" : "true"
},
"deal30" : {
"label" : "Autres pièces relatives au dossier",
"placeholder" : "",
"info" : "",
"type" : "tpls.forms.uploader",
"uploader" : {
"docType" : "file",
"paste" : "false",
"restricted" : "true",
"itemLimit" : "10"
},
"showUpdateDate" : "true"
},
"deal32" : {
"label" : "Total des dépenses prévisionnelles (en €)",
"placeholder" : "",
"info" : "",
"info" : "En cas de décimal, utilisez un point (.) à la place de la virgule (,)",
"type" : "text"
},
"deal33" : {
"label" : "Total des dépenses subventionnables (en €)",
"placeholder" : "",
"info" : "",
"info" : "En cas de décimal, utilisez un point (.) à la place de la virgule (,)",
"type" : "text"
},
"verifyNumberdeal3" : {
......
......@@ -802,5 +802,10 @@ class Form {
return true;
}
public static function getFormById($id){
$form = PHDB::findOne( Form::COLLECTION, ["id"=>$id] );
return $form;
}
}
?>
\ No newline at end of file
......@@ -8,6 +8,9 @@ HtmlHelper::registerCssAndScriptsFiles(array(
.toolsMenu{
box-shadow: 0px 1px 3px 0px #a3a3a3;
}
#modal-preview-coop{
overflow : scroll;
}
</style>
<script type="text/javascript">
var sectionDyf = {};
......@@ -25,6 +28,7 @@ HtmlHelper::registerCssAndScriptsFiles(array(
</div>
<div class="col-xs-12 no-padding container-preview">
<?php
$params = [
"form"=> PHDB::findOneById( Form::COLLECTION , $element["form"]),
"canEdit" => @$canEdit,
......@@ -43,7 +47,7 @@ HtmlHelper::registerCssAndScriptsFiles(array(
$params["canEditForm"]=false;
$params["canAdminAnswer"] = false;
//var_dump($params["canAdminAnswer"]);
//var_dump($params);
echo $this->renderPartial("survey.views.tpls.forms.wizard",$params);
?>
</div>
......
<div class="form-group">
<?php
if(!empty($label)){ ?>
<h3 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h3>
<?php } ?>
<?php
$deal3=Form::getFormById("deal3");
// var_dump ($deal3["inputs"]["deal37"]);exit;
for ($i=37;$i<=38;$i++){
if(isset($answer["answers"]["deal3"]["deal".$i])){
$deal3["inputs"]["deal".$i]["label"]; ?>
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $key.$i ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $deal3["inputs"]["deal".$i]["label"] ?></h4></label><br/>
<?php echo $answer["answers"]["deal3"]["deal".$i]; ?>
</div>
<?php
}
}
?>
\ No newline at end of file
<?php
$nbAnswer = (isset($answer["answers"][$form["id"]]["deal404"])) ? count($answer["answers"][$form["id"]]["deal404"]) : 0 ;
$nbAns=(isset($answer["answers"]["deal3"]["deal36"])) ? count($answer["answers"]["deal3"]["deal36"]) : 0;
$refused=null;
if(isset($answer["answers"][$form["id"]]["deal404"])){
$refused = 0;
foreach ($answer["answers"][$form["id"]]["deal404"] as $fin => $ans) {
if(in_array("refused", $ans)){
$refused ++;
}
}
}
$reloadIn = "";
foreach ($form["inputs"] as $keyfI => $valuefI) {
if ($valuefI["type"] == "tpls.forms.costum.deal.validateStep") {
$reloadIn = $keyfI;
}
}
?>
<script type="text/javascript">
$("form :input").on('blur', function() {
mylog.log("aaaaaaaa");
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
});
$(document).ready(function() {
var tplCtx = {};
<?php
if(empty($answers && isset($refused))){ ?>
// alert("pas vide");
<?php if ($nbAnswer==$nbAns && $refused==0) {
?> // alert("égale");
tplCtx.value = "validée";
$.when(validateNumberInput<?php echo $kunik ?>()).then(
reloadInput("<?php echo $reloadIn ?>", "<?php echo (string)$form["_id"] ?>")
);
<?php
} else if($refused>0){ ?>
alert("Un financeur a refusé l'attribution d'une subvention. Le dossier est donc pour le moment en suspens.");
<?php } ?>
// }
// else{
// alert("pas égale");
// tplCtx.value = "";
// $.when(validateNumberInput<?php echo $kunik ?>()).then(
// reloadInput("<?php echo $reloadIn ?>", "<?php echo (string)$form["_id"] ?>")
// );
<?php
// }
}
?>
function validateNumberInput<?php echo $kunik ?>() {
tplCtx.id = "<?php echo $answer["_id"] ?>";
tplCtx.path = "<?php echo "answers.".$form["id"].".".$key ?>";
tplCtx.collection = "<?php echo Form::ANSWER_COLLECTION ?>";
mylog.log("validateNumberdeal4",tplCtx);
dataHelper.path2Value( tplCtx, function(params) {
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
} );
};
});
</script>
\ No newline at end of file
<?php
$formList = [];
$paramsData = [
"sign" => "",
"one" => "",
"two" => "",
"oneValue" => "",
"twoValue" => ""
];
$sign = [
"more" => "N1 > N2",
"moreEqual" => "N1 >= N2",
"less" => "N1 < N2",
"lessEqual" => "N1 <= N2",
"equal" => "N1 = N2"
];
$editParamsBtn = ($canEditForm and $mode != "r" || $mode != "pdf") ? "Comparateur <a href='javascript:;' data-id='".$parentForm["_id"]."' data-collection='".Form::COLLECTION."' data-path='params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
if( isset($parentForm["params"][$kunik]["sign"]) ){
$paramsData["sign"] = $parentForm["params"][$kunik]["sign"];
}
if( isset($parentForm["params"][$kunik]["one"]) ){
$paramsData["one"] = $parentForm["params"][$kunik]["one"];
if (isset($answer["answers"][$form["id"]])) {
foreach ($answer["answers"][$form["id"]] as $kAns => $vAns) {
// var_dump("(",$kAns,")");
// var_dump(is_numeric($vAns));
if(strpos($kAns, $parentForm["params"][$kunik]["one"]) !== false && is_numeric($vAns) ){
$paramsData["oneValue"] = (int)$vAns;
}
}
}
}
if( isset($parentForm["params"][$kunik]["two"]) ){
$paramsData["two"] = $parentForm["params"][$kunik]["two"];
if (isset($answer["answers"][$form["id"]])) {
foreach ($answer["answers"][$form["id"]] as $kAns => $vAns) {
if(strpos($kAns, $parentForm["params"][$kunik]["two"]) !== false && is_numeric($vAns) ){
$paramsData["twoValue"] = (int)$vAns;
}
}
}
}
if (isset($form)) {
foreach ($form["inputs"] as $fid => $fvalue) {
if ($fid != $key) {
$formList[$fid] = $fvalue["label"];
}
}
}
function isValid($sign,$oneV,$twoV){
if ($sign == "more" && $oneV > $twoV) {
return true;
} elseif ($sign == "moreEqual" && $oneV >= $twoV) {
return true;
} elseif ($sign == "less" && $oneV < $twoV) {
return true;
} elseif ($sign == "lessEqual" && $oneV <= $twoV) {
return true;
}
return false;
}
echo $editParamsBtn;
$reloadIn = "";
foreach ($form["inputs"] as $keyfI => $valuefI) {
if ($valuefI["type"] == "tpls.forms.costum.deal.validateStep") {
$reloadIn = $keyfI;
}
}
?>
<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 ); ?>;
$("form :input").on('blur', function() {
mylog.log("aaaaaaaa");
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
});
$(document).ready(function() {
<?php
if ($paramsData["sign"] != "" && $paramsData["one"] != "" && $paramsData["two"] != "" && $paramsData["oneValue"] != "" && $paramsData["twoValue"] != "" && $answers == null && isValid($paramsData["sign"], $paramsData["oneValue"],$paramsData["twoValue"]) && $reloadIn != "") {
?>
$.when(validateNumberInput<?php echo $kunik ?>()).then(
reloadInput("<?php echo $reloadIn ?>", "<?php echo (string)$form["_id"] ?>")
);
<?php
}
?>
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"description" : "Liste de question possible",
"icon" : "fa-cog",
"properties" : {
sign : {
inputType : "select",
label : "Fonction",
options : <?php echo json_encode($sign) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.sign
},
one : {
inputType : "select",
label : "N1",
options : <?php echo json_encode($formList) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.one
},
two : {
inputType : "select",
label : "N2",
options : <?php echo json_encode($formList) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.two
}
},
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) {
dyFObj.closeForm();
urlCtrl.loadByHash(location.hash);
} );
}
}
}
};
$(".edit<?php echo $kunik ?>Params").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 ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
function validateNumberInput<?php echo $kunik ?>() {
tplCtx = {};
tplCtx.id = "<?php echo $answer["_id"] ?>",
tplCtx.path = "<?php echo "answers.".$form["id"].".".$key ?>",
tplCtx.collection = "<?php echo Form::ANSWER_COLLECTION ?>";
tplCtx.value = "validée";
dataHelper.path2Value( tplCtx, function(params) {
reloadInput("<?php echo $key ?>", "<?php echo (string)$form["_id"] ?>");
} );
};
});
</script>
\ No newline at end of file
<div class="form-group">
<?php if(!empty($label)){ ?>
<h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4>
<?php } ?>
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
<?php
$community=$this->costum["communityLinks"]["members"];
foreach ($community as $id => $value){
if(isset($value["roles"]) && isset($value["type"]) && $value["type"]=="organizations" && in_array("Financeur",$value["roles"])){
$el=Element::getElementById($id,"organizations");
//echo $el["name"];
$value = (isset($answer["answers"][$form["id"]][$key][$id])) ? $answer["answers"][$form["id"]][$key][$id] : "";
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h5 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $el["name"] ?></h5></label><br/>
<?php echo $value; ?>
</div>
<?php
}else{
?>
<div class="form-group">
<label for="<?php echo $key ?>"><h5 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $el["name"] ?></h5></label>
<br/><input type="text" class="form-control <?php echo $key ?>"
data-id="<?php echo $id ?>" data-path="<?php echo "answers.".$form["id"].".".$key.".".$id ?>" aria-describedby="<?php echo $key ?>Help" placeholder="<?php echo (isset($placeholder)) ? $placeholder : '' ?>" data-form='<?php echo $form["id"] ?>' value= "<?php echo $value ?>" >
</div>
<?php }
}
}
// var_dump("<pre>",$this->costum["communityLinks"]["members"],"</pre>");exit;
?>
</div>
<script type="text/javascript">
var answerId = <?php echo json_encode((String)$answer['_id']); ?>;
var key = <?php echo json_encode($key) ?>;
$( document ).ready(function() {
$('.' + key ).change(function(){
tplCtx={};
tplCtx.id=answerId;
tplCtx.collection="answers";
tplCtx.path=$(this).data("path");
tplCtx.value=$(this).val();
dataHelper.path2Value( tplCtx, function(params) {
toastr.success("Demande de financement enregistrée");
});
});
});
</script>
\ No newline at end of file
......@@ -9,18 +9,20 @@ if($type == "tags")
if($saveOneByOne)
$inpClass .= " saveOneByOne";
$isFinanceur=false;
$isOperator=false;
if(Authorisation::isInterfaceAdmin())
$isFinanceur=true;
if(isset($this->costum[$this->costum["slug"]]["financorOf"])){
if(isset($this->costum["financorOf"])){
$isFinanceur=true;
}
if(isset($this->costum["hasRoles"]) && in_array("Opérateur", $this->costum["hasRoles"])){
$isOperator=true;
}
if ($isFinanceur || $isOperator) {
// if ($isFinanceur || $isOperator) {
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
......@@ -71,4 +73,6 @@ if($mode == "r" || $mode == "pdf"){ ?>
</script>
<?php } } ?>
\ No newline at end of file
<?php }
// }
?>
\ No newline at end of file
<?php
$cssJS = array(
'/plugins/jQuery-Knob/js/jquery.knob.js',
'/plugins/jQuery-Smart-Wizard/js/jquery.smartWizard.js',
//'/plugins/jQuery-Smart-Wizard/styles/smart_wizard.css',
// SHOWDOWN
'/plugins/showdown/showdown.min.js',
// MARKDOWN
'/plugins/to-markdown/to-markdown.js'
);
HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->request->baseUrl);
HtmlHelper::registerCssAndScriptsFiles(array(
'/js/answer.js',
), Yii::app()->getModule( Survey::MODULE )->getAssetsUrl() );
$isFinanceur=false;
if(Authorisation::isInterfaceAdmin())
$isFinanceur=true;
if(isset($this->costum[$this->costum["slug"]]["financorOf"])){
if(isset($this->costum["financorOf"])){
$isFinanceur=true;
}
......
......@@ -33,7 +33,7 @@ if($mode == "r" || $mode == "pdf"){ ?>
?>
<div class="form-group">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<br/><input type="<?php echo (!empty($type)) ? $type : 'text' ?>" class="<?php echo $inpClass ?>" id="<?php echo $key ?>" aria-describedby="<?php echo $key ?>Help" placeholder="<?php echo (isset($placeholder)) ? $placeholder : '' ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> >
<br/><input type="<?php echo (!empty($type)) ? $type : 'text' ?>" readonly class="<?php echo $inpClass ?>" id="<?php echo $key ?>" aria-describedby="<?php echo $key ?>Help" placeholder="<?php echo (isset($placeholder)) ? $placeholder : '' ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> >
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>