| Line 163... |
Line 163... |
| 163 |
|
163 |
|
| 164 |
}
|
164 |
}
|
| 165 |
|
165 |
|
| 166 |
function catalogPurchaseSaleChart(startDate, endDate, brand, supplierId, label) {
|
166 |
function catalogPurchaseSaleChart(startDate, endDate, brand, supplierId, label) {
|
| 167 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/catalog-quantity?startDate=${startDate}&endDate=${endDate}&brand=${brand}&supplierId=${supplierId}&label=${label}`, function (response) {
|
167 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/catalog-quantity?startDate=${startDate}&endDate=${endDate}&brand=${brand}&supplierId=${supplierId}&label=${label}`, function (response) {
|
| - |
|
168 |
console.log("response to check status - ",response);
|
| 168 |
createCatalogPurchaseSaleBarChart(response, startDate, endDate, supplierId);
|
169 |
createCatalogPurchaseSaleBarChart(response, startDate, endDate, supplierId);
|
| 169 |
});
|
170 |
});
|
| 170 |
}
|
171 |
}
|
| 171 |
|
172 |
|
| 172 |
function getCatalogAgeDetail(startDate, endDate, supplierId, label) {
|
173 |
function getCatalogAgeDetail(startDate, endDate, supplierId, label,status) {
|
| 173 |
// /catalog-age-detail
|
174 |
// /catalog-age-detail
|
| 174 |
let modelNumber = label;
|
175 |
let modelNumber = label;
|
| 175 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/catalog-age-detail?startDate=${startDate}&endDate=${endDate}&modelNumber=${modelNumber}&supplierId=${supplierId}`, function (response) {
|
176 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/catalog-age-detail?startDate=${startDate}&endDate=${endDate}&modelNumber=${modelNumber}&supplierId=${supplierId}&status=${status}`, function (response) {
|
| 176 |
$('#catalog-age-div #catalogModalBody').html(response);
|
177 |
$('#catalog-age-div #catalogModalBody').html(response);
|
| 177 |
$('#catalog-age-div').modal('show');
|
178 |
$('#catalog-age-div').modal('show');
|
| 178 |
});
|
179 |
});
|
| 179 |
}
|
180 |
}
|
| 180 |
|
181 |
|
| 181 |
function createCatalogPurchaseSaleBarChart(response, startDate, endDate, supplierId) {
|
182 |
function createCatalogPurchaseSaleBarChart(response, startDate, endDate, supplierId) {
|
| 182 |
let labels = [], totalQuantities = [], soldQuantities = [];
|
183 |
let labels = [], totalQuantities = [], soldQuantities = [];
|
| - |
|
184 |
|
| 183 |
let filterResponse = response.filter(res => res.sale !== res.purchase);
|
185 |
let filterResponse = response.filter(res => res.sale !== res.purchase);
|
| - |
|
186 |
|
| 184 |
labels = filterResponse.map(sale => sale.model);
|
187 |
labels = filterResponse.map(sale => sale.model);
|
| 185 |
totalQuantities = filterResponse.map(sale => sale.purchase);
|
188 |
totalQuantities = filterResponse.map(sale => sale.purchase);
|
| 186 |
soldQuantities = filterResponse.map(sale => sale.sale);
|
189 |
soldQuantities = filterResponse.map(sale => sale.sale);
|
| 187 |
|
- |
|
| - |
|
190 |
let status = filterResponse.map(sale => sale.status)[0];
|
| 188 |
let charContainer = document.getElementById('chartContainer');
|
191 |
let charContainer = document.getElementById('chartContainer');
|
| - |
|
192 |
|
| 189 |
//destroy old Catalog Chart Container
|
193 |
//destroy old Catalog Chart Container
|
| 190 |
$('#catalogChartContainer').remove();
|
194 |
$('#catalogChartContainer').remove();
|
| - |
|
195 |
|
| 191 |
//create new Catalog Chart Container
|
196 |
//create new Catalog Chart Container
|
| 192 |
let newCatalogChartContainer = document.createElement('div');
|
197 |
let newCatalogChartContainer = document.createElement('div');
|
| 193 |
newCatalogChartContainer.id = 'catalogChartContainer';
|
198 |
newCatalogChartContainer.id = 'catalogChartContainer';
|
| 194 |
newCatalogChartContainer.classList.add('col-md-6');
|
199 |
newCatalogChartContainer.classList.add('col-md-6');
|
| 195 |
|
200 |
|
| Line 285... |
Line 290... |
| 285 |
}, onClick: function (event, activeElements) {
|
290 |
}, onClick: function (event, activeElements) {
|
| 286 |
if (activeElements.length > 0) {
|
291 |
if (activeElements.length > 0) {
|
| 287 |
const element = activeElements[0]; // Get the clicked element
|
292 |
const element = activeElements[0]; // Get the clicked element
|
| 288 |
const datasetIndex = element.datasetIndex; // Get the dataset (Sale or Purchase)
|
293 |
const datasetIndex = element.datasetIndex; // Get the dataset (Sale or Purchase)
|
| 289 |
const dataIndex = element.index; // Get the index of the clicked bar
|
294 |
const dataIndex = element.index; // Get the index of the clicked bar
|
| 290 |
const label = this.data.labels[dataIndex]; // Get the label for the clicked bar
|
295 |
const modelNumber = this.data.labels[dataIndex]; // Get the label for the clicked bar that is modelNumber this time
|
| 291 |
const value = this.data.datasets[datasetIndex].data[dataIndex]; // Get the value of the clicked bar
|
296 |
const value = this.data.datasets[datasetIndex].data[dataIndex]; // Get the value of the clicked bar
|
| 292 |
getCatalogAgeDetail(startDate, endDate, supplierId, label);
|
297 |
getCatalogAgeDetail(startDate, endDate, supplierId, modelNumber,status);
|
| 293 |
}
|
298 |
}
|
| 294 |
},
|
299 |
},
|
| 295 |
indexAxis: 'y',
|
300 |
indexAxis: 'y',
|
| 296 |
scales: {
|
301 |
scales: {
|
| 297 |
x: {
|
302 |
x: {
|