Subversion Repositories SmartDukaan

Rev

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