Subversion Repositories SmartDukaan

Rev

Rev 33930 | Rev 33932 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33930 Rev 33931
Line 43... Line 43...
43
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
43
            <table id="rbm-arr-table" class="table table-border table-condensed table-bordered" style="width:100%">
44
 
44
 
45
                <thead>
45
                <thead>
46
                <tr>
46
                <tr>
47
                    <th rowspan="2" class="text-left">RBM</th>
47
                    <th rowspan="2" class="text-left">RBM</th>
48
                    <th colspan="2" class="text-center">HID</th>
48
                    <th class="text-center">HID</th>
49
                    <th colspan="2">RUN</th>
49
                    <th>RUN</th>
50
                    <th colspan="2">SLOW</th>
50
                    <th>SLOW</th>
51
                    <th colspan="2">EOL</th>
51
                    <th>EOL</th>
52
                    <th colspan="2">Other</th>
52
                    <th>Other</th>
53
                    <th colspan="2">Total</th>
53
                    <th>Total</th>
54
                </tr>
54
                </tr>
55
                <tr>
55
                <tr>
56
                    <th>TGT</th>
-
 
57
                    <th>ACH</th>
56
                    <th>ACH/TGT</th>
58
 
57
 
59
                    <th>TGT</th>
-
 
60
                    <th>ACH</th>
58
                    <th>ACH/TGT</th>
61
 
59
 
62
                    <th>TGT</th>
-
 
63
                    <th>ACH</th>
60
                    <th>ACH/TGT</th>
64
 
61
 
65
                    <th>TGT</th>
-
 
66
                    <th>ACH</th>
62
                    <th>ACH/TGT</th>
67
 
63
 
68
                    <th>TGT</th>
64
                    <th>ACH/TGT</th>
-
 
65
 
69
                    <th>ACH</th>
66
                    <th>ACH/TGT</th>
70
 
67
 
71
                    <th>TGT</th>
-
 
72
                    <th>ACH</th>
-
 
73
                </tr>
68
                </tr>
74
 
69
 
75
                </thead>
70
                </thead>
76
                #foreach($target in $rbmArrViewModels)
71
                #foreach($target in $rbmArrViewModels)
77
                    <tbody>
72
                    <tbody>
78
                    <tr>
73
                    <tr>
79
                        <td class="rb-name">$target.getRbmName()- $target.getWarehouseName()</td>
74
                        <td class="rb-name">$target.getRbmName()- $target.getWarehouseName()</td>
80
 
75
 
81
                        <td class="target-cell">$target.getTodayHidTarget()</td>
76
                        <td><span class="target-cell">$target.getTodayAchievedHidTarget()</span> / <span
82
                        <td class="achieved-cell">$target.getTodayAchievedHidTarget()</td>
77
                                class="achieved-cell">$target.getTodayHidTarget()</span></td>
83
 
78
 
84
                        <td class="target-cell">$target.getTodayFastMovingTarget()</td>
79
                        <td><span class="target-cell">$target.getTodayAchievedFastMovingTarget()</span> / <span
85
                        <td class="achieved-cell">$target.getTodayAchievedFastMovingTarget()</td>
80
                                class="achieved-cell">$target.getTodayFastMovingTarget()</span></td>
86
 
81
 
87
                        <td class="target-cell">$target.getTodaySlowMovingTarget()</td>
82
                        <td><span class="target-cell">$target.getTodayAchievedSlowMovingTarget()</span> / <span
88
                        <td class="achieved-cell">$target.getTodayAchievedSlowMovingTarget()</td>
83
                                class="achieved-cell">$target.getTodaySlowMovingTarget()</span></td>
89
 
84
 
90
                        <td class="target-cell">$target.getTodayEolTarget()</td>
85
                        <td><span class="target-cell">$target.getTodayAchievedEolTarget()</span> / <span
91
                        <td class="achieved-cell">$target.getTodayAchievedEolTarget()</td>
86
                                class="achieved-cell">$target.getTodayEolTarget()</span></td>
92
 
87
 
93
                        <td class="target-cell">$target.getTodayOtherMovingTarget()</td>
88
                        <td><span class="target-cell">$target.getTodayAchievedOtherMovingTarget()</span> / <span
94
                        <td class="achieved-cell">$target.getTodayAchievedOtherMovingTarget()</td>
89
                                class="achieved-cell">$target.getTodayOtherMovingTarget()</span></td>
95
 
90
 
96
                        <td class="target-cell">$target.getTodayTarget()</td>
91
                        <td><span class="target-cell">$target.getTotalAchievedTarget()</span> / <span
97
                        <td class="achieved-cell">$target.getTotalAchievedTarget()</td>
92
                                class="achieved-cell">$target.getTodayTarget()</span></td>
98
                    </tr>
93
                    </tr>
99
                    </tbody>
94
                    </tbody>
100
                #end
95
                #end
101
 
96
 
102
            </table>
97
            </table>
Line 107... Line 102...
107
 
102
 
108
 
103
 
109
</section>
104
</section>
110
 
105
 
111
<script>
106
<script>
112
    // Function to format the numbers with appropriate abbreviations
107
    // Function to format all values in lakhs, converting thousands to lakhs and ignoring hundreds
113
    function formatValue(value) {
108
    function formatValueInLakhs(value) {
114
        if (value >= 10000000) {  // 1 Crore and above
109
        if (value >= 1000) {
115
            return (value / 10000000).toFixed(1) + 'Cr'; // 1 Cr = 10,000,000
-
 
116
        } else if (value >= 100000) {  // 1 Lakh and above
-
 
117
            return (value / 100000).toFixed(1) + 'L'; // 1 Lakh = 100,000
110
            return (value / 100000).toFixed(1) + ' L'; // Convert thousands and above to lakhs
118
        } else if (value >= 1000) {  // 1 Thousand and above
-
 
119
            return (value / 1000).toFixed(1) + 'K'; // 1K = 1,000
-
 
120
        } else {
111
        } else {
121
            return value.toFixed(1); // Show decimals for values below 1000
112
            return '0.0 L'; // Display as 0.0 L for values less than 1000
122
        }
113
        }
123
    }
114
    }
124
 
115
 
125
    // Function to format all target and achieved values in the table and apply color conditionally
116
    // Function to format target and achieved values in lakhs, with special handling for target = 0
126
    function formatTargets() {
117
    function formatTargets() {
127
        // Select all rows to compare target and achieved cells
118
        // Select all rows
128
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
119
        const rows = document.querySelectorAll('#rbm-arr-table tbody tr');
129
 
120
 
130
        rows.forEach(row => {
121
        rows.forEach(row => {
131
            // Get all target and achieved cells in the current row
122
            // Find cells that contain both target and achieved values (ACH/TGT)
132
            const targetCells = row.querySelectorAll('.target-cell');
123
            const cells = row.querySelectorAll('td');
133
            const achievedCells = row.querySelectorAll('.achieved-cell');
-
 
134
 
124
 
135
            targetCells.forEach((targetCell, index) => {
125
            cells.forEach(cell => {
-
 
126
                // Separate achieved and target values using the `/` separator
-
 
127
                let values = cell.textContent.split('/').map(val => val.trim());
-
 
128
 
136
                // Convert text content to numeric values
129
                if (values.length === 2) {
137
                let targetValue = parseFloat(targetCell.textContent.replace(/[^\d.-]/g, ''));
130
                    let achievedValue = parseFloat(values[0].replace(/[^\d.-]/g, ''));
138
                let achievedValue = parseFloat(achievedCells[index].textContent.replace(/[^\d.-]/g, ''));
131
                    let targetValue = parseFloat(values[1].replace(/[^\d.-]/g, ''));
139
 
132
 
-
 
133
                    if (targetValue === 0) {
-
 
134
                        // If target is 0, display '-'
-
 
135
                        cell.innerHTML = '-';
-
 
136
                    } else {
140
                // Format both cells with the abbreviated units
137
                        // Format values to lakhs
-
 
138
                        let formattedAchieved = !isNaN(achievedValue) ? formatValueInLakhs(achievedValue) : '0.0 L';
141
                if (!isNaN(targetValue)) targetCell.textContent = formatValue(targetValue);
139
                        let formattedTarget = !isNaN(targetValue) ? formatValueInLakhs(targetValue) : '0.0 L';
-
 
140
 
142
                if (!isNaN(achievedValue)) achievedCells[index].textContent = formatValue(achievedValue);
141
                        // Replace cell content with formatted values
-
 
142
                        cell.innerHTML = `<span class="achieved-cell">${formattedAchieved}</span> / <span class="target-cell">${formattedTarget}</span>`;
143
 
143
 
144
                // Apply green background if achieved value is greater than or equal to target
144
                        // Apply green background if achieved >= target
145
                if (!isNaN(targetValue) && !isNaN(achievedValue) && achievedValue >= targetValue) {
145
                        if (!isNaN(achievedValue) && !isNaN(targetValue) && achievedValue >= targetValue) {
146
                    achievedCells[index].style.backgroundColor = '#abf2abd4';
146
                            cell.querySelector('.achieved-cell').style.backgroundColor = '#abf2abd4';
-
 
147
                        }
-
 
148
                    }
147
                }
149
                }
148
            });
150
            });
149
        });
151
        });
150
    }
152
    }
151
 
153
 
Line 155... Line 157...
155
 
157
 
156
 
158
 
157
 
159
 
158
 
160
 
159
 
161
 
-
 
162
 
-
 
163
 
-
 
164
 
-
 
165