| 31020 |
tejbeer |
1 |
|
| 34527 |
tejus.loha |
2 |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
| 31001 |
amit.gupta |
3 |
|
| 34527 |
tejus.loha |
4 |
|
|
|
5 |
<!-- Chart.js Datalabels plugin for v2 -->
|
|
|
6 |
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0"></script>
|
|
|
7 |
|
|
|
8 |
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"></script>
|
|
|
9 |
|
|
|
10 |
|
| 33501 |
ranu |
11 |
<div>
|
| 31001 |
amit.gupta |
12 |
|
|
|
13 |
|
| 34527 |
tejus.loha |
14 |
|
| 31001 |
amit.gupta |
15 |
<div class="row">
|
| 34527 |
tejus.loha |
16 |
<div class="col-lg-7">
|
|
|
17 |
<h4><strong>Investometer</strong></h4>
|
|
|
18 |
<canvas id="investometerGauge"></canvas>
|
|
|
19 |
</div>
|
| 31001 |
amit.gupta |
20 |
|
| 34527 |
tejus.loha |
21 |
|
|
|
22 |
|
|
|
23 |
<div class="col-lg-5">
|
|
|
24 |
<h4 style="margin-bottom:24px " ><strong>Banner for Shopfront</strong></h4>
|
| 33501 |
ranu |
25 |
<div class="form-group">
|
| 33504 |
ranu |
26 |
#if(!$printResources.isEmpty())
|
| 34527 |
tejus.loha |
27 |
<div id="myCarousel" class="carousel slide" data-ride="carousel" style="margin-top: 50px">
|
| 33504 |
ranu |
28 |
<!-- Wrapper for slides -->
|
|
|
29 |
<div class="carousel-inner text-center">
|
| 33501 |
ranu |
30 |
#set($first = true)
|
|
|
31 |
#foreach($printResource in $printResources)
|
|
|
32 |
<div class="item #if($first)active#set($first = false)#end">
|
|
|
33 |
<img src="$printResource.getThumbnailUrl()" alt="Los Angeles"
|
|
|
34 |
style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
|
|
|
35 |
<div class="carousel-caption">
|
|
|
36 |
<br>
|
| 33502 |
ranu |
37 |
<button class="btn btn-danger btn-sm partner_print_resources">Get File !
|
|
|
38 |
</button>
|
| 33501 |
ranu |
39 |
</div>
|
|
|
40 |
</div>
|
| 34527 |
tejus.loha |
41 |
|
| 33501 |
ranu |
42 |
#end
|
| 33504 |
ranu |
43 |
</div>
|
|
|
44 |
<!-- Left and right controls -->
|
|
|
45 |
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
|
|
|
46 |
<span class="glyphicon glyphicon-chevron-left"></span>
|
|
|
47 |
<span class="sr-only">Previous</span>
|
|
|
48 |
</a>
|
|
|
49 |
<a class="right carousel-control" href="#myCarousel" data-slide="next">
|
|
|
50 |
<span class="glyphicon glyphicon-chevron-right"></span>
|
|
|
51 |
<span class="sr-only">Next</span>
|
|
|
52 |
</a>
|
| 33501 |
ranu |
53 |
</div>
|
| 33504 |
ranu |
54 |
#end
|
|
|
55 |
#if($printResources.isEmpty())
|
|
|
56 |
<div class="form-group">
|
|
|
57 |
<img src="/resources/images/image-not-found.png"
|
|
|
58 |
style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
|
|
|
59 |
</div>
|
|
|
60 |
#end
|
| 33501 |
ranu |
61 |
</div>
|
| 31001 |
amit.gupta |
62 |
</div>
|
|
|
63 |
</div>
|
|
|
64 |
|
|
|
65 |
</div>
|
|
|
66 |
<script>
|
| 34527 |
tejus.loha |
67 |
|
|
|
68 |
function formatIndianNumber(number) {
|
|
|
69 |
return Number(number).toLocaleString('en-IN');
|
| 31001 |
amit.gupta |
70 |
}
|
| 34527 |
tejus.loha |
71 |
|
|
|
72 |
(function () {
|
|
|
73 |
const isInvestmentOk = $investments.get('isInvestmentOk');
|
|
|
74 |
const partnerType = "$investments.get('partnerType')";
|
|
|
75 |
let cutOfPercent = $investments.get('cutOf');
|
|
|
76 |
let minimumInvestmentParcent = $investments.get('minInvestment');
|
|
|
77 |
|
|
|
78 |
let agreedInvestment =$investments.get('minimumInvestment');
|
|
|
79 |
let currentInvestment =$investments.get('totalInvestment');
|
|
|
80 |
let billBlockPercentAmt = ((agreedInvestment*cutOfPercent)/100).toFixed(2);
|
|
|
81 |
let maintainPercentAmt= ((agreedInvestment*minimumInvestmentParcent)/100).toFixed(2);
|
|
|
82 |
|
|
|
83 |
var percentForNeedle=0.00;
|
|
|
84 |
|
|
|
85 |
if(currentInvestment>agreedInvestment){
|
|
|
86 |
percentForNeedle = 98;
|
|
|
87 |
}else{
|
|
|
88 |
percentForNeedle = ((currentInvestment / agreedInvestment) * 100).toFixed(2)
|
|
|
89 |
}
|
|
|
90 |
const percent = ((currentInvestment / agreedInvestment) * 100).toFixed(2);
|
|
|
91 |
console.log("percentForNeedle - ",percentForNeedle)
|
|
|
92 |
console.log("percent - ",percent)
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
let billBlockPercentAmtFormmated=formatIndianNumber(billBlockPercentAmt);
|
|
|
96 |
let agreedInvestmentFormmated=formatIndianNumber(agreedInvestment);
|
|
|
97 |
let currentInvestmentFormmated=formatIndianNumber(currentInvestment);
|
|
|
98 |
let maintainPercentAmtFormmated=formatIndianNumber(maintainPercentAmt);
|
|
|
99 |
const ctx = document.getElementById("investometerGauge").getContext("2d");
|
|
|
100 |
let labels = [];
|
|
|
101 |
let data = [];
|
|
|
102 |
let colors = [];
|
|
|
103 |
|
|
|
104 |
if (isInvestmentOk) {
|
|
|
105 |
if(partnerType=="BRONZE"){
|
|
|
106 |
// One segments: Investment OK bcoz of Partner type BRONZE
|
|
|
107 |
labels = [
|
|
|
108 |
`Investment OK (${currentInvestmentFormmated})+`
|
|
|
109 |
];
|
|
|
110 |
data = [100];
|
|
|
111 |
colors = ["green"];
|
|
|
112 |
}else{
|
|
|
113 |
// Three segments: Billing Blocked, Increase Investment, Investment OK
|
|
|
114 |
labels = [
|
|
|
115 |
`70% of Agreed Investment(Billing Block) (${billBlockPercentAmtFormmated})`,
|
|
|
116 |
`75% of Agreed Investment(Increase Investment) (${maintainPercentAmtFormmated})`,
|
|
|
117 |
`Investment OK (${maintainPercentAmtFormmated})+`
|
|
|
118 |
];
|
|
|
119 |
data = [70, 5, 25];
|
|
|
120 |
colors = ["red", "orange", "green"];
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
} else {
|
|
|
125 |
// Only two segments: Billing Blocked and Investment OK
|
|
|
126 |
labels = [
|
|
|
127 |
`75% of Agreed Investment(Billing Block) (${billBlockPercentAmtFormmated})`,
|
|
|
128 |
`Investment OK (${maintainPercentAmtFormmated})+`
|
|
|
129 |
];
|
|
|
130 |
data = [75, 25];
|
|
|
131 |
colors = ["red", "green"];
|
|
|
132 |
}
|
|
|
133 |
const gaugeChart = new Chart(ctx, {
|
|
|
134 |
type: 'doughnut',
|
|
|
135 |
data: {
|
|
|
136 |
labels: labels,
|
|
|
137 |
datasets: [{
|
|
|
138 |
data: data,
|
|
|
139 |
backgroundColor: colors,
|
|
|
140 |
borderWidth: 2
|
|
|
141 |
}]
|
|
|
142 |
|
|
|
143 |
},
|
|
|
144 |
options: {
|
|
|
145 |
responsive: true,
|
|
|
146 |
cutoutPercentage: 20,
|
|
|
147 |
rotation: -Math.PI,
|
|
|
148 |
circumference: Math.PI,
|
|
|
149 |
title: {
|
|
|
150 |
display: true,
|
|
|
151 |
text: `Current Invested Value: Rs.${currentInvestment.toLocaleString('en-IN')}(${percent}%)`
|
|
|
152 |
},
|
|
|
153 |
tooltips: { enabled: true },
|
|
|
154 |
animation: {
|
|
|
155 |
animateRotate: true,
|
|
|
156 |
animateScale: false
|
|
|
157 |
},
|
|
|
158 |
plugins: {
|
|
|
159 |
datalabels: {
|
|
|
160 |
display: true,
|
|
|
161 |
formatter: (value, context) => context.chart.data.labels[context.dataIndex],
|
|
|
162 |
}
|
|
|
163 |
}
|
|
|
164 |
},
|
|
|
165 |
plugins: [{
|
|
|
166 |
// Draw needle after the chart renders
|
|
|
167 |
afterDraw: function (chart) {
|
|
|
168 |
const needleValue = percentForNeedle;
|
|
|
169 |
const total = chart.config.data.datasets[0].data.reduce((a, b) => a + b, 0);
|
|
|
170 |
const angle = Math.PI + (Math.PI * needleValue / total);
|
|
|
171 |
const ctx = chart.chart.ctx;
|
|
|
172 |
const cw = chart.chartArea;
|
|
|
173 |
const cx = (cw.left + cw.right) / 2;
|
|
|
174 |
const cy = chart.chartArea.bottom;
|
|
|
175 |
const needleLength = chart.outerRadius * 0.9;
|
|
|
176 |
const needleRadius = 8;
|
|
|
177 |
|
|
|
178 |
// Clear needle
|
|
|
179 |
ctx.save();
|
|
|
180 |
|
|
|
181 |
// Draw needle
|
|
|
182 |
ctx.translate(cx, cy);
|
|
|
183 |
ctx.rotate(angle);
|
|
|
184 |
ctx.beginPath();
|
|
|
185 |
ctx.moveTo(0, -needleRadius);
|
|
|
186 |
ctx.lineTo(needleLength, 0);
|
|
|
187 |
ctx.lineTo(0, needleRadius);
|
|
|
188 |
ctx.fillStyle = 'black';
|
|
|
189 |
ctx.fill();
|
|
|
190 |
|
|
|
191 |
// Draw needle dot
|
|
|
192 |
ctx.beginPath();
|
|
|
193 |
ctx.arc(0, 0, needleRadius, 0, Math.PI * 2);
|
|
|
194 |
ctx.fill();
|
|
|
195 |
|
|
|
196 |
ctx.restore();
|
|
|
197 |
},
|
|
|
198 |
datalabels: {
|
|
|
199 |
display: true,
|
|
|
200 |
formatter: function(value, context) {
|
|
|
201 |
const label = context.chart.data.labels[context.dataIndex];
|
|
|
202 |
|
|
|
203 |
if (label.includes("Billing Block")) {
|
|
|
204 |
return `₹${currentInvestment.toLocaleString('en-IN')}`;
|
|
|
205 |
}
|
|
|
206 |
if (label.includes("Investment OK")) {
|
|
|
207 |
return `₹${agreedInvestment.toLocaleString('en-IN')}`;
|
|
|
208 |
}
|
|
|
209 |
return label;
|
|
|
210 |
},
|
|
|
211 |
color: 'white',
|
|
|
212 |
font: {
|
|
|
213 |
weight: 'bold'
|
|
|
214 |
}
|
|
|
215 |
}
|
|
|
216 |
}]
|
|
|
217 |
});
|
|
|
218 |
})();
|
| 31001 |
amit.gupta |
219 |
</script>
|
| 34527 |
tejus.loha |
220 |
##<script type="text/javascript" src="resources/js/gauge.min.js"></script>
|