Subversion Repositories SmartDukaan

Rev

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

Rev 29103 Rev 30080
Line 1... Line -...
1
 
-
 
2
<script src="https://cdn.datatables.net/plug-ins/1.10.19/api/sum().js"></script>
1
<script src="https://cdn.datatables.net/plug-ins/1.10.19/api/sum().js"></script>
3
 
2
 
-
 
3
<style>
-
 
4
    .table td.text {
-
 
5
        max-width: 150px;
-
 
6
    }
-
 
7
 
-
 
8
    .table td.text span {
-
 
9
        white-space: nowrap;
-
 
10
        overflow: hidden;
-
 
11
        text-overflow: ellipsis;
-
 
12
        display: inline-block;
-
 
13
        max-width: 100%;
-
 
14
    }
4
 
15
 
-
 
16
</style>
5
	<button type="submit" class="btn btn-primary mk_fetch_plan" >Download Plan Statement</button>
17
<button type="submit" class="btn btn-primary mk_fetch_plan">Download Plan Statement</button>
6
 
-
 
7
 
18
 
8
 
19
 
9
<div class="row">
20
<div class="row">
10
 
21
 
11
 
22
 
12
	#if(!$inStocksMap.isEmpty())
23
    #if(!$inStocksMap.isEmpty())
13
	<div class="col-lg-12">
24
        <div class="col-lg-12">
14
		<table
25
            <table
15
			class="table table-striped table-advance table-hover partner-planning-details">
26
                    class="table table-striped table-advance table-hover partner-planning-details">
16
			<thead>
27
                <thead>
17
 
28
 
18
				<tr>
29
                <tr>
19
					<th rowspan="3">Warehouse</th>
30
                    <th rowspan="3">Warehouse</th>
20
					<th rowspan="3">Category</th>
31
                    <th rowspan="3">Category</th>
-
 
32
                    <th rowspan="3">Partner Name</th>
-
 
33
                    <th rowspan="3">Terrirory Manager</th>
21
					<th rowspan="3">Partner Name</th> #foreach($catalog in
34
                    #foreach($catalog in
22
					$catalogItemMap.entrySet())
35
                        $catalogItemMap.entrySet())
-
 
36
                        <th colspan="3">
23
					<th colspan="3">WOD : <span class="wod"></span>, TS:<span
37
                            WOD : <span class="wod"></span>,
24
						class="ts"></span><span>/</span><span
38
                            TS:<span class="ts"></span>,
-
 
39
                            WOS: <span class="wos"></span>,
25
						class="tp"></span>, WOS: <span class="wos"></span>, TSale: <span class="sts"> </span>
40
                            TSale: <span class="sts"> </span>
-
 
41
                        </th>
26
					</th> #end
42
                    #end
27
					<th rowspan="3">PO</th>
43
                    <th rowspan="3">PO</th>
28
					<th rowspan="3">last Po Entry</th>
44
                    <th rowspan="3">last Po Entry</th>
29
 
45
 
30
				</tr>
46
                </tr>
31
 
47
 
32
				<tr>
48
                <tr>
33
					#foreach($catalog in $catalogItemMap.entrySet())
49
                    #foreach($catalog in $catalogItemMap.entrySet())
34
					<th colspan="3">$catalog.getValue().get(0).getBrand()
50
                        <th colspan="3">$catalog.getValue().get(0).getBrand()
35
						$catalog.getValue().get(0).getModelName()
51
						$catalog.getValue().get(0).getModelName()
36
						$catalog.getValue().get(0).getModelNumber()</th> #end
52
						$catalog.getValue().get(0).getModelNumber()</th> #end
37
 
53
 
-
 
54
                </tr>
-
 
55
                <tr>
-
 
56
                    #foreach($catalog in $catalogItemMap.entrySet())
-
 
57
                        <th>Stock</th>
-
 
58
                        <th>Sale</th>
-
 
59
                        <th>SD Stock</th> #end
-
 
60
 
-
 
61
                </tr>
-
 
62
 
-
 
63
 
-
 
64
                </thead>
-
 
65
                <tbody>
-
 
66
                    #foreach($customRetailerEntry in $customRetailers.entrySet())
-
 
67
                    <tr>
-
 
68
                        <td>$warehouseMap.get($customRetailerEntry.getValue().getWarehouseId())</td>
-
 
69
                        <td>$fofoIdPartnerTypeMap.get($customRetailerEntry.getKey())</td>
-
 
70
 
-
 
71
                        <td class="text"><span
-
 
72
                                title="$customRetailerEntry.getValue().getBusinessName()-$customRetailerEntry.getValue().getCode()">$customRetailerEntry.getValue().getBusinessName()</span>
-
 
73
                        </td>
-
 
74
                        <td class="text"><span
-
 
75
                                title="$salesHeadersMap.get($customRetailerEntry.getKey()).getTerritoryManager()">$salesHeadersMap.get($customRetailerEntry.getKey()).getTerritoryManager()</span>
-
 
76
                        </td>
-
 
77
 
-
 
78
                        #foreach($catalog in $catalogItemMap.entrySet())
-
 
79
                            #set($inStock=0)
-
 
80
                            #set($pendingIndent=0)
-
 
81
                            #if($inStocksMap.get($customRetailerEntry.getKey()).get($catalog.getKey()))
-
 
82
                                #set($inStock = $inStocksMap.get($customRetailerEntry.getKey()).get($catalog.getKey()))
-
 
83
                            #end
-
 
84
                            #if($pendingIndentMap.get($customRetailerEntry.getKey()).get($catalog.getKey()))
-
 
85
                                #set($pendingIndent = $pendingIndentMap.get($customRetailerEntry.getKey()).get($catalog.getKey()))
-
 
86
                            #end
-
 
87
                            #set($totalStock = $inStock + $pendingIndent)
-
 
88
                            <td class="instockItem" data-fofoid="$customRetailerEntry.getKey()"
-
 
89
                                data-catalogid="$catalog.getKey()" data-toggle="modal"
-
 
90
                                data-target="#inStockQtyModel">
-
 
91
                                $totalStock</td>
-
 
92
 
-
 
93
                            #if($fofoSalesMap.get($customRetailerEntry.getKey()).get($catalog.getKey()))
-
 
94
 
-
 
95
                                <td class="inSaleItem"
-
 
96
                                    data-fofoid="$customRetailerEntry.getValue().getFofoId()" data-toggle="modal"
-
 
97
                                    data-target="#inSaleItemModel">$fofoSalesMap.get($customRetailerEntry.getKey()).get($catalog.getKey())</td>
-
 
98
                            #else
-
 
99
                                <td>0</td> #end
-
 
100
                            #if($warehouseStockMap.get($customRetailerEntry.getValue().getWarehouseId()).get($catalog.getKey()))
-
 
101
 
-
 
102
                                <td class="warehouseStockItem"
-
 
103
                                    data-warehouseid="$customRetailerEntry.getValue().getWarehouseId()"
-
 
104
                                    data-catalogid="$customRetailerEntry.getValue().getWarehouseId()"
-
 
105
                                    data-toggle="modal"
-
 
106
                                    data-target="#warehouseStockItemModel">$warehouseStockMap.get($customRetailerEntry.getValue().getWarehouseId()).get($catalog.getKey())</td>
-
 
107
                            #else
-
 
108
                                <td>0</td> #end #end
-
 
109
                        <td><a class="selctItemQty" data-toggle="modal"
-
 
110
                               data-fofoid="$customRetailerEntry.getKey()" data-target="#selectModelItems">
-
 
111
                            Add to po </a></td> #if($suggestedPoEntry.get($customRetailerEntry))
-
 
112
 
-
 
113
                        <td><a class="podetails" data-fofoid="$customRetailerEntry.getKey()"
-
 
114
                               data-datetime="$suggestedPoEntry.get($customRetailerEntry.getKey())"
-
 
115
                               data-toggle="modal"
-
 
116
                               data-target="#ItemsPo">$suggestedPoEntry.get($customRetailerEntry.getKey()).format($dateTimeFormatter)</a>
-
 
117
                        </td>
-
 
118
                    #else
-
 
119
                        <td></td> #end
-
 
120
 
-
 
121
                    </tr>
-
 
122
                    #end
-
 
123
 
-
 
124
                </tbody>
-
 
125
            </table>
-
 
126
        </div>
-
 
127
    #else
-
 
128
 
-
 
129
        <div class="col-lg-6">
-
 
130
            <table
-
 
131
                    class="table table-striped table-advance table-hover partner-planning-details">
-
 
132
                <thead>
-
 
133
                <tr>
-
 
134
                    <th>Warehouse</th>
-
 
135
                    <th>Category</th>
-
 
136
                    <th>Partner Name</th>
-
 
137
                    <th>Item</th>
-
 
138
                    <th>Stock</th>
-
 
139
                    <th>Sale</th>
-
 
140
                    <th>Warehouse Stock</th>
-
 
141
                    <th>PO</th>
-
 
142
                    <th>last Po Entry</th>
-
 
143
 
-
 
144
 
-
 
145
                </tr>
-
 
146
                </thead>
-
 
147
                <tbody>
-
 
148
                    #foreach($keyvalue in $inStockItemMap.entrySet())
-
 
149
                    <tr>
-
 
150
                        <td>$warehouseMap.get($keyvalue.getValue().getWarehouseId())</td>
-
 
151
                        <td>$fofoIdPartnerTypeMap.get($keyvalue.getKey().getFofoId())</td>
38
 
152
 
39
				</tr>
-
 
40
				<tr>
-
 
41
					#foreach($catalog in $catalogItemMap.entrySet())
-
 
42
					<th>Stock</th>
-
 
43
					<th>Sale</th>
-
 
44
					<th>SD Stock</th> #end
-
 
45
 
-
 
46
				</tr>
-
 
47
 
-
 
48
 
-
 
49
 
-
 
50
			</thead>
-
 
51
			<tbody>
-
 
52
				#foreach($keyvalue in $customRetailers.entrySet())
-
 
53
				<tr>
-
 
54
					<td>$warehouseMap.get($keyvalue.getValue().getWarehouseId())</td>
-
 
55
					<td>$fofoIdPartnerTypeMap.get($keyvalue.getKey())</td>
-
 
56
 
-
 
57
					<td>$customRetailers.get($keyvalue.getKey()).getBusinessName()</td>
-
 
58
 
-
 
59
					#foreach($catalog in $catalogItemMap.entrySet())
-
 
60
					#if($inStocksMap.get($keyvalue.getKey()).get($catalog.getKey()))
-
 
61
					<td class="instockItem" data-fofoid="$keyvalue.getKey()"
-
 
62
						data-catalogid="$catalog.getKey()" data-toggle="modal"
-
 
63
						data-target="#inStockQtyModel">$inStocksMap.get($keyvalue.getKey()).get($catalog.getKey())/#if($pendingIndentMap.get($keyvalue.getKey()).get($catalog.getKey())) $pendingIndentMap.get($keyvalue.getKey()).get($catalog.getKey()) #else 0 #end</td>
-
 
64
					#else
-
 
65
					<td>0/#if($pendingIndentMap.get($keyvalue.getKey()).get($catalog.getKey())) $pendingIndentMap.get($keyvalue.getKey()).get($catalog.getKey()) #else 0 #end</td> #end
-
 
66
					#if($fofoSalesMap.get($keyvalue.getKey()).get($catalog.getKey()))
-
 
67
 
-
 
68
					<td class="inSaleItem"
-
 
69
						data-fofoid="$keyvalue.getValue().getFofoId()" data-toggle="modal"
-
 
70
						data-target="#inSaleItemModel">$fofoSalesMap.get($keyvalue.getKey()).get($catalog.getKey())</td>
-
 
71
					#else
-
 
72
					<td>0</td> #end
-
 
73
					#if($warehouseStockMap.get($keyvalue.getValue().getWarehouseId()).get($catalog.getKey()))
-
 
74
 
-
 
75
					<td class="warehouseStockItem"
-
 
76
						data-warehouseid="$keyvalue.getValue().getWarehouseId()"
-
 
77
						data-catalogid="$keyvalue.getValue().getWarehouseId()"
-
 
78
						data-toggle="modal" data-target="#warehouseStockItemModel">$warehouseStockMap.get($keyvalue.getValue().getWarehouseId()).get($catalog.getKey())</td>
-
 
79
					#else
-
 
80
					<td>0</td> #end #end
-
 
81
					<td><a class="selctItemQty" data-toggle="modal"
-
 
82
						data-fofoid="$keyvalue.getKey()" data-target="#selectModelItems">
-
 
83
							Add to po </a></td> #if($suggestedPoEntry.get($keyvalue))
-
 
84
 
-
 
85
					<td><a class="podetails" data-fofoid="$keyvalue.getKey()"
-
 
86
						data-datetime="$suggestedPoEntry.get($keyvalue.getKey())"
-
 
87
						data-toggle="modal" data-target="#ItemsPo">$suggestedPoEntry.get($keyvalue.getKey()).format($dateTimeFormatter)</a></td>
-
 
88
					#else
-
 
89
					<td></td> #end
-
 
90
 
-
 
91
				</tr>
-
 
92
				#end
-
 
93
 
-
 
94
			</tbody>
-
 
95
		</table>
-
 
96
	</div>
-
 
97
	#else
-
 
98
 
-
 
99
	<div class="col-lg-6">
-
 
100
		<table
-
 
101
			class="table table-striped table-advance table-hover partner-planning-details">
-
 
102
			<thead>
-
 
103
				<tr>
-
 
104
					<th>Warehouse</th>
-
 
105
					<th>Category</th>
-
 
106
					<th>Partner Name</th>
-
 
107
					<th>Item</th>
-
 
108
					<th>Stock</th>
-
 
109
					<th>Sale</th>
-
 
110
					<th>Warehouse Stock</th>
-
 
111
					<th>PO</th>
-
 
112
					<th>last Po Entry</th>
-
 
113
 
-
 
114
 
-
 
115
 
-
 
116
				</tr>
-
 
117
			</thead>
-
 
118
			<tbody>
-
 
119
				#foreach($keyvalue in $inStockItemMap.entrySet())
-
 
120
				<tr>
-
 
121
					<td>$warehouseMap.get($keyvalue.getValue().getWarehouseId())</td>
-
 
122
					<td>$fofoIdPartnerTypeMap.get($keyvalue.getKey().getFofoId())</td>
-
 
123
 
-
 
124
					<td>$customRetailers.get($keyvalue.getKey().getFofoId()).getBusinessName()</td>
153
                        <td>$customRetailers.get($keyvalue.getKey().getFofoId()).getBusinessName()</td>
125
					<td>$keyvalue.getValue().getBrand()
154
                        <td>$keyvalue.getValue().getBrand()
126
						$keyvalue.getValue().getModelName()
155
						$keyvalue.getValue().getModelName()
127
						$keyvalue.getValue().getModelNumber()</td>
156
						$keyvalue.getValue().getModelNumber()</td>
128
					<td>$keyvalue.getValue().getQty()</td>
157
                        <td>$keyvalue.getValue().getQty()</td>
129
					#if($fofoSaleItem.get($keyvalue.getKey()))
158
                        #if($fofoSaleItem.get($keyvalue.getKey()))
130
					<td>$fofoSaleItem.get($keyvalue.getKey()).getQty()</td> #else
159
                            <td>$fofoSaleItem.get($keyvalue.getKey()).getQty()</td>
-
 
160
                        #else
-
 
161
                            <td>0</td>
131
					<td>0</td> #end
162
                        #end
132
 
-
 
133
 
163
 
134
					<td>$keyvalue.getValue().getWarehouseQty()</td>
164
                        <td>$keyvalue.getValue().getWarehouseQty()</td>
135
					<td><a class="selctItemQty" data-toggle="modal"
165
                        <td><a class="selctItemQty" data-toggle="modal"
136
						data-fofoid="$keyvalue.getValue().getFofoId()"
166
                               data-fofoid="$keyvalue.getValue().getFofoId()"
137
						data-target="#selectModelItems"> Add to po </a></td>
167
                               data-target="#selectModelItems"> Add to po </a></td>
138
					#if($suggestedPoEntry.get($keyvalue.getKey().getFofoId()))
168
                        #if($suggestedPoEntry.get($keyvalue.getKey().getFofoId()))
139
 
169
 
140
					<td><a class="podetails"
170
                            <td><a class="podetails"
141
						data-fofoid="$keyvalue.getKey().getFofoId()" data-toggle="modal"
171
                                   data-fofoid="$keyvalue.getKey().getFofoId()" data-toggle="modal"
142
						data-target="#ItemsPo"
172
                                   data-target="#ItemsPo"
143
						data-datetime="$suggestedPoEntry.get($keyvalue.getValue().getFofoId())">
173
                                   data-datetime="$suggestedPoEntry.get($keyvalue.getValue().getFofoId())">
144
							$suggestedPoEntry.get($keyvalue.getKey().getFofoId()).format($dateTimeFormatter)
174
                                $suggestedPoEntry.get($keyvalue.getKey().getFofoId()).format($dateTimeFormatter)
145
					</a></td> #else
175
                            </a></td> #else
146
					<td></td> #end
176
                            <td></td> #end
147
 
177
 
148
				</tr>
178
                    </tr>
149
				#end
179
                    #end
150
 
180
 
151
			</tbody>
181
                </tbody>
152
		</table>
182
            </table>
153
	</div>
183
        </div>
154
 
184
 
155
	#end
185
    #end
156
</div>
186
</div>
157
 
187
 
158
 
188
 
159
<div id="inStockItemModel" class="modal" role="dialog">
189
<div id="inStockItemModel" class="modal" role="dialog">
160
	<div class="modal-dialog">
190
    <div class="modal-dialog">
161
		<div class="modal-content"></div>
191
        <div class="modal-content"></div>
162
	</div>
192
    </div>
163
</div>
193
</div>
164
 
194
 
165
<div id="inStockQtyModel" class="modal" role="dialog">
195
<div id="inStockQtyModel" class="modal" role="dialog">
166
	<div class="modal-dialog">
196
    <div class="modal-dialog">
167
		<div class="modal-content"></div>
197
        <div class="modal-content"></div>
168
	</div>
198
    </div>
169
</div>
199
</div>
170
 
200
 
171
<div id="inSaleItemModel" class="modal" role="dialog">
201
<div id="inSaleItemModel" class="modal" role="dialog">
172
	<div class="modal-dialog">
202
    <div class="modal-dialog">
173
		<div class="modal-content"></div>
203
        <div class="modal-content"></div>
174
	</div>
204
    </div>
175
</div>
205
</div>
176
 
206
 
177
<div id="warehouseStockItemModel" class="modal" role="dialog">
207
<div id="warehouseStockItemModel" class="modal" role="dialog">
178
	<div class="modal-dialog">
208
    <div class="modal-dialog">
179
		<div class="modal-content"></div>
209
        <div class="modal-content"></div>
180
	</div>
210
    </div>
181
</div>
211
</div>
182
 
212
 
183
 
213
 
184
<div id="selectModelItems" class="modal" role="dialog">
214
<div id="selectModelItems" class="modal" role="dialog">
185
	<div class="modal-dialog">
215
    <div class="modal-dialog">
186
		<div class="modal-content"></div>
216
        <div class="modal-content"></div>
187
	</div>
217
    </div>
188
</div>
218
</div>
189
 
219
 
190
<div id="ItemsPo" class="modal" role="dialog">
220
<div id="ItemsPo" class="modal" role="dialog">
191
	<div class="modal-dialog">
221
    <div class="modal-dialog">
192
		<div class="modal-content"></div>
222
        <div class="modal-content"></div>
193
	</div>
223
    </div>
194
</div>
224
</div>
195
<script type="text/javascript">
225
<script type="text/javascript">
196
	var table
226
    var table
-
 
227
 
-
 
228
    $(document).ready(function () {
-
 
229
        var targetArray = [];
-
 
230
 
-
 
231
 
-
 
232
        targetArray = Array.apply(null, Array($catalogItemMap.size())).map(function (_, i) {
-
 
233
            return 3 + (i * 3);
-
 
234
        });
-
 
235
        table = $('.partner-planning-details').DataTable({
-
 
236
 
-
 
237
            "lengthMenu": [10, 25, 50, 75, 100, 250],
-
 
238
            "scrollX": true,
-
 
239
            "pageLength": 250,
-
 
240
            "orderCellsTop": true,
-
 
241
            "fixedHeader": true,
-
 
242
            "fixedColumns": {
-
 
243
                leftColumns: 4
-
 
244
 
-
 
245
            },
-
 
246
 
-
 
247
            "columnDefs": [
-
 
248
                {"targets": targetArray, "orderDataType": "dom-stock-numeric", "type": "number"},
-
 
249
            ]
-
 
250
 
-
 
251
        });
-
 
252
 
-
 
253
 
-
 
254
        datatableSum();
-
 
255
 
-
 
256
        table.on('search.dt', function () {
-
 
257
            console.log('Currently applied global search: ' + table.search());
-
 
258
 
-
 
259
            datatableSum();
-
 
260
 
-
 
261
        });
-
 
262
    });
-
 
263
 
-
 
264
    function datatableSum() {
-
 
265
        let wod = [];
-
 
266
        let wos = [];
-
 
267
        let sos = [];
-
 
268
        let sts = [];
-
 
269
        table.rows({
-
 
270
            "search": "applied"
-
 
271
        }).every(function () {
-
 
272
            var data = this.data();
-
 
273
 
-
 
274
            for (let i = 4; i < data.length - 2; i = i + 3) {
-
 
275
                console.log("Iloop");
-
 
276
                console.log(data[i]);
-
 
277
                j = Math.floor(i / 3);
-
 
278
                if (wod[j] == undefined) {
-
 
279
                    wod[j] = 0;
-
 
280
                }
-
 
281
                if (parseInt(data[i]) > 0) {
-
 
282
                    wod[j]++;
-
 
283
                }
-
 
284
 
-
 
285
                if (sos[j] == undefined) {
-
 
286
                    sos[j] = parseInt(data[i]);
-
 
287
                } else {
-
 
288
                    sos[j] += parseInt(data[i]);
-
 
289
 
-
 
290
                }
-
 
291
            }
-
 
292
 
-
 
293
            for (let h = 5; h < data.length - 2; h = h + 3) {
-
 
294
                console.log("Hloop");
-
 
295
                console.log(data[h]);
-
 
296
                g = Math.floor(h / 3)
-
 
297
 
-
 
298
                if (wos[g] == undefined) {
-
 
299
                    wos[g] = 0;
-
 
300
                }
-
 
301
                if (parseInt(data[h]) > 0) {
-
 
302
                    wos[g]++;
-
 
303
                }
-
 
304
 
-
 
305
                if (sts[g] == undefined) {
-
 
306
                    sts[g] = parseInt(data[h]);
-
 
307
                } else {
-
 
308
                    sts[g] += parseInt(data[h]);
-
 
309
                }
-
 
310
 
-
 
311
            }
-
 
312
 
-
 
313
        });
-
 
314
 
-
 
315
        console.log(wod);
-
 
316
        console.log(wos);
-
 
317
        console.log(sos);
-
 
318
        console.log(sts);
-
 
319
        for (let m = 1; m < wod.length; m++) {
-
 
320
            let indexNum = m + 4;
-
 
321
            var stockHeader = $(`.partner-planning-details thead tr th:nth-child(${indexNum})`)
-
 
322
            stockHeader.find('.wod').html(wod[m]);
-
 
323
            stockHeader.find('.ts').html(sos[m]);
-
 
324
            stockHeader.find('.wos').html(wos[m]);
-
 
325
            stockHeader.find('.sts').html(sts[m]);
-
 
326
        }
-
 
327
 
-
 
328
    }
-
 
329
 
-
 
330
    /*$('.partner-planning-details').on(
-
 
331
            'click',
-
 
332
            '.instockItem',
-
 
333
            function() {
-
 
334
                var fofoId = $(this).data('fofoid');
-
 
335
                var catalogIds = $('.criteria-item-catalogids').val();
-
 
336
                console.log(catalogIds);
-
 
337
 
-
 
338
                doGetAjaxRequestHandler(context
-
 
339
                        + "/getInStockItembyFofoId?fofoId=" + fofoId
-
 
340
                        + "&catalogItemIds=" + catalogIds, function(response) {
-
 
341
                    console.log(response)
-
 
342
                    $('#inStockItemModel .modal-content').html(response);
-
 
343
 
-
 
344
                });
-
 
345
            });*/
-
 
346
 
-
 
347
    $('.partner-planning-details').on(
-
 
348
            'click',
-
 
349
            '.instockItem',
-
 
350
            function () {
-
 
351
                var fofoId = $(this).data('fofoid');
-
 
352
                var catalogId = $(this).data('catalogid');
-
 
353
                console.log(catalogId);
-
 
354
 
-
 
355
                doGetAjaxRequestHandler(context + "/getInStockItemQty?fofoId="
-
 
356
                        + fofoId + "&catalogItemId=" + catalogId, function (
-
 
357
                        response) {
-
 
358
                    console.log(response)
-
 
359
                    $('#inStockQtyModel .modal-content').html(response);
-
 
360
 
-
 
361
                });
-
 
362
            });
-
 
363
 
-
 
364
    $('.partner-planning-details').on(
-
 
365
            'click',
-
 
366
            '.inSaleItem',
-
 
367
            function () {
-
 
368
                var fofoId = $(this).data('fofoid');
-
 
369
                var catalogIds = $('.criteria-item-catalogids').val();
-
 
370
                console.log(catalogIds);
-
 
371
 
-
 
372
                doGetAjaxRequestHandler(context
-
 
373
                        + "/getSaleItembyCatalogFofoId?fofoId=" + fofoId
-
 
374
                        + "&catalogItemIds=" + catalogIds + "&date="
-
 
375
                        + startDate, function (response) {
-
 
376
                    console.log(response)
-
 
377
                    $('#inSaleItemModel .modal-content').html(response);
-
 
378
 
-
 
379
                });
-
 
380
            });
-
 
381
 
-
 
382
    $('.partner-planning-details').on(
-
 
383
            'click',
-
 
384
            '.warehouseStockItem',
-
 
385
            function () {
-
 
386
                var warehouseId = $(this).data('warehouseid');
-
 
387
                var catalogIds = $('.criteria-item-catalogids').val();
-
 
388
                console.log(catalogIds);
-
 
389
 
-
 
390
                doGetAjaxRequestHandler(context
-
 
391
                        + "/getWarehouseStockItem?warehouseId=" + warehouseId
-
 
392
                        + "&catalogItemIds=" + catalogIds,
-
 
393
                        function (response) {
-
 
394
                            console.log(response)
-
 
395
                            $('#warehouseStockItemModel .modal-content').html(
-
 
396
                                    response);
-
 
397
 
-
 
398
                        });
-
 
399
            });
-
 
400
 
-
 
401
    $('.partner-planning-details').on(
-
 
402
            'click',
-
 
403
            '.selctItemQty',
-
 
404
            function () {
-
 
405
                var catalogIds = $('.criteria-item-catalogids').val();
-
 
406
                console.log(catalogIds);
-
 
407
                var fofoId = $(this).data('fofoid');
-
 
408
 
-
 
409
                doGetAjaxRequestHandler(context
-
 
410
                        + "/selectItemColorByCatalog?catalogIds=" + catalogIds
-
 
411
 
-
 
412
                        + "&fofoId=" + fofoId, function (response) {
-
 
413
                    console.log(response)
-
 
414
                    $('#selectModelItems .modal-content').html(response);
-
 
415
 
-
 
416
                });
-
 
417
            });
-
 
418
 
-
 
419
    $(document).on(
-
 
420
            "click",
-
 
421
            ".submit-item-po",
-
 
422
            function (e) {
-
 
423
                var seletedIds;
-
 
424
                var jsonObject = {};
-
 
425
                var seletedIdsJson = [];
-
 
426
                var fofoId = $(this).data('fofoid');
-
 
427
 
-
 
428
                $('#select-item').find('tr').each(function () {
-
 
429
                    var row = $(this);
-
 
430
 
-
 
431
                    console.log(row);
-
 
432
                    if (row.find('input[type="checkbox"]').is(':checked')) {
-
 
433
                        var currentRow = $(this).closest("tr");
-
 
434
 
-
 
435
                        var itemId = currentRow.find("td:eq(1)").html();
-
 
436
                        var name = currentRow.find("td:eq(2)").html();
-
 
437
                        var quantity = currentRow.find("td:eq(3) input").val();
-
 
438
                        console.log(quantity)
-
 
439
                        if (quantity == "") {
-
 
440
                            alert("Select the Quantity");
-
 
441
                            return false;
-
 
442
 
-
 
443
                        }
-
 
444
 
-
 
445
                        seletedIds = {
-
 
446
                            "itemId": itemId,
-
 
447
                            "qty": quantity
-
 
448
                        }
-
 
449
                        seletedIdsJson.push(seletedIds)
-
 
450
 
-
 
451
                    }
-
 
452
 
-
 
453
                });
-
 
454
 
-
 
455
                console.log(fofoId)
-
 
456
                if (fofoId == null) {
-
 
457
                    alert("fofoId is required");
-
 
458
                    return false;
-
 
459
                }
-
 
460
                if (seletedIdsJson.length === 0) {
-
 
461
                    alert("Atleast one Item selected");
-
 
462
                    return false;
-
 
463
                }
-
 
464
                console.log(seletedIdsJson);
-
 
465
 
-
 
466
                jsonObject['poIds'] = seletedIdsJson;
-
 
467
                jsonObject['fofoId'] = fofoId;
-
 
468
                console.log(jsonObject)
-
 
469
                if (confirm("Are you sure you want to create po") == true) {
-
 
470
 
-
 
471
                    doPostAjaxRequestWithJsonHandler(context + "/createPo",
-
 
472
                            JSON.stringify(jsonObject), function (response) {
-
 
473
                                if (response == 'true') {
-
 
474
                                    alert("successfully create");
-
 
475
 
-
 
476
                                    $("#selectModelItems").modal("hide");
-
 
477
                                    $("button.search-partner-stock").click();
-
 
478
                                }
-
 
479
                            });
-
 
480
                }
-
 
481
 
-
 
482
            });
-
 
483
 
-
 
484
    $('.partner-planning-details').on(
-
 
485
            'click',
-
 
486
            '.podetails',
-
 
487
            function () {
-
 
488
                var fofoId = $(this).data('fofoid');
-
 
489
                var datetime = $(this).data('datetime');
-
 
490
 
-
 
491
                doGetAjaxRequestHandler(context
-
 
492
                        + "/getSuggestedPoDetail?fofoId=" + fofoId
-
 
493
                        + "&datetime=" + datetime, function (response) {
-
 
494
                    console.log(response)
-
 
495
                    $('#ItemsPo .modal-content').html(response);
-
 
496
 
-
 
497
                });
-
 
498
            });
-
 
499
 
197
 
500
 
198
	$(document).ready(function() {
-
 
199
	var targetArray = [];
-
 
200
	
-
 
201
	
-
 
202
 targetArray = 	Array.apply(null, Array($catalogItemMap.size())).map(function (_, i) {return 3+(i*3);});
-
 
203
		table = $('.partner-planning-details').DataTable({
-
 
204
 
-
 
205
			"lengthMenu" : [ 10, 25, 50, 75, 100, 250 ],
-
 
206
			"scrollX" : true,
-
 
207
			"pageLength" : 250,
-
 
208
			"orderCellsTop" : true,
-
 
209
			"fixedHeader" : true,
-
 
210
			"fixedColumns" : {
-
 
211
				leftColumns : 3
-
 
212
 
-
 
213
			},
-
 
214
			
-
 
215
			   "columnDefs": [
-
 
216
                   { "targets": targetArray, "orderDataType":  "dom-stock-numeric", "type":"number" },
-
 
217
                 ]
-
 
218
 
-
 
219
		});
-
 
220
		
-
 
221
		
-
 
222
 
-
 
223
		datatableSum();
-
 
224
 
-
 
225
		table.on('search.dt', function() {
-
 
226
			console.log('Currently applied global search: ' + table.search());
-
 
227
 
-
 
228
			datatableSum();
-
 
229
 
-
 
230
		});
-
 
231
	});
-
 
232
 
-
 
233
	function datatableSum() {
-
 
234
		let wod = [];
-
 
235
		let wos = [];
-
 
236
		let sos = [];
-
 
237
		let pos = [];
-
 
238
		let sts = [];
-
 
239
		table.rows({
-
 
240
			"search" : "applied"
-
 
241
		}).every(function() {
-
 
242
			var data = this.data();
-
 
243
			
-
 
244
			for (let i = 3; i < data.length - 2; i = i + 3) {
-
 
245
				j = i / 3
-
 
246
				if (wod[j] == undefined) {
-
 
247
					wod[j] = 0;
-
 
248
				}
-
 
249
				if (parseInt(data[i]) > 0) {
-
 
250
					wod[j]++;
-
 
251
				}
-
 
252
 
-
 
253
	         var fields = data[i].split('/');
-
 
254
			
-
 
255
				if (sos[j] == undefined) {
-
 
256
					sos[j] = parseInt(fields[0]);
-
 
257
				} else {
-
 
258
					sos[j] += parseInt(fields[0]);
-
 
259
						
-
 
260
				}
-
 
261
				
-
 
262
				if (pos[j] == undefined) {
-
 
263
					pos[j] = parseInt(fields[1]);
-
 
264
				} else {
-
 
265
				var fields = data[i].split('/');
-
 
266
					pos[j]+= parseInt(fields[1]);
-
 
267
						
-
 
268
				}
-
 
269
			}
-
 
270
 
-
 
271
			for (let h = 4; h < data.length - 2; h = h + 3) {
-
 
272
				g = Math.floor(h / 3)
-
 
273
 
-
 
274
				if (wos[g] == undefined) {
-
 
275
					wos[g] = 0;
-
 
276
				}
-
 
277
				if (parseInt(data[h]) > 0) {
-
 
278
					wos[g]++;
-
 
279
				}
-
 
280
				
-
 
281
				if (sts[g] == undefined) {
-
 
282
					sts[g] = parseInt(data[h]);
-
 
283
				} else {
-
 
284
					sts[g] += parseInt(data[h]);
-
 
285
				}
-
 
286
 
-
 
287
			}
-
 
288
 
-
 
289
		});
-
 
290
 
-
 
291
		console.log(wod);
-
 
292
		console.log(wos);
-
 
293
		console.log(sos);
-
 
294
		console.log(sts);
-
 
295
		console.log(pos)
-
 
296
		for (let m = 3; m < wod.length + 2; m++) {
-
 
297
			let indexNum = m + 1;
-
 
298
			var stockHeader = $(`.partner-planning-details thead tr th:nth-child(${indexNum})`)
-
 
299
			stockHeader.find('.wod').html(wod[m - 2])
-
 
300
			stockHeader.find('.ts').html(sos[m - 2])
-
 
301
			stockHeader.find('.tp').html(pos[m - 2])
-
 
302
		}
-
 
303
 
-
 
304
		for (let l = 3; l < wos.length + 2; l++) {
-
 
305
			let indexNum = l + 1;
-
 
306
			console.log(indexNum)
-
 
307
			var stockHeader = $(`.partner-planning-details thead tr th:nth-child(${indexNum})`)
-
 
308
			stockHeader.find('.wos').html(wos[l - 2])
-
 
309
			stockHeader.find('.sts').html(sts[l - 2])
-
 
310
		}
-
 
311
 
-
 
312
	}
-
 
313
 
-
 
314
	/*$('.partner-planning-details').on(
-
 
315
			'click',
-
 
316
			'.instockItem',
-
 
317
			function() {
-
 
318
				var fofoId = $(this).data('fofoid');
-
 
319
				var catalogIds = $('.criteria-item-catalogids').val();
-
 
320
				console.log(catalogIds);
-
 
321
 
-
 
322
				doGetAjaxRequestHandler(context
-
 
323
						+ "/getInStockItembyFofoId?fofoId=" + fofoId
-
 
324
						+ "&catalogItemIds=" + catalogIds, function(response) {
-
 
325
					console.log(response)
-
 
326
					$('#inStockItemModel .modal-content').html(response);
-
 
327
 
-
 
328
				});
-
 
329
			});*/
-
 
330
 
-
 
331
	$('.partner-planning-details').on(
-
 
332
			'click',
-
 
333
			'.instockItem',
-
 
334
			function() {
-
 
335
				var fofoId = $(this).data('fofoid');
-
 
336
				var catalogId = $(this).data('catalogid');
-
 
337
				console.log(catalogId);
-
 
338
 
-
 
339
				doGetAjaxRequestHandler(context + "/getInStockItemQty?fofoId="
-
 
340
						+ fofoId + "&catalogItemId=" + catalogId, function(
-
 
341
						response) {
-
 
342
					console.log(response)
-
 
343
					$('#inStockQtyModel .modal-content').html(response);
-
 
344
 
-
 
345
				});
-
 
346
			});
-
 
347
 
-
 
348
	$('.partner-planning-details').on(
-
 
349
			'click',
-
 
350
			'.inSaleItem',
-
 
351
			function() {
-
 
352
				var fofoId = $(this).data('fofoid');
-
 
353
				var catalogIds = $('.criteria-item-catalogids').val();
-
 
354
				console.log(catalogIds);
-
 
355
 
-
 
356
				doGetAjaxRequestHandler(context
-
 
357
						+ "/getSaleItembyCatalogFofoId?fofoId=" + fofoId
-
 
358
						+ "&catalogItemIds=" + catalogIds + "&date="
-
 
359
						+ startDate, function(response) {
-
 
360
					console.log(response)
-
 
361
					$('#inSaleItemModel .modal-content').html(response);
-
 
362
 
-
 
363
				});
-
 
364
			});
-
 
365
 
-
 
366
	$('.partner-planning-details').on(
-
 
367
			'click',
-
 
368
			'.warehouseStockItem',
-
 
369
			function() {
-
 
370
				var warehouseId = $(this).data('warehouseid');
-
 
371
				var catalogIds = $('.criteria-item-catalogids').val();
-
 
372
				console.log(catalogIds);
-
 
373
 
-
 
374
				doGetAjaxRequestHandler(context
-
 
375
						+ "/getWarehouseStockItem?warehouseId=" + warehouseId
-
 
376
						+ "&catalogItemIds=" + catalogIds,
-
 
377
						function(response) {
-
 
378
							console.log(response)
-
 
379
							$('#warehouseStockItemModel .modal-content').html(
-
 
380
									response);
-
 
381
 
-
 
382
						});
-
 
383
			});
-
 
384
 
-
 
385
	$('.partner-planning-details').on(
-
 
386
			'click',
-
 
387
			'.selctItemQty',
-
 
388
			function() {
-
 
389
				var catalogIds = $('.criteria-item-catalogids').val();
-
 
390
				console.log(catalogIds);
-
 
391
				var fofoId = $(this).data('fofoid');
-
 
392
 
-
 
393
				doGetAjaxRequestHandler(context
-
 
394
						+ "/selectItemColorByCatalog?catalogIds=" + catalogIds
-
 
395
 
-
 
396
						+ "&fofoId=" + fofoId, function(response) {
-
 
397
					console.log(response)
-
 
398
					$('#selectModelItems .modal-content').html(response);
-
 
399
 
-
 
400
				});
-
 
401
			});
-
 
402
 
-
 
403
	$(document).on(
-
 
404
			"click",
-
 
405
			".submit-item-po",
-
 
406
			function(e) {
-
 
407
				var seletedIds;
-
 
408
				var jsonObject = {};
-
 
409
				var seletedIdsJson = [];
-
 
410
				var fofoId = $(this).data('fofoid');
-
 
411
 
-
 
412
				$('#select-item').find('tr').each(function() {
-
 
413
					var row = $(this);
-
 
414
 
-
 
415
					console.log(row);
-
 
416
					if (row.find('input[type="checkbox"]').is(':checked')) {
-
 
417
						var currentRow = $(this).closest("tr");
-
 
418
 
-
 
419
						var itemId = currentRow.find("td:eq(1)").html();
-
 
420
						var name = currentRow.find("td:eq(2)").html();
-
 
421
						var quantity = currentRow.find("td:eq(3) input").val();
-
 
422
						console.log(quantity)
-
 
423
						if (quantity == "") {
-
 
424
							alert("Select the Quantity");
-
 
425
							return false;
-
 
426
 
-
 
427
						}
-
 
428
 
-
 
429
						seletedIds = {
-
 
430
							"itemId" : itemId,
-
 
431
							"qty" : quantity
-
 
432
						}
-
 
433
						seletedIdsJson.push(seletedIds)
-
 
434
 
-
 
435
					}
-
 
436
 
-
 
437
				});
-
 
438
 
-
 
439
				console.log(fofoId)
-
 
440
				if (fofoId == null) {
-
 
441
					alert("fofoId is required");
-
 
442
					return false;
-
 
443
				}
-
 
444
				if (seletedIdsJson.length === 0) {
-
 
445
					alert("Atleast one Item selected");
-
 
446
					return false;
-
 
447
				}
-
 
448
				console.log(seletedIdsJson);
-
 
449
 
-
 
450
				jsonObject['poIds'] = seletedIdsJson;
-
 
451
				jsonObject['fofoId'] = fofoId;
-
 
452
				console.log(jsonObject)
-
 
453
				if (confirm("Are you sure you want to create po") == true) {
-
 
454
 
-
 
455
					doPostAjaxRequestWithJsonHandler(context + "/createPo",
-
 
456
							JSON.stringify(jsonObject), function(response) {
-
 
457
								if (response == 'true') {
-
 
458
									alert("successfully create");
-
 
459
 
-
 
460
									$("#selectModelItems").modal("hide");
-
 
461
									$("button.search-partner-stock").click();
-
 
462
								}
-
 
463
							});
-
 
464
				}
-
 
465
 
-
 
466
			});
-
 
467
 
-
 
468
	$('.partner-planning-details').on(
-
 
469
			'click',
-
 
470
			'.podetails',
-
 
471
			function() {
-
 
472
				var fofoId = $(this).data('fofoid');
-
 
473
				var datetime = $(this).data('datetime');
-
 
474
 
-
 
475
				doGetAjaxRequestHandler(context
-
 
476
						+ "/getSuggestedPoDetail?fofoId=" + fofoId
-
 
477
						+ "&datetime=" + datetime, function(response) {
-
 
478
					console.log(response)
-
 
479
					$('#ItemsPo .modal-content').html(response);
-
 
480
 
-
 
481
				});
-
 
482
			});
-
 
483
			
-
 
484
	
-
 
485
</script>
501
</script>
486
502