@extends('Admin.layout')

<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css">

@section('content')
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <style>
        .dataTables_info,
        .dataTables_paginate {
            padding: 0 18px 18px !important;
        }
    </style>

    <div class="row align-items-center justify-content-between mb-3 mt-3 m-2">
        <div class="col-auto">
            <h5 class="page-title">
                <i class="ti tabler-diamond text-warning me-2"></i>Diamond BDB Payout
            </h5>
        </div>
        <div class="col-auto">
<a href="{{ route('admin.diamond_generate') }}">            <button class="btn btn-primary">Generate Payout</button>
        </div>
    </div>

    <div class="card main-card m-2">

        <div class="top-filter p-3">
            <div class="row g-3 align-items-end d-flex justify-content-end">
                <div class="col-auto">
                    <select id="pageLength" class="form-select">
                        <option value="10">10</option>
                        <option value="25">25</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                        <option value="All">All</option>
                    </select>
                </div>
                <div class="col-lg-2 col-md-6">
                    <label class="form-label">From Date</label>
                    <input type="date" class="form-control">
                </div>

                <div class="col-lg-2 col-md-6">
                    <label class="form-label">To Date</label>
                    <input type="date" class="form-control">
                </div>

                <div class="col-lg-2 col-md-6">
                    <label class="form-label">User Name</label>
                    <input type="text" class="form-control" placeholder="Search user">
                </div>

                <div class="col-lg-1 col-md-6">
                    <button class="btn btn-primary w-100">
                        <i class="ti tabler-search me-1"></i> Search
                    </button>
                </div>
                <div class="col-md-3 ms-auto">
                    <input type="text" id="customSearch" class="form-control" placeholder="Search table...">
                </div>

                <div class="col-lg-1 col-md-6">
                    <button class="btn btn-label-secondary w-100">
                        <i class="ti tabler-download me-1"></i> Export
                    </button>
                </div>

            </div>
        </div>
        <div class="table-responsive table-wrap">
            <table class="table w-100" id="usersTable">
                <thead>
                    <tr>
                        <th>Sno</th>
                        <th>From Date</th>
                        <th>To Date</th>
                        <th>Amount&nbsp;Details</th>
                        <th>Status</th>
                        <th>Action</th>
                        <th>Team Report</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>

    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>

    <script>
        $(document).ready(function () {

            const users = [
                {
                    name: '26',
                    id: '4306.04',
                    phone: '2158.23',
                    ref: '2153.23',
                    team: '38758.02',
                    investment: 'Unpaid',
                    date: '12/10/2025',
                    to: '12/12/2025'
                },

            ];

            let table = $('#usersTable').DataTable({
                data: users,
                pageLength: 10,
                ordering: false,
                searching: true,
                info: true,
                lengthChange: false,

                columnDefs: [{
                    targets: '_all',
                    className: 'text-nowrap'
                }],

                columns: [

                    {
                        data: null,
                        render: function (data, type, row, meta) {
                            return meta.row + 1;
                        }
                    },
                    {
                        data: 'date',
                        render: function (data) {
                            return `<span>${data}</span>`;
                        }
                    },
                    {
                        data: 'to'
                    },

                    {
                        data: null,
                        render: function (data, type, row) {
                            return `
                                            <div class="d-flex flex-column gap-3">
                                        <div class="label-sm">Users :&nbsp;${row.name}</div>

                                        <div class="label-sm">Amount :&nbsp;${row.id}</div>
                                        <div class="label-sm">TDS :&nbsp;${row.phone}</div>
                                        <div class="label-sm">Admin Charge :&nbsp;${row.ref}</div>
                                        <div class="label-sm">Payable Amount :&nbsp;${row.team}</div>
                                    </div>
                                `;
                        }
                    },




                    {
                        data: 'investment',
                        render: function (data) {
                            return ` ${data}`;
                        }
                    },
                    {
                        data: null,

                        render: function (data) {
                            return `<a href="{{ route('admin.diamond_bdb_gen_history') }}"> <i class="ti tabler-eye text-primary menu-icon" style="cursor:pointer;"></i></a>`;
                        }
                    },
                    {
                        data: null,

                        render: function (data) {
                            return `<a href="{{ route('admin.diamond_bdb_payout_team') }}"> <i class="ti tabler-eye text-primary menu-icon" style="cursor:pointer;"></i></a>`;
                        }
                    }






                ]
            });

            $('#customSearch').keyup(function () {
                table.search($(this).val()).draw();
            });

            $('#pageLength').change(function () {
                table.page.len($(this).val()).draw();
            });

        });
    </script>

@endsection