Subversion Repositories SmartDukaan

Rev

Rev 34898 | Rev 35001 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
34813 aman 1
<meta charset="UTF-8">
2
<link id="modal-bootstrap-css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
3
      rel="stylesheet"/>
4
<style>
5
 
6
    .chart-wrapper {
7
        overflow: hidden;
8
        transition: all 0.3s ease;
9
    }
10
 
11
    .chart-content {
12
        display: flex;
13
        flex-wrap: nowrap;
14
        gap: 20px;
15
        align-items: flex-start;
16
    }
17
 
18
    .chart-container {
19
        flex: 0 0 550px;
20
        height: 320px;
21
    }
22
 
23
    .partner-income-container {
24
        flex: 1 1 auto;
25
        min-width: 300px;
26
    }
27
 
28
 
29
    .legend {
30
        background: #f8f9fa;
31
        padding: 15px;
32
        border-radius: 8px;
33
        margin-bottom: 30px;
34
    }
35
 
36
    .status-badge {
37
        display: inline-block;
38
        padding: 6px 12px;
39
        border-radius: 20px;
40
        font-size: 12px;
41
        font-weight: 600;
42
        text-transform: uppercase;
43
        letter-spacing: 0.5px;
44
    }
45
 
46
    .status-ok {
47
        background-color: #d4edda;
48
        color: #155724;
49
        border: 1px solid #c3e6cb;
50
    }
51
 
52
    .status-not-ok {
53
        background-color: #f8d7da;
54
        color: #721c24;
55
        border: 1px solid #f5c6cb;
56
    }
57
 
58
    .brand-card {
59
        background: white;
60
        border: 1px solid #e9ecef;
61
        border-radius: 12px;
62
        padding: 20px;
63
        margin-bottom: 15px;
64
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
65
        transition: transform 0.2s ease, box-shadow 0.2s ease;
66
    }
67
 
68
    .brand-card:hover {
69
        transform: translateY(-2px);
70
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
71
    }
72
 
73
    .brand-name {
74
        font-size: 1.5rem;
75
        font-weight: 700;
76
        margin-bottom: 15px;
77
        color: #2c3e50;
78
    }
79
 
80
    .quantity-row {
81
        display: flex;
82
        justify-content: space-between;
83
        align-items: center;
84
        padding: 8px 0;
85
        border-bottom: 1px solid #f1f3f4;
86
    }
87
 
88
    .quantity-row:last-child {
89
        border-bottom: none;
90
    }
91
 
92
    .quantity-label {
93
        font-weight: 500;
94
        color: #6c757d;
95
    }
96
 
97
    .quantity-value {
98
        font-weight: 600;
99
        color: #2c3e50;
100
    }
101
 
102
    .left-panel {
103
        background: #f8f9fa;
104
        border-radius: 8px;
105
        padding: 20px;
106
    }
107
 
108
    .right-panel {
109
        background: white;
110
        border-radius: 8px;
111
        padding: 20px;
112
        border: 1px solid #e9ecef;
113
    }
114
 
115
    .chart-legend {
116
        max-height: 400px;
117
        overflow-y: auto;
118
    }
119
 
120
    .legend-item {
121
        transition: transform 0.2s ease;
122
        margin-bottom: 10px;
123
 
124
    }
125
 
126
    .legend-item:hover {
34898 aman 127
        transform: translateX(5px) scale(1.02);
128
        z-index: 10;
34813 aman 129
    }
130
 
131
 
132
    .legend-color {
133
        width: 20px;
134
        height: 20px;
135
        border-radius: 6px;
136
        margin-right: 12px;
137
        flex-shrink: 0;
138
    }
139
 
140
    .legend-brand {
141
        font-weight: 750;
142
        color: #2d3748;
143
        font-size: 14px;
144
    }
145
 
146
    .legend-percentage {
147
        font-weight: 700;
148
        font-size: 14px;
149
        color: #4a5568;
150
    }
151
 
152
 
153
    @keyframes shimmer {
154
        0% {
155
            left: -100%;
156
        }
157
        100% {
158
            left: 100%;
159
        }
160
    }
161
 
162
 
163
    .brand-card {
164
        transition: all 0.2s ease;
165
        border: 1px solid #e9ecef;
166
    }
167
 
168
    .brand-card:hover {
169
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
170
        transform: translateY(-1px);
171
    }
172
 
173
    .brand-logo {
174
        width: 80px;
175
        height: 80px;
176
        object-fit: contain;
177
        border-radius: 12px;
178
        background-color: #f8f9fa;
179
        padding: 2px;
180
    }
181
 
182
    .brand-name {
183
        font-size: 13px;
184
        font-weight: 700;
185
        color: #212529;
186
        margin-bottom: 8px;
187
    }
188
 
189
    .status-badge {
190
        font-size: 12px;
191
        font-weight: 600;
192
        padding: 8px 16px;
193
        border-radius: 25px;
194
        border: none;
195
    }
196
 
197
    .legend {
198
        background-color: #f8f9fa;
199
        border-radius: 8px;
200
        padding: 12px;
201
        margin-bottom: 24px;
202
    }
203
 
204
    .modal-backdrop.in {
205
        filter: alpha(opacity=50);
206
        opacity: 0.35;
207
        width: auto;
208
        height: auto;
209
    }
210
 
211
    .brandText {
212
        transform: rotate(270deg) !important;
213
    }
214
 
215
    .rounded-corner {
216
        border-top-left-radius: 30px !important;
217
        border-top-right-radius: 30px !important;
218
 
219
    }
220
 
221
    .bg-danger {
222
        background-color: #D3181F !important;
223
    }
224
 
225
    .fs-8 {
226
        font-size: 25px !important;
227
    }
228
 
229
    .table-bordered th {
230
        border: 1px solid rgba(255, 255, 255, 0.2);
231
    }
232
 
233
    .table-bordered td {
234
        border: 1px solid #dee2e6;
235
        vertical-align: middle;
236
    }
237
 
238
    .fs-5 {
239
        font-size: 1.2rem !important;
240
    }
241
 
242
    .brand-btn {
243
        transition: all 0.3s ease;
244
        font-weight: normal;
245
        border-radius: 25px;
246
        padding: 4px 10px;
247
        margin: 5px;
248
        border: 2px solid #666;
249
    }
250
 
251
    .brand-logo {
252
        height: 40px;
253
        object-fit: contain;
254
    }
255
 
256
 
257
    .curve {
258
        padding-left: 100px !important;
259
        border-radius: 40px 0 0 40px !important;
260
        width: 250px !important;
261
    }
262
 
263
 
264
    .stock-ribbon {
265
        position: relative;
266
        padding: 5px 15px;
267
        color: white;
268
        clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
269
        min-width: 220px;
270
    }
271
 
272
    .mandatory-ribbon {
273
        background-color: #D3181F !important;
274
    }
275
 
276
    .other-ribbon {
277
        background-color: #000;
278
    }
279
 
280
    .brand-item {
281
        display: flex;
282
        align-items: center;
283
        margin-bottom: 20px;
284
    }
285
 
286
    .category-header {
287
        font-size: 15px;
288
        font-weight: bold;
289
        margin: 20px 0;
290
        padding-left: 15px;
291
    }
292
 
293
    .mandatory-header {
294
        color: #d32f2f;
295
    }
296
 
297
    .other-header {
298
        color: #333;
299
    }
300
 
301
    .bg-orange {
302
        background-color: #FF6700 !important;
303
        color: white;
304
    }
305
 
306
    .bg-cryan {
307
        background-color: #004d51 !important;
308
        color: white;
309
    }
310
 
311
    .bg-dark-light {
312
        background-color: #3e3e3e !important;
313
        color: white;
314
    }
315
 
316
    .table-bordered td, .table-bordered th {
317
        border: 1px solid #dee2e6;
318
    }
319
 
320
    .brand-circle {
321
        width: 60px;
322
        height: 60px;
323
        object-fit: cover;
324
        border: 5px solid rgb(122, 116, 116);
325
    }
326
 
327
 
328
    .currency::before {
329
        content: "\20B9";
330
    }
331
 
332
 
333
    .table thead th {
334
        font-weight: 600;
335
        letter-spacing: 0.5px;
336
    }
337
 
338
    .table tbody td {
339
        font-weight: normal;
340
    }
341
 
342
    .fs-3, .fs-5 {
343
        font-weight: normal;
344
    }
345
 
346
    .fw-bold {
347
        font-weight: bold !important;
348
    }
349
 
350
    .btn {
351
        font-weight: normal;
352
    }
353
 
354
    .payment-circle {
355
        width: 200px;
356
        height: 200px;
357
        border: 25px solid #e0dcdc;
358
        border-radius: 50%;
359
        display: flex;
360
        align-items: center;
361
        justify-content: center;
362
        transition: transform 0.3s ease;
363
    }
364
 
365
    .payment-content {
366
        text-align: center;
367
        color: white;
368
        padding: 20px;
369
    }
370
 
371
    .payment-amount {
372
        font-size: 18px;
373
        font-weight: 700;
374
        margin-bottom: 10px;
375
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
376
    }
377
 
378
    .payment-label {
379
        font-size: 18px;
380
        line-height: 1.3;
381
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
382
    }
383
 
384
 
385
    .table-border td {
386
        border: 1px solid black !important;
387
    }
388
 
389
    .table-border thead {
390
        border: 1px solid black;
391
    }
392
 
393
    .p-0 {
394
        padding: 0 !important;
395
    }
396
</style>
397
<body style="background-color: rgb(247, 247, 247);zoom: 100%!important;">
398
<div style="overflow-y:auto;max-height: 120vh; ">
399
    <section id="ajaxSection" class="rounded"
400
             style="max-height: 120vh; overflow-y: auto;">
401
        <div class="w-full bg-danger h-25 py-3 mb-4">
402
            <h1 class="text-center text-white " style="font-size: 30px !important; font-weight: 800">Pending
403
                Tasks</h1>
404
        </div>
405
        <div class="container">
406
            ##-----------------------------------------------GRN Pending -----------------------------------------------------
407
            <div class="container-fluid p-4">
408
                #if($grnPendingOrders.entrySet().size()>0)
409
                    <div class="row justify-content-center">
410
                        <div class="col-10">
411
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
412
                                <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">GRN Pending</h1>
413
                            </div>
414
                        </div>
415
                    </div>
416
 
417
                    <div class="table-responsive rounded-3 shadow p-5">
418
                        <table id="grnTable" class="table table-bordered mb-0 table-border" style="width:100%">
419
                            <thead>
420
                            <tr class="bg-danger text-white">
421
                                <th class="ps-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center"
422
                                    style="padding: 10px !important;">BRANDS
423
                                </th>
424
                                <th class="fs-5 fw-bold text-uppercase bg-danger text-white text-center"
425
                                    style="padding: 10px !important;">QUANTITY
426
                                </th>
427
                                <th class="pe-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center"
428
                                    style="padding: 10px !important;">VALUE
429
                                </th>
430
                            </tr>
431
                            </thead>
432
                            <tbody>
433
                                #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
434
                                #foreach($entry in $grnPendingOrders.entrySet())
435
                                    #set($brand = $entry.key)
436
                                    #set($details = $entry.value)
437
                                <tr class="">
438
                                    <td class="ps-4 text-center p-0">
439
                                        <div class="d-flex align-items-center justify-content-center">
440
                                            <div class="row align-items-center" style="width: 200px;">
441
                                                <div class="col-auto">
442
                                                    <img src="$brandLogos.getOrDefault($brand,
443
                                                        'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
444
                                                         alt="$brand logo"
445
                                                         class="brand-logo rounded-circle"
446
                                                         style="width:35px;height:35px">
447
                                                </div>
448
                                                <div class="col text-start">
449
                                                    <span class="fw-bold fs-5">$brand</span>
450
                                                </div>
451
                                            </div>
452
                                        </div>
453
                                    </td>
454
                                    <td class="text-center align-middle fs-5 fw-semibold p-0">
455
                                        $details.quantity
456
                                    </td>
457
                                    <td class="pe-4 text-center align-middle fs-5 fw-semibold currency p-0 ">
458
                                        $nf.format($details.mrp)
459
                                    </td>
460
                                </tr>
461
                                #end
462
                            </tbody>
463
                        </table>
464
                    </div>
465
                #end
466
            </div>
467
 
468
            ##-----------------------------------------------Unbilled Activated -----------------------------------------------------
469
 
470
            <div class="container-fluid p-4">
471
                #if($unbilledActivated.entrySet().size()>0)
472
                    <div class="row justify-content-center">
473
                        <div class="col-10">
474
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
475
                                <h1 class="text-white text-center mb-0 py-2 fw-bold fs-8">Pending Billing</h1>
476
                            </div>
477
                        </div>
478
                    </div>
479
 
480
                    <div class="table-responsive rounded-3 shadow p-5">
481
                        <table id="unbilledTable" class="table table-bordered mb-0 table-border" style="width:100%">
482
 
483
                            <thead>
484
                            <tr class="bg-danger text-white">
485
                                <th class="ps-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
486
                                    style="padding: 10px !important;">BRANDS
487
                                </th>
488
                                <th class="fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
489
                                    style="padding: 10px !important;">QUANTITY
490
                                </th>
491
                                <th class="pe-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
492
                                    style="padding: 10px !important;">VALUE
493
                                </th>
494
                            </tr>
495
                            </thead>
496
                            <tbody>
497
                                #set($mandatoryBrands = ["Vivo", "Realme", "Oppo", "Samsung"])
498
 
499
                                #foreach($entry in $unbilledActivated.entrySet())
500
                                    #set($brand = $entry.key)
501
                                    #set($details = $entry.value)
502
                                <tr>
503
                                    <td class="ps-4 text-center p-0">
504
                                        <div class="d-flex align-items-center justify-content-center">
505
                                            <div class="row align-items-center" style="width: 200px;">
506
                                                <div class="col-auto">
507
                                                    <img src="$brandLogos.getOrDefault($brand,
508
                                                        'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
509
                                                         alt="$brand logo"
510
                                                         class="brand-logo rounded-circle"
511
                                                         style="width:35px;height:35px">
512
                                                </div>
513
                                                <div class="col text-start">
514
                                                    <span class="fw-bold fs-5">$brand</span>
515
                                                </div>
516
                                            </div>
517
                                        </div>
518
                                    </td>
519
                                    <td class="text-center align-middle fs-5 fw-semibold   p-0">
520
                                        $details.quantity
521
                                    </td>
522
                                    <td class="pe-4 text-center align-middle p-0 currency fw-semibold fs-5">
523
                                        $nf.format( $details.mtd)
524
                                    </td>
525
                                </tr>
526
                                #end
527
                            </tbody>
528
                        </table>
529
                    </div>
530
                #end
531
            </div>
532
 
533
 
534
            ##-----------------------------------------------Loan Amount -----------------------------------------------------
34971 aman 535
            #if( $totalDefaultAmount != 0 || $totalOverdueAmount != 0 || $totalDueAmount != 0 || $totalLoan != 0 )
536
                <div class="container-fluid p-4">
537
                    <div class="row mb-5 justify-content-center">
538
                        <div class="col-10">
539
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
540
                                <h1 class="text-white text-center mb-0  fw-bold py-2 fs-8">Loan </h1>
541
                            </div>
34813 aman 542
                        </div>
543
                    </div>
34971 aman 544
                    <div class="row justify-content-center">
545
                        <div class="col-12 col-md-4 text-center ">
546
                            <div class="payment-circle shadow-lg shadow-dark mx-auto "
547
                                 style="background-color: #cc0000 !important;">
548
                                <div class="payment-content">
549
                                    <div class="payment-amount currency"> $nf.format( $totalDefaultAmount) </div>
34813 aman 550
 
34971 aman 551
                                </div>
34813 aman 552
                            </div>
34971 aman 553
                            <h1 class="payment-label fw-bold mt-4" style="font-weight: 400 !important;">Default
554
                                Payment<br>(Above
555
                                30 days)</h1>
34813 aman 556
                        </div>
557
 
34971 aman 558
                        <div class="col-12 col-md-4 text-center">
559
                            <div class="payment-circle shadow-lg mx-auto" style="background-color: #FF9433 !important;">
560
                                <div class="payment-content">
561
                                    <div class="payment-amount currency">  $nf.format($totalOverdueAmount) </div>
562
                                </div>
34813 aman 563
                            </div>
34971 aman 564
                            <h1 class="payment-label fw-bold mt-4"
565
                                style="font-size: 20px !important;  font-weight: 400 !important;">Due Payment<br>(Above
566
                                15
567
                                Days)</h1>
568
 
34813 aman 569
                        </div>
34971 aman 570
                        <div class="col-12 col-md-4 text-center">
571
                            <div class="payment-circle shadow-lg mx-auto "
572
                                 style="background-color: #00B050 !important;">
573
                                <div class="payment-content">
574
                                    <div class="payment-amount currency">  $nf.format($totalDueAmount) </div>
575
                                </div>
34813 aman 576
                            </div>
34971 aman 577
                            <h1 class="payment-label fw-bold mt-4"
578
                                style="font-size: 20px !important; font-weight: 400 !important;">Other Loan<br>(Within
579
                                15
580
                                Days)</h1>
34813 aman 581
                        </div>
582
 
583
 
34971 aman 584
                        <div class="mt-4 mx-5 " style="margin-top: 6rem !important;">
585
                            <h1 class="text-center " style="font-size:30px !important;font-weight:300 !important;">Total
586
                                Loan Value :
587
                                <span class="currency fw-bold"> $nf.format( $totalLoan )</span>
588
                            </h1>
589
                        </div>
34813 aman 590
                    </div>
591
                </div>
34971 aman 592
            #end
34813 aman 593
        </div>
594
 
595
        <div class="w-full bg-danger h-25 py-3 my-4">
596
            <h1 class="text-center text-white fw-bold" style="font-size: 30px !important; font-weight: 800">My Business
597
                Analysis</h1>
598
        </div>
599
        <div class="container-fluid p-5 mt-5">
600
 
601
            <div class="row mb-1 my-4 mx-3 justify-content-center">
602
                <div class="col-10">
603
                    <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
604
                        <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">My Earning </h1>
605
                    </div>
606
                </div>
607
            </div>
608
 
609
            <div class="container mt-4">
610
                <div class="chart-wrapper card shadow-lg rounded-5 p-2">
611
                    <span class="text-danger fs-3 fw-bold text-end">** Click on the bar to see the details</span>
612
 
613
                    <div class="chart-content ">
614
                        <div class="chart-container">
615
                            <canvas id="sixMonthChart"></canvas>
616
                        </div>
617
                        <div id="partner-income" class="partner-income-container"></div>
618
                    </div>
619
                </div>
620
            </div>
621
 
622
        </div>
623
        ##        ----------------------------------------anyalysis---------------------------=//
624
        #set($marketShareData = [
625
        {"Brand": "Vivo", "MarketShare": "20%", "Quarter": "Q1 2025", "BgColor": "#2196F3", "Rank": "1"},
626
        {"Brand": "Samsung", "MarketShare": "18%", "Quarter": "Q1 2025", "BgColor": "#1428A0", "Rank": "2"},
627
        {"Brand": "Xiaomi", "MarketShare": "13%", "Quarter": "Q1 2025", "BgColor": "#FF6900", "Rank": "3"},
628
        {"Brand": "OPPO", "MarketShare": "12%", "Quarter": "Q1 2025", "BgColor": "#006B33", "Rank": "4"},
629
        {"Brand": "realme", "MarketShare": "11%", "Quarter": "Q1 2025", "BgColor": "#FFC915", "Rank": "5"},
630
        {"Brand": "Others", "MarketShare": "26%", "Quarter": "Q1 2025", "BgColor": "#6b7280", "Rank": "-"}
631
        ])
632
 
633
        <div class="container-fluid p-5">
634
            <div class="row mb-1 my-4 mx-3 justify-content-center">
635
                <div class="col-10">
636
                    <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
637
                        <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">Brand Analysis </h1>
638
                    </div>
639
                </div>
640
            </div>
641
            ##        ----------------------------------------stagged chart ------------------------------------------
642
            <div class="container d-flex ">
643
                <div class="p-5" style=" height: 350px !important;width: 650px !important;">
644
                    <div class="chart-title fs-2 text-center fw-bold">Brands Share Analysis (QTY)</div>
645
                    <canvas id="combinedStackedChart"></canvas>
646
                </div>
647
                <div class="" style="width: 400px!important;">
648
                    <div class="right-panel">
649
                        <h4 class="mb-4">Quantity Analysis</h4>
650
 
651
                        <div class="brand-analysis-container">
652
                            <div class="table-responsive">
653
                                <table class="table table-striped table-hover">
654
                                    <thead class="table-light table-bordered">
655
                                    <tr>
656
                                        <th scope="col">Brand Name</th>
657
                                        <th scope="col">Available Models</th>
658
                                        <th scope="col">Required Models</th>
659
                                        <th scope="col" class="text-center">Status</th>
660
                                    </tr>
661
                                    </thead>
662
                                    <tbody class="table-bordered">
663
                                        #foreach($brandName in $targetBrands)
664
                                            #set($analysis = $brandAnalysisData.get($brandName))
665
                                        <tr>
666
                                            <td>
667
                                                <strong class="brand-name">${brandName}</strong>
668
                                            </td>
669
                                            <td>
670
                                                <span class="quantity-value">${analysis.get('availableQuantity')}</span>
671
                                            </td>
672
                                            <td>
673
                                                <span class="quantity-value">${analysis.get('requiredQuantity')}</span>
674
                                            </td>
675
                                            <td class="text-center">
676
                        <span class="badge #if($analysis.get('isOK'))bg-success#else bg-danger#end">
677
                            ${analysis.get('status')}
678
                        </span>
679
                                            </td>
680
                                        </tr>
681
                                        #end
682
                                    </tbody>
683
                                </table>
684
                            </div>
685
                        </div>
686
                    </div>
687
                </div>
688
            </div>
689
 
690
 
691
            ##        -----------------------------------------------Fast Selling & HID model ------------------------------------------------
692
            <div class="container-fluid py-3">
693
                <div class="card mb-4 p-5 ">
694
                    <div class="row  justify-content-center ">
695
                        <div class="col-10">
696
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
697
                                <h3 class="text-white text-center mb-0  fw-bold py-2 fs-8">Fast Selling Models &
698
                                    HID </h3>
699
                            </div>
700
                        </div>
701
                    </div>
702
 
703
                    <div class="card-body card shadow-lg rounded-5 p-3">
704
                        <!-- Dynamic Brand Filters -->
705
                        <div class="d-flex flex-wrap justify-content-center gap-2 p-1 border-bottom fs-5">
706
                            #foreach($brand in $brands)
707
                                <button class="brand-btn" data-brand="$brand.toLowerCase()"
708
                                >
709
                                    $brand
710
                                </button>
711
                            #end
712
                        </div>
713
 
714
 
715
                        <div class="card-header text-center fw-bold ">
716
                            <h4>HID</h4>
717
                        </div>
718
 
719
 
720
                        <div class="row mx-0 mt-4">
721
                            <div class="col-3 text-center">
722
                                <div class="p-1 py-3 rounded-top" style="background: #555; color: white;">
723
                                    <strong class="fs-4  fw-bold">Model </strong>
724
                                </div>
725
                            </div>
726
                            <div class="col-3 text-center">
727
                                <div class="p-1 py-3 rounded-top" style="background: #d82c2c; color: white;">
728
                                    <strong class="fs-4  fw-bold">Suggested Qty</strong>
729
                                </div>
730
                            </div>
731
                            <div class="col-3 text-center">
732
                                <div class="p-1 py-3 rounded-top" style="background: #555; color: white;">
733
                                    <strong class="fw-bold" style="font-size: 1.3rem !important;">My Stock + Pending
734
                                        Indent</strong>
735
                                </div>
736
                            </div>
737
                            <div class="col-3 text-center">
738
                                <div class="p-1 py-3 rounded-top" style="background: #d82c2c; color: white;">
739
                                    <strong class="fs-4 fw-bold">Remarks</strong>
740
                                </div>
741
                            </div>
742
                        </div>
743
 
744
                        <!-- Data Rows -->
745
                        #foreach($brand in $brands)
746
                            #if($hidAllocationModelBrandMap.containsKey($brand) && !$hidAllocationModelBrandMap.get($brand).isEmpty())
747
                                #foreach($model in $hidAllocationModelBrandMap.get($brand))
748
                                    <div class="brand-data" data-brand="$brand.toLowerCase()">
749
                                        <div class="row mx-0">
750
                                            <div class="col-3 text-center">
751
                                                <div class="p-4 border border-light fs-5 trim"
752
                                                     style="background: #444; color: white;">
753
                                                    $model.getModelNumber()
754
                                                </div>
755
                                            </div>
756
                                            <div class="col-3 text-center">
757
                                                <div class="p-4 border border-light fs-5"
758
                                                     style="background: #b30606; color: white;">
759
                                                    $model.getHidAllocation()
760
                                                </div>
761
                                            </div>
762
                                            <div class="col-3 text-center">
763
                                                <div class="p-4 border border-light fs-5"
764
                                                     style="background: #444; color: white;">
765
                                                    <strong>$model.getAvailableStock()</strong>
766
                                                </div>
767
                                            </div>
768
                                            <div class="col-3 text-center">
769
 
770
                                                <div class="p-4 border border-light fs-5"
771
                                                     style="background: #b30606; color: white;">
772
                                                    <strong>#if($model.getAvailableStock() == 0)
773
                                                        <span class="fw-bold  p-4 w-full text-warning">Urgently Required</span>
774
                                                    #elseif($model.getAvailableStock() < $model.getHidAllocation())
775
                                                        <span class="fw-bold  p-4 text-info ">Need to Order</span>
776
                                                    #else
777
                                                        <span class=" fw-bold  p-4 text-success"
778
                                                              style="color: rgb(61 251 163) !important;">Stock OK</span>
779
                                                    #end</strong>
780
                                                </div>
781
                                            </div>
782
                                        </div>
783
                                    </div>
784
                                #end
785
                            #else
786
                                <div class="brand-data" data-brand="$brand.toLowerCase()">
787
                                    <div class="row mx-0">
788
                                        <div class="col-12 text-center p-4 fs-5" style="background: #f8f9fa;">
789
                                            No Data Available
790
                                        </div>
791
                                    </div>
792
                                </div>
793
                            #end
794
                        #end
795
 
796
 
797
                        ##                    -----------------------------------Fast Selling Modal-------------------------------
798
                        <div class="card-header text-center fw-bold ">
799
                            <h4> Fast Selling Model</h4>
800
                        </div>
801
 
802
                        #if($brandwiseFastmoving && $brandwiseFastmoving.entrySet().size() > 0)
803
                            #foreach($brandEntry in $brandwiseFastmoving.entrySet())
804
                                #foreach($model in $brandEntry.value)
805
                                    <div class="brand-data col-12" data-brand="$brandEntry.key.toLowerCase()">
806
                                        <div class="row mx-0  ">
807
                                            <div class="col-3   text-center   ">
808
                                                <div class="p-4 border border-light fs-5 text-truncate"
809
                                                     style="background: #444; color: white;">
810
                                                    <strong>$model.modelNumber</strong>
811
                                                </div>
812
                                            </div>
813
 
814
                                            <div class="col-3   text-center  ">
815
                                                <div class="p-4 border border-light fs-5"
816
                                                     style="background: #b30606; color: white;">
817
                                                    <strong>   #set($suggestedQty =  2)
818
 
819
                                            $suggestedQty
820
                                                    </strong>
821
                                                </div>
822
                                            </div>
823
 
824
                                            <div class="col-3   text-center   ">
825
                                                <div class="p-4 border border-light fs-5 "
826
                                                     style="background: #444; color: white;">
827
                                                    <strong> $model.partnerCurrentQty
828
                                                        #if($processingOrderCatalogQtyMap.get($model.getCatalogId()))
829
                                                            +  $processingOrderCatalogQtyMap.get($model.getCatalogId())
830
                                                        #end
831
                                                    </strong>
832
                                                </div>
833
                                            </div>
834
                                            #set($processingQty = $processingOrderCatalogQtyMap.get($model.getCatalogId()))
835
                                            #if(!$processingQty)
836
                                                #set($processingQty = 0)
837
                                            #end
838
                                            #set($totalQty = $model.partnerCurrentQty + $processingQty)
839
 
840
                                            <div class="col-3   text-center   ">
841
                                                <div class="p-4 border border-light fs-5"
842
                                                     style="background: #b30606; color: white;">
843
                                                    <strong>#if($totalQty == 0)
844
                                                        <span class="fw-bold  p-4 w-full text-warning">Urgently Required</span>
845
                                                    #elseif($totalQty < 2)
846
                                                        <span class="fw-bold  p-4 text-info ">Need to Order</span>
847
                                                    #else
848
                                                        <span class=" fw-bold  p-4 text-success"
849
                                                              style="color: rgb(61 251 163) !important;">Stock OK</span>
850
                                                    #end</strong>
851
                                                </div>
852
                                            </div>
853
                                        </div>
854
                                    </div>
855
                                #end
856
                            #end
857
                        #else
858
                            <div class="brand-data">
859
                                <div class="row mx-0">
860
                                    <div class="col-12 text-center p-4 fs-5" style="background: #f8f9fa;">
861
                                        No Data Available
862
                                    </div>
863
                                </div>
864
                            </div>
865
                        #end
866
 
867
                    </div>
868
 
869
 
870
                </div>
871
            </div>
872
            ##        -----------------------------------------------My Stock ------------------------------------------------
873
            <div class="row mb-1 my-4 justify-content-center">
874
                <div class="col-10">
875
                    <div class=" bg-dark-light rounded-3 p-3 shadow rounded-corner">
876
                        <h1 class="text-center mb-0 fw-bold py-2 text-white fs-8">My Stock</h1>
877
                    </div>
878
                </div>
879
            </div>
880
 
881
            <div class="row px-5" style="margin-left: 10rem !important;">
882
                <div class="col-md-6">
883
                    <div class="category-header mandatory-header">MANDATORY BRANDS</div>
884
 
885
                    #foreach($brandStockPrice in $brandStockPrices)
886
                        #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
887
                        #if($mandatoryBrands.contains($brandStockPrice.getBrand()))
888
                            <div class="brand-item">
889
                                <div class="position-relative" style="z-index: 10">
890
                                    <img src="${brandStockPrice.getBrandUrl()}"
891
                                         class="brand-circle img-fluid rounded-circle shadow border border-danger"
892
                                         data-stockbrand="$brandStockPrice.getBrand()"
893
                                         alt="$brandStockPrice.getBrand()">
894
                                </div>
895
 
896
                                <div class="stock-ribbon mandatory-ribbon ms-n3  position-absolute curve ">
897
                                    <div class="d-flex d-flex  mb-1">
898
                                        <span class="fw-bold text-start fs-5">QTY:  </span>
899
                                        <span class="fw-bold text-start fs-5">$brandStockPrice.getTotalQty()</span>
900
                                    </div>
901
                                    <div class="d-flex ">
902
                                        <span class="fw-bold text-start fs-5">Value:  </span>
903
                                        <span class="currency fw-bold text-start fs-5">  $nf.format( $brandStockPrice.getTotalValue())</span>
904
                                    </div>
905
 
906
                                    #if($brandStockPrice.getAgedValue() > 0)
907
                                        <div class="aged-stock mt-2 pt-2 border-top border-light border-opacity-25">
908
                                            <div class="d-flex justify-content-between">
909
                                                <span>Focus Stock:</span>
910
                                                <span>
911
                                        <span class="currency">  $nf.format($brandStockPrice.getAgedValue()) </span>/
912
                                                    $brandStockPrice.getAgedQty()
913
                                    </span>
914
                                            </div>
915
                                        </div>
916
                                    #end
917
                                </div>
918
                            </div>
919
                        #end
920
                    #end
921
                </div>
922
 
923
                <div class="col-md-6">
924
                    <div class="category-header other-header">OTHER BRANDS</div>
925
                    #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
926
 
927
                    #foreach($brandStockPrice in $brandStockPrices)
928
                        #if(!$mandatoryBrands.contains($brandStockPrice.getBrand()))
929
                            <div class="brand-item">
930
                                <div class="position-relative " style="z-index: 10">
931
                                    <img src="${brandStockPrice.getBrandUrl()}"
932
                                         class="brand-circle img-fluid rounded-circle shadow border border-dark"
933
                                         data-stockbrand="$brandStockPrice.getBrand()"
934
                                         alt="$brandStockPrice.getBrand()">
935
                                </div>
936
 
937
                                <div class="stock-ribbon other-ribbon ms-n3 position-absolute  curve">
938
                                    <div class="d-flex d-flex  mb-1">
939
                                        <span class="fw-bold text-start fs-5">QTY:  </span>
940
                                        <span class="fw-bold text-start fs-5">$brandStockPrice.getTotalQty()</span>
941
                                    </div>
942
                                    <div class="d-flex ">
943
                                        <span class="fw-bold text-start fs-5">Value:  </span>
944
                                        <span class="currency fw-bold text-start fs-5">  $nf.format($brandStockPrice.getTotalValue())</span>
945
                                    </div>
946
 
947
                                    #if($brandStockPrice.getAgedValue() > 0)
948
                                        <div class="aged-stock mt-2 pt-2 border-top border-light border-opacity-25">
949
                                            <div class="d-flex justify-content-between">
950
                                                <span>Focus Stock:</span>
951
                                                <span>
952
                                        <span class="currency"> $nf.format($brandStockPrice.getAgedValue())</span>/
953
                                                    $brandStockPrice.getAgedQty()
954
                                    </span>
955
                                            </div>
956
                                        </div>
957
                                    #end
958
                                </div>
959
                            </div>
960
                        #end
961
                    #end
962
                </div>
963
            </div>
964
 
965
            ##        ------------------------------------my stock ageing---------------------------------
966
 
967
            <div class="card shadow-lg rounded-3">
968
                <div class="row mb-1 my-4 justify-content-center">
969
                    <div class="col-10">
970
                        <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
971
                            <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">My Stock Ageing</h1>
972
                        </div>
973
                    </div>
974
                </div>
975
                <div class="card-body">
976
                    <div class="row mb-4">
977
                        <div class="col-md-4">
978
                            <div class="btn-group" role="group">
979
                                <button type="button" class="btn btn-danger rounded-pill px-4 me-2 fs-5" id="btnVolume">
980
                                    Volume
981
                                </button>
982
                                <button type="button" class="btn btn-danger rounded-pill px-4 fs-5" id="btnValue">Value
983
                                </button>
984
                            </div>
985
                        </div>
986
                    </div>
987
 
988
                    <div class="table-responsive rounded-5 p-5">
989
                        <table class="table table-bordered rounded-4" id="stockAgingTable">
990
                            <thead>
991
                            <tr class="text-center">
992
                                <th></th>
993
                                <th class="align-middle bg-danger text-white fs-5 fw-bold" style="width: 180px;">
994
                                    Brands
995
                                </th>
996
                                #set($intervals = ["Less Than 15 Days", "16 - 30 Days", "31 - 45 Days",
997
                                    "More Than 45 Days"])
998
                                #set($bgColors = ["bg-success", "bg-cryan", "bg-orange", "bg-danger"])
999
                                #set($textColors = ["text-white", "text-white", "text-white", "text-white"])
1000
 
1001
                                #foreach($interval in $intervals)
1002
                                    <th class="align-middle fs-5 fw-bold $bgColors.get($foreach.index) text-wrap"
1003
                                        style="width: 180px;height: 55px !important; word-wrap: break-word; white-space: normal;">
1004
                                        <span class="$textColors.get($foreach.index) text-wrap ">$interval</span>
1005
                                    </th>
1006
                                #end
1007
                            </tr>
1008
                            </thead>
1009
                            <tbody>
1010
                                #if(!$inventoryGroupedByBrand.isEmpty())
1011
                                    #set($mandatoryBrands = ["vivo", "oppo", "samsung", "realme"])
1012
                                    #set($otherBrands = [])
1013
 
1014
                                <tr>
1015
                                    <td class="align-middle bg-secondary text-center text-white fw-bold " rowspan="5"
1016
                                        style="width: 60px !important; font-size: 10px !important;">
1017
                                        <div class="brandText">MANDATORY BRANDS</div>
1018
                                    </td>
1019
                                </tr>
1020
 
1021
                                    #foreach($brandKey in $mandatoryBrands)
1022
                                        #set($found = false)
1023
                                        #foreach($entry in $inventoryGroupedByBrand.entrySet())
1024
                                            #if($entry.getKey().toLowerCase() == $brandKey)
1025
                                                #set($found = true)
1026
                                            <tr>
1027
                                                <td class="brand-cell text-start p-0">
1028
                                                    <div class="p-3 bg-danger  #getBrandBgColor($entry.getKey())"
1029
                                                         style="height: 40px; display: flex; align-items: center; justify-content: start;">
1030
                                                    <span class="text-white fw-bold fs-5"><img
1031
                                                            src="$brandLogos.getOrDefault($entry.getKey(),
1032
                                                                'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
1033
                                                            alt="$entry.getKey() logo"
1034
                                                            class="brand-logo rounded-circle me-3"
1035
                                                            style="width:35px;height:35px">$entry.getKey()</span>
1036
                                                    </div>
1037
                                                </td>
1038
                                                #foreach($i in [0..3])
1039
                                                    <td class="align-middle text-center  $bgColors.get($i)"
1040
                                                        style="opacity: 0.9;">
1041
                                                        #set($qty = 0)
1042
                                                        #set($value = 0)
1043
                                                        #foreach($item in $entry.getValue())
1044
                                                            #if($i < $item.getValues().size() && $item.getValues().get($i))
1045
                                                                #set($qty = $math.add($qty, $item.getValues().get($i).getQuantity()))
1046
                                                                #set($itemValue = $math.mul($item.getValues().get($i).getPrice(), $item.getValues().get($i).getQuantity()))
1047
                                                                #set($value = $math.add($value, $itemValue))
1048
                                                            #end
1049
                                                        #end
1050
                                                        <div class="volume-view fs-5 fw-bold text-white ">$qty</div>
1051
                                                        <div class="value-view currency fs-5 fw-bold text-white"
1052
                                                             style="display: none;"> $nf.format(  $value)</div>
1053
                                                    </td>
1054
                                                #end
1055
                                            </tr>
1056
                                            #end
1057
                                        #end
1058
 
1059
                                        #if(!$found)
1060
                                        <tr>
1061
                                            <td class="brand-cell text-center p-0">
1062
                                                <div class="p-3 #getBrandBgColor($brandKey)"
1063
                                                     style="height: 40px; display: flex; align-items: center; justify-content: center;">
1064
                                                    <span class="text-white fw-bold">$brandKey</span>
1065
                                                </div>
1066
                                            </td>
1067
                                            #foreach($i in [0..3])
1068
                                                <td class="text-center align-middle $bgColors.get($i)"
1069
                                                    style="opacity: 0.9;">
1070
                                                    <div class="volume-view fs-5 fw-bold text-white">0</div>
1071
                                                    <div class="value-view currency fs-5 fw-bold text-white"
1072
                                                         style="display: none;">0.00
1073
                                                    </div>
1074
                                                </td>
1075
                                            #end
1076
                                        </tr>
1077
                                        #end
1078
                                    #end
1079
 
1080
                                <tr>
1081
                                    <td class="align-middle bg-dark-light text-center text-white fw-bold "
1082
                                        rowspan="$inventoryGroupedByBrand.size()"
1083
                                        style="width: 60px !important; font-size: 10px !important;">
1084
                                        <div class="brandText">OTHER BRANDS</div>
1085
                                    </td>
1086
                                </tr>
1087
 
1088
                                    #foreach($entry in $inventoryGroupedByBrand.entrySet())
1089
                                        #set($isOtherBrand = true)
1090
                                        #foreach($mandatoryBrand in $mandatoryBrands)
1091
                                            #if($entry.getKey().toLowerCase() == $mandatoryBrand)
1092
                                                #set($isOtherBrand = false)
1093
                                                #break
1094
                                            #end
1095
                                        #end
1096
 
1097
                                        #if($isOtherBrand)
1098
                                        <tr>
1099
                                            <td class="brand-cell text-start p-0">
1100
                                                <div class="p-3 bg-secondary #getBrandBgColor($entry.getKey())"
1101
                                                     style="height: 40px; display: flex; align-items: center; justify-content: start;">
1102
                                                <span class="text-white fw-bold fs-5  "><img
1103
                                                        src="$brandLogos.getOrDefault($entry.getKey(),
1104
                                                            'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
1105
                                                        alt="$entry.getKey() logo"
1106
                                                        class="brand-logo rounded-circle me-3"
1107
                                                        style="width:35px;height:35px">$entry.getKey()</span>
1108
                                                </div>
1109
                                            </td>
1110
                                            #foreach($i in [0..3])
1111
                                                <td class="text-center align-middle pb-4 $bgColors.get($i)"
1112
                                                    style="opacity: 0.9;">
1113
                                                    #set($qty = 0)
1114
                                                    #set($value = 0)
1115
                                                    #foreach($item in $entry.getValue())
1116
                                                        #if($i < $item.getValues().size() && $item.getValues().get($i))
1117
                                                            #set($qty = $math.add($qty, $item.getValues().get($i).getQuantity()))
1118
                                                            #set($itemValue = $math.mul($item.getValues().get($i).getPrice(), $item.getValues().get($i).getQuantity()))
1119
                                                            #set($value = $math.add($value, $itemValue))
1120
                                                        #end
1121
                                                    #end
1122
                                                    <div class="volume-view fs-5 fw-bold text-white">$qty</div>
1123
                                                    <div class="value-view currency fs-5 fw-bold text-white"
1124
                                                         style="display: none;"> $nf.format($value)</div>
1125
                                                </td>
1126
                                            #end
1127
                                        </tr>
1128
                                        #end
1129
                                    #end
1130
                                #else
1131
                                <tr>
1132
                                    <td colspan="6" class="text-center">No inventory data available</td>
1133
                                </tr>
1134
                                #end
1135
                            </tbody>
1136
                        </table>
1137
                    </div>
1138
                    <div class="d-flex justify-content-center mt-5 ">
1139
                        <button type="button" class="btn-sm btn-danger fs-2 fw-bold px-4" data-dismiss="modal">X CLOSE
1140
                        </button>
1141
                    </div>
1142
                </div>
1143
            </div>
1144
    </section>
1145
</div>
1146
</body>
1147
<script>
1148
    var chart;
1149
    const brandColors = {
1150
        'vivo': '#2196F3',
1151
        'oppo': '#006b35',
1152
        'samsung': '#1428A0',
1153
        'realme': '#FFC107',
1154
        'xiaomi': '#FF5722',
1155
        'apple': '#666666',
1156
        'poco': '#FFD403',
1157
        'tecno': '#0064FE',
1158
        'lava': '#ED0F53'
1159
    };
1160
 
1161
 
1162
    function loadMonthDetails(monthIndex) {
1163
        console.log(`Loading details for month: ${monthIndex}`);
1164
        doGetAjaxRequestHandler(`${context}/monthWisePartnerIncome/${monthIndex}?partnerTask=true`, function (response) {
1165
            $('.bootbox.modal .modal-body .bootbox-body').empty();
1166
            $('#partner-income').html(response);
1167
            const $section = $('#ajaxSection');
1168
        });
1169
    }
1170
 
1171
    $(document).on("click", ".pending-income", function () {
1172
        lastMonthCreditIncome("main-content");
1173
    });
1174
 
1175
    function doGetAjaxRequestHandler(url, successCallback) {
1176
        $.ajax({
1177
            url: url,
1178
            type: 'GET',
1179
            success: successCallback,
1180
            error: function (xhr, status, error) {
1181
                console.error("AJAX request failed:", error);
1182
            }
1183
        });
1184
    }
1185
 
1186
    $(function () {
1187
        $('#reportrange').daterangepicker(getRangedDatePicker());
1188
    });
1189
    $(document).ready(function () {
1190
 
1191
        $("#btnVolume").addClass("active");
1192
 
1193
        $("#btnVolume").click(function () {
1194
            $(this).addClass("active");
1195
            $("#btnValue").removeClass("active");
1196
            $(".volume-view").show();
1197
            $(".value-view").hide();
1198
        });
1199
 
1200
        $("#btnValue").click(function () {
1201
            $(this).addClass("active");
1202
            $("#btnVolume").removeClass("active");
1203
            $(".volume-view").hide();
1204
            $(".value-view").show();
1205
        });
1206
    });
1207
    document.querySelectorAll('.brand-btn').forEach(button => {
1208
        button.addEventListener('click', function () {
1209
            const selectedBrand = this.getAttribute('data-brand');
1210
            document.querySelectorAll('.brand-data').forEach(row => {
1211
                row.style.display = (row.getAttribute('data-brand') === selectedBrand || selectedBrand === 'all') ? 'block' : 'none';
1212
            });
1213
        });
1214
    });
1215
 
1216
    function initializeBrandButtons() {
1217
        const brandButtons = document.querySelectorAll('.brand-btn');
1218
 
1219
        brandButtons.forEach(button => {
34898 aman 1220
            const brand = button.dataset.brand;
34813 aman 1221
            const color = brandColors[brand] || '#666';
1222
 
1223
            button.style.border = `2px solid ${color}`;
1224
            button.style.color = color;
1225
            button.style.backgroundColor = '#fff';
1226
        });
1227
 
1228
        brandButtons.forEach(button => {
1229
            button.addEventListener('click', function () {
1230
                const selectedBrand = this.dataset.brand;
1231
 
1232
                brandButtons.forEach(btn => {
1233
                    const brandColor = brandColors[btn.dataset.brand] || '#666';
1234
                    btn.style.backgroundColor = '#fff';
1235
                    btn.style.color = brandColor;
1236
                });
1237
 
1238
                this.style.backgroundColor = brandColors[selectedBrand] || '#666';
1239
                this.style.color = '#fff';
1240
 
1241
                document.querySelectorAll('.brand-data').forEach(row => {
1242
                    row.style.display = row.dataset.brand === selectedBrand ? 'block' : 'none';
1243
                });
1244
            });
1245
        });
1246
        brandButtons[0]?.click();
1247
    }
1248
 
1249
    initializeBrandButtons();
1250
 
1251
</script>
1252
<script>
1253
    document.querySelectorAll('.brand-btn').forEach(button => {
1254
        button.addEventListener('click', function () {
1255
            const brand = this.getAttribute('data-brand');
1256
 
1257
            document.querySelectorAll('.brand-btn').forEach(btn => {
1258
                btn.style.backgroundColor = '';
1259
                btn.style.color = '';
1260
            });
1261
            this.style.backgroundColor = '#006b35';
1262
            this.style.color = 'white';
1263
 
1264
            document.querySelectorAll('.brand-data').forEach(item => {
1265
                item.style.display = item.getAttribute('data-brand') === brand ? 'block' : 'none';
1266
            });
1267
        });
1268
    });
1269
    document.querySelector('.brand-btn')?.click();
1270
</script>
1271
 
1272
##-------------------------------------------------------------------My Earning  chart -----------------------------------------
1273
<script>
1274
    $(document).ready(function () {
1275
        // loadMonthDetails(0);
1276
        const monthData = [
1277
            #foreach( $item in $summaryList )
1278
                {
1279
                    month: "$!item.monthValueMap[$item.monthIndex]",
1280
                    monthIndex: "$item.monthIndex",
1281
                    total: $item.get('totalIncome'),
1282
                    credited: $item.get('creditedIncome'),
1283
                    pending: $item.get('pendingIncome')
1284
                }
1285
                #if($foreach.hasNext),#end
1286
            #end
1287
        ].reverse();
1288
 
1289
        const formatIndianCurrency = (amount) => {
1290
            const rounded = Math.round(amount);
1291
            return rounded.toLocaleString('en-IN');
1292
        };
1293
 
1294
        monthData.forEach(item => {
1295
            item.totalFormatted = formatIndianCurrency(item.total);
1296
            item.creditedFormatted = formatIndianCurrency(item.credited);
1297
            item.pendingFormatted = formatIndianCurrency(item.pending);
1298
        });
1299
        chart = new Chart(document.getElementById('sixMonthChart'), {
1300
            type: 'bar',
1301
            data: {
1302
                labels: monthData.map(d => d.month),
1303
                datasets: [
1304
                    {
1305
                        label: 'Credited Income',
1306
                        data: monthData.map(d => Math.round(d.credited)),
1307
                        backgroundColor: '#aadcb4',
1308
                        borderColor: '#aadcb4',
1309
                        borderWidth: 1,
1310
                        barThickness: 30,
1311
                        hitRadius: 30,
1312
                        order: 1,
1313
                        yAxisID: 'y',
1314
                        hoverBorderWidth: 3,
1315
                        hoverBorderColor: '#aadcb4'
1316
                    },
1317
                    {
1318
                        label: 'Pending Income',
1319
                        data: monthData.map(d => Math.round(d.pending)),
1320
                        backgroundColor: 'rgba(255,0,0,0.7)',
1321
                        borderColor: 'rgba(255,0,0,1)',
1322
                        borderWidth: 1,
1323
                        barThickness: 30,
1324
                        order: 2,
1325
                        hitRadius: 0,
1326
                        yAxisID: 'y',
1327
                        hoverBorderWidth: 3,
1328
                        hoverBorderColor: '#ff0000'
1329
                    },
1330
                    {
1331
                        label: 'Total Income',
1332
                        data: monthData.map(d => Math.round(d.total)),
1333
                        borderColor: '#4bc0c0',
1334
                        backgroundColor: 'rgba(75, 192, 192, 0.1)',
1335
                        borderWidth: 4,
1336
                        type: 'line',
1337
                        order: 3,
1338
                        pointRadius: 6,
1339
                        pointHoverRadius: 0,
1340
                        pointHitRadius: 0,
1341
                        pointBackgroundColor: '#4bc0c0',
1342
                        pointBorderColor: '#ffffff',
1343
                        pointBorderWidth: 2,
1344
                        yAxisID: 'y',
1345
                        tension: 0.3
1346
                    }
1347
 
1348
                ]
1349
            },
1350
            options: {
1351
                responsive: true,
1352
                maintainAspectRatio: true,
1353
                interaction: {
1354
                    mode: 'point',
1355
                    intersect: true,
1356
                },
1357
                plugins: {
1358
                    datalabels: {
1359
                        formatter: function (value) {
1360
                            return Math.round(value).toLocaleString('en-IN');
1361
                        },
1362
                        color: '#fff',
1363
                        backgroundColor: '#333',
1364
                        borderRadius: 4,
1365
                        padding: 4,
34898 aman 1366
                        font: {weight: 'bold'},
34813 aman 1367
                        display: function (context) {
34898 aman 1368
                            const datasetLabel = context.dataset.label;
34813 aman 1369
                            const rawValue = context.dataset.data[context.dataIndex];
34898 aman 1370
                            if (!rawValue || rawValue === 0) return false;
1371
                            if (datasetLabel === 'Credited Income') {
1372
                                const total = context.chart.data.datasets
1373
                                        .find(d => d.label === 'Total Income')
1374
                                        .data[context.dataIndex];
1375
                                if (Math.round(total) === Math.round(rawValue)) return false;
1376
                            }
1377
                            return true;
1378
                        }
34813 aman 1379
                    },
1380
                    tooltip: {
1381
                        mode: 'index',
1382
                        intersect: false,
1383
                        backgroundColor: 'rgba(0, 0, 0, 0.9)',
1384
                        titleColor: '#ffffff',
1385
                        bodyColor: '#ffffff',
1386
                        borderColor: '#4bc0c0',
1387
                        borderWidth: 2,
1388
                        displayColors: true,
1389
                        padding: 12,
1390
                        boxWidth: 15,
1391
                        boxHeight: 15,
1392
                        cornerRadius: 8,
1393
                        usePointStyle: true,
1394
                        bodyFont: {
1395
                            size: 14,
34898 aman 1396
                            weight: 'bold'
34813 aman 1397
                        },
1398
                        titleFont: {
1399
                            size: 16,
1400
                            weight: 'bold'
1401
                        },
1402
                        footerFont: {
1403
                            size: 12,
34898 aman 1404
                            weight: 'bold'
34813 aman 1405
                        },
1406
                        callbacks: {
1407
                            title: function (context) {
1408
                                return `Month: ${context[0].label}`;
1409
                            },
1410
                            label: function (context) {
1411
                                const value = context.parsed.y;
1412
                                const roundedValue = Math.round(value);
1413
                                const formattedValue = roundedValue.toLocaleString('en-IN');
1414
 
1415
                                const label = context.dataset.label;
1416
                                return `${label}: ${formattedValue}`;
1417
                            },
1418
                            footer: function (tooltipItems) {
1419
                                const credited = tooltipItems.find(item => item.dataset.label === 'Credited Income')?.parsed.y || 0;
1420
                                const total = tooltipItems.find(item => item.dataset.label === 'Total Income')?.parsed.y || 0;
1421
                                if (total > 0) {
1422
                                    const percentage = ((credited / total) * 100).toFixed(1);
1423
                                    return `Credited: ${percentage}% of total income`;
1424
                                }
1425
                                return '';
1426
                            },
1427
                            labelColor: function (context) {
1428
                                return {
1429
                                    borderColor: 'transparent',
1430
                                    backgroundColor: context.dataset.borderColor,
1431
                                    borderRadius: 4,
1432
                                    borderWidth: 2
1433
                                };
1434
                            },
1435
                            labelTextColor: function (context) {
34898 aman 1436
                                return '#ffffff';
34813 aman 1437
                            }
1438
                        }
1439
                    },
1440
                    legend: {
1441
                        display: true,
1442
                        position: 'top',
1443
                        labels: {
1444
                            usePointStyle: true,
1445
                            padding: 20,
1446
                            font: {
1447
                                size: 14,
1448
                                weight: 'bold'
1449
                            },
1450
                            color: '#333',
1451
                            boxWidth: 15,
1452
                            boxHeight: 15
1453
                        }
1454
                    }
1455
                },
1456
                scales: {
1457
                    x: {
1458
 
1459
                        ticks: {
1460
 
1461
                            autoSkip: false,
1462
                            font: {
1463
                                size: 12,
1464
                                weight: 'bold'
1465
                            },
1466
                            color: '#333',
1467
                            padding: 10
1468
                        }
1469
                    },
1470
                    y: {
1471
                        type: 'linear',
1472
                        display: true,
1473
                        position: 'left',
1474
                        stacked: false,
1475
                        beginAtZero: true,
1476
                        grid: {
1477
                            color: 'rgba(0, 0, 0, 0.1)',
1478
                            lineWidth: 1
1479
                        },
1480
                        ticks: {
1481
                            callback: function (value) {
1482
                                // Round the value first, then format
1483
                                const roundedValue = Math.round(value);
1484
                                return roundedValue.toLocaleString('en-IN');
1485
                            },
1486
                            font: {
1487
                                size: 12,
1488
                                weight: 'bold'
1489
                            },
1490
                            color: '#333'
1491
                        }
1492
                    }
1493
                },
1494
                elements: {
1495
                    bar: {
1496
                        borderRadius: 4,
1497
                        categoryPercentage: 0.8,
1498
                        barPercentage: 0.9
1499
                    },
1500
                    line: {
1501
                        borderJoinStyle: 'round'
1502
                    },
1503
                    point: {
1504
                        hoverBorderWidth: 1
1505
                    }
1506
                },
1507
                onHover: function (event, elements) {
1508
                    event.native.target.style.cursor = elements.length > 0 ? 'pointer' : 'default';
1509
                },
1510
                onClick: function (event, elements) {
1511
                    if (elements && elements.length > 0) {
1512
                        const clickedIndex = elements[0].index;
1513
                        const clickedData = monthData[clickedIndex];
1514
 
1515
                        event.chart.canvas.style.cursor = 'wait';
1516
 
1517
                        console.log(`Loading details for month: ${clickedData.monthIndex} (${clickedData.month})`);
1518
 
1519
                        loadMonthDetails(clickedData.monthIndex);
1520
 
1521
                        setTimeout(() => {
1522
                            document.getElementById('partner-income').scrollIntoView({
1523
                                behavior: 'smooth',
1524
                                block: 'start'
1525
                            });
1526
                            event.chart.canvas.style.cursor = 'pointer';
1527
                        }, 300);
1528
                    }
1529
                }
1530
            }
1531
        });
1532
    })
1533
</script>
1534
##-----------------------------------------------------------------------Stagged CHart ---------------------------------
1535
<script>
1536
    $(document).ready(function () {
1537
        const MAJOR_BRANDS = ['vivo', 'samsung', 'oppo', 'realme', 'xiaomi'];
1538
 
1539
        const marketSegments = [];
1540
        const otherMarketData = {
1541
            brand: "Others",
1542
            marketShare: 0,
1543
            color: '#6b7280'
1544
        };
1545
 
1546
        const stockSegments = [];
1547
        const otherStockData = {
1548
            brand: "Others",
1549
            quantity: 0,
1550
            value: 0
1551
        };
1552
 
1553
        #foreach($entry in $marketShareData)
1554
            var marketBrandName = '$entry.Brand'.toLowerCase();
1555
            if (MAJOR_BRANDS.includes(marketBrandName)) {
1556
                marketSegments.push({
1557
                    brand: marketBrandName,
1558
                    marketShare: ${entry.MarketShare.replace('%', '')},
1559
                    color: '$entry.BgColor'
1560
                });
1561
            } else {
1562
                otherMarketData.marketShare += ${entry.MarketShare.replace('%', '')};
1563
            }
1564
        #end
1565
 
1566
        #foreach($brandStockPrice in $brandStockPrices)
1567
            var stockBrandName = "$brandStockPrice.getBrand()".toLowerCase();
1568
            if (MAJOR_BRANDS.includes(stockBrandName)) {
1569
                stockSegments.push({
1570
                    brand: stockBrandName,
1571
                    quantity: $brandStockPrice.getTotalQty(),
1572
                    value: $brandStockPrice.getTotalValue()
1573
                });
1574
            } else {
1575
                otherStockData.quantity += $brandStockPrice.getTotalQty();
1576
                otherStockData.value += $brandStockPrice.getTotalValue();
1577
            }
1578
        #end
1579
 
1580
        if (otherMarketData.marketShare > 0) {
1581
            marketSegments.push(otherMarketData);
1582
        }
1583
        if (otherStockData.quantity > 0) {
1584
            stockSegments.push(otherStockData);
1585
        }
1586
 
1587
        const combinedSegments = [];
1588
        const allBrands = [...new Set([
1589
            ...marketSegments.map(d => d.brand),
1590
            ...stockSegments.map(d => d.brand)
1591
        ])];
1592
 
1593
        allBrands.forEach(brand => {
1594
            const marketInfo = marketSegments.find(m => m.brand === brand) || {};
1595
            const stockInfo = stockSegments.find(s => s.brand === brand) || {};
1596
 
1597
            combinedSegments.push({
1598
                brand: brand.charAt(0).toUpperCase() + brand.slice(1),
1599
                marketShare: marketInfo.marketShare || 0,
1600
                stockQuantity: stockInfo.quantity || 0,
1601
                stockValue: stockInfo.value || 0,
1602
                color: marketInfo.color || brandColors[brand] || '#95a5a6'
1603
            });
1604
        });
1605
 
1606
        const totalStockQuantity = stockSegments.reduce((sum, b) => sum + b.quantity, 0);
1607
 
1608
        const ctx4 = document.getElementById('combinedStackedChart').getContext('2d');
1609
        const staggedChart = new Chart(ctx4, {
1610
            type: 'bar',
1611
            data: {
1612
                labels: combinedSegments.map(item => item.brand),
1613
                datasets: [
1614
                    {
1615
                        label: 'Brand Market Share (%)',
1616
                        data: combinedSegments.map(item => item.marketShare),
1617
                        backgroundColor: combinedSegments.map(item => item.color + '80'),
1618
                        borderColor: combinedSegments.map(item => item.color),
1619
                        borderWidth: 2
1620
                    },
1621
                    {
1622
                        label: 'Your Brand Share (%)',
1623
                        data: combinedSegments.map(item => ((item.stockQuantity / totalStockQuantity) * 100).toFixed(1)),
1624
                        backgroundColor: combinedSegments.map(item => item.color + '40'),
1625
                        borderColor: combinedSegments.map(item => item.color),
1626
                        borderWidth: 1
1627
                    }
1628
                ]
1629
            },
1630
            options: {
1631
                responsive: true,
1632
                scales: {
1633
                    x: {
1634
                        stacked: true
1635
                    },
1636
                    y: {
1637
                        stacked: true,
1638
                        beginAtZero: true,
1639
                        title: {
1640
                            display: true,
1641
                            text: 'Percentage (%)'
1642
                        }
1643
                    }
1644
                },
1645
                plugins: {
1646
                    tooltip: {
1647
                        callbacks: {
1648
                            label: function (context) {
1649
                                const segment = combinedSegments[context.dataIndex];
1650
                                if (context.datasetIndex === 0) {
1651
                                    return `Market Share: ${segment.marketShare}%`;
1652
                                } else {
1653
                                    return [
1654
                                        `Stock Quantity: ${segment.stockQuantity}`,
1655
                                        `Percentage: ${((segment.stockQuantity / totalStockQuantity) * 100).toFixed(1)}%`
1656
                                    ];
1657
                                }
1658
                            }
1659
                        }
1660
                    }
1661
                }
1662
            }
1663
        });
1664
    });
1665
</script>