Subversion Repositories SmartDukaan

Rev

Rev 33504 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33504 Rev 34527
Line 1... Line -...
1
##<div class="col-lg-5">
-
 
-
 
1
 
2
####    <h4 style="margin-top:-2px;margin-bottom:6px"><strong>#springMessage("dashboard.myperformance")</strong></h4>
2
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
3
####    <table class="table table-condensed indianflag">
-
 
4
####        <tbody>
-
 
5
####        <tr class="current">
-
 
6
####            <td>#springMessage("dashboard.currentmonth")</td>
-
 
7
####            <td>
-
 
8
####                <div class="stars-outer">
-
 
9
####                    <div class="stars-inner"></div>
-
 
10
####                </div>
-
 
11
####            </td>
-
 
12
####            <td>$currentMonthRating/5</td>
-
 
13
####        </tr>
-
 
14
####        <tr class="last">
-
 
15
####            <td>Last Month</td>
-
 
16
####            <td>
-
 
17
####                <div class="stars-outer">
-
 
18
####                    <div class="stars-inner"></div>
-
 
19
####                </div>
-
 
20
####            </td>
-
 
-
 
3
 
-
 
4
 
21
####            <td>$lastMonthRating/5</td>
5
<!-- Chart.js Datalabels plugin for v2 -->
22
####        </tr>
-
 
23
####        <tr class="tilldate">
-
 
24
####            <td>#springMessage("dashboard.tilldate")</td>
6
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0"></script>
25
####            <td>
-
 
26
####                <div class="stars-outer">
-
 
-
 
7
 
27
####                    <div class="stars-inner"></div>
8
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"></script>
28
####                </div>
-
 
29
####            </td>
-
 
30
####            <td>$ratingTillDate/5</td>
-
 
31
####        </tr>
-
 
32
####        </tbody>
-
 
33
####    </table>
-
 
34
##</div>
-
 
35
 
9
 
36
 
10
 
37
<div>
11
<div>
38
 
12
 
39
    ##    <div class="row" style="width:50%">
-
 
40
    ##
-
 
41
    ##        <select class="form-control input-sm" id="performance-months" name="months" placeholder="months"
-
 
42
    ##                style="width:50%; margin:auto;">
-
 
43
    ##            <option value="" disabled selected>month</option>
-
 
44
    ##            #foreach($mVM in $monthValueMap.entrySet())
-
 
45
    ##                #if($mVM.getKey()== $month )
-
 
46
    ##                    <option value="$mVM.getKey()" selected>$mVM.getValue()</option>
-
 
47
    ##                #else
-
 
48
    ##                    <option value="$mVM.getKey()">$mVM.getValue()</option>
-
 
49
    ##                #end
-
 
50
    ##            #end
-
 
51
    ##        </select>
-
 
52
    ##    </div>
-
 
53
 
13
 
54
    <div class="row">
-
 
55
        ##        <div class="col-lg-6">
-
 
56
        ##            <canvas data-type="radial-gauge" id="hygeine"
-
 
57
        ##                    data-width="200" ,
-
 
58
        ##                    data-height="200"
-
 
59
        ##                    data-title="Hygeine"
-
 
60
        ##                    data-units="${hygienePercentage}%"
-
 
61
        ##                    data-min-value="0"
-
 
62
        ##                    data-max-value="100"
-
 
63
        ##                    data-value="${hygienePercentage}"
-
 
64
        ##                    data-major-ticks="0,20,40,60,80,100"
-
 
65
        ##                    data-minor-ticks="2"
-
 
66
        ##                    data-stroke-ticks="true"
-
 
67
        ##                    data-highlights='[
-
 
68
        ##					{"from": 0, "to": 80, "color": "red"},
-
 
69
        ##					{"from": 80, "to": 90, "color": "yellow"},
-
 
70
        ##					{"from": 90, "to": 100, "color": "green"}
-
 
71
        ##				    ]' ,
-
 
72
        ##                    data-value-box="false"
-
 
73
        ##                    data-color-plate="#fff"
-
 
74
        ##                    data-border-shadow-width="0"
-
 
75
        ##                    data-borders="false"
-
 
76
        ##                    data-needle-type="arrow"
-
 
77
        ##                    data-needle-width="2"
-
 
78
        ##                    data-needle-circle-size="7"
-
 
79
        ##                    data-font-value-size="42"
-
 
80
        ##                    data-font-title-size="42"
-
 
81
        ##                    data-font-units-size="42"
-
 
82
        ##                    data-needle-circle-outer="true"
-
 
83
        ##                    data-needle-circle-inner="false"
-
 
84
        ##                    data-animation-duration="1500"
-
 
85
        ##                    data-animation-rule="linear"
-
 
86
        ##            ></canvas>
-
 
87
        ##
-
 
88
        ##        </div>
-
 
89
 
14
 
-
 
15
    <div class="row">
90
        <div class="col-lg-7">
16
        <div class="col-lg-7">
-
 
17
            <h4><strong>Investometer</strong></h4>
-
 
18
            <canvas id="investometerGauge"></canvas>
-
 
19
        </div>
-
 
20
 
-
 
21
 
-
 
22
 
-
 
23
        <div class="col-lg-5">
91
            <h4 style="margin-top:-2px;margin-bottom:24px"><strong>Banner for Shopfront</strong></h4>
24
            <h4 style="margin-bottom:24px " ><strong>Banner for Shopfront</strong></h4>
92
            <div class="form-group">
25
            <div class="form-group">
93
                #if(!$printResources.isEmpty())
26
                #if(!$printResources.isEmpty())
94
                    <div id="myCarousel" class="carousel slide" data-ride="carousel">
27
                    <div id="myCarousel" class="carousel slide" data-ride="carousel" style="margin-top: 50px">
95
                        <!-- Wrapper for slides -->
28
                        <!-- Wrapper for slides -->
96
                        <div class="carousel-inner text-center">
29
                        <div class="carousel-inner text-center">
97
 
-
 
98
                            #set($first = true)
30
                            #set($first = true)
99
                            #foreach($printResource in $printResources)
31
                            #foreach($printResource in $printResources)
100
                                <div class="item #if($first)active#set($first = false)#end">
32
                                <div class="item #if($first)active#set($first = false)#end">
101
                                    <img src="$printResource.getThumbnailUrl()" alt="Los Angeles"
33
                                    <img src="$printResource.getThumbnailUrl()" alt="Los Angeles"
102
                                         style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
34
                                         style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
Line 104... Line 36...
104
                                        <br>
36
                                        <br>
105
                                        <button class="btn btn-danger btn-sm partner_print_resources">Get File !
37
                                        <button class="btn btn-danger btn-sm partner_print_resources">Get File !
106
                                        </button>
38
                                        </button>
107
                                    </div>
39
                                    </div>
108
                                </div>
40
                                </div>
109
                            #end
-
 
110
 
41
 
-
 
42
                            #end
111
                        </div>
43
                        </div>
112
                        <!-- Left and right controls -->
44
                        <!-- Left and right controls -->
113
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
45
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
114
                            <span class="glyphicon glyphicon-chevron-left"></span>
46
                            <span class="glyphicon glyphicon-chevron-left"></span>
115
                            <span class="sr-only">Previous</span>
47
                            <span class="sr-only">Previous</span>
Line 126... Line 58...
126
                             style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
58
                             style="max-height:150px;width:auto;max-width: 100%;margin: auto;">
127
                    </div>
59
                    </div>
128
                #end
60
                #end
129
            </div>
61
            </div>
130
        </div>
62
        </div>
131
        <div class="col-lg-5">
-
 
132
            <h4 style="margin-top:-2px;margin-bottom:24px"><strong>Investment</strong></h4>
-
 
133
            <canvas data-type="radial-gauge" id="investment"
-
 
134
                    data-width="200"
-
 
135
                    data-height="200"
-
 
136
                    data-title="Investments"
-
 
137
                    data-units="${investments.get('okDays')}/${dayOfMonth}"
-
 
138
                    data-value="${investments.get('okDays')}"
-
 
139
                    data-min-value="0"
-
 
140
                    data-major-ticks=[]
-
 
141
                    data-max-value="${monthDays}"
-
 
142
                    data-highlights='[
-
 
143
					{"from": 0, "to": 7, "color": "red"},
-
 
144
					{"from": 7, "to": 12, "color": "yellow"},
-
 
145
					{"from": 12, "to": ${monthDays}, "color": "green"}
-
 
146
				    ]'
-
 
147
                    data-value-box="false"
-
 
148
                    data-color-plate="#fff"
-
 
149
                    data-border-shadow-width="0"
-
 
150
                    data-borders="false"
-
 
151
                    data-needle-type="arrow"
-
 
152
                    data-needle-width="2"
-
 
153
                    data-needle-circle-size="7"
-
 
154
                    data-font-value-size="42"
-
 
155
                    data-font-title-size="42"
-
 
156
                    data-font-units-size="42"
-
 
157
 
-
 
158
                    data-needle-circle-outer="true"
-
 
159
                    data-needle-circle-inner="false"
-
 
160
                    data-animation-duration="1500"
-
 
161
                    data-animation-rule="linear"
-
 
162
            ></canvas>
-
 
163
        </div>
-
 
164
    </div>
63
    </div>
165
 
64
 
166
</div>
65
</div>
167
<script>
66
<script>
168
    starTotal = 5;
-
 
169
    ratings = {
-
 
170
        current: $currentMonthRating,
-
 
171
        last: $lastMonthRating,
-
 
172
        tilldate: $ratingTillDate
-
 
173
    };
67
 
174
    for (const rating in ratings) {
68
    function formatIndianNumber(number) {
175
        // 2
-
 
176
        const starPercentage = (ratings[rating] / starTotal) * 100;
-
 
177
        // 3
-
 
178
        const starPercentageRounded = `${starPercentage}%`;
69
        return Number(number).toLocaleString('en-IN');
179
        // 4
-
 
180
        document.querySelector(`.${rating} .stars-inner`).style.width = starPercentageRounded;
-
 
181
    }
70
    }
-
 
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
    })();
182
</script>
219
</script>
183
<script type="text/javascript" src="resources/js/gauge.min.js"></script>
-
 
184
220
##<script type="text/javascript" src="resources/js/gauge.min.js"></script>
-
 
221
185
222