Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33997 ranu 1
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
2
      integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
3
<link rel="stylesheet"
4
      href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.1.0/daterangepicker.min.css"/>
5
 
6
<style>
7
    table th {
8
        text-align: center;
9
    }
10
 
11
    #rbm-arr-table td, #rbm-arr-table th {
12
        padding: 0.35rem;
13
        font-size: 18px;
14
    }
15
 
16
    .text-bold {
17
        font-weight: bold !important;
18
    }
19
 
20
    .text-bold span {
21
        font-weight: bold;
22
    }
23
 
24
    .rb-name {
25
        font-size: 16px;
26
        font-weight: bold;
27
    }
28
 
29
    #rbm-arr-table td {
30
        text-align: center;
31
        background-size: 100% 100%;
32
        background-repeat: no-repeat;
33
        color: #000; /* Ensure text remains visible */
34
        font-weight: 400;
35
    }
36
 
37
</style>
38
 
39
<section class="wrapper">
40
    <div class="row">
41
        <div class="col-lg-12">
42
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
43
                <tr>
44
                    <th>RBM</th>
45
                    <th>Total (ACH/TGT)</th>
46
                    <th>%</th>
47
                    <th>HID (ACH/TGT)</th>
48
                    <th>%</th>
49
                    <th>FAST (ACH/TGT)</th>
50
                    <th>%</th>
51
                    <th>RUN (ACH/TGT)</th>
52
                    <th>%</th>
53
                    <th>EOL (ACH/TGT)</th>
54
                    <th>%</th>
55
                    <th>Other (ACH/TGT)</th>
56
                    <th>%</th>
57
                </tr>
58
                #foreach($target in $rbmTargetAndAchievementsModels)
59
                    <tr>
60
                        <td>$target.getRbmName()- $target.getWarehouseName()</td>
61
                        <td><span class="achieved-cell">$target.getTotalAchievemnt()</span> / <span
62
                                class="target-cell">$target.getTotalTarget()</span></td>
63
                        <td class="total-percent"></td>
64
                        <td><span class="achieved-cell">$target.getAchievedHid()</span> / <span
65
                                class="target-cell">$target.getHidTarget()</span></td>
66
                        <td class="hid-percent"></td>
67
                        <td><span class="achieved-cell">$target.getAchievedFastMoving()</span> / <span
68
                                class="target-cell">$target.getFastMovingTarget()</span></td>
69
                        <td class="run-percent"></td>
70
                        <td><span class="achieved-cell">$target.getAchievedSlowMoving()</span> / <span
71
                                class="target-cell">$target.getSlowMovingTarget()</span></td>
72
                        <td class="slow-percent"></td>
73
                        <td><span class="achieved-cell">$target.getAchievedEol()</span> / <span
74
                                class="target-cell">$target.getEolTarget()</span></td>
75
                        <td class="eol-percent"></td>
76
                        <td><span class="achieved-cell">$target.getAchievedOtherMoving()</span> / <span
77
                                class="target-cell">$target.getOtherMovingTarget()</span></td>
78
                        <td class="other-percent"></td>
79
                    </tr>
80
                #end
81
                <!-- Add a row for totals -->
82
                <tr>
83
                    <td><strong>Total</strong></td>
84
                    <td class="text-bold"><span class="achieved-cell">$totalAchieved </span> / <span
85
                            class="target-cell">$totalTarget</span></td>
86
                    <td class="total-percent text-bold"></td>
87
 
88
                    <td class="text-bold"><span class="achieved-cell">$totalAchievedHid</span> / <span
89
                            class="target-cell">$totalTargetHid</span></td>
90
                    <td class="hid-percent text-bold"></td>
91
 
92
                    <td class="text-bold"><span class="achieved-cell">$totalAchievedFast</span> / <span
93
                            class="target-cell">$totalTargetFast</span></td>
94
                    <td class="run-percent text-bold"></td>
95
 
96
                    <td class="text-bold"><span class="achieved-cell">$totalAchievedSlow</span> / <span
97
                            class="target-cell">$totalTargetSlow</span></td>
98
                    <td class="slow-percent text-bold"></td>
99
 
100
                    <td class="text-bold"><span class="achieved-cell">$totalAchievedEol</span> / <span
101
                            class="target-cell">$totalTargetEol</span></td>
102
                    <td class="eol-percent text-bold"></td>
103
 
104
                    <td class="text-bold"><span class="achieved-cell">$totalAchievedOther</span> / <span
105
                            class="target-cell">$totalTargetOther</span></td>
106
                    <td class="other-percent text-bold"></td>
107
                </tr>
108
 
109
            </table>
110
        </div>
111
    </div>
112
</section>
113
 
114
<script>
115
    function formatValueInLakh(value) {
116
        return (value / 100000).toFixed(1) + 'L';
117
    }
118
 
119
    function formatTargets() {
120
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
121
        let totalAchieved = 0, totalTarget = 0;
122
        let totalAchievedHid = 0, totalTargetHid = 0;
123
        let totalAchievedRun = 0, totalTargetRun = 0;
124
        let totalAchievedSlow = 0, totalTargetSlow = 0;
125
        let totalAchievedEol = 0, totalTargetEol = 0;
126
        let totalAchievedOther = 0, totalTargetOther = 0;
127
 
128
        rows.forEach(row => {
129
            const cells = row.querySelectorAll('td');
130
            cells.forEach((cell, index) => {
131
                const achievedSpan = cell.querySelector('.achieved-cell');
132
                const targetSpan = cell.querySelector('.target-cell');
133
                if (achievedSpan && targetSpan) {
134
                    const achievedValue = parseFloat(achievedSpan.textContent.replace(/[^\d.-]/g, ''));
135
                    const targetValue = parseFloat(targetSpan.textContent.replace(/[^\d.-]/g, ''));
136
 
137
                    // Add to totals
138
                    if (index === 1) {
139
                        totalAchieved += achievedValue || 0;
140
                        totalTarget += targetValue || 0;
141
                    } else if (index === 3) {
142
                        totalAchievedHid += achievedValue || 0;
143
                        totalTargetHid += targetValue || 0;
144
                    } else if (index === 5) {
145
                        totalAchievedRun += achievedValue || 0;
146
                        totalTargetRun += targetValue || 0;
147
                    } else if (index === 7) {
148
                        totalAchievedSlow += achievedValue || 0;
149
                        totalTargetSlow += targetValue || 0;
150
                    } else if (index === 9) {
151
                        totalAchievedEol += achievedValue || 0;
152
                        totalTargetEol += targetValue || 0;
153
                    } else if (index === 11) {
154
                        totalAchievedOther += achievedValue || 0;
155
                        totalTargetOther += targetValue || 0;
156
                    }
157
 
158
                    // Format values in lakh
159
                    if (!isNaN(achievedValue)) achievedSpan.textContent = formatValueInLakh(achievedValue);
160
                    if (!isNaN(targetValue)) targetSpan.textContent = formatValueInLakh(targetValue);
161
 
162
                    const percentCell = cell.nextElementSibling;
163
                    if (percentCell && targetValue > 0) {
164
                        const percentage = ((achievedValue / targetValue) * 100).toFixed(1);
165
                        percentCell.textContent = percentage + '%';
166
 
167
                        // Determine background color based on percentage
168
                        let color;
169
                        if (percentage <= 1) {
170
                            percentCell.style.color = `red`
171
                        }
172
                        if (percentage <= 40) {
173
                            color = '#F56983FF'; // Orange for <= 40%
174
                        } else if (percentage > 40 && percentage <= 75) {
175
                            color = '#f2c947e8'; // Yellow for 41% - 75%
176
                        } else {
177
                            color = '#82ef8299'; // Green for > 75%
178
                        }
179
 
180
                        // Apply gradient background with the color
181
                        percentCell.style.background = `linear-gradient(to right, ${color} ${percentage}%, transparent ${percentage}%)`;
182
                    } else if (percentCell) {
183
                        percentCell.textContent = "-";
184
                        percentCell.style.background = 'none';
185
                    }
186
                }
187
            });
188
        });
189
 
190
    }
191
 
192
    function groupRowsByRbm() {
193
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
194
        let currentRbm = null;
195
        let rbmGroup = [];
196
 
197
        rows.forEach((row, index) => {
198
            const rbmCell = row.cells[0];
199
            if (!rbmCell) return;
200
 
201
            const rbmName = rbmCell.textContent.split('-')[0].trim(); // Extract RBM name
202
 
203
            if (rbmName !== currentRbm) {
204
                // Apply border to the previous group
205
                if (rbmGroup.length > 0) {
206
                    applyBorderToGroup(rbmGroup);
207
                }
208
 
209
                // Reset for new RBM
210
                currentRbm = rbmName;
211
                rbmGroup = [];
212
            }
213
 
214
            // Add the row to the current group
215
            rbmGroup.push(row);
216
 
217
            // Apply border to the last group
218
            if (index === rows.length - 1 && rbmGroup.length > 0) {
219
                applyBorderToGroup(rbmGroup);
220
            }
221
        });
222
    }
223
 
224
    function applyBorderToGroup(group) {
225
        if (group.length === 0) return;
226
 
227
        // Add border styles to the first and last rows in the group
228
        //group[0].style.borderTop = '2px solid #000'; // Black border for start
229
        group[group.length - 1].style.borderBottom = '2px solid #000'; // Black border for end
230
    }
231
 
232
    window.onload = function () {
233
        formatTargets(); // Format targets first
234
        groupRowsByRbm(); // Group rows by RBM
235
    };
236
 
237
 
238
</script>