| Line 55... |
Line 55... |
| 55 |
-
|
55 |
-
|
| 56 |
#end
|
56 |
#end
|
| 57 |
#end
|
57 |
#end
|
| 58 |
|
58 |
|
| 59 |
<tbody id="monthSalesBody">
|
59 |
<tbody id="monthSalesBody">
|
| 60 |
#set($start = 1)
|
60 |
#set($start = 0)
|
| 61 |
#set($end = 6)
|
61 |
#set($end = 6)
|
| 62 |
#set($range = [$start..$end])
|
62 |
#set($range = [$start..$end])
|
| 63 |
#foreach($i in $range)
|
63 |
#foreach($i in $range)
|
| 64 |
<tr class="clickable-row cursor-pointer" data-month="$monthSales.get($i).getMonth()">
|
64 |
<tr class="clickable-row cursor-pointer" data-month="$i">
|
| 65 |
<td><b>#safe($monthSales.get($i).getMonth())</b></td>
|
65 |
<td><b>#safe($monthSales.get($i).getMonth())</b></td>
|
| 66 |
<td>#safe($monthSales.get($i).getMonthlySales())</td>
|
66 |
<td>#safe($monthSales.get($i).getMonthlySales())</td>
|
| 67 |
<td>#safe($monthSales.get($i).getMtdSales())</td>
|
67 |
<td>#safe($monthSales.get($i).getMtdSales())</td>
|
| 68 |
<td>#safe($monthSales.get($i).getPartnerType())</td>
|
68 |
<td>#safe($monthSales.get($i).getPartnerType())</td>
|
| 69 |
<td class="toggle-cell">
|
69 |
<td class="toggle-cell">
|
| Line 78... |
Line 78... |
| 78 |
<!-- Added table-striped and nested-table-striped classes -->
|
78 |
<!-- Added table-striped and nested-table-striped classes -->
|
| 79 |
<table class="table table-striped nested-table-striped brand-wise-table">
|
79 |
<table class="table table-striped nested-table-striped brand-wise-table">
|
| 80 |
<thead>
|
80 |
<thead>
|
| 81 |
<tr>
|
81 |
<tr>
|
| 82 |
<th>Brand</th>
|
82 |
<th>Brand</th>
|
| 83 |
<th>LMS</th>
|
83 |
<th class="lmsHead">LMS</th>
|
| 84 |
<th>LMTD</th>
|
- |
|
| 85 |
<th>MTD</th>
|
84 |
<th class="mtdHead">MTD</th>
|
| 86 |
<th>MTDQTY</th>
|
85 |
<th>MTDQTY</th>
|
| 87 |
<th></th>
|
86 |
<th></th>
|
| 88 |
</tr>
|
87 |
</tr>
|
| 89 |
</thead>
|
88 |
</thead>
|
| 90 |
<tbody class="brandWiseBody">
|
89 |
<tbody class="brandWiseBody">
|
| Line 132... |
Line 131... |
| 132 |
const brandItemRows = otherRow.parentNode.querySelectorAll('.brand-item-wise-sale-row');
|
131 |
const brandItemRows = otherRow.parentNode.querySelectorAll('.brand-item-wise-sale-row');
|
| 133 |
brandItemRows.forEach(itemRow => itemRow.style.display = 'none');
|
132 |
brandItemRows.forEach(itemRow => itemRow.style.display = 'none');
|
| 134 |
}
|
133 |
}
|
| 135 |
});
|
134 |
});
|
| 136 |
|
135 |
|
| 137 |
let monthString = row.getAttribute('data-month');
|
136 |
let minusmonth = row.getAttribute('data-month');
|
| 138 |
const monthMap = {
|
- |
|
| 139 |
'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4,
|
- |
|
| 140 |
'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8,
|
- |
|
| 141 |
'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12
|
- |
|
| 142 |
};
|
- |
|
| 143 |
|
137 |
|
| 144 |
const monthAbbr = monthString.substring(0, 3);
|
- |
|
| 145 |
const monthNumber = monthMap[monthAbbr];
|
- |
|
| 146 |
|
- |
|
| 147 |
if (!monthNumber) {
|
138 |
if (!minusmonth) {
|
| 148 |
console.error('Invalid month:', monthString);
|
139 |
console.error('Invalid month:', minusmonth);
|
| 149 |
return;
|
140 |
return;
|
| 150 |
}
|
141 |
}
|
| 151 |
|
142 |
|
| 152 |
// Toggle the brand-wise row
|
143 |
// Toggle the brand-wise row
|
| 153 |
if (brandWiseRow.style.display === 'none') {
|
144 |
if (brandWiseRow.style.display === 'none') {
|
| 154 |
brandWiseRow.style.display = '';
|
145 |
brandWiseRow.style.display = '';
|
| 155 |
|
146 |
|
| 156 |
doGetAjaxRequestHandler(
|
147 |
doGetAjaxRequestHandler(
|
| 157 |
`getBrandwisePartnerSale?month=${monthNumber}`,
|
148 |
`getBrandwisePartnerSale?month=${minusmonth}`,
|
| 158 |
function (response) {
|
149 |
function (response) {
|
| - |
|
150 |
let currentDate = new Date();
|
| - |
|
151 |
let selectedMonth = new Date();
|
| - |
|
152 |
selectedMonth.setMonth(currentDate.getMonth() - minusmonth);
|
| - |
|
153 |
|
| - |
|
154 |
let prevMonth = new Date();
|
| - |
|
155 |
prevMonth.setMonth(selectedMonth.getMonth() - 1);
|
| - |
|
156 |
|
| - |
|
157 |
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
| - |
|
158 |
|
| - |
|
159 |
brandWiseRow.querySelector(".lmsHead").innerText = "LMS (" + monthNames[prevMonth.getMonth()] + ")";
|
| - |
|
160 |
brandWiseRow.querySelector(".mtdHead").innerText = "MTD (" + monthNames[selectedMonth.getMonth()] + ")";
|
| - |
|
161 |
|
| 159 |
const brandBody = brandWiseRow.querySelector('.brandWiseBody');
|
162 |
const brandBody = brandWiseRow.querySelector('.brandWiseBody');
|
| 160 |
brandBody.innerHTML = '';
|
163 |
brandBody.innerHTML = '';
|
| 161 |
|
164 |
|
| 162 |
response.forEach(function (item) {
|
165 |
response.forEach(function (item) {
|
| 163 |
const safe = (val) => (val == null || val === "null" ? 0 : val);
|
166 |
const safe = (val) => (val == null || val === "null" ? 0 : val);
|
| Line 165... |
Line 168... |
| 165 |
brandRow.classList.add('clickable-brandrow');
|
168 |
brandRow.classList.add('clickable-brandrow');
|
| 166 |
brandRow.setAttribute('data-brand', item.brand);
|
169 |
brandRow.setAttribute('data-brand', item.brand);
|
| 167 |
brandRow.innerHTML =
|
170 |
brandRow.innerHTML =
|
| 168 |
'<td><b>' + safe(item.brand) + '</b></td>' +
|
171 |
'<td><b>' + safe(item.brand) + '</b></td>' +
|
| 169 |
'<td>' + safe(item.lms) + '</td>' +
|
172 |
'<td>' + safe(item.lms) + '</td>' +
|
| 170 |
'<td>' + safe(item.lmtd) + '</td>' +
|
- |
|
| 171 |
'<td>' + safe(item.mtd) + '</td>' +
|
173 |
'<td>' + safe(item.mtd) + '</td>' +
|
| 172 |
'<td>' + safe(item.mtdQty) + '</td>' +
|
174 |
'<td>' + safe(item.mtdQty) + '</td>' +
|
| 173 |
'<td class="toggle-cell"><i class="fa fa-angle-down dropdown-icon" style="cursor:pointer; font-size: 27px;width: 27px;height: 27px;margin-top: 0px;color: rgba(255, 255, 255, 0.75);line-height: 27px;"></i></td>';
|
175 |
'<td class="toggle-cell"><i class="fa fa-angle-down dropdown-icon" style="cursor:pointer; font-size: 27px;width: 27px;height: 27px;margin-top: 0px;color: rgba(255, 255, 255, 0.75);line-height: 27px;"></i></td>';
|
| 174 |
|
176 |
|
| 175 |
brandRow.addEventListener('click', function () {
|
177 |
brandRow.addEventListener('click', function () {
|
| Line 206... |
Line 208... |
| 206 |
|
208 |
|
| 207 |
// Toggle current row - same logic as month rows
|
209 |
// Toggle current row - same logic as month rows
|
| 208 |
if (brandItemWiseRow.style.display === 'none') {
|
210 |
if (brandItemWiseRow.style.display === 'none') {
|
| 209 |
brandItemWiseRow.style.display = '';
|
211 |
brandItemWiseRow.style.display = '';
|
| 210 |
doGetAjaxRequestHandler(
|
212 |
doGetAjaxRequestHandler(
|
| 211 |
'getBrandItemwisePartnerSale?month=' + monthNumber + '&brand=' + encodeURIComponent(brandName) + '&fofoId=' + encodeURIComponent(fofoId),
|
213 |
'getBrandItemwisePartnerSale?month=' + minusmonth + '&brand=' + encodeURIComponent(brandName) + '&fofoId=' + encodeURIComponent(fofoId),
|
| 212 |
function (response) {
|
214 |
function (response) {
|
| 213 |
const tbody = brandItemWiseRow.querySelector('.brandItemWiseBody');
|
215 |
const tbody = brandItemWiseRow.querySelector('.brandItemWiseBody');
|
| 214 |
tbody.innerHTML = '';
|
216 |
tbody.innerHTML = '';
|
| 215 |
response.forEach(item => {
|
217 |
response.forEach(item => {
|
| 216 |
const tr = document.createElement('tr');
|
218 |
const tr = document.createElement('tr');
|