Subversion Repositories SmartDukaan

Rev

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

Rev 35064 Rev 35084
Line 12... Line 12...
12
        box-shadow: 4px 4px 4px grey;
12
        box-shadow: 4px 4px 4px grey;
13
        background-image: linear-gradient(#57889c, #B0C4DE);
13
        background-image: linear-gradient(#57889c, #B0C4DE);
14
    }
14
    }
15
 
15
 
16
    .brand-wise-table {
16
    .brand-wise-table {
17
        /*margin-top: 10px;*/
-
 
18
        width: 100%;
17
        width: 100%;
19
        border-collapse: collapse;
18
        border-collapse: collapse;
20
    }
19
    }
21
 
20
 
22
    .brand-wise-table th, .brand-wise-table td {
21
    .brand-wise-table th, .brand-wise-table td {
Line 26... Line 25...
26
 
25
 
27
    .brand-wise-table th {
26
    .brand-wise-table th {
28
        background-color: #57889c;
27
        background-color: #57889c;
29
        color: #fff;
28
        color: #fff;
30
    }
29
    }
-
 
30
 
-
 
31
    /* Add striped styling for nested tables */
-
 
32
    .nested-table-striped tbody tr:nth-of-type(odd) {
-
 
33
        background-color: rgba(0, 0, 0, 0.05);
-
 
34
    }
-
 
35
 
-
 
36
    .nested-table-striped tbody tr:hover {
-
 
37
        background-color: rgba(0, 0, 0, 0.075);
-
 
38
    }
31
</style>
39
</style>
32
 
40
 
33
<table class="table table-striped saleTable" style="color:blue;">
41
<table class="table table-striped saleTable" style="color:blue;">
34
    <thead>
42
    <thead>
35
    <tr class="cursor-pointer">
43
    <tr class="cursor-pointer">
Line 57... Line 65...
57
            </td>
65
            </td>
58
        </tr>
66
        </tr>
59
 
67
 
60
        <tr class="brand-wise-sale-row cursor-pointer" style="display: none;">
68
        <tr class="brand-wise-sale-row cursor-pointer" style="display: none;">
61
            <td colspan="6">
69
            <td colspan="6">
-
 
70
                <!-- Added table-striped and nested-table-striped classes -->
62
                <table class="brand-wise-table">
71
                <table class="table table-striped nested-table-striped brand-wise-table">
63
                    <thead>
72
                    <thead>
64
                    <tr>
73
                    <tr>
65
                        <th>Brand</th>
74
                        <th>Brand</th>
66
                        <th>LMS</th>
75
                        <th>LMS</th>
67
                        <th>LMTD</th>
76
                        <th>LMTD</th>
Line 75... Line 84...
75
                </table>
84
                </table>
76
            </td>
85
            </td>
77
        </tr>
86
        </tr>
78
        <tr class="brand-item-wise-sale-row cursor-pointer" style="display: none;">
87
        <tr class="brand-item-wise-sale-row cursor-pointer" style="display: none;">
79
            <td colspan="6">
88
            <td colspan="6">
-
 
89
                <!-- Added table-striped and nested-table-striped classes -->
80
                <table class="brand-wise-table">
90
                <table class="table table-striped nested-table-striped brand-wise-table">
81
                    <thead>
91
                    <thead>
82
                    <tr>
92
                    <tr>
83
                        <!--						<th>Brand</th>-->
-
 
84
                        <th>Model</th>
93
                        <th>Model</th>
85
                        <th>Quantity</th>
94
                        <th>Quantity</th>
86
                    </tr>
95
                    </tr>
87
                    </thead>
96
                    </thead>
88
                    <tbody class="brandItemWiseBody">
97
                    <tbody class="brandItemWiseBody">
Line 106... Line 115...
106
    document.querySelectorAll('.clickable-row').forEach(function (row) {
115
    document.querySelectorAll('.clickable-row').forEach(function (row) {
107
        row.addEventListener('click', function () {
116
        row.addEventListener('click', function () {
108
            const brandWiseRow = row.nextElementSibling;
117
            const brandWiseRow = row.nextElementSibling;
109
            const allBrandWiseRows = document.querySelectorAll('.brand-wise-sale-row');
118
            const allBrandWiseRows = document.querySelectorAll('.brand-wise-sale-row');
110
            const fofoId = getCookie("fofoId");
119
            const fofoId = getCookie("fofoId");
-
 
120
 
111
            allBrandWiseRows.forEach(function (otherRow) {
121
            allBrandWiseRows.forEach(function (otherRow) {
112
                if (otherRow !== brandWiseRow) {
122
                if (otherRow !== brandWiseRow) {
113
                    otherRow.style.display = 'none';
123
                    otherRow.style.display = 'none';
-
 
124
                    const brandItemRows = otherRow.parentNode.querySelectorAll('.brand-item-wise-sale-row');
-
 
125
                    brandItemRows.forEach(itemRow => itemRow.style.display = 'none');
114
                }
126
                }
115
            });
127
            });
116
 
128
 
117
            let monthString = row.getAttribute('data-month');
129
            let monthString = row.getAttribute('data-month');
118
            const monthMap = {
130
            const monthMap = {
Line 127... Line 139...
127
            if (!monthNumber) {
139
            if (!monthNumber) {
128
                console.error('Invalid month:', monthString);
140
                console.error('Invalid month:', monthString);
129
                return;
141
                return;
130
            }
142
            }
131
 
143
 
-
 
144
            // Toggle the brand-wise row
132
            if (brandWiseRow.style.display === 'none') {
145
            if (brandWiseRow.style.display === 'none') {
133
                brandWiseRow.style.display = '';
146
                brandWiseRow.style.display = '';
134
 
147
 
135
                doGetAjaxRequestHandler(
148
                doGetAjaxRequestHandler(
136
                        `${context}/getBrandwisePartnerSale?month=${monthNumber}`,
149
                        `getBrandwisePartnerSale?month=${monthNumber}`,
137
                        function (response) {
150
                        function (response) {
138
                            const brandBody = brandWiseRow.querySelector('.brandWiseBody');
151
                            const brandBody = brandWiseRow.querySelector('.brandWiseBody');
139
                            brandBody.innerHTML = '';
152
                            brandBody.innerHTML = '';
140
 
153
 
141
                            response.forEach(function (item) {
154
                            response.forEach(function (item) {
142
                                const safe = (val) => (val == null || val === "null" ? 0 : val);
155
                                const safe = (val) => (val == null || val === "null" ? 0 : val);
143
                                const brandRow = document.createElement('tr');
156
                                const brandRow = document.createElement('tr');
144
                                brandRow.classList.add('clickable-brandrow');
157
                                brandRow.classList.add('clickable-brandrow');
-
 
158
                                brandRow.setAttribute('data-brand', item.brand);
145
                                brandRow.innerHTML =
159
                                brandRow.innerHTML =
146
                                        '<td><b>' + safe(item.brand) + '</b></td>' +
160
                                        '<td><b>' + safe(item.brand) + '</b></td>' +
147
                                        '<td>' + safe(item.lms) + '</td>' +
161
                                        '<td>' + safe(item.lms) + '</td>' +
148
                                        '<td>' + safe(item.lmtd) + '</td>' +
162
                                        '<td>' + safe(item.lmtd) + '</td>' +
149
                                        '<td>' + safe(item.mtd) + '</td>' +
163
                                        '<td>' + safe(item.mtd) + '</td>' +
150
                                        '<td>' + safe(item.mtdQty) + '</td>' +
164
                                        '<td>' + safe(item.mtdQty) + '</td>' +
151
                                        '<td><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>';
165
                                        '<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>';
-
 
166
 
152
                                brandRow.addEventListener('click', function () {
167
                                brandRow.addEventListener('click', function () {
153
                                    const brandName = item.brand;
168
                                    const brandName = item.brand;
154
 
169
 
155
                                    let brandItemWiseRow = brandRow.nextElementSibling;
170
                                    let brandItemWiseRow = brandRow.nextElementSibling;
156
                                    if (!brandItemWiseRow || !brandItemWiseRow.classList.contains('brand-item-wise-sale-row')) {
171
                                    if (!brandItemWiseRow || !brandItemWiseRow.classList.contains('brand-item-wise-sale-row')) {
157
                                        brandItemWiseRow = document.createElement('tr');
172
                                        brandItemWiseRow = document.createElement('tr');
158
                                        brandItemWiseRow.classList.add('brand-item-wise-sale-row');
173
                                        brandItemWiseRow.classList.add('brand-item-wise-sale-row');
-
 
174
                                        brandItemWiseRow.style.display = 'none';
159
                                        brandItemWiseRow.innerHTML = `
175
                                        brandItemWiseRow.innerHTML = `
160
            <td colspan="6">
176
                <td colspan="6">
161
                <table class="brand-wise-table">
177
                    <table class="table table-striped nested-table-striped brand-wise-table">
162
                    <thead>
178
                        <thead>
163
                        <tr>
179
                            <tr>
164
<!--                            <th>Brand</th>-->
-
 
165
                            <th>Model</th>
180
                                <th>Model</th>
166
                            <th>Quantity</th>
181
                                <th>Quantity</th>
167
                        </tr>
182
                            </tr>
168
                    </thead>
183
                        </thead>
169
                    <tbody class="brandItemWiseBody"></tbody>
184
                        <tbody class="brandItemWiseBody"></tbody>
170
                </table>
185
                    </table>
171
            </td>
186
                </td>
172
        `;
187
            `;
173
                                        // insert right after the clicked brand row
-
 
174
                                        brandRow.insertAdjacentElement('afterend', brandItemWiseRow);
188
                                        brandRow.insertAdjacentElement('afterend', brandItemWiseRow);
175
                                    }
189
                                    }
176
 
190
 
177
                                    // toggle visibility
191
                                    // Hide all other brand-item-wise rows
178
                                    const isHidden = brandItemWiseRow.style.display === 'none' || brandItemWiseRow.style.display === '';
192
                                    const allBrandItemWiseRows = document.querySelectorAll('.brand-item-wise-sale-row');
179
                                    document.querySelectorAll('.brand-item-wise-sale-row').forEach(r => r.style.display = 'none');
193
                                    allBrandItemWiseRows.forEach(function (otherRow) {
-
 
194
                                        if (otherRow !== brandItemWiseRow) {
-
 
195
                                            otherRow.style.display = 'none';
-
 
196
                                        }
-
 
197
                                    });
180
 
198
 
-
 
199
                                    // Toggle current row - same logic as month rows
181
                                    if (isHidden) {
200
                                    if (brandItemWiseRow.style.display === 'none') {
182
                                        brandItemWiseRow.style.display = '';
201
                                        brandItemWiseRow.style.display = '';
183
                                        doGetAjaxRequestHandler(
202
                                        doGetAjaxRequestHandler(
184
                                                context + '/getBrandItemwisePartnerSale?month=' + monthNumber + '&brand=' + encodeURIComponent(brandName) + '&fofoId=' + encodeURIComponent(fofoId),
203
                                                'getBrandItemwisePartnerSale?month=' + monthNumber + '&brand=' + encodeURIComponent(brandName) + '&fofoId=' + encodeURIComponent(fofoId),
185
                                                function (response) {
204
                                                function (response) {
186
                                                    const tbody = brandItemWiseRow.querySelector('.brandItemWiseBody');
205
                                                    const tbody = brandItemWiseRow.querySelector('.brandItemWiseBody');
187
                                                    tbody.innerHTML = '';
206
                                                    tbody.innerHTML = '';
188
                                                    response.forEach(item => {
207
                                                    response.forEach(item => {
189
                                                        const tr = document.createElement('tr');
208
                                                        const tr = document.createElement('tr');
190
                                                        tr.innerHTML =
209
                                                        tr.innerHTML =
191
                                                                // '<td>' + item.brand + '</td>' +
-
 
192
                                                                '<td>' + item.modelNumber + '</td>' +
210
                                                                '<td>' + item.modelName + item.modelNumber + '</td>' +
193
                                                                '<td>' + item.quantity + '</td>';
211
                                                                '<td>' + item.quantity + " pcs" + '</td>';
194
                                                        tbody.appendChild(tr);
212
                                                        tbody.appendChild(tr);
195
                                                    });
213
                                                    });
196
                                                }
214
                                                }
197
                                        );
215
                                        );
-
 
216
                                    } else {
-
 
217
                                        brandItemWiseRow.style.display = 'none';
198
                                    }
218
                                    }
199
                                });
219
                                });
200
 
220
 
201
 
-
 
202
                                brandBody.appendChild(brandRow);
221
                                brandBody.appendChild(brandRow);
203
                            });
222
                            });
204
                        }
223
                        }
205
                );
224
                );
206
            } else {
225
            } else {
207
                brandWiseRow.style.display = 'none';
226
                brandWiseRow.style.display = 'none';
-
 
227
                const brandItemRows = brandWiseRow.parentNode.querySelectorAll('.brand-item-wise-sale-row');
-
 
228
                brandItemRows.forEach(itemRow => itemRow.style.display = 'none');
208
            }
229
            }
209
        });
230
        });
210
    });
231
    });
211
</script>
232
</script>
212
 
-
 
213
233