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

Merge branch 'development' of https://gitlab.adullact.net/pixelhumain/survey into development

parents 2d251feb d5da39f3
var answerObject={
delete : function(id, callB){
getAjax("",baseUrl+"/survey/co/delete/id/"+id,function(){
if(notNull(callB))
callB();
else{
toastr.success("La candidature a été supprimée avec succès");
$("#allAnswersList .ansline"+id).remove();
}
},"html");
}
}
\ No newline at end of file
......@@ -417,11 +417,8 @@ class Form {
public static function canSeeAnswer($userId, $answer, $form, $parentForm){
if(self::canEditAnswer($userId, $answer, $form, $parentForm))
return true;
// else if(Costum::sameFunction("canSeeAnswer", array("answer"=>$answer))){
// return true;
// }
else if(Costum::isSameFunction("canEditAnswer", array("answer"=>$answer)))
return Costum::sameFunction("canEditAnswer", array("answer"=>$answer));
else if(Costum::isSameFunction("canSeeAnswer", array("answer"=>$answer)))
return Costum::sameFunction("canSeeAnswer", array("answer"=>$answer));
return false;
}
public static function canEditAnswer($userId, $answer, $form, $parentForm){
......
......@@ -3,7 +3,7 @@
#allAnswersList li{ padding:5px; border-bottom: 1px solid #ccc; }
</style>
<div class="col-xs-12 text-center">
<div class="col-xs-12 text-center dash-answers">
<a href="javascript:;" class='btn btn- btn-default' id="showAnswerBtn<?php echo @$viewDom ?>"><i class="fa fa-bars"></i> Les <?php echo $what ?></a>
<a href="#dashboard" class='lbh btn btn-default'><i class="fa fa-area-chart"></i> Observatoire Global</a>
<a href="#community" class='lbh btn btn-default'><i class="fa fa-group"></i> Communauté</a>
......
<?php
//check show btn use cases
// role is financer or operater
if( Form::canFormAccess( ['roles'=>["Financeur","opérateur"] ]))
if( Form::canFormAccess( ['roles'=>["Financeur","Opérateur"] ]))
{
if( isset($form['id']) )
{ ?>
......@@ -86,8 +87,21 @@ if( Form::canFormAccess( ['roles'=>["Financeur","opérateur"] ]))
</tbody>
</table>
<?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 } ?>
</div>
<?php } ?>
......@@ -125,7 +139,17 @@ $(document).ready(function() {
} );
} );
});
$('.validateForSubmit').off().on("click", function() {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal1"
};
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
});
} );
$('.intentOperator').off().on("click", function() {
var oid = $(this).data("oid");
ctxTpl = {
......@@ -143,8 +167,3 @@ $(document).ready(function() {
});
</script>
<?php } else {?>
<div class="col-xs-12">
Cette étape sera validé par un opérateur et les financeurs.
</div>
<?php } ?>
\ No newline at end of file
......@@ -119,11 +119,11 @@ sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData
$(document).ready(function() {
sectionDyf.<?php echo $kunik ?> = {
"jsonSchema" : {
"title" : "Budget prévisionnel",
"icon" : "fa-money",
"text" : "Décrire ici les principaux postes de dépenses : à quoi correspondent les coûts ? <br/>Préciser ce qui relève des dépenses de fonctionnement et des dépenses d’investissement.<br/>Les coûts doivent être en <b>hors taxe</b>.",
"properties" : <?php echo json_encode( $properties ); ?>,
jsonSchema : {
title : "Budget prévisionnel",
icon : "fa-money",
text : "Décrire ici les principaux postes de dépenses : à quoi correspondent les coûts ? <br/>Préciser ce qui relève des dépenses de fonctionnement et des dépenses d’investissement.<br/>Les coûts doivent être en <b>hors taxe</b>.",
properties : <?php echo json_encode( $properties ); ?>,
save : function () {
var today = new Date();
tplCtx.value = { date : today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear() };
......@@ -137,20 +137,19 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
}
}
};
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"description" : "Liste de question possible",
"icon" : "fa-cog",
"properties" : {
jsonSchema : {
title : "<?php echo $kunik ?> config",
description : "Liste de question possible",
icon : "fa-cog",
properties : {
group : {
inputType : "array",
label : "Liste des groups",
......@@ -201,7 +200,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -231,9 +230,6 @@ $(document).ready(function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//if no params config on the element.costum.form.params.<?php echo $kunik ?>
//then we load default values available in forms.inputs.<?php echo $kunik ?>xxx.params
//mylog.log(".editParams",sectionDyf.<?php echo $kunik ?>Params,calData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
......@@ -325,6 +321,13 @@ $(document).ready(function() {
});
function closePrioModal(){
prioModal.modal('hide');
}
function closePrioModalRel(){
closePrioModal();
urlCtrl.loadByHash(location.hash);
}
</script>
<?php } else {
//echo "<h4 class='text-red'>CALENDAR works with existing answers</h4>";
......
......@@ -146,7 +146,7 @@ $(document).ready(function() {
dataHelper.path2Value( tplCtx, function(params) {
//$("#ajax-modal").modal('hide');
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -185,7 +185,7 @@ $(document).ready(function() {
dataHelper.path2Value( tplCtx, function(params) {
//$("#ajax-modal").modal('hide');
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -3,6 +3,9 @@
if( isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
$copy = $this->costum["form"]["params"][$kunik]["budgetCopy"];
else if( count(Yii::app()->session["budgetInputList"]) == 1 )
$copy = array_keys( Yii::app()->session["budgetInputList"])[0];
//var_dump($copy);
$copyT = explode(".", $copy);
$copyF = $copyT[0];
......@@ -287,6 +290,8 @@ if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
<script type="text/javascript">
if(typeof costum.lists == "undefined")
costum.lists = {};
if(typeof costum.lists == "undefined")
costum.lists.budgetInputList = <?php echo json_encode( Yii::app()->session["budgetInputList"] ); ?>;
//costum.lists.financerTypeList = <?php //echo json_encode(Ctenat::$financerTypeList); ?>;
costum.lists.workerList = <?php echo json_encode($orgs); ?>;
......@@ -313,7 +318,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -358,7 +363,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -491,7 +496,7 @@ function closePrioModal(){
}
function closePrioModalRel(){
closePrioModal();
location.reload();
urlCtrl.loadByHash(location.hash);
}
</script>
<?php } else {
......
......@@ -186,7 +186,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -223,7 +223,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -154,7 +154,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value ( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
}
......@@ -205,7 +205,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -137,7 +137,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -235,7 +235,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -282,7 +282,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -4,6 +4,8 @@ $copy = "opalProcess1.depense";
if( isset($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
$copy = $this->costum["form"]["params"][$kunik]["budgetCopy"];
else if( count(Yii::app()->session["budgetInputList"]) == 1 )
$copy = array_keys( Yii::app()->session["budgetInputList"])[0];
//var_dump($copy);
$copyT = explode(".", $copy);
$copyF = $copyT[0];
......@@ -95,7 +97,7 @@ $properties = [
"size" => 6,
]
];
$amounts = (isset($this->costum["form"]["params"][$budgetKey]["amounts"])) ? $this->costum["form"]["params"][$budgetKey]["amounts"] : ["price" => "Price"] ;
$amounts = (isset($this->costum["form"]["params"][$budgetKey]["amounts"])) ? $this->costum["form"]["params"][$budgetKey]["amounts"] : ["price" => "Montant Financé"] ;
foreach ( $amounts as $k => $l) {
$properties[$k] = [ "inputType" => "text",
"label" => $l,
......@@ -112,7 +114,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($this->costum["form"]["params"][$kunik]["budgetCopy"]) )
if( !isset($budgetKey) )
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>
......@@ -132,6 +134,7 @@ foreach ( $amounts as $k => $l) {
<?php
$ct = 0;
$totalFunded = 0;
$total = 0;
if($answers){
foreach ($answers as $q => $a) {
......@@ -184,11 +187,13 @@ foreach ( $amounts as $k => $l) {
if(!empty($fin["amount"])){
$tds .= $fin["amount"]."€";
$totalAmountFunded += (int)$fin["amount"];
}
$tds .= "</td>";
$tds .= "<td class='col-xs-2'>";
if(!empty($fin["amount"]) && isset($a["price"])){
$percent = $fin["amount"] * 100 / (int)$a["price"];
$tds .= " <span class='pull-right label label-primary'>".floor($percent)."%</span>";
}
......@@ -196,11 +201,14 @@ foreach ( $amounts as $k => $l) {
$tds .= "</tr>";
}
$totalFunded += $totalAmountFunded;
$tds .= "</table>";
if($totalAmountFunded>0 && isset( $a["price"] )){
$percentAmountFunded = $totalAmountFunded * 100 / (int)$a["price"];
$total += (int)$a["price"];
$percol = "danger";
$trStyle = "background-color:#ffdada";
if( $percentAmountFunded >= 50 ){
......@@ -248,17 +256,16 @@ foreach ( $amounts as $k => $l) {
$color = "default";
$valbl = "?";
$tool= "En attente de validation";
if( isset($a["financing"]["valid"]) ){
if( $a["valid"]["valid"] == "validated" ){
if( isset($a["validFinal"]["valid"]) ){
if( $a["validFinal"]["valid"] == "validated" ){
$color = "success";
$valbl = "V";
$tool="Validé sans réserve";
$totalFunded += 300;
} else if( $a["financing"]["valid"] == "reserved" ){
} else if( $a["validFinal"]["valid"] == "reserved" ){
$color = "warning";
$valbl = "R";
$tool="Validé avec réserves";
} else if( $a["financing"]["valid"] == "refused" ){
} else if( $a["validFinal"]["valid"] == "refused" ){
$color = "danger";
$valbl = "NV";
$tool="Non validé";
......@@ -279,22 +286,21 @@ foreach ( $amounts as $k => $l) {
}
$total = (isset(Yii::app()->session["totalBudget"])) ? Yii::app()->session["totalBudget"] : 0;
if($totalFunded > 0){
if($total > 0){
echo "<tr class='bold'>";
echo "<td colspan=".count($properties)." style='text-align:right'>TOTAL FINANCÉ: </td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($totalFunded),3, ' ')))." €</td>";
echo "<td colspan=2 style='text-align:right'>TOTAL À FINANCER : </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
}
if($total > 0){
if($totalFunded > 0){
echo "<tr class='bold'>";
echo "<td colspan=".count($properties)." style='text-align:right'>TOTAL À FINANCER : </td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "<td colspan=2 style='text-align:right'>TOTAL FINANCÉ: </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($totalFunded),3, ' ')))." €</td>";
echo "</tr>";
}
......@@ -302,6 +308,8 @@ if($total > 0){
?>
</tbody>
</table>
......@@ -311,7 +319,7 @@ if($total > 0){
<?php
$percol = "warning";
$financedPercentage = (!empty($total)) ? $totalFunded * 100 / $total: 0;
if( $financedPercentage == 100 ){
if( $financedPercentage >= 100 ){
$percol = "success";
}
echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Pourcentage de Financement Globale</h4>".
......@@ -335,14 +343,16 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Pourcentage
<td>Pourcentage financé</td>
<td><?php echo floor($financedPercentage) ?> %</td>
</tr>
<?php if($total>$totalFunded){ ?>
<tr>
<td>Reste à financer </td>
<td><?php echo floor($total-$totalFunded) ?></td>
</tr>
<tr>
<td>Resta à financer </td>
<td><?php echo floor(100-$financedPercentage)+1 ?> %</td>
</tr>
<td>% Reste à financer </td>
<td><?php echo floor(100-$financedPercentage) ?> %</td>
</tr>
<?php } ?>
</tbody>
</table>
......@@ -403,6 +413,8 @@ if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
<script type="text/javascript">
if(typeof costum.lists == "undefined")
costum.lists = {};
if(typeof costum.lists == "undefined")
costum.lists.budgetInputList = <?php echo json_encode( Yii::app()->session["budgetInputList"] ); ?>;
costum.lists.financerTypeList = <?php echo json_encode(Ctenat::$financerTypeList); ?>;
costum.lists.financersList = <?php echo json_encode($orgs); ?>;
......@@ -427,10 +439,7 @@ $(document).ready(function() {
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
} );
dataHelper.path2Value( tplCtx, closePrioModalRel );
}
}
......@@ -494,7 +503,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -549,7 +558,7 @@ $(document).ready(function() {
var formInputsHere = formInputs;
tplCtx.path = "answers";
if( notNull(formInputs [tplCtx.form]) )
tplCtx.path = "answers."+tplCtx.form;
tplCtx.path = "answers";
tplCtx.path = tplCtx.path+"."+tplCtx.budgetpath+"."+tplCtx.pos+".validFinal";
......@@ -623,7 +632,7 @@ $(document).ready(function() {
mylog.log("btnFinancer save",tplCtx);
dataHelper.path2Value( tplCtx, function(params) {
prioModal.modal('hide');
saveLinks(answerObj._id.$id,"financerAdded",userId,function(){location.reload();});
saveLinks(answerObj._id.$id,"financerAdded",userId,function(){urlCtrl.loadByHash(location.hash);});
} );
}
......
......@@ -145,7 +145,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -184,7 +184,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -231,7 +231,7 @@ $(document).ready(function() {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
}
......
......@@ -65,7 +65,7 @@ jQuery(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -140,7 +140,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -184,7 +184,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -65,7 +65,7 @@ jQuery(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -22,7 +22,7 @@ if( Form::canFormAccess( ['roles'=>["Financeur"] ]) )
<tbody class="directoryLines">
<tr>
<td colspan='2' ><43 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Validation</h4>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Validation</h4>
</td>
</tr>
<?php
......@@ -134,7 +134,7 @@ $(document).ready(function() {
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......@@ -202,10 +202,10 @@ $(document).ready(function() {
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
location.reload();
urlCtrl.loadByHash(location.hash);
} );
} else
location.reload();
urlCtrl.loadByHash(location.hash);
} );