Subversion Repositories SmartDukaan

Rev

Rev 34002 | Rev 34071 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33991 ranu 1
<link rel="stylesheet"
2
      href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.1.0/daterangepicker.min.css"/>
3
 
33951 ranu 4
<style>
5
    table th {
6
        text-align: center;
7
    }
8
 
9
    #rbm-arr-table td, #rbm-arr-table th {
10
        padding: 0.35rem;
33997 ranu 11
        font-size: 18px;
33951 ranu 12
    }
13
 
33953 ranu 14
    .text-bold {
15
        font-weight: bold !important;
16
    }
17
 
18
    .text-bold span {
19
        font-weight: bold;
20
    }
21
 
33951 ranu 22
    .rb-name {
33997 ranu 23
        font-size: 16px;
33951 ranu 24
        font-weight: bold;
25
    }
26
 
27
    #rbm-arr-table td {
28
        text-align: center;
29
        background-size: 100% 100%;
30
        background-repeat: no-repeat;
31
        color: #000; /* Ensure text remains visible */
32
        font-weight: 400;
33
    }
34
 
34055 ranu 35
    #rbm-aging-table td {
36
        text-align: center;
37
        background-size: 100% 100%;
38
        background-repeat: no-repeat;
39
        color: #000; /* Ensure text remains visible */
40
        font-weight: 400;
41
    }
42
 
43
    .border-top-bottom {
44
        border-top: 2px solid #000 !important;
45
        border-bottom: 2px solid #000 !important;
46
    }
47
 
48
    #rbm-aging-table td, #rbm-aging-table th {
49
        padding: 0.35rem;
50
        font-size: 18px;
51
    }
52
 
33951 ranu 53
</style>
54
 
33917 ranu 55
<section class="wrapper">
34055 ranu 56
    <div class="row" style="margin: 0">
33992 ranu 57
        #if($isGtEqL3)
33991 ranu 58
        <div class="col-md-12 text-right">
34055 ranu 59
            <h4>RBM Wise Today's ARR (Basis Product Movement)</h4>
33991 ranu 60
            <table style="float:right;margin-bottom: 10px;">
61
                <tr>
62
                    <td>
63
                        <input placeholder="Set Duration" name="rbmArrPeriod"
64
                               id="rbmArrPeriod"
65
                               type="text" value="" class="form-control input-sm" style="height: 34px;">
66
                    </td>
67
                    <td>
34002 ranu 68
                        <input class="btn btn-primary btn-sm rbm-target-achievement"
69
                               type="button"
70
                               value="View">
71
                    </td>
72
                    <td>
33991 ranu 73
                        <input class="btn btn-primary btn-sm sold-catalog-report"
74
                               type="button"
75
                               value="Download row data">
76
                    </td>
77
                </tr>
78
            </table>
79
        </div>
33992 ranu 80
        #end
33917 ranu 81
        <div class="col-lg-12">
82
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
83
                <tr>
33939 ranu 84
                    <th>RBM</th>
85
                    <th>Total (ACH/TGT)</th>
86
                    <th>%</th>
87
                    <th>HID (ACH/TGT)</th>
88
                    <th>%</th>
33956 ranu 89
                    <th>FAST (ACH/TGT)</th>
90
                    <th>%</th>
33939 ranu 91
                    <th>RUN (ACH/TGT)</th>
92
                    <th>%</th>
93
                    <th>EOL (ACH/TGT)</th>
94
                    <th>%</th>
95
                    <th>Other (ACH/TGT)</th>
96
                    <th>%</th>
33917 ranu 97
                </tr>
33939 ranu 98
                    #foreach($target in $rbmArrViewModels)
33917 ranu 99
                    <tr>
33933 ranu 100
                        <td>$target.getRbmName()- $target.getWarehouseName()</td>
33939 ranu 101
                        <td><span class="achieved-cell">$target.getTotalAchievedTarget()</span> / <span
102
                                class="target-cell">$target.getTodayTarget()</span></td>
103
                        <td class="total-percent"></td>
104
                        <td><span class="achieved-cell">$target.getTodayAchievedHidTarget()</span> / <span
105
                                class="target-cell">$target.getTodayHidTarget()</span></td>
106
                        <td class="hid-percent"></td>
107
                        <td><span class="achieved-cell">$target.getTodayAchievedFastMovingTarget()</span> / <span
108
                                class="target-cell">$target.getTodayFastMovingTarget()</span></td>
109
                        <td class="run-percent"></td>
110
                        <td><span class="achieved-cell">$target.getTodayAchievedSlowMovingTarget()</span> / <span
111
                                class="target-cell">$target.getTodaySlowMovingTarget()</span></td>
112
                        <td class="slow-percent"></td>
113
                        <td><span class="achieved-cell">$target.getTodayAchievedEolTarget()</span> / <span
114
                                class="target-cell">$target.getTodayEolTarget()</span></td>
115
                        <td class="eol-percent"></td>
116
                        <td><span class="achieved-cell">$target.getTodayAchievedOtherMovingTarget()</span> / <span
117
                                class="target-cell">$target.getTodayOtherMovingTarget()</span></td>
118
                        <td class="other-percent"></td>
33917 ranu 119
                    </tr>
33939 ranu 120
                    #end
33946 ranu 121
                <!-- Add a row for totals -->
33942 ranu 122
                <tr>
123
                    <td><strong>Total</strong></td>
33953 ranu 124
                    <td class="text-bold"><span class="achieved-cell">$totalAchieved </span> / <span
125
                            class="target-cell">$totalTargetSum</span></td>
126
                    <td class="total-percent text-bold"></td>
33951 ranu 127
 
33953 ranu 128
                    <td class="text-bold"><span class="achieved-cell">$totalHidAchievedSum</span> / <span
129
                            class="target-cell">$totalHidSum</span></td>
130
                    <td class="hid-percent text-bold"></td>
33951 ranu 131
 
33953 ranu 132
                    <td class="text-bold"><span class="achieved-cell">$totalFastAchievedSum</span> / <span
133
                            class="target-cell">$totalFastSum</span></td>
134
                    <td class="run-percent text-bold"></td>
33951 ranu 135
 
33953 ranu 136
                    <td class="text-bold"><span class="achieved-cell">$totalSlowAchievedSum</span> / <span
137
                            class="target-cell">$totalSlowSum</span></td>
138
                    <td class="slow-percent text-bold"></td>
33951 ranu 139
 
33953 ranu 140
                    <td class="text-bold"><span class="achieved-cell">$totalEolAchievedSum</span> / <span
141
                            class="target-cell">$totalEolSum</span></td>
142
                    <td class="eol-percent text-bold"></td>
33951 ranu 143
 
33953 ranu 144
                    <td class="text-bold"><span class="achieved-cell">$totalOtherAchievedSum</span> / <span
145
                            class="target-cell">$totalOtherSum</span></td>
146
                    <td class="other-percent text-bold"></td>
33942 ranu 147
                </tr>
33951 ranu 148
 
33917 ranu 149
            </table>
150
        </div>
151
    </div>
34055 ranu 152
 
153
    <div class="row" style="margin: 0">
154
        #if($isGtEqL3)
155
 
156
            <div class="col-md-12">
157
                <br>
158
                <h4> > 15 Days Aging Sold </h4>
159
                <table id="rbm-aging-table" class="table table-border table-condensed table-bordered"
160
                       style="width:100%">
161
                    <thead>
162
                    <tr>
163
                        <th>RBM</th>
164
                        <th>EOL</th>
165
                        <th>RUNNING</th>
166
                        <th>FASTMOVING</th>
167
                        <th>HID</th>
168
                        <th>OTHER</th>
169
                        <th>TOTAL</th>
170
                    </tr>
171
                    </thead>
172
                    <tbody>
173
                        #foreach($model in $sold15daysOldAgingModels)
174
                        <tr>
175
                            <th>$model.getRbmName()</th>
176
                            <td>$model.getEolBilled()</td>
177
                            <td>$model.getRunningBilled()</td>
178
                            <td>$model.getFastmovingBilled()</td>
179
                            <td>$model.getHidBilled()</td>
180
                            <td>$model.getOthersBilled()</td>
181
                            <td>$model.getTotalBilled()</td>
182
                        </tr>
183
                        #end
184
                    <tr>
185
                        <th class="border-top-bottom"> Total</th>
186
                        <td class="border-top-bottom">$totalSoldEol</td>
187
                        <td class="border-top-bottom">$totalSoldRun</td>
188
                        <td class="border-top-bottom">$totalSoldFast</td>
189
                        <td class="border-top-bottom">$totalSoldHid</td>
190
                        <td class="border-top-bottom">$totalSoldOther</td>
191
                        <td class="border-top-bottom">$totalSoldAging</td>
192
                    </tr>
193
                        #foreach($aging in $our15DaysOldAgingStocks)
194
                        <tr>
195
                            <th class="border-top-bottom"> 15 days Balance Value</th>
196
                            <td class="border-top-bottom">$aging.getEolAgingStock()</td>
197
                            <td class="border-top-bottom">$aging.getRunningAgingStock()</td>
198
                            <td class="border-top-bottom">$aging.getFastmovingAgingStock()</td>
199
                            <td class="border-top-bottom">$aging.getHidAgingStock()</td>
200
                            <td class="border-top-bottom">$aging.getOtherAgingStock()</td>
201
                            <td class="border-top-bottom">$aging.getTotal()</td>
202
                        </tr>
203
                        #end
204
                    </tbody>
205
                </table>
206
            </div>
207
        #end
208
    </div>
33930 ranu 209
</section>
33945 ranu 210
 
33930 ranu 211
<script>
33933 ranu 212
    function formatValueInLakh(value) {
33939 ranu 213
        return (value / 100000).toFixed(1) + 'L';
33930 ranu 214
    }
215
 
216
    function formatTargets() {
217
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
33942 ranu 218
        let totalAchieved = 0, totalTarget = 0;
219
        let totalAchievedHid = 0, totalTargetHid = 0;
220
        let totalAchievedRun = 0, totalTargetRun = 0;
221
        let totalAchievedSlow = 0, totalTargetSlow = 0;
222
        let totalAchievedEol = 0, totalTargetEol = 0;
223
        let totalAchievedOther = 0, totalTargetOther = 0;
33930 ranu 224
 
225
        rows.forEach(row => {
33931 ranu 226
            const cells = row.querySelectorAll('td');
33946 ranu 227
            cells.forEach((cell, index) => {
228
                const achievedSpan = cell.querySelector('.achieved-cell');
229
                const targetSpan = cell.querySelector('.target-cell');
230
                if (achievedSpan && targetSpan) {
231
                    const achievedValue = parseFloat(achievedSpan.textContent.replace(/[^\d.-]/g, ''));
232
                    const targetValue = parseFloat(targetSpan.textContent.replace(/[^\d.-]/g, ''));
33944 ranu 233
 
33946 ranu 234
                    // Add to totals
235
                    if (index === 1) {
236
                        totalAchieved += achievedValue || 0;
237
                        totalTarget += targetValue || 0;
238
                    } else if (index === 3) {
239
                        totalAchievedHid += achievedValue || 0;
240
                        totalTargetHid += targetValue || 0;
241
                    } else if (index === 5) {
242
                        totalAchievedRun += achievedValue || 0;
243
                        totalTargetRun += targetValue || 0;
244
                    } else if (index === 7) {
245
                        totalAchievedSlow += achievedValue || 0;
246
                        totalTargetSlow += targetValue || 0;
247
                    } else if (index === 9) {
248
                        totalAchievedEol += achievedValue || 0;
249
                        totalTargetEol += targetValue || 0;
250
                    } else if (index === 11) {
251
                        totalAchievedOther += achievedValue || 0;
252
                        totalTargetOther += targetValue || 0;
253
                    }
33930 ranu 254
 
33946 ranu 255
                    // Format values in lakh
256
                    if (!isNaN(achievedValue)) achievedSpan.textContent = formatValueInLakh(achievedValue);
257
                    if (!isNaN(targetValue)) targetSpan.textContent = formatValueInLakh(targetValue);
33942 ranu 258
 
33946 ranu 259
                    const percentCell = cell.nextElementSibling;
260
                    if (percentCell && targetValue > 0) {
261
                        const percentage = ((achievedValue / targetValue) * 100).toFixed(1);
262
                        percentCell.textContent = percentage + '%';
33931 ranu 263
 
33946 ranu 264
                        // Determine background color based on percentage
265
                        let color;
33962 ranu 266
                        if (percentage <= 1) {
267
                            percentCell.style.color = `red`
268
                        }
33946 ranu 269
                        if (percentage <= 40) {
270
                            color = '#F56983FF'; // Orange for <= 40%
271
                        } else if (percentage > 40 && percentage <= 75) {
272
                            color = '#f2c947e8'; // Yellow for 41% - 75%
273
                        } else {
274
                            color = '#82ef8299'; // Green for > 75%
275
                        }
33945 ranu 276
 
33946 ranu 277
                        // Apply gradient background with the color
278
                        percentCell.style.background = `linear-gradient(to right, ${color} ${percentage}%, transparent ${percentage}%)`;
279
                    } else if (percentCell) {
33953 ranu 280
                        percentCell.textContent = "-";
33946 ranu 281
                        percentCell.style.background = 'none';
33931 ranu 282
                    }
33946 ranu 283
                }
33930 ranu 284
            });
33946 ranu 285
        });
33942 ranu 286
 
33946 ranu 287
    }
33944 ranu 288
 
33958 ranu 289
    function groupRowsByRbm() {
290
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
291
        let currentRbm = null;
292
        let rbmGroup = [];
293
 
294
        rows.forEach((row, index) => {
295
            const rbmCell = row.cells[0];
296
            if (!rbmCell) return;
297
 
298
            const rbmName = rbmCell.textContent.split('-')[0].trim(); // Extract RBM name
299
 
300
            if (rbmName !== currentRbm) {
301
                // Apply border to the previous group
302
                if (rbmGroup.length > 0) {
303
                    applyBorderToGroup(rbmGroup);
304
                }
305
 
306
                // Reset for new RBM
307
                currentRbm = rbmName;
308
                rbmGroup = [];
309
            }
310
 
311
            // Add the row to the current group
312
            rbmGroup.push(row);
313
 
314
            // Apply border to the last group
315
            if (index === rows.length - 1 && rbmGroup.length > 0) {
316
                applyBorderToGroup(rbmGroup);
317
            }
318
        });
319
    }
320
 
321
    function applyBorderToGroup(group) {
322
        if (group.length === 0) return;
323
 
324
        // Add border styles to the first and last rows in the group
325
        //group[0].style.borderTop = '2px solid #000'; // Black border for start
326
        group[group.length - 1].style.borderBottom = '2px solid #000'; // Black border for end
327
    }
328
 
329
    window.onload = function () {
330
        formatTargets(); // Format targets first
331
        groupRowsByRbm(); // Group rows by RBM
332
    };
333
 
334
 
33945 ranu 335
</script>