Subversion Repositories SmartDukaan

Rev

Rev 34898 | Go to most recent revision | Details | 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 {
127
        transform: translateX(5px) scale(1.02); /* Scale instead of shift */
128
        z-index: 10; /* Bring hovered items to front */
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
    /* Only make specific elements bold when needed */
347
    .fw-bold {
348
        font-weight: bold !important;
349
    }
350
 
351
    .btn {
352
        font-weight: normal;
353
    }
354
 
355
    .payment-circle {
356
        width: 200px;
357
        height: 200px;
358
        border: 25px solid #e0dcdc;
359
        border-radius: 50%;
360
        display: flex;
361
        align-items: center;
362
        justify-content: center;
363
        transition: transform 0.3s ease;
364
    }
365
 
366
    .payment-content {
367
        text-align: center;
368
        color: white;
369
        padding: 20px;
370
    }
371
 
372
    .payment-amount {
373
        font-size: 18px;
374
        font-weight: 700;
375
        margin-bottom: 10px;
376
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
377
    }
378
 
379
    .payment-label {
380
        font-size: 18px;
381
        line-height: 1.3;
382
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
383
    }
384
 
385
 
386
    .table-border td {
387
        border: 1px solid black !important;
388
    }
389
 
390
    .table-border thead {
391
        border: 1px solid black;
392
    }
393
 
394
    .p-0 {
395
        padding: 0 !important;
396
    }
397
</style>
398
<body style="background-color: rgb(247, 247, 247);zoom: 100%!important;">
399
<div style="overflow-y:auto;max-height: 120vh; ">
400
    <section id="ajaxSection" class="rounded"
401
             style="max-height: 120vh; overflow-y: auto;">
402
        <!-- Header Section -->
403
        <div class="w-full bg-danger h-25 py-3 mb-4">
404
            <h1 class="text-center text-white " style="font-size: 30px !important; font-weight: 800">Pending
405
                Tasks</h1>
406
        </div>
407
        <div class="container">
408
            ##-----------------------------------------------GRN Pending -----------------------------------------------------
409
            <div class="container-fluid p-4">
410
                #if($grnPendingOrders.entrySet().size()>0)
411
                    <!-- Section Header -->
412
                    <div class="row justify-content-center">
413
                        <div class="col-10">
414
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
415
                                <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">GRN Pending</h1>
416
                            </div>
417
                        </div>
418
                    </div>
419
 
420
                    <!-- Responsive Table -->
421
                    <div class="table-responsive rounded-3 shadow p-5">
422
                        <table id="grnTable" class="table table-bordered mb-0 table-border" style="width:100%">
423
 
424
                            <!-- MANDATORY BRANDS SECTION -->
425
                            <thead>
426
                            <tr class="bg-danger text-white">
427
                                <th class="ps-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center"
428
                                    style="padding: 10px !important;">BRANDS
429
                                </th>
430
                                <th class="fs-5 fw-bold text-uppercase bg-danger text-white text-center"
431
                                    style="padding: 10px !important;">QUANTITY
432
                                </th>
433
                                <th class="pe-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center"
434
                                    style="padding: 10px !important;">VALUE
435
                                </th>
436
                            </tr>
437
                            </thead>
438
                            <tbody>
439
                                ## Define mandatory brands
440
                                #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
441
 
442
                                ## Process mandatory brands first
443
                                #foreach($entry in $grnPendingOrders.entrySet())
444
                                    #set($brand = $entry.key)
445
                                    #set($details = $entry.value)
446
                                    ##                                #if($mandatoryBrands.contains($brand))
447
                                <tr class="">
448
                                    <td class="ps-4 text-center p-0">
449
                                        <div class="d-flex align-items-center justify-content-center">
450
                                            <div class="row align-items-center" style="width: 200px;">
451
                                                <div class="col-auto">
452
                                                    <img src="$brandLogos.getOrDefault($brand,
453
                                                        'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
454
                                                         alt="$brand logo"
455
                                                         class="brand-logo rounded-circle"
456
                                                         style="width:35px;height:35px">
457
                                                </div>
458
                                                <div class="col text-start">
459
                                                    <span class="fw-bold fs-5">$brand</span>
460
                                                </div>
461
                                            </div>
462
                                        </div>
463
                                    </td>
464
                                    <td class="text-center align-middle fs-5 fw-semibold p-0">
465
                                        $details.quantity
466
                                    </td>
467
                                    <td class="pe-4 text-center align-middle fs-5 fw-semibold currency p-0 ">
468
                                        $nf.format($details.mrp)
469
                                    </td>
470
                                </tr>
471
                                #end
472
                                ##                            #end
473
                            </tbody>
474
                            ##
475
                            ##
476
                        </table>
477
                    </div>
478
                #end
479
            </div>
480
 
481
            ##-----------------------------------------------Unbilled Activated -----------------------------------------------------
482
 
483
            <div class="container-fluid p-4">
484
                #if($unbilledActivated.entrySet().size()>0)
485
                    <!-- Section Header -->
486
                    <div class="row justify-content-center">
487
                        <div class="col-10">
488
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
489
                                <h1 class="text-white text-center mb-0 py-2 fw-bold fs-8">Pending Billing</h1>
490
                            </div>
491
                        </div>
492
                    </div>
493
 
494
                    <!-- Responsive Table -->
495
                    <div class="table-responsive rounded-3 shadow p-5">
496
                        <table id="unbilledTable" class="table table-bordered mb-0 table-border" style="width:100%">
497
 
498
                            <!-- MANDATORY BRANDS SECTION -->
499
                            <thead>
500
                            <tr class="bg-danger text-white">
501
                                <th class="ps-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
502
                                    style="padding: 10px !important;">BRANDS
503
                                </th>
504
                                <th class="fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
505
                                    style="padding: 10px !important;">QUANTITY
506
                                </th>
507
                                <th class="pe-4 fs-5 fw-bold text-uppercase bg-danger text-white text-center p-0"
508
                                    style="padding: 10px !important;">VALUE
509
                                </th>
510
                            </tr>
511
                            </thead>
512
                            <tbody>
513
                                ## Define mandatory brands
514
                                #set($mandatoryBrands = ["Vivo", "Realme", "Oppo", "Samsung"])
515
 
516
                                ## Process mandatory brands first
517
                                #foreach($entry in $unbilledActivated.entrySet())
518
                                    #set($brand = $entry.key)
519
                                    #set($details = $entry.value)
520
                                    ##                                #if($mandatoryBrands.contains($brand))
521
                                <tr>
522
                                    <td class="ps-4 text-center p-0">
523
                                        <div class="d-flex align-items-center justify-content-center">
524
                                            <div class="row align-items-center" style="width: 200px;">
525
                                                <div class="col-auto">
526
                                                    <img src="$brandLogos.getOrDefault($brand,
527
                                                        'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
528
                                                         alt="$brand logo"
529
                                                         class="brand-logo rounded-circle"
530
                                                         style="width:35px;height:35px">
531
                                                </div>
532
                                                <div class="col text-start">
533
                                                    <span class="fw-bold fs-5">$brand</span>
534
                                                </div>
535
                                            </div>
536
                                        </div>
537
                                    </td>
538
                                    <td class="text-center align-middle fs-5 fw-semibold   p-0">
539
                                        $details.quantity
540
                                    </td>
541
                                    <td class="pe-4 text-center align-middle p-0 currency fw-semibold fs-5">
542
                                        $nf.format( $details.mtd)
543
                                    </td>
544
                                </tr>
545
                                #end
546
                            </tbody>
547
                        </table>
548
                    </div>
549
                #end
550
            </div>
551
 
552
 
553
            ##-----------------------------------------------Loan Amount -----------------------------------------------------
554
 
555
            <div class="container-fluid p-4">
556
                <!-- Section Header -->
557
                <div class="row mb-5 justify-content-center">
558
                    <div class="col-10">
559
                        <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
560
                            <h1 class="text-white text-center mb-0  fw-bold py-2 fs-8">Loan </h1>
561
                        </div>
562
                    </div>
563
                </div>
564
                <div class="row justify-content-center">
565
                    <!-- Default Payment -->
566
                    <div class="col-12 col-md-4 text-center ">
567
                        <div class="payment-circle shadow-lg shadow-dark mx-auto "
568
                             style="background-color: #cc0000 !important;">
569
                            <div class="payment-content">
570
                                <div class="payment-amount currency"> $nf.format( $totalDefaultAmount) </div>
571
 
572
                            </div>
573
                        </div>
574
                        <h1 class="payment-label fw-bold mt-4" style="font-weight: 400 !important;">Default Payment<br>(Above
575
                            30 days)</h1>
576
                    </div>
577
 
578
                    <!-- Due Payment -->
579
                    <div class="col-12 col-md-4 text-center">
580
                        <div class="payment-circle shadow-lg mx-auto" style="background-color: #FF9433 !important;">
581
                            <div class="payment-content">
582
                                <div class="payment-amount currency">  $nf.format($totalOverdueAmount) </div>
583
                            </div>
584
                        </div>
585
                        <h1 class="payment-label fw-bold mt-4"
586
                            style="font-size: 20px !important;  font-weight: 400 !important;">Due Payment<br>(Above 15
587
                            Days)</h1>
588
 
589
                    </div>
590
                    <!-- Other Payment -->
591
                    <div class="col-12 col-md-4 text-center">
592
                        <div class="payment-circle shadow-lg mx-auto " style="background-color: #00B050 !important;">
593
                            <div class="payment-content">
594
                                <div class="payment-amount currency">  $nf.format($totalDueAmount) </div>
595
                            </div>
596
                        </div>
597
                        <h1 class="payment-label fw-bold mt-4"
598
                            style="font-size: 20px !important; font-weight: 400 !important;">Other Loan<br>(Within 15
599
                            Days)</h1>
600
                    </div>
601
 
602
 
603
                    <!-- Total Loan Value -->
604
                    <div class="mt-4 mx-5 " style="margin-top: 6rem !important;">
605
                        <h1 class="text-center " style="font-size:30px !important;font-weight:300 !important;">Total
606
                            Loan Value :
607
                            <span class="currency fw-bold"> $nf.format( $totalLoan )</span>
608
                        </h1>
609
                    </div>
610
                </div>
611
            </div>
612
        </div>
613
 
614
        ## Add this chart section after the loan circles
615
        <div class="w-full bg-danger h-25 py-3 my-4">
616
            <h1 class="text-center text-white fw-bold" style="font-size: 30px !important; font-weight: 800">My Business
617
                Analysis</h1>
618
        </div>
619
        <div class="container-fluid p-5 mt-5">
620
 
621
            <!-- Chart Section Header -->
622
            <div class="row mb-1 my-4 mx-3 justify-content-center">
623
                <div class="col-10">
624
                    <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
625
                        <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">My Earning </h1>
626
                    </div>
627
                </div>
628
            </div>
629
 
630
            <!-- Chart Container -->
631
            <div class="container mt-4">
632
                <div class="chart-wrapper card shadow-lg rounded-5 p-2">
633
                    <span class="text-danger fs-3 fw-bold text-end">** Click on the bar to see the details</span>
634
 
635
                    <div class="chart-content ">
636
                        <div class="chart-container">
637
                            <canvas id="sixMonthChart"></canvas>
638
                        </div>
639
                        <div id="partner-income" class="partner-income-container"></div>
640
                    </div>
641
                </div>
642
            </div>
643
 
644
        </div>
645
        ##        ----------------------------------------anyalysis---------------------------=//
646
        #set($marketShareData = [
647
        {"Brand": "Vivo", "MarketShare": "20%", "Quarter": "Q1 2025", "BgColor": "#2196F3", "Rank": "1"},
648
        {"Brand": "Samsung", "MarketShare": "18%", "Quarter": "Q1 2025", "BgColor": "#1428A0", "Rank": "2"},
649
        {"Brand": "Xiaomi", "MarketShare": "13%", "Quarter": "Q1 2025", "BgColor": "#FF6900", "Rank": "3"},
650
        {"Brand": "OPPO", "MarketShare": "12%", "Quarter": "Q1 2025", "BgColor": "#006B33", "Rank": "4"},
651
        {"Brand": "realme", "MarketShare": "11%", "Quarter": "Q1 2025", "BgColor": "#FFC915", "Rank": "5"},
652
        {"Brand": "Others", "MarketShare": "26%", "Quarter": "Q1 2025", "BgColor": "#6b7280", "Rank": "-"}
653
        ])
654
 
655
        <div class="container-fluid p-5">
656
            <!-- Chart Section Header -->
657
            <div class="row mb-1 my-4 mx-3 justify-content-center">
658
                <div class="col-10">
659
                    <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
660
                        <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">Brand Analysis </h1>
661
                    </div>
662
                </div>
663
            </div>
664
            ##        ----------------------------------------stagged chart ------------------------------------------
665
            <div class="container d-flex ">
666
                <div class="p-5" style=" height: 350px !important;width: 650px !important;">
667
                    <div class="chart-title fs-2 text-center fw-bold">Brands Share Analysis (QTY)</div>
668
                    <canvas id="combinedStackedChart"></canvas>
669
                </div>
670
                <div class="" style="width: 400px!important;">
671
                    <div class="right-panel">
672
                        <h4 class="mb-4">Quantity Analysis</h4>
673
 
674
                        <div class="brand-analysis-container">
675
                            <div class="table-responsive">
676
                                <table class="table table-striped table-hover">
677
                                    <thead class="table-light table-bordered">
678
                                    <tr>
679
                                        <th scope="col">Brand Name</th>
680
                                        <th scope="col">Available Models</th>
681
                                        <th scope="col">Required Models</th>
682
                                        <th scope="col" class="text-center">Status</th>
683
                                    </tr>
684
                                    </thead>
685
                                    <tbody class="table-bordered">
686
                                        #foreach($brandName in $targetBrands)
687
                                            #set($analysis = $brandAnalysisData.get($brandName))
688
                                        <tr>
689
                                            <td>
690
                                                <strong class="brand-name">${brandName}</strong>
691
                                            </td>
692
                                            <td>
693
                                                <span class="quantity-value">${analysis.get('availableQuantity')}</span>
694
                                            </td>
695
                                            <td>
696
                                                <span class="quantity-value">${analysis.get('requiredQuantity')}</span>
697
                                            </td>
698
                                            <td class="text-center">
699
                        <span class="badge #if($analysis.get('isOK'))bg-success#else bg-danger#end">
700
                            ${analysis.get('status')}
701
                        </span>
702
                                            </td>
703
                                        </tr>
704
                                        #end
705
                                    </tbody>
706
                                </table>
707
                            </div>
708
                        </div>
709
                    </div>
710
                </div>
711
            </div>
712
 
713
 
714
            ##        -----------------------------------------------Fast Selling & HID model ------------------------------------------------
715
            <div class="container-fluid py-3">
716
                <div class="card mb-4 p-5 ">
717
                    <div class="row  justify-content-center ">
718
                        <div class="col-10">
719
                            <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
720
                                <h3 class="text-white text-center mb-0  fw-bold py-2 fs-8">Fast Selling Models &
721
                                    HID </h3>
722
                            </div>
723
                        </div>
724
                    </div>
725
 
726
                    <div class="card-body card shadow-lg rounded-5 p-3">
727
                        <!-- Dynamic Brand Filters -->
728
                        <div class="d-flex flex-wrap justify-content-center gap-2 p-1 border-bottom fs-5">
729
                            #foreach($brand in $brands)
730
                                <button class="brand-btn" data-brand="$brand.toLowerCase()"
731
                                >
732
                                    $brand
733
                                </button>
734
                            #end
735
                        </div>
736
 
737
 
738
                        <div class="card-header text-center fw-bold ">
739
                            <h4>HID</h4>
740
                        </div>
741
 
742
 
743
                        <!-- Table Header -->
744
 
745
                        <div class="row mx-0 mt-4">
746
                            <div class="col-3 text-center">
747
                                <div class="p-1 py-3 rounded-top" style="background: #555; color: white;">
748
                                    <strong class="fs-4  fw-bold">Model </strong>
749
                                </div>
750
                            </div>
751
                            <div class="col-3 text-center">
752
                                <div class="p-1 py-3 rounded-top" style="background: #d82c2c; color: white;">
753
                                    <strong class="fs-4  fw-bold">Suggested Qty</strong>
754
                                </div>
755
                            </div>
756
                            <div class="col-3 text-center">
757
                                <div class="p-1 py-3 rounded-top" style="background: #555; color: white;">
758
                                    <strong class="fw-bold" style="font-size: 1.3rem !important;">My Stock + Pending
759
                                        Indent</strong>
760
                                </div>
761
                            </div>
762
                            <div class="col-3 text-center">
763
                                <div class="p-1 py-3 rounded-top" style="background: #d82c2c; color: white;">
764
                                    <strong class="fs-4 fw-bold">Remarks</strong>
765
                                </div>
766
                            </div>
767
                        </div>
768
 
769
                        <!-- Data Rows -->
770
                        #foreach($brand in $brands)
771
                            #if($hidAllocationModelBrandMap.containsKey($brand) && !$hidAllocationModelBrandMap.get($brand).isEmpty())
772
                                #foreach($model in $hidAllocationModelBrandMap.get($brand))
773
                                    <div class="brand-data" data-brand="$brand.toLowerCase()">
774
                                        <div class="row mx-0">
775
                                            <div class="col-3 text-center">
776
                                                <div class="p-4 border border-light fs-5 trim"
777
                                                     style="background: #444; color: white;">
778
                                                    $model.getModelNumber()
779
                                                </div>
780
                                            </div>
781
                                            <div class="col-3 text-center">
782
                                                <div class="p-4 border border-light fs-5"
783
                                                     style="background: #b30606; color: white;">
784
                                                    $model.getHidAllocation()
785
                                                </div>
786
                                            </div>
787
                                            <div class="col-3 text-center">
788
                                                <div class="p-4 border border-light fs-5"
789
                                                     style="background: #444; color: white;">
790
                                                    <strong>$model.getAvailableStock()</strong>
791
                                                </div>
792
                                            </div>
793
                                            <div class="col-3 text-center">
794
 
795
                                                <div class="p-4 border border-light fs-5"
796
                                                     style="background: #b30606; color: white;">
797
                                                    <strong>#if($model.getAvailableStock() == 0)
798
                                                        <span class="fw-bold  p-4 w-full text-warning">Urgently Required</span>
799
                                                    #elseif($model.getAvailableStock() < $model.getHidAllocation())
800
                                                        <span class="fw-bold  p-4 text-info ">Need to Order</span>
801
                                                    #else
802
                                                        <span class=" fw-bold  p-4 text-success"
803
                                                              style="color: rgb(61 251 163) !important;">Stock OK</span>
804
                                                    #end</strong>
805
                                                </div>
806
                                            </div>
807
                                        </div>
808
                                    </div>
809
                                #end
810
                            #else
811
                                <div class="brand-data" data-brand="$brand.toLowerCase()">
812
                                    <div class="row mx-0">
813
                                        <div class="col-12 text-center p-4 fs-5" style="background: #f8f9fa;">
814
                                            No Data Available
815
                                        </div>
816
                                    </div>
817
                                </div>
818
                            #end
819
                        #end
820
 
821
 
822
                        ##                    -----------------------------------Fast Selling Modal-------------------------------
823
                        <div class="card-header text-center fw-bold ">
824
                            <h4> Fast Selling Model</h4>
825
                        </div>
826
 
827
                        #if($brandwiseFastmoving && $brandwiseFastmoving.entrySet().size() > 0)
828
                            #foreach($brandEntry in $brandwiseFastmoving.entrySet())
829
                                #foreach($model in $brandEntry.value)
830
                                    <div class="brand-data col-12" data-brand="$brandEntry.key.toLowerCase()">
831
                                        <div class="row mx-0  ">
832
                                            <div class="col-3   text-center   ">
833
                                                <div class="p-4 border border-light fs-5 text-truncate"
834
                                                     style="background: #444; color: white;">
835
                                                    <strong>$model.modelNumber</strong>
836
                                                </div>
837
                                            </div>
838
 
839
                                            <div class="col-3   text-center  ">
840
                                                <div class="p-4 border border-light fs-5"
841
                                                     style="background: #b30606; color: white;">
842
                                                    <strong>   #set($suggestedQty =  2)
843
 
844
                                            $suggestedQty
845
                                                    </strong>
846
                                                </div>
847
                                            </div>
848
 
849
                                            <div class="col-3   text-center   ">
850
                                                <div class="p-4 border border-light fs-5 "
851
                                                     style="background: #444; color: white;">
852
                                                    <strong> $model.partnerCurrentQty
853
                                                        #if($processingOrderCatalogQtyMap.get($model.getCatalogId()))
854
                                                            +  $processingOrderCatalogQtyMap.get($model.getCatalogId())
855
                                                        #end
856
                                                    </strong>
857
                                                </div>
858
                                            </div>
859
                                            #set($processingQty = $processingOrderCatalogQtyMap.get($model.getCatalogId()))
860
                                            #if(!$processingQty)
861
                                                #set($processingQty = 0)
862
                                            #end
863
                                            #set($totalQty = $model.partnerCurrentQty + $processingQty)
864
 
865
                                            <div class="col-3   text-center   ">
866
                                                <div class="p-4 border border-light fs-5"
867
                                                     style="background: #b30606; color: white;">
868
                                                    <strong>#if($totalQty == 0)
869
                                                        <span class="fw-bold  p-4 w-full text-warning">Urgently Required</span>
870
                                                    #elseif($totalQty < 2)
871
                                                        <span class="fw-bold  p-4 text-info ">Need to Order</span>
872
                                                    #else
873
                                                        <span class=" fw-bold  p-4 text-success"
874
                                                              style="color: rgb(61 251 163) !important;">Stock OK</span>
875
                                                    #end</strong>
876
                                                </div>
877
                                            </div>
878
                                        </div>
879
                                    </div>
880
                                #end
881
                            #end
882
                        #else
883
                            <div class="brand-data">
884
                                <div class="row mx-0">
885
                                    <div class="col-12 text-center p-4 fs-5" style="background: #f8f9fa;">
886
                                        No Data Available
887
                                    </div>
888
                                </div>
889
                            </div>
890
                        #end
891
 
892
                    </div>
893
 
894
 
895
                </div>
896
            </div>
897
            ##        -----------------------------------------------My Stock ------------------------------------------------
898
            <div class="row mb-1 my-4 justify-content-center">
899
                <div class="col-10">
900
                    <div class=" bg-dark-light rounded-3 p-3 shadow rounded-corner">
901
                        <h1 class="text-center mb-0 fw-bold py-2 text-white fs-8">My Stock</h1>
902
                    </div>
903
                </div>
904
            </div>
905
 
906
            <div class="row px-5" style="margin-left: 10rem !important;">
907
                <!-- MANDATORY BRANDS COLUMN -->
908
                <div class="col-md-6">
909
                    <div class="category-header mandatory-header">MANDATORY BRANDS</div>
910
 
911
                    #foreach($brandStockPrice in $brandStockPrices)
912
                        #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
913
                        #if($mandatoryBrands.contains($brandStockPrice.getBrand()))
914
                            <div class="brand-item">
915
                                <!-- Brand Logo Circle -->
916
                                <div class="position-relative" style="z-index: 10">
917
                                    <img src="${brandStockPrice.getBrandUrl()}"
918
                                         class="brand-circle img-fluid rounded-circle shadow border border-danger"
919
                                         data-stockbrand="$brandStockPrice.getBrand()"
920
                                         alt="$brandStockPrice.getBrand()">
921
                                </div>
922
 
923
                                <!-- Ribbon with Stock Info -->
924
                                <div class="stock-ribbon mandatory-ribbon ms-n3  position-absolute curve ">
925
                                    <div class="d-flex d-flex  mb-1">
926
                                        <span class="fw-bold text-start fs-5">QTY:  </span>
927
                                        <span class="fw-bold text-start fs-5">$brandStockPrice.getTotalQty()</span>
928
                                    </div>
929
                                    <div class="d-flex ">
930
                                        <span class="fw-bold text-start fs-5">Value:  </span>
931
                                        <span class="currency fw-bold text-start fs-5">  $nf.format( $brandStockPrice.getTotalValue())</span>
932
                                    </div>
933
 
934
                                    #if($brandStockPrice.getAgedValue() > 0)
935
                                        <div class="aged-stock mt-2 pt-2 border-top border-light border-opacity-25">
936
                                            <div class="d-flex justify-content-between">
937
                                                <span>Focus Stock:</span>
938
                                                <span>
939
                                        <span class="currency">  $nf.format($brandStockPrice.getAgedValue()) </span>/
940
                                                    $brandStockPrice.getAgedQty()
941
                                    </span>
942
                                            </div>
943
                                        </div>
944
                                    #end
945
                                </div>
946
                            </div>
947
                        #end
948
                    #end
949
                </div>
950
 
951
                <!-- OTHER BRANDS COLUMN -->
952
                <div class="col-md-6">
953
                    <div class="category-header other-header">OTHER BRANDS</div>
954
                    #set($mandatoryBrands = ["Vivo", "Oppo", "Samsung", "Realme"])
955
 
956
                    #foreach($brandStockPrice in $brandStockPrices)
957
                        #if(!$mandatoryBrands.contains($brandStockPrice.getBrand()))
958
                            <div class="brand-item">
959
                                <!-- Brand Logo Circle -->
960
                                <div class="position-relative " style="z-index: 10">
961
                                    <img src="${brandStockPrice.getBrandUrl()}"
962
                                         class="brand-circle img-fluid rounded-circle shadow border border-dark"
963
                                         data-stockbrand="$brandStockPrice.getBrand()"
964
                                         alt="$brandStockPrice.getBrand()">
965
                                </div>
966
 
967
                                <!-- Ribbon with Stock Info -->
968
                                <div class="stock-ribbon other-ribbon ms-n3 position-absolute  curve">
969
                                    <div class="d-flex d-flex  mb-1">
970
                                        <span class="fw-bold text-start fs-5">QTY:  </span>
971
                                        <span class="fw-bold text-start fs-5">$brandStockPrice.getTotalQty()</span>
972
                                    </div>
973
                                    <div class="d-flex ">
974
                                        <span class="fw-bold text-start fs-5">Value:  </span>
975
                                        <span class="currency fw-bold text-start fs-5">  $nf.format($brandStockPrice.getTotalValue())</span>
976
                                    </div>
977
 
978
                                    #if($brandStockPrice.getAgedValue() > 0)
979
                                        <div class="aged-stock mt-2 pt-2 border-top border-light border-opacity-25">
980
                                            <div class="d-flex justify-content-between">
981
                                                <span>Focus Stock:</span>
982
                                                <span>
983
                                        <span class="currency"> $nf.format($brandStockPrice.getAgedValue())</span>/
984
                                                    $brandStockPrice.getAgedQty()
985
                                    </span>
986
                                            </div>
987
                                        </div>
988
                                    #end
989
                                </div>
990
                            </div>
991
                        #end
992
                    #end
993
                </div>
994
            </div>
995
 
996
            ##        ------------------------------------my stock ageing---------------------------------
997
 
998
            <div class="card shadow-lg rounded-3">
999
                <div class="row mb-1 my-4 justify-content-center">
1000
                    <div class="col-10">
1001
                        <div class="bg-dark-light rounded-3 p-3 shadow rounded-corner">
1002
                            <h1 class="text-white text-center mb-0 fw-bold py-2 fs-8">My Stock Ageing</h1>
1003
                        </div>
1004
                    </div>
1005
                </div>
1006
                <div class="card-body">
1007
                    <!-- Controls for Volume/Value toggle -->
1008
                    <div class="row mb-4">
1009
                        <div class="col-md-4">
1010
                            <div class="btn-group" role="group">
1011
                                <button type="button" class="btn btn-danger rounded-pill px-4 me-2 fs-5" id="btnVolume">
1012
                                    Volume
1013
                                </button>
1014
                                <button type="button" class="btn btn-danger rounded-pill px-4 fs-5" id="btnValue">Value
1015
                                </button>
1016
                            </div>
1017
                        </div>
1018
                    </div>
1019
 
1020
                    <!-- Main stock aging grid -->
1021
                    <div class="table-responsive rounded-5 p-5">
1022
                        <table class="table table-bordered rounded-4" id="stockAgingTable">
1023
                            <thead>
1024
                            <tr class="text-center">
1025
                                <th></th>
1026
                                <th class="align-middle bg-danger text-white fs-5 fw-bold" style="width: 180px;">
1027
                                    Brands
1028
                                </th>
1029
                                #set($intervals = ["Less Than 15 Days", "16 - 30 Days", "31 - 45 Days",
1030
                                    "More Than 45 Days"])
1031
                                #set($bgColors = ["bg-success", "bg-cryan", "bg-orange", "bg-danger"])
1032
                                #set($textColors = ["text-white", "text-white", "text-white", "text-white"])
1033
 
1034
                                #foreach($interval in $intervals)
1035
                                    <th class="align-middle fs-5 fw-bold $bgColors.get($foreach.index) text-wrap"
1036
                                        style="width: 180px;height: 55px !important; word-wrap: break-word; white-space: normal;">
1037
                                        <span class="$textColors.get($foreach.index) text-wrap ">$interval</span>
1038
                                    </th>
1039
                                #end
1040
                            </tr>
1041
                            </thead>
1042
                            <tbody>
1043
                                #if(!$inventoryGroupedByBrand.isEmpty())
1044
                                    #set($mandatoryBrands = ["vivo", "oppo", "samsung", "realme"])
1045
                                    #set($otherBrands = [])
1046
 
1047
                                    ## First process mandatory brands
1048
                                <tr>
1049
                                    <td class="align-middle bg-secondary text-center text-white fw-bold " rowspan="5"
1050
                                        style="width: 60px !important; font-size: 10px !important;">
1051
                                        <div class="brandText">MANDATORY BRANDS</div>
1052
                                    </td>
1053
                                </tr>
1054
 
1055
                                    #foreach($brandKey in $mandatoryBrands)
1056
                                        #set($found = false)
1057
                                        #foreach($entry in $inventoryGroupedByBrand.entrySet())
1058
                                            #if($entry.getKey().toLowerCase() == $brandKey)
1059
                                                #set($found = true)
1060
                                            <tr>
1061
                                                <td class="brand-cell text-start p-0">
1062
                                                    <div class="p-3 bg-danger  #getBrandBgColor($entry.getKey())"
1063
                                                         style="height: 40px; display: flex; align-items: center; justify-content: start;">
1064
                                                    <span class="text-white fw-bold fs-5"><img
1065
                                                            src="$brandLogos.getOrDefault($entry.getKey(),
1066
                                                                'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
1067
                                                            alt="$entry.getKey() logo"
1068
                                                            class="brand-logo rounded-circle me-3"
1069
                                                            style="width:35px;height:35px">$entry.getKey()</span>
1070
                                                    </div>
1071
                                                </td>
1072
                                                #foreach($i in [0..3])
1073
                                                    <td class="align-middle text-center  $bgColors.get($i)"
1074
                                                        style="opacity: 0.9;">
1075
                                                        #set($qty = 0)
1076
                                                        #set($value = 0)
1077
                                                        #foreach($item in $entry.getValue())
1078
                                                            #if($i < $item.getValues().size() && $item.getValues().get($i))
1079
                                                                #set($qty = $math.add($qty, $item.getValues().get($i).getQuantity()))
1080
                                                                #set($itemValue = $math.mul($item.getValues().get($i).getPrice(), $item.getValues().get($i).getQuantity()))
1081
                                                                #set($value = $math.add($value, $itemValue))
1082
                                                            #end
1083
                                                        #end
1084
                                                        <div class="volume-view fs-5 fw-bold text-white ">$qty</div>
1085
                                                        <div class="value-view currency fs-5 fw-bold text-white"
1086
                                                             style="display: none;"> $nf.format(  $value)</div>
1087
                                                    </td>
1088
                                                #end
1089
                                            </tr>
1090
                                            #end
1091
                                        #end
1092
 
1093
                                        #if(!$found)
1094
                                        <tr>
1095
                                            <td class="brand-cell text-center p-0">
1096
                                                <div class="p-3 #getBrandBgColor($brandKey)"
1097
                                                     style="height: 40px; display: flex; align-items: center; justify-content: center;">
1098
                                                    <span class="text-white fw-bold">$brandKey</span>
1099
                                                </div>
1100
                                            </td>
1101
                                            #foreach($i in [0..3])
1102
                                                <td class="text-center align-middle $bgColors.get($i)"
1103
                                                    style="opacity: 0.9;">
1104
                                                    <div class="volume-view fs-5 fw-bold text-white">0</div>
1105
                                                    <div class="value-view currency fs-5 fw-bold text-white"
1106
                                                         style="display: none;">0.00
1107
                                                    </div>
1108
                                                </td>
1109
                                            #end
1110
                                        </tr>
1111
                                        #end
1112
                                    #end
1113
 
1114
                                    ## Process other brands
1115
                                <tr>
1116
                                    <td class="align-middle bg-dark-light text-center text-white fw-bold "
1117
                                        rowspan="$inventoryGroupedByBrand.size()"
1118
                                        style="width: 60px !important; font-size: 10px !important;">
1119
                                        <div class="brandText">OTHER BRANDS</div>
1120
                                    </td>
1121
                                </tr>
1122
 
1123
                                    #foreach($entry in $inventoryGroupedByBrand.entrySet())
1124
                                        #set($isOtherBrand = true)
1125
                                        #foreach($mandatoryBrand in $mandatoryBrands)
1126
                                            #if($entry.getKey().toLowerCase() == $mandatoryBrand)
1127
                                                #set($isOtherBrand = false)
1128
                                                #break
1129
                                            #end
1130
                                        #end
1131
 
1132
                                        #if($isOtherBrand)
1133
                                        <tr>
1134
                                            <td class="brand-cell text-start p-0">
1135
                                                <div class="p-3 bg-secondary #getBrandBgColor($entry.getKey())"
1136
                                                     style="height: 40px; display: flex; align-items: center; justify-content: start;">
1137
                                                <span class="text-white fw-bold fs-5  "><img
1138
                                                        src="$brandLogos.getOrDefault($entry.getKey(),
1139
                                                            'https://static.vecteezy.com/system/resources/thumbnails/025/213/042/small_2x/mobile-phone-icon-in-black-circle-png.png')"
1140
                                                        alt="$entry.getKey() logo"
1141
                                                        class="brand-logo rounded-circle me-3"
1142
                                                        style="width:35px;height:35px">$entry.getKey()</span>
1143
                                                </div>
1144
                                            </td>
1145
                                            #foreach($i in [0..3])
1146
                                                <td class="text-center align-middle pb-4 $bgColors.get($i)"
1147
                                                    style="opacity: 0.9;">
1148
                                                    #set($qty = 0)
1149
                                                    #set($value = 0)
1150
                                                    #foreach($item in $entry.getValue())
1151
                                                        #if($i < $item.getValues().size() && $item.getValues().get($i))
1152
                                                            #set($qty = $math.add($qty, $item.getValues().get($i).getQuantity()))
1153
                                                            #set($itemValue = $math.mul($item.getValues().get($i).getPrice(), $item.getValues().get($i).getQuantity()))
1154
                                                            #set($value = $math.add($value, $itemValue))
1155
                                                        #end
1156
                                                    #end
1157
                                                    <div class="volume-view fs-5 fw-bold text-white">$qty</div>
1158
                                                    <div class="value-view currency fs-5 fw-bold text-white"
1159
                                                         style="display: none;"> $nf.format($value)</div>
1160
                                                </td>
1161
                                            #end
1162
                                        </tr>
1163
                                        #end
1164
                                    #end
1165
                                #else
1166
                                <tr>
1167
                                    <td colspan="6" class="text-center">No inventory data available</td>
1168
                                </tr>
1169
                                #end
1170
                            </tbody>
1171
                        </table>
1172
                    </div>
1173
                    <div class="d-flex justify-content-center mt-5 ">
1174
                        <button type="button" class="btn-sm btn-danger fs-2 fw-bold px-4" data-dismiss="modal">X CLOSE
1175
                        </button>
1176
                    </div>
1177
                </div>
1178
            </div>
1179
    </section>
1180
</div>
1181
</body>
1182
<script>
1183
    var chart;
1184
    const brandColors = {
1185
        'vivo': '#2196F3',
1186
        'oppo': '#006b35',
1187
        'samsung': '#1428A0',
1188
        'realme': '#FFC107',
1189
        'xiaomi': '#FF5722',
1190
        'apple': '#666666',
1191
        'poco': '#FFD403',
1192
        'tecno': '#0064FE',
1193
        'lava': '#ED0F53'
1194
        // Add other brands here...
1195
    };
1196
 
1197
 
1198
    function loadMonthDetails(monthIndex) {
1199
        console.log(`Loading details for month: ${monthIndex}`);
1200
        doGetAjaxRequestHandler(`${context}/monthWisePartnerIncome/${monthIndex}?partnerTask=true`, function (response) {
1201
            $('.bootbox.modal .modal-body .bootbox-body').empty();
1202
            $('#partner-income').html(response);
1203
            const $section = $('#ajaxSection');
1204
        });
1205
    }
1206
 
1207
    $(document).on("click", ".pending-income", function () {
1208
        lastMonthCreditIncome("main-content");
1209
    });
1210
 
1211
    // Standard AJAX handler - assuming this already exists, but including for completeness
1212
    function doGetAjaxRequestHandler(url, successCallback) {
1213
        $.ajax({
1214
            url: url,
1215
            type: 'GET',
1216
            success: successCallback,
1217
            error: function (xhr, status, error) {
1218
                console.error("AJAX request failed:", error);
1219
            }
1220
        });
1221
    }
1222
 
1223
    $(function () {
1224
        $('#reportrange').daterangepicker(getRangedDatePicker());
1225
    });
1226
    $(document).ready(function () {
1227
 
1228
        $("#btnVolume").addClass("active");
1229
 
1230
        $("#btnVolume").click(function () {
1231
            $(this).addClass("active");
1232
            $("#btnValue").removeClass("active");
1233
            $(".volume-view").show();
1234
            $(".value-view").hide();
1235
        });
1236
 
1237
        $("#btnValue").click(function () {
1238
            $(this).addClass("active");
1239
            $("#btnVolume").removeClass("active");
1240
            $(".volume-view").hide();
1241
            $(".value-view").show();
1242
        });
1243
    });
1244
    document.querySelectorAll('.brand-btn').forEach(button => {
1245
        button.addEventListener('click', function () {
1246
            const selectedBrand = this.getAttribute('data-brand');
1247
            document.querySelectorAll('.brand-data').forEach(row => {
1248
                row.style.display = (row.getAttribute('data-brand') === selectedBrand || selectedBrand === 'all') ? 'block' : 'none';
1249
            });
1250
        });
1251
    });
1252
 
1253
    function initializeBrandButtons() {
1254
        const brandButtons = document.querySelectorAll('.brand-btn');
1255
 
1256
        brandButtons.forEach(button => {
1257
            const brand = button.dataset.brand; // Already lowercase from server
1258
            const color = brandColors[brand] || '#666';
1259
 
1260
            // Apply initial styles
1261
            button.style.border = `2px solid ${color}`;
1262
            button.style.color = color;
1263
            button.style.backgroundColor = '#fff';
1264
        });
1265
 
1266
        // Add click handlers
1267
        brandButtons.forEach(button => {
1268
            button.addEventListener('click', function () {
1269
                const selectedBrand = this.dataset.brand;
1270
 
1271
                // Reset all buttons
1272
                brandButtons.forEach(btn => {
1273
                    const brandColor = brandColors[btn.dataset.brand] || '#666';
1274
                    btn.style.backgroundColor = '#fff';
1275
                    btn.style.color = brandColor;
1276
                });
1277
 
1278
                // Activate clicked button
1279
                this.style.backgroundColor = brandColors[selectedBrand] || '#666';
1280
                this.style.color = '#fff';
1281
 
1282
                // Filter rows
1283
                document.querySelectorAll('.brand-data').forEach(row => {
1284
                    row.style.display = row.dataset.brand === selectedBrand ? 'block' : 'none';
1285
                });
1286
            });
1287
        });
1288
        brandButtons[0]?.click();
1289
    }
1290
 
1291
    initializeBrandButtons();
1292
 
1293
</script>
1294
<script>
1295
    // Brand filtering functionality
1296
    document.querySelectorAll('.brand-btn').forEach(button => {
1297
        button.addEventListener('click', function () {
1298
            const brand = this.getAttribute('data-brand');
1299
 
1300
            // Update active button
1301
            document.querySelectorAll('.brand-btn').forEach(btn => {
1302
                btn.style.backgroundColor = '';
1303
                btn.style.color = '';
1304
            });
1305
            this.style.backgroundColor = '#006b35';
1306
            this.style.color = 'white';
1307
 
1308
            // Show selected brand data
1309
            document.querySelectorAll('.brand-data').forEach(item => {
1310
                item.style.display = item.getAttribute('data-brand') === brand ? 'block' : 'none';
1311
            });
1312
        });
1313
    });
1314
    // Activate first brand by default
1315
    document.querySelector('.brand-btn')?.click();
1316
</script>
1317
 
1318
##-------------------------------------------------------------------My Earning  chart -----------------------------------------
1319
<script>
1320
    $(document).ready(function () {
1321
        // loadMonthDetails(0);
1322
        const monthData = [
1323
            #foreach( $item in $summaryList )
1324
                {
1325
                    month: "$!item.monthValueMap[$item.monthIndex]",
1326
                    monthIndex: "$item.monthIndex",
1327
                    total: $item.get('totalIncome'),
1328
                    credited: $item.get('creditedIncome'),
1329
                    pending: $item.get('pendingIncome')
1330
                }
1331
                #if($foreach.hasNext),#end
1332
            #end
1333
        ].reverse();
1334
 
1335
        // Simple formatting with rounding
1336
        const formatIndianCurrency = (amount) => {
1337
            const rounded = Math.round(amount);
1338
            return rounded.toLocaleString('en-IN');
1339
        };
1340
 
1341
        // Apply formatting when displaying
1342
        monthData.forEach(item => {
1343
            item.totalFormatted = formatIndianCurrency(item.total);
1344
            item.creditedFormatted = formatIndianCurrency(item.credited);
1345
            item.pendingFormatted = formatIndianCurrency(item.pending);
1346
        });
1347
        chart = new Chart(document.getElementById('sixMonthChart'), {
1348
            type: 'bar',
1349
            data: {
1350
                labels: monthData.map(d => d.month),
1351
                datasets: [
1352
                    // Bar: Credited Income
1353
                    {
1354
                        label: 'Credited Income',
1355
                        data: monthData.map(d => Math.round(d.credited)),
1356
                        backgroundColor: '#aadcb4',
1357
                        borderColor: '#aadcb4',
1358
                        borderWidth: 1,
1359
                        barThickness: 30,
1360
                        hitRadius: 30,
1361
                        order: 1,
1362
                        yAxisID: 'y',
1363
                        hoverBorderWidth: 3,
1364
                        hoverBorderColor: '#aadcb4'
1365
                    },
1366
                    // Bar: Pending Income
1367
                    {
1368
                        label: 'Pending Income',
1369
                        data: monthData.map(d => Math.round(d.pending)),
1370
                        backgroundColor: 'rgba(255,0,0,0.7)',
1371
                        borderColor: 'rgba(255,0,0,1)',
1372
                        borderWidth: 1,
1373
                        barThickness: 30,
1374
                        order: 2,
1375
                        hitRadius: 0,
1376
                        yAxisID: 'y',
1377
                        hoverBorderWidth: 3,
1378
                        hoverBorderColor: '#ff0000'
1379
                    },
1380
                    // Line: Total Income
1381
                    {
1382
                        label: 'Total Income',
1383
                        data: monthData.map(d => Math.round(d.total)),
1384
                        borderColor: '#4bc0c0',
1385
                        backgroundColor: 'rgba(75, 192, 192, 0.1)',
1386
                        borderWidth: 4,
1387
                        type: 'line',
1388
                        order: 3,
1389
                        pointRadius: 6,
1390
                        pointHoverRadius: 0,
1391
                        pointHitRadius: 0,
1392
                        pointBackgroundColor: '#4bc0c0',
1393
                        pointBorderColor: '#ffffff',
1394
                        pointBorderWidth: 2,
1395
                        yAxisID: 'y',
1396
                        tension: 0.3
1397
                    }
1398
 
1399
                ]
1400
            },
1401
            options: {
1402
                responsive: true,
1403
                maintainAspectRatio: true,
1404
                interaction: {
1405
                    mode: 'point',
1406
                    intersect: true,
1407
                },
1408
                plugins: {
1409
                    datalabels: {
1410
                        formatter: function (value) {
1411
                            return Math.round(value).toLocaleString('en-IN');
1412
                        },
1413
                        color: '#fff',
1414
                        backgroundColor: '#333',
1415
                        borderRadius: 4,
1416
                        padding: 4,
1417
                        font: {
1418
                            weight: 'bold'
1419
                        },
1420
                        display: function (context) {
1421
                            const rawValue = context.dataset.data[context.dataIndex];
1422
                            return context.datasetIndex < 3 && rawValue != null && rawValue !== 0;
1423
                        },
1424
 
1425
                    },
1426
                    tooltip: {
1427
                        mode: 'index',
1428
                        intersect: false,
1429
                        backgroundColor: 'rgba(0, 0, 0, 0.9)',
1430
                        titleColor: '#ffffff',
1431
                        bodyColor: '#ffffff',
1432
                        borderColor: '#4bc0c0',
1433
                        borderWidth: 2,
1434
                        displayColors: true,
1435
                        padding: 12,
1436
                        boxWidth: 15,
1437
                        boxHeight: 15,
1438
                        cornerRadius: 8,
1439
                        usePointStyle: true,
1440
                        bodyFont: {
1441
                            size: 14,
1442
                            weight: 'bold'  // Make body text bold
1443
                        },
1444
                        titleFont: {
1445
                            size: 16,
1446
                            weight: 'bold'
1447
                        },
1448
                        footerFont: {
1449
                            size: 12,
1450
                            weight: 'bold'  // Make footer bold too
1451
                        },
1452
                        callbacks: {
1453
                            title: function (context) {
1454
                                return `Month: ${context[0].label}`;
1455
                            },
1456
                            label: function (context) {
1457
                                const value = context.parsed.y;
1458
                                // Round the value first, then format with currency symbol
1459
                                const roundedValue = Math.round(value);
1460
                                const formattedValue = roundedValue.toLocaleString('en-IN');
1461
 
1462
                                // Format with proper spacing and bold styling
1463
                                const label = context.dataset.label;
1464
                                return `${label}: ${formattedValue}`;
1465
                            },
1466
                            footer: function (tooltipItems) {
1467
                                // Calculate and show percentage for credited vs total
1468
                                const credited = tooltipItems.find(item => item.dataset.label === 'Credited Income')?.parsed.y || 0;
1469
                                const total = tooltipItems.find(item => item.dataset.label === 'Total Income')?.parsed.y || 0;
1470
                                if (total > 0) {
1471
                                    const percentage = ((credited / total) * 100).toFixed(1);
1472
                                    return `Credited: ${percentage}% of total income`;
1473
                                }
1474
                                return '';
1475
                            },
1476
                            labelColor: function (context) {
1477
                                return {
1478
                                    borderColor: 'transparent',
1479
                                    backgroundColor: context.dataset.borderColor,
1480
                                    borderRadius: 4,
1481
                                    borderWidth: 2
1482
                                };
1483
                            },
1484
                            labelTextColor: function (context) {
1485
                                return '#ffffff'; // Ensure text is white and visible
1486
                            }
1487
                        }
1488
                    },
1489
                    legend: {
1490
                        display: true,
1491
                        position: 'top',
1492
                        labels: {
1493
                            usePointStyle: true,
1494
                            padding: 20,
1495
                            font: {
1496
                                size: 14,
1497
                                weight: 'bold'
1498
                            },
1499
                            color: '#333',
1500
                            boxWidth: 15,
1501
                            boxHeight: 15
1502
                        }
1503
                    }
1504
                },
1505
                scales: {
1506
                    x: {
1507
 
1508
                        ticks: {
1509
 
1510
                            autoSkip: false,
1511
                            font: {
1512
                                size: 12,
1513
                                weight: 'bold'
1514
                            },
1515
                            color: '#333',
1516
                            padding: 10
1517
                        }
1518
                    },
1519
                    y: {
1520
                        type: 'linear',
1521
                        display: true,
1522
                        position: 'left',
1523
                        stacked: false,
1524
                        beginAtZero: true,
1525
                        grid: {
1526
                            color: 'rgba(0, 0, 0, 0.1)',
1527
                            lineWidth: 1
1528
                        },
1529
                        ticks: {
1530
                            callback: function (value) {
1531
                                // Round the value first, then format
1532
                                const roundedValue = Math.round(value);
1533
                                return roundedValue.toLocaleString('en-IN');
1534
                            },
1535
                            font: {
1536
                                size: 12,
1537
                                weight: 'bold'
1538
                            },
1539
                            color: '#333'
1540
                        }
1541
                    }
1542
                },
1543
                elements: {
1544
                    bar: {
1545
                        borderRadius: 4,
1546
                        categoryPercentage: 0.8,
1547
                        barPercentage: 0.9
1548
                    },
1549
                    line: {
1550
                        borderJoinStyle: 'round'
1551
                    },
1552
                    point: {
1553
                        hoverBorderWidth: 1
1554
                    }
1555
                },
1556
                onHover: function (event, elements) {
1557
                    event.native.target.style.cursor = elements.length > 0 ? 'pointer' : 'default';
1558
                },
1559
                onClick: function (event, elements) {
1560
                    if (elements && elements.length > 0) {
1561
                        const clickedIndex = elements[0].index;
1562
                        const clickedData = monthData[clickedIndex];
1563
 
1564
                        // Visual feedback
1565
                        event.chart.canvas.style.cursor = 'wait';
1566
 
1567
                        console.log(`Loading details for month: ${clickedData.monthIndex} (${clickedData.month})`);
1568
 
1569
                        loadMonthDetails(clickedData.monthIndex);
1570
 
1571
                        // Smooth scroll to results
1572
                        setTimeout(() => {
1573
                            document.getElementById('partner-income').scrollIntoView({
1574
                                behavior: 'smooth',
1575
                                block: 'start'
1576
                            });
1577
                            event.chart.canvas.style.cursor = 'pointer';
1578
                        }, 300);
1579
                    }
1580
                }
1581
            }
1582
        });
1583
    })
1584
</script>
1585
##-----------------------------------------------------------------------Stagged CHart ---------------------------------
1586
<script>
1587
    $(document).ready(function () {
1588
        // Define major brands to keep separate
1589
        const MAJOR_BRANDS = ['vivo', 'samsung', 'oppo', 'realme', 'xiaomi'];
1590
 
1591
        // Prepare market data
1592
        const marketSegments = [];
1593
        const otherMarketData = {
1594
            brand: "Others",
1595
            marketShare: 0,
1596
            color: '#6b7280'
1597
        };
1598
 
1599
        // Prepare stock data
1600
        const stockSegments = [];
1601
        const otherStockData = {
1602
            brand: "Others",
1603
            quantity: 0,
1604
            value: 0
1605
        };
1606
 
1607
        // Process market share data
1608
        #foreach($entry in $marketShareData)
1609
            var marketBrandName = '$entry.Brand'.toLowerCase();
1610
            if (MAJOR_BRANDS.includes(marketBrandName)) {
1611
                marketSegments.push({
1612
                    brand: marketBrandName,
1613
                    marketShare: ${entry.MarketShare.replace('%', '')},
1614
                    color: '$entry.BgColor'
1615
                });
1616
            } else {
1617
                otherMarketData.marketShare += ${entry.MarketShare.replace('%', '')};
1618
            }
1619
        #end
1620
 
1621
        // Process stock data
1622
        #foreach($brandStockPrice in $brandStockPrices)
1623
            var stockBrandName = "$brandStockPrice.getBrand()".toLowerCase();
1624
            if (MAJOR_BRANDS.includes(stockBrandName)) {
1625
                stockSegments.push({
1626
                    brand: stockBrandName,
1627
                    quantity: $brandStockPrice.getTotalQty(),
1628
                    value: $brandStockPrice.getTotalValue()
1629
                });
1630
            } else {
1631
                otherStockData.quantity += $brandStockPrice.getTotalQty();
1632
                otherStockData.value += $brandStockPrice.getTotalValue();
1633
            }
1634
        #end
1635
 
1636
        // Add Others categories if they have data
1637
        if (otherMarketData.marketShare > 0) {
1638
            marketSegments.push(otherMarketData);
1639
        }
1640
        if (otherStockData.quantity > 0) {
1641
            stockSegments.push(otherStockData);
1642
        }
1643
 
1644
        // Combine data
1645
        const combinedSegments = [];
1646
        const allBrands = [...new Set([
1647
            ...marketSegments.map(d => d.brand),
1648
            ...stockSegments.map(d => d.brand)
1649
        ])];
1650
 
1651
        allBrands.forEach(brand => {
1652
            const marketInfo = marketSegments.find(m => m.brand === brand) || {};
1653
            const stockInfo = stockSegments.find(s => s.brand === brand) || {};
1654
 
1655
            combinedSegments.push({
1656
                brand: brand.charAt(0).toUpperCase() + brand.slice(1),
1657
                marketShare: marketInfo.marketShare || 0,
1658
                stockQuantity: stockInfo.quantity || 0,
1659
                stockValue: stockInfo.value || 0,
1660
                color: marketInfo.color || brandColors[brand] || '#95a5a6'
1661
            });
1662
        });
1663
 
1664
        // Calculate total stock quantity
1665
        const totalStockQuantity = stockSegments.reduce((sum, b) => sum + b.quantity, 0);
1666
 
1667
        // Create stacked bar chart
1668
        const ctx4 = document.getElementById('combinedStackedChart').getContext('2d');
1669
        const staggedChart = new Chart(ctx4, {
1670
            type: 'bar',
1671
            data: {
1672
                labels: combinedSegments.map(item => item.brand),
1673
                datasets: [
1674
                    {
1675
                        label: 'Brand Market Share (%)',
1676
                        data: combinedSegments.map(item => item.marketShare),
1677
                        backgroundColor: combinedSegments.map(item => item.color + '80'),
1678
                        borderColor: combinedSegments.map(item => item.color),
1679
                        borderWidth: 2
1680
                    },
1681
                    {
1682
                        label: 'Your Brand Share (%)',
1683
                        data: combinedSegments.map(item => ((item.stockQuantity / totalStockQuantity) * 100).toFixed(1)),
1684
                        backgroundColor: combinedSegments.map(item => item.color + '40'),
1685
                        borderColor: combinedSegments.map(item => item.color),
1686
                        borderWidth: 1
1687
                    }
1688
                ]
1689
            },
1690
            options: {
1691
                responsive: true,
1692
                scales: {
1693
                    x: {
1694
                        stacked: true
1695
                    },
1696
                    y: {
1697
                        stacked: true,
1698
                        beginAtZero: true,
1699
                        title: {
1700
                            display: true,
1701
                            text: 'Percentage (%)'
1702
                        }
1703
                    }
1704
                },
1705
                plugins: {
1706
                    tooltip: {
1707
                        callbacks: {
1708
                            label: function (context) {
1709
                                const segment = combinedSegments[context.dataIndex];
1710
                                if (context.datasetIndex === 0) {
1711
                                    return `Market Share: ${segment.marketShare}%`;
1712
                                } else {
1713
                                    return [
1714
                                        `Stock Quantity: ${segment.stockQuantity}`,
1715
                                        `Percentage: ${((segment.stockQuantity / totalStockQuantity) * 100).toFixed(1)}%`
1716
                                    ];
1717
                                }
1718
                            }
1719
                        }
1720
                    }
1721
                }
1722
            }
1723
        });
1724
    });
1725
</script>