Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
33917 ranu 1
<style>
33930 ranu 2
    table th {
3
        text-align: center;
33917 ranu 4
    }
5
 
33930 ranu 6
    #rbm-arr-table td, #rbm-arr-table th {
7
        padding: 0.35rem;
8
        font-size: 20px;
33917 ranu 9
    }
33930 ranu 10
 
11
    .rb-name {
12
        font-size: 17px;
13
        font-weight: bold;
14
    }
33939 ranu 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
 
33917 ranu 24
</style>
25
 
26
<section class="wrapper">
33925 ranu 27
    ##    <div class="row">
28
    ##        <div class="col-lg-12">
29
    ##            <h3 class="page-header"><i class="icon_document_alt"></i>RBM ARR</h3>
30
    ##            <ol class="breadcrumb">
31
    ##                <li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
32
    ##                <li><i class="icon_document_alt"></i>RBM Wise Today's ARR (Basis Product Movement)</li>
33
    ##            </ol>
34
    ##        </div>
35
    ##    </div>
33917 ranu 36
 
37
    <div class="row">
33925 ranu 38
        ##        <div class="col-lg-4">
33939 ranu 39
        ##            <table>
40
        ##                <tr>
41
        ##                    <td><input type="date" class="form-control arr-start_date" placeholder="select date"></td>
42
        ##                    <td><button type="button" class="btn btn-info arr-button-mk">Submit</button></td>
43
        ##                </tr>
44
        ##            </table>
33925 ranu 45
        ##        </div>
33939 ranu 46
        ##        <div class="clearfix"></div>
47
        ##        <br>
33917 ranu 48
        <div class="col-lg-12">
49
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
50
                <thead>
51
                <tr>
33939 ranu 52
                    <th>RBM</th>
53
                    <th>Total (ACH/TGT)</th>
54
                    <th>%</th>
55
                    <th>HID (ACH/TGT)</th>
56
                    <th>%</th>
57
                    <th>RUN (ACH/TGT)</th>
58
                    <th>%</th>
59
                    <th>SLOW (ACH/TGT)</th>
60
                    <th>%</th>
61
                    <th>EOL (ACH/TGT)</th>
62
                    <th>%</th>
63
                    <th>Other (ACH/TGT)</th>
64
                    <th>%</th>
33917 ranu 65
                </tr>
66
                </thead>
33939 ranu 67
                <tbody>
68
                    #foreach($target in $rbmArrViewModels)
33917 ranu 69
                    <tr>
33933 ranu 70
                        <td>$target.getRbmName()- $target.getWarehouseName()</td>
33939 ranu 71
                        <td><span class="achieved-cell">$target.getTotalAchievedTarget()</span> / <span
72
                                class="target-cell">$target.getTodayTarget()</span></td>
73
                        <td class="total-percent"></td>
74
                        <td><span class="achieved-cell">$target.getTodayAchievedHidTarget()</span> / <span
75
                                class="target-cell">$target.getTodayHidTarget()</span></td>
76
                        <td class="hid-percent"></td>
77
                        <td><span class="achieved-cell">$target.getTodayAchievedFastMovingTarget()</span> / <span
78
                                class="target-cell">$target.getTodayFastMovingTarget()</span></td>
79
                        <td class="run-percent"></td>
80
                        <td><span class="achieved-cell">$target.getTodayAchievedSlowMovingTarget()</span> / <span
81
                                class="target-cell">$target.getTodaySlowMovingTarget()</span></td>
82
                        <td class="slow-percent"></td>
83
                        <td><span class="achieved-cell">$target.getTodayAchievedEolTarget()</span> / <span
84
                                class="target-cell">$target.getTodayEolTarget()</span></td>
85
                        <td class="eol-percent"></td>
86
                        <td><span class="achieved-cell">$target.getTodayAchievedOtherMovingTarget()</span> / <span
87
                                class="target-cell">$target.getTodayOtherMovingTarget()</span></td>
88
                        <td class="other-percent"></td>
33917 ranu 89
                    </tr>
33939 ranu 90
                    #end
91
                </tbody>
33942 ranu 92
                <tfoot>
93
                <tr>
94
                    <td><strong>Total</strong></td>
95
                    <td><span id="total-achieved"></span> / <span id="total-target"></span></td>
96
                    <td class="total-percent"></td>
97
                    <td><span id="total-achieved-hid"></span> / <span id="total-target-hid"></span></td>
98
                    <td class="hid-percent"></td>
99
                    <td><span id="total-achieved-run"></span> / <span id="total-target-run"></span></td>
100
                    <td class="run-percent"></td>
101
                    <td><span id="total-achieved-slow"></span> / <span id="total-target-slow"></span></td>
102
                    <td class="slow-percent"></td>
103
                    <td><span id="total-achieved-eol"></span> / <span id="total-target-eol"></span></td>
104
                    <td class="eol-percent"></td>
105
                    <td><span id="total-achieved-other"></span> / <span id="total-target-other"></span></td>
106
                    <td class="other-percent"></td>
107
                </tr>
108
                </tfoot>
33917 ranu 109
            </table>
110
        </div>
111
    </div>
33930 ranu 112
</section>
113
 
114
<script>
33933 ranu 115
    function formatValueInLakh(value) {
33939 ranu 116
        return (value / 100000).toFixed(1) + 'L';
33930 ranu 117
    }
118
 
119
    function formatTargets() {
120
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
33942 ranu 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;
33930 ranu 127
 
128
        rows.forEach(row => {
33931 ranu 129
            const cells = row.querySelectorAll('td');
33942 ranu 130
            cells.forEach((cell, index) => {
33939 ranu 131
                const achievedSpan = cell.querySelector('.achieved-cell');
33933 ranu 132
                const targetSpan = cell.querySelector('.target-cell');
33939 ranu 133
                if (achievedSpan && targetSpan) {
134
                    const achievedValue = parseFloat(achievedSpan.textContent.replace(/[^\d.-]/g, ''));
135
                    const targetValue = parseFloat(targetSpan.textContent.replace(/[^\d.-]/g, ''));
33930 ranu 136
 
33942 ranu 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
 
33939 ranu 158
                    // Format values in lakh
159
                    if (!isNaN(achievedValue)) achievedSpan.textContent = formatValueInLakh(achievedValue);
33933 ranu 160
                    if (!isNaN(targetValue)) targetSpan.textContent = formatValueInLakh(targetValue);
33931 ranu 161
 
33939 ranu 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 <= 40) {
170
                            color = '#F56983FF'; // Orange for <= 40%
171
                        } else if (percentage > 40 && percentage <= 75) {
172
                            color = '#f2c947e8'; // Yellow for 41% - 75%
173
                        } else {
174
                            color = '#82ef8299'; // Green for > 75%
175
                        }
176
 
177
                        // Apply gradient background with the color
178
                        percentCell.style.background = `linear-gradient(to right, ${color} ${percentage}%, transparent ${percentage}%)`;
179
                    } else if (percentCell) {
180
                        percentCell.textContent = 'N/A';
181
                        percentCell.style.background = 'none';
33931 ranu 182
                    }
33930 ranu 183
                }
184
            });
185
        });
33942 ranu 186
 
187
        // Update total row with calculated totals
188
        document.getElementById('total-achieved').textContent = formatValueInLakh(totalAchieved);
189
        document.getElementById('total-target').textContent = formatValueInLakh(totalTarget);
190
        document.getElementById('total-achieved-hid').textContent = formatValueInLakh(totalAchievedHid);
191
        document.getElementById('total-target-hid').textContent = formatValueInLakh(totalTargetHid);
192
        document.getElementById('total-achieved-run').textContent = formatValueInLakh(totalAchievedRun);
193
        document.getElementById('total-target-run').textContent = formatValueInLakh(totalTargetRun);
194
        document.getElementById('total-achieved-slow').textContent = formatValueInLakh(totalAchievedSlow);
195
        document.getElementById('total-target-slow').textContent = formatValueInLakh(totalTargetSlow);
196
        document.getElementById('total-achieved-eol').textContent = formatValueInLakh(totalAchievedEol);
197
        document.getElementById('total-target-eol').textContent = formatValueInLakh(totalTargetEol);
198
        document.getElementById('total-achieved-other').textContent = formatValueInLakh(totalAchievedOther);
199
        document.getElementById('total-target-other').textContent = formatValueInLakh(totalTargetOther);
33930 ranu 200
    }
201
 
33939 ranu 202
    window.onload = formatTargets;
33930 ranu 203
</script>
204
 
205