Subversion Repositories SmartDukaan

Rev

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

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