Subversion Repositories SmartDukaan

Rev

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