Subversion Repositories SmartDukaan

Rev

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