Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
33951 ranu 1
<style>
2
    table th {
3
        text-align: center;
4
    }
5
 
6
    #rbm-arr-table td, #rbm-arr-table th {
7
        padding: 0.35rem;
8
        font-size: 20px;
9
    }
10
 
11
    .rb-name {
12
        font-size: 17px;
13
        font-weight: bold;
14
    }
15
 
16
    #rbm-arr-table td {
17
        text-align: center;
18
        background-size: 100% 100%;
19
        background-repeat: no-repeat;
20
        color: #000; /* Ensure text remains visible */
21
        font-weight: 400;
22
    }
23
 
24
</style>
25
 
33917 ranu 26
<section class="wrapper">
27
    <div class="row">
28
        <div class="col-lg-12">
29
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
30
                <tr>
33939 ranu 31
                    <th>RBM</th>
32
                    <th>Total (ACH/TGT)</th>
33
                    <th>%</th>
34
                    <th>HID (ACH/TGT)</th>
35
                    <th>%</th>
36
                    <th>RUN (ACH/TGT)</th>
37
                    <th>%</th>
38
                    <th>SLOW (ACH/TGT)</th>
39
                    <th>%</th>
40
                    <th>EOL (ACH/TGT)</th>
41
                    <th>%</th>
42
                    <th>Other (ACH/TGT)</th>
43
                    <th>%</th>
33917 ranu 44
                </tr>
33939 ranu 45
                    #foreach($target in $rbmArrViewModels)
33917 ranu 46
                    <tr>
33933 ranu 47
                        <td>$target.getRbmName()- $target.getWarehouseName()</td>
33939 ranu 48
                        <td><span class="achieved-cell">$target.getTotalAchievedTarget()</span> / <span
49
                                class="target-cell">$target.getTodayTarget()</span></td>
50
                        <td class="total-percent"></td>
51
                        <td><span class="achieved-cell">$target.getTodayAchievedHidTarget()</span> / <span
52
                                class="target-cell">$target.getTodayHidTarget()</span></td>
53
                        <td class="hid-percent"></td>
54
                        <td><span class="achieved-cell">$target.getTodayAchievedFastMovingTarget()</span> / <span
55
                                class="target-cell">$target.getTodayFastMovingTarget()</span></td>
56
                        <td class="run-percent"></td>
57
                        <td><span class="achieved-cell">$target.getTodayAchievedSlowMovingTarget()</span> / <span
58
                                class="target-cell">$target.getTodaySlowMovingTarget()</span></td>
59
                        <td class="slow-percent"></td>
60
                        <td><span class="achieved-cell">$target.getTodayAchievedEolTarget()</span> / <span
61
                                class="target-cell">$target.getTodayEolTarget()</span></td>
62
                        <td class="eol-percent"></td>
63
                        <td><span class="achieved-cell">$target.getTodayAchievedOtherMovingTarget()</span> / <span
64
                                class="target-cell">$target.getTodayOtherMovingTarget()</span></td>
65
                        <td class="other-percent"></td>
33917 ranu 66
                    </tr>
33939 ranu 67
                    #end
33946 ranu 68
                <!-- Add a row for totals -->
33942 ranu 69
                <tr>
70
                    <td><strong>Total</strong></td>
33951 ranu 71
                    <td><span class="achieved-cell" id="total-achieved"></span> / <span class="target-cell"
72
                                                                                        id="total-target"></span></td>
33942 ranu 73
                    <td class="total-percent"></td>
33951 ranu 74
 
75
                    <td><span id="total-achieved-hid" class="achieved-cell"></span> / <span id="total-target-hid"
76
                                                                                            class="target-cell"></span>
77
                    </td>
33942 ranu 78
                    <td class="hid-percent"></td>
33951 ranu 79
 
80
                    <td><span id="total-achieved-run" class="achieved-cell"></span> / <span id="total-target-run"
81
                                                                                            class="target-cell"></span>
82
                    </td>
33942 ranu 83
                    <td class="run-percent"></td>
33951 ranu 84
 
85
                    <td><span id="total-achieved-slow" class="achieved-cell"></span> / <span id="total-target-slow"
86
                                                                                             class="target-cell"></span>
87
                    </td>
33942 ranu 88
                    <td class="slow-percent"></td>
33951 ranu 89
 
90
                    <td><span id="total-achieved-eol" class="achieved-cell"></span> / <span id="total-target-eol"
91
                                                                                            class="target-cell"></span>
92
                    </td>
33942 ranu 93
                    <td class="eol-percent"></td>
33951 ranu 94
 
95
                    <td><span id="total-achieved-other" class="achieved-cell"></span> / <span id="total-target-other"
96
                                                                                              class="target-cell"></span>
97
                    </td>
33942 ranu 98
                    <td class="other-percent"></td>
99
                </tr>
33951 ranu 100
 
33917 ranu 101
            </table>
102
        </div>
103
    </div>
33930 ranu 104
</section>
33945 ranu 105
 
33930 ranu 106
<script>
33933 ranu 107
    function formatValueInLakh(value) {
33939 ranu 108
        return (value / 100000).toFixed(1) + 'L';
33930 ranu 109
    }
110
 
111
    function formatTargets() {
112
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
33942 ranu 113
        let totalAchieved = 0, totalTarget = 0;
114
        let totalAchievedHid = 0, totalTargetHid = 0;
115
        let totalAchievedRun = 0, totalTargetRun = 0;
116
        let totalAchievedSlow = 0, totalTargetSlow = 0;
117
        let totalAchievedEol = 0, totalTargetEol = 0;
118
        let totalAchievedOther = 0, totalTargetOther = 0;
33930 ranu 119
 
120
        rows.forEach(row => {
33931 ranu 121
            const cells = row.querySelectorAll('td');
33946 ranu 122
            cells.forEach((cell, index) => {
123
                const achievedSpan = cell.querySelector('.achieved-cell');
124
                const targetSpan = cell.querySelector('.target-cell');
125
                if (achievedSpan && targetSpan) {
126
                    const achievedValue = parseFloat(achievedSpan.textContent.replace(/[^\d.-]/g, ''));
127
                    const targetValue = parseFloat(targetSpan.textContent.replace(/[^\d.-]/g, ''));
33944 ranu 128
 
33946 ranu 129
                    // Add to totals
130
                    if (index === 1) {
131
                        totalAchieved += achievedValue || 0;
132
                        totalTarget += targetValue || 0;
133
                    } else if (index === 3) {
134
                        totalAchievedHid += achievedValue || 0;
135
                        totalTargetHid += targetValue || 0;
136
                    } else if (index === 5) {
137
                        totalAchievedRun += achievedValue || 0;
138
                        totalTargetRun += targetValue || 0;
139
                    } else if (index === 7) {
140
                        totalAchievedSlow += achievedValue || 0;
141
                        totalTargetSlow += targetValue || 0;
142
                    } else if (index === 9) {
143
                        totalAchievedEol += achievedValue || 0;
144
                        totalTargetEol += targetValue || 0;
145
                    } else if (index === 11) {
146
                        totalAchievedOther += achievedValue || 0;
147
                        totalTargetOther += targetValue || 0;
148
                    }
33930 ranu 149
 
33946 ranu 150
                    // Format values in lakh
151
                    if (!isNaN(achievedValue)) achievedSpan.textContent = formatValueInLakh(achievedValue);
152
                    if (!isNaN(targetValue)) targetSpan.textContent = formatValueInLakh(targetValue);
33942 ranu 153
 
33946 ranu 154
                    const percentCell = cell.nextElementSibling;
155
                    if (percentCell && targetValue > 0) {
156
                        const percentage = ((achievedValue / targetValue) * 100).toFixed(1);
157
                        percentCell.textContent = percentage + '%';
33931 ranu 158
 
33946 ranu 159
                        // Determine background color based on percentage
160
                        let color;
161
                        if (percentage <= 40) {
162
                            color = '#F56983FF'; // Orange for <= 40%
163
                        } else if (percentage > 40 && percentage <= 75) {
164
                            color = '#f2c947e8'; // Yellow for 41% - 75%
165
                        } else {
166
                            color = '#82ef8299'; // Green for > 75%
167
                        }
33945 ranu 168
 
33946 ranu 169
                        // Apply gradient background with the color
170
                        percentCell.style.background = `linear-gradient(to right, ${color} ${percentage}%, transparent ${percentage}%)`;
171
                    } else if (percentCell) {
33951 ranu 172
                        percentCell.textContent = "0";
33946 ranu 173
                        percentCell.style.background = 'none';
33931 ranu 174
                    }
33946 ranu 175
                }
33930 ranu 176
            });
33946 ranu 177
        });
33942 ranu 178
 
33946 ranu 179
        // Update total row with calculated totals
180
        document.getElementById('total-achieved').textContent = formatValueInLakh(totalAchieved);
181
        document.getElementById('total-target').textContent = formatValueInLakh(totalTarget);
182
        document.getElementById('total-achieved-hid').textContent = formatValueInLakh(totalAchievedHid);
183
        document.getElementById('total-target-hid').textContent = formatValueInLakh(totalTargetHid);
184
        document.getElementById('total-achieved-run').textContent = formatValueInLakh(totalAchievedRun);
185
        document.getElementById('total-target-run').textContent = formatValueInLakh(totalTargetRun);
186
        document.getElementById('total-achieved-slow').textContent = formatValueInLakh(totalAchievedSlow);
187
        document.getElementById('total-target-slow').textContent = formatValueInLakh(totalTargetSlow);
188
        document.getElementById('total-achieved-eol').textContent = formatValueInLakh(totalAchievedEol);
189
        document.getElementById('total-target-eol').textContent = formatValueInLakh(totalTargetEol);
190
        document.getElementById('total-achieved-other').textContent = formatValueInLakh(totalAchievedOther);
191
        document.getElementById('total-target-other').textContent = formatValueInLakh(totalTargetOther);
192
    }
33944 ranu 193
 
33946 ranu 194
    window.onload = formatTargets;
33945 ranu 195
</script>