Subversion Repositories SmartDukaan

Rev

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

Rev 27488 Rev 35064
Line 1... Line 1...
1
<style>
1
<style>
2
.saleTable tr th{
2
    .saleTable tr th {
3
    color: 	#FFFFFF;
3
        color: #FFFFFF;
4
    padding-bottom:6px;
4
        padding-bottom: 6px;
5
}
5
    }
6
 
6
 
7
.saleTable tr td{
7
    .saleTable tr td {
8
   
-
 
9
    padding-bottom:6px;
8
        padding-bottom: 6px;
-
 
9
    }
10
}
10
 
11
.blue-bg{
11
    .blue-bg {
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 {
-
 
17
        /*margin-top: 10px;*/
-
 
18
        width: 100%;
-
 
19
        border-collapse: collapse;
-
 
20
    }
16
 
21
 
-
 
22
    .brand-wise-table th, .brand-wise-table td {
-
 
23
        border: 1px solid #ddd;
-
 
24
        padding: 8px;
17
 
25
    }
18
 
26
 
-
 
27
    .brand-wise-table th {
-
 
28
        background-color: #57889c;
-
 
29
        color: #fff;
19
 
30
    }
20
</style>
31
</style>
21
 
32
 
22
		<table class="table table-striped saleTable" style="color:blue;" >
33
<table class="table table-striped saleTable" style="color:blue;">
23
			<thead>
34
    <thead>
24
					 <tr>
35
    <tr class="cursor-pointer">
25
					 	<th></th>
36
        <th></th>
26
						 <th>Sales</th>
37
        <th>Sales</th>
27
						 <th>MTD</th>
38
        <th>MTD</th>
28
						 <th>Type</th>
39
        <th>Type</th>
-
 
40
        <th></th>
29
					</tr>
41
    </tr>
30
			</thead>
42
    </thead>
31
							    
43
 
32
			<tbody>
44
    <tbody id="monthSalesBody">
33
					#set($start = 1)
45
        #set($start = 1)
34
					#set($end = 6)
46
        #set($end = 6)
35
				    #set($range = [$start..$end])
47
        #set($range = [$start..$end])
36
				    #foreach($i in $range)
48
        #foreach($i in $range)
37
								
-
 
38
					    <tr> 
49
        <tr class="clickable-row cursor-pointer" data-month="$monthSales.get($i).getMonth()">
39
						   <td><b>$monthSales.get($i).getMonth()</b></td>
50
            <td><b>$monthSales.get($i).getMonth()</b></td>
40
						   <td>$monthSales.get($i).getMonthlySales()</td>
51
            <td>$monthSales.get($i).getMonthlySales()</td>
41
						   <td>$monthSales.get($i).getMtdSales()</td>
52
            <td>$monthSales.get($i).getMtdSales()</td>
42
						   <td>$monthSales.get($i).getPartnerType()</td>
53
            <td>$monthSales.get($i).getPartnerType() </td>
-
 
54
            <td class="toggle-cell">
-
 
55
                <i class="fa fa-angle-down dropdown-icon"
-
 
56
                   style="cursor:pointer; font-size: 27px;width: 27px;height: 27px;margin-top: 0px;color: rgba(255, 255, 255, 0.75);line-height: 27px;"></i>
-
 
57
            </td>
-
 
58
        </tr>
-
 
59
 
-
 
60
        <tr class="brand-wise-sale-row cursor-pointer" style="display: none;">
-
 
61
            <td colspan="6">
-
 
62
                <table class="brand-wise-table">
-
 
63
                    <thead>
-
 
64
                    <tr>
-
 
65
                        <th>Brand</th>
-
 
66
                        <th>LMS</th>
-
 
67
                        <th>LMTD</th>
-
 
68
                        <th>MTD</th>
-
 
69
                        <th>MTDQTY</th>
-
 
70
                        <th></th>
-
 
71
                    </tr>
-
 
72
                    </thead>
-
 
73
                    <tbody class="brandWiseBody">
-
 
74
                    </tbody>
-
 
75
                </table>
-
 
76
            </td>
43
					    </tr>
77
        </tr>
-
 
78
        <tr class="brand-item-wise-sale-row cursor-pointer" style="display: none;">
-
 
79
            <td colspan="6">
-
 
80
                <table class="brand-wise-table">
-
 
81
                    <thead>
-
 
82
                    <tr>
-
 
83
                        <!--						<th>Brand</th>-->
-
 
84
                        <th>Model</th>
-
 
85
                        <th>Quantity</th>
-
 
86
                    </tr>
-
 
87
                    </thead>
-
 
88
                    <tbody class="brandItemWiseBody">
-
 
89
                    </tbody>
-
 
90
                </table>
-
 
91
            </td>
44
							
92
        </tr>
45
					#end
93
        #end
46
			</tbody>
94
    </tbody>
47
		</table>
95
</table>
-
 
96
 
-
 
97
<script>
-
 
98
    function getCookie(name) {
-
 
99
        const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
-
 
100
        if (match) {
-
 
101
            return decodeURIComponent(match[2]);
-
 
102
        }
-
 
103
        return null;
-
 
104
    }
-
 
105
 
-
 
106
    document.querySelectorAll('.clickable-row').forEach(function (row) {
-
 
107
        row.addEventListener('click', function () {
-
 
108
            const brandWiseRow = row.nextElementSibling;
-
 
109
            const allBrandWiseRows = document.querySelectorAll('.brand-wise-sale-row');
-
 
110
            const fofoId = getCookie("fofoId");
-
 
111
            allBrandWiseRows.forEach(function (otherRow) {
-
 
112
                if (otherRow !== brandWiseRow) {
-
 
113
                    otherRow.style.display = 'none';
-
 
114
                }
-
 
115
            });
-
 
116
 
-
 
117
            let monthString = row.getAttribute('data-month');
-
 
118
            const monthMap = {
-
 
119
                'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4,
-
 
120
                'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8,
-
 
121
                'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12
-
 
122
            };
-
 
123
 
-
 
124
            const monthAbbr = monthString.substring(0, 3);
-
 
125
            const monthNumber = monthMap[monthAbbr];
-
 
126
 
-
 
127
            if (!monthNumber) {
-
 
128
                console.error('Invalid month:', monthString);
-
 
129
                return;
-
 
130
            }
-
 
131
 
-
 
132
            if (brandWiseRow.style.display === 'none') {
-
 
133
                brandWiseRow.style.display = '';
-
 
134
 
-
 
135
                doGetAjaxRequestHandler(
-
 
136
                        `${context}/getBrandwisePartnerSale?month=${monthNumber}`,
-
 
137
                        function (response) {
-
 
138
                            const brandBody = brandWiseRow.querySelector('.brandWiseBody');
-
 
139
                            brandBody.innerHTML = '';
-
 
140
 
-
 
141
                            response.forEach(function (item) {
-
 
142
                                const safe = (val) => (val == null || val === "null" ? 0 : val);
-
 
143
                                const brandRow = document.createElement('tr');
-
 
144
                                brandRow.classList.add('clickable-brandrow');
-
 
145
                                brandRow.innerHTML =
-
 
146
                                        '<td><b>' + safe(item.brand) + '</b></td>' +
-
 
147
                                        '<td>' + safe(item.lms) + '</td>' +
-
 
148
                                        '<td>' + safe(item.lmtd) + '</td>' +
-
 
149
                                        '<td>' + safe(item.mtd) + '</td>' +
-
 
150
                                        '<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>';
-
 
152
                                brandRow.addEventListener('click', function () {
-
 
153
                                    const brandName = item.brand;
-
 
154
 
-
 
155
                                    let brandItemWiseRow = brandRow.nextElementSibling;
-
 
156
                                    if (!brandItemWiseRow || !brandItemWiseRow.classList.contains('brand-item-wise-sale-row')) {
-
 
157
                                        brandItemWiseRow = document.createElement('tr');
-
 
158
                                        brandItemWiseRow.classList.add('brand-item-wise-sale-row');
-
 
159
                                        brandItemWiseRow.innerHTML = `
-
 
160
            <td colspan="6">
-
 
161
                <table class="brand-wise-table">
-
 
162
                    <thead>
-
 
163
                        <tr>
-
 
164
<!--                            <th>Brand</th>-->
-
 
165
                            <th>Model</th>
-
 
166
                            <th>Quantity</th>
-
 
167
                        </tr>
-
 
168
                    </thead>
-
 
169
                    <tbody class="brandItemWiseBody"></tbody>
-
 
170
                </table>
-
 
171
            </td>
-
 
172
        `;
-
 
173
                                        // insert right after the clicked brand row
-
 
174
                                        brandRow.insertAdjacentElement('afterend', brandItemWiseRow);
-
 
175
                                    }
-
 
176
 
-
 
177
                                    // toggle visibility
-
 
178
                                    const isHidden = brandItemWiseRow.style.display === 'none' || brandItemWiseRow.style.display === '';
-
 
179
                                    document.querySelectorAll('.brand-item-wise-sale-row').forEach(r => r.style.display = 'none');
-
 
180
 
-
 
181
                                    if (isHidden) {
-
 
182
                                        brandItemWiseRow.style.display = '';
-
 
183
                                        doGetAjaxRequestHandler(
-
 
184
                                                context + '/getBrandItemwisePartnerSale?month=' + monthNumber + '&brand=' + encodeURIComponent(brandName) + '&fofoId=' + encodeURIComponent(fofoId),
-
 
185
                                                function (response) {
-
 
186
                                                    const tbody = brandItemWiseRow.querySelector('.brandItemWiseBody');
-
 
187
                                                    tbody.innerHTML = '';
-
 
188
                                                    response.forEach(item => {
-
 
189
                                                        const tr = document.createElement('tr');
-
 
190
                                                        tr.innerHTML =
-
 
191
                                                                // '<td>' + item.brand + '</td>' +
-
 
192
                                                                '<td>' + item.modelNumber + '</td>' +
-
 
193
                                                                '<td>' + item.quantity + '</td>';
-
 
194
                                                        tbody.appendChild(tr);
-
 
195
                                                    });
-
 
196
                                                }
-
 
197
                                        );
-
 
198
                                    }
-
 
199
                                });
-
 
200
 
-
 
201
 
-
 
202
                                brandBody.appendChild(brandRow);
-
 
203
                            });
-
 
204
                        }
-
 
205
                );
-
 
206
            } else {
-
 
207
                brandWiseRow.style.display = 'none';
-
 
208
            }
-
 
209
        });
-
 
210
    });
-
 
211
</script>
-
 
212