Subversion Repositories SmartDukaan

Rev

Rev 33991 | Rev 33997 | 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;
11
        font-size: 20px;
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 {
23
        font-size: 17px;
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
 
35
</style>
36
 
33917 ranu 37
<section class="wrapper">
38
    <div class="row">
33992 ranu 39
        #if($isGtEqL3)
33991 ranu 40
        <div class="col-md-12 text-right">
41
            <table style="float:right;margin-bottom: 10px;">
42
                <tr>
43
                    <td>
44
                        <input placeholder="Set Duration" name="rbmArrPeriod"
45
                               id="rbmArrPeriod"
46
                               type="text" value="" class="form-control input-sm" style="height: 34px;">
47
                    </td>
48
                    <td>
49
                        <input class="btn btn-primary btn-sm sold-catalog-report"
50
                               type="button"
51
                               value="Download row data">
52
                    </td>
53
                </tr>
54
            </table>
55
        </div>
33992 ranu 56
        #end
33917 ranu 57
        <div class="col-lg-12">
58
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
59
                <tr>
33939 ranu 60
                    <th>RBM</th>
61
                    <th>Total (ACH/TGT)</th>
62
                    <th>%</th>
63
                    <th>HID (ACH/TGT)</th>
64
                    <th>%</th>
33956 ranu 65
                    <th>FAST (ACH/TGT)</th>
66
                    <th>%</th>
33939 ranu 67
                    <th>RUN (ACH/TGT)</th>
68
                    <th>%</th>
69
                    <th>EOL (ACH/TGT)</th>
70
                    <th>%</th>
71
                    <th>Other (ACH/TGT)</th>
72
                    <th>%</th>
33917 ranu 73
                </tr>
33939 ranu 74
                    #foreach($target in $rbmArrViewModels)
33917 ranu 75
                    <tr>
33933 ranu 76
                        <td>$target.getRbmName()- $target.getWarehouseName()</td>
33939 ranu 77
                        <td><span class="achieved-cell">$target.getTotalAchievedTarget()</span> / <span
78
                                class="target-cell">$target.getTodayTarget()</span></td>
79
                        <td class="total-percent"></td>
80
                        <td><span class="achieved-cell">$target.getTodayAchievedHidTarget()</span> / <span
81
                                class="target-cell">$target.getTodayHidTarget()</span></td>
82
                        <td class="hid-percent"></td>
83
                        <td><span class="achieved-cell">$target.getTodayAchievedFastMovingTarget()</span> / <span
84
                                class="target-cell">$target.getTodayFastMovingTarget()</span></td>
85
                        <td class="run-percent"></td>
86
                        <td><span class="achieved-cell">$target.getTodayAchievedSlowMovingTarget()</span> / <span
87
                                class="target-cell">$target.getTodaySlowMovingTarget()</span></td>
88
                        <td class="slow-percent"></td>
89
                        <td><span class="achieved-cell">$target.getTodayAchievedEolTarget()</span> / <span
90
                                class="target-cell">$target.getTodayEolTarget()</span></td>
91
                        <td class="eol-percent"></td>
92
                        <td><span class="achieved-cell">$target.getTodayAchievedOtherMovingTarget()</span> / <span
93
                                class="target-cell">$target.getTodayOtherMovingTarget()</span></td>
94
                        <td class="other-percent"></td>
33917 ranu 95
                    </tr>
33939 ranu 96
                    #end
33946 ranu 97
                <!-- Add a row for totals -->
33942 ranu 98
                <tr>
99
                    <td><strong>Total</strong></td>
33953 ranu 100
                    <td class="text-bold"><span class="achieved-cell">$totalAchieved </span> / <span
101
                            class="target-cell">$totalTargetSum</span></td>
102
                    <td class="total-percent text-bold"></td>
33951 ranu 103
 
33953 ranu 104
                    <td class="text-bold"><span class="achieved-cell">$totalHidAchievedSum</span> / <span
105
                            class="target-cell">$totalHidSum</span></td>
106
                    <td class="hid-percent text-bold"></td>
33951 ranu 107
 
33953 ranu 108
                    <td class="text-bold"><span class="achieved-cell">$totalFastAchievedSum</span> / <span
109
                            class="target-cell">$totalFastSum</span></td>
110
                    <td class="run-percent text-bold"></td>
33951 ranu 111
 
33953 ranu 112
                    <td class="text-bold"><span class="achieved-cell">$totalSlowAchievedSum</span> / <span
113
                            class="target-cell">$totalSlowSum</span></td>
114
                    <td class="slow-percent text-bold"></td>
33951 ranu 115
 
33953 ranu 116
                    <td class="text-bold"><span class="achieved-cell">$totalEolAchievedSum</span> / <span
117
                            class="target-cell">$totalEolSum</span></td>
118
                    <td class="eol-percent text-bold"></td>
33951 ranu 119
 
33953 ranu 120
                    <td class="text-bold"><span class="achieved-cell">$totalOtherAchievedSum</span> / <span
121
                            class="target-cell">$totalOtherSum</span></td>
122
                    <td class="other-percent text-bold"></td>
33942 ranu 123
                </tr>
33951 ranu 124
 
33917 ranu 125
            </table>
126
        </div>
127
    </div>
33930 ranu 128
</section>
33945 ranu 129
 
33930 ranu 130
<script>
33933 ranu 131
    function formatValueInLakh(value) {
33939 ranu 132
        return (value / 100000).toFixed(1) + 'L';
33930 ranu 133
    }
134
 
135
    function formatTargets() {
136
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
33942 ranu 137
        let totalAchieved = 0, totalTarget = 0;
138
        let totalAchievedHid = 0, totalTargetHid = 0;
139
        let totalAchievedRun = 0, totalTargetRun = 0;
140
        let totalAchievedSlow = 0, totalTargetSlow = 0;
141
        let totalAchievedEol = 0, totalTargetEol = 0;
142
        let totalAchievedOther = 0, totalTargetOther = 0;
33930 ranu 143
 
144
        rows.forEach(row => {
33931 ranu 145
            const cells = row.querySelectorAll('td');
33946 ranu 146
            cells.forEach((cell, index) => {
147
                const achievedSpan = cell.querySelector('.achieved-cell');
148
                const targetSpan = cell.querySelector('.target-cell');
149
                if (achievedSpan && targetSpan) {
150
                    const achievedValue = parseFloat(achievedSpan.textContent.replace(/[^\d.-]/g, ''));
151
                    const targetValue = parseFloat(targetSpan.textContent.replace(/[^\d.-]/g, ''));
33944 ranu 152
 
33946 ranu 153
                    // Add to totals
154
                    if (index === 1) {
155
                        totalAchieved += achievedValue || 0;
156
                        totalTarget += targetValue || 0;
157
                    } else if (index === 3) {
158
                        totalAchievedHid += achievedValue || 0;
159
                        totalTargetHid += targetValue || 0;
160
                    } else if (index === 5) {
161
                        totalAchievedRun += achievedValue || 0;
162
                        totalTargetRun += targetValue || 0;
163
                    } else if (index === 7) {
164
                        totalAchievedSlow += achievedValue || 0;
165
                        totalTargetSlow += targetValue || 0;
166
                    } else if (index === 9) {
167
                        totalAchievedEol += achievedValue || 0;
168
                        totalTargetEol += targetValue || 0;
169
                    } else if (index === 11) {
170
                        totalAchievedOther += achievedValue || 0;
171
                        totalTargetOther += targetValue || 0;
172
                    }
33930 ranu 173
 
33946 ranu 174
                    // Format values in lakh
175
                    if (!isNaN(achievedValue)) achievedSpan.textContent = formatValueInLakh(achievedValue);
176
                    if (!isNaN(targetValue)) targetSpan.textContent = formatValueInLakh(targetValue);
33942 ranu 177
 
33946 ranu 178
                    const percentCell = cell.nextElementSibling;
179
                    if (percentCell && targetValue > 0) {
180
                        const percentage = ((achievedValue / targetValue) * 100).toFixed(1);
181
                        percentCell.textContent = percentage + '%';
33931 ranu 182
 
33946 ranu 183
                        // Determine background color based on percentage
184
                        let color;
33962 ranu 185
                        if (percentage <= 1) {
186
                            percentCell.style.color = `red`
187
                        }
33946 ranu 188
                        if (percentage <= 40) {
189
                            color = '#F56983FF'; // Orange for <= 40%
190
                        } else if (percentage > 40 && percentage <= 75) {
191
                            color = '#f2c947e8'; // Yellow for 41% - 75%
192
                        } else {
193
                            color = '#82ef8299'; // Green for > 75%
194
                        }
33945 ranu 195
 
33946 ranu 196
                        // Apply gradient background with the color
197
                        percentCell.style.background = `linear-gradient(to right, ${color} ${percentage}%, transparent ${percentage}%)`;
198
                    } else if (percentCell) {
33953 ranu 199
                        percentCell.textContent = "-";
33946 ranu 200
                        percentCell.style.background = 'none';
33931 ranu 201
                    }
33946 ranu 202
                }
33930 ranu 203
            });
33946 ranu 204
        });
33942 ranu 205
 
33946 ranu 206
    }
33944 ranu 207
 
33958 ranu 208
    function groupRowsByRbm() {
209
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
210
        let currentRbm = null;
211
        let rbmGroup = [];
212
 
213
        rows.forEach((row, index) => {
214
            const rbmCell = row.cells[0];
215
            if (!rbmCell) return;
216
 
217
            const rbmName = rbmCell.textContent.split('-')[0].trim(); // Extract RBM name
218
 
219
            if (rbmName !== currentRbm) {
220
                // Apply border to the previous group
221
                if (rbmGroup.length > 0) {
222
                    applyBorderToGroup(rbmGroup);
223
                }
224
 
225
                // Reset for new RBM
226
                currentRbm = rbmName;
227
                rbmGroup = [];
228
            }
229
 
230
            // Add the row to the current group
231
            rbmGroup.push(row);
232
 
233
            // Apply border to the last group
234
            if (index === rows.length - 1 && rbmGroup.length > 0) {
235
                applyBorderToGroup(rbmGroup);
236
            }
237
        });
238
    }
239
 
240
    function applyBorderToGroup(group) {
241
        if (group.length === 0) return;
242
 
243
        // Add border styles to the first and last rows in the group
244
        //group[0].style.borderTop = '2px solid #000'; // Black border for start
245
        group[group.length - 1].style.borderBottom = '2px solid #000'; // Black border for end
246
    }
247
 
248
    window.onload = function () {
249
        formatTargets(); // Format targets first
250
        groupRowsByRbm(); // Group rows by RBM
251
    };
252
 
253
 
33945 ranu 254
</script>