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

repairing finance input on deal

parent 0d1d9c8f
......@@ -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() };
......@@ -145,11 +145,11 @@ $(document).ready(function() {
};
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",
......@@ -230,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);
});
......@@ -324,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>";
......
......@@ -97,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,
......@@ -134,6 +134,7 @@ foreach ( $amounts as $k => $l) {
<?php
$ct = 0;
$totalFunded = 0;
$total = 0;
if($answers){
foreach ($answers as $q => $a) {
......@@ -186,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>";
}
......@@ -198,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 ){
......@@ -250,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é";
......@@ -281,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>";
}
......@@ -304,6 +308,8 @@ if($total > 0){
?>
</tbody>
</table>
......@@ -313,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>".
......@@ -337,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>
......@@ -431,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');
urlCtrl.loadByHash(location.hash);
} );
dataHelper.path2Value( tplCtx, closePrioModalRel );
}
}
......@@ -553,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";
......
......@@ -139,7 +139,7 @@ $properties = [
<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>
......@@ -1126,13 +1126,8 @@ var listObj = {
}
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>";
......
......@@ -527,7 +527,8 @@ function saveLinks(id,linkType,uid,callB){
if(typeof callB == "function" )
callB();
} );
}
} else if(typeof callB == "function" )
callB();
}
</script>
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