@extends('Admin.layout')
<style>
    .dt-search,
    .dt-length {
        display: none !important;
    }
</style>
@section('content')

    <h5><button type="button" class="btn btn-icon bg-white me-2 waves-effect waves-light"
            style="box-shadow: 0px 9px 12px -2px #66328E1F;">
            <a href="{{ route('admin.salary_report') }}">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000"
                    stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler">
                    <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                    <path d="M15 6l-6 6l6 6"></path>
                </svg>
            </a>
        </button>Salary List</h5>

    <div class="row mt-5">
        <div class="col-lg-12">
            <div class="card">

                <div class="card-body">
                    <div class="row g-3 align-items-center justify-content-between">

                        <!-- LEFT -->
                        <div class="col-12 col-lg-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-12 col-lg-auto">

                            <div class="d-flex flex-column flex-sm-row align-items-stretch align-items-sm-center gap-2">


                                <input type="text" id="customSearch" class="form-control" placeholder="Search table...">

                                <button class="btn btn-label-secondary">
                                    Export
                                </button>
                            </div>

                        </div>

                    </div>

                    <div class="table-responsive">
                        <table id="usersTable" class="table table-striped table-bordered align-middle nowrap w-100">
                            <thead>
                                <tr>
                                    <th class="text-nowrap">#</th>
                                    <th class="text-nowrap">Date</th>
                                    <th class="text-nowrap">Month</th>
                                    <th class="text-nowrap">Year</th>
                                    <th class="text-nowrap">User Id</th>
                                    <th class="text-nowrap">Position</th>
                                    <th class="text-nowrap">Salary</th>
                                    <th class="text-nowrap">Diamond First Leg</th>
                                    <th class="text-nowrap">Diamond Second Leg</th>
                                    <th class="text-nowrap">Diamond Balance Leg</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>

    <script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>

    <script src="https://cdn.datatables.net/1.13.8/js/dataTables.bootstrap5.min.js"></script>

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

           const salaryData = [

                    {
                        id: 1,
                        date: '2026-05-17 21:50:56',
                        month: 'April',
                        year: '2026',
                        user_id: 'OM5837932665',
                        position: 'Assistant Sales Manager',
                        salary: '30000.00',
                        diamond_first_leg: '4000000.00',
                        diamond_second_leg: '3000000.00',
                        diamond_balance_leg: '2500000.00'
                    },

                    {
                        id: 2,
                        date: '2026-04-15 18:20:10',
                        month: 'March',
                        year: '2026',
                        user_id: 'OM9837462821',
                        position: 'Team Leader',
                        salary: '25000.00',
                        diamond_first_leg: '3500000.00',
                        diamond_second_leg: '2800000.00',
                        diamond_balance_leg: '2100000.00'
                    },

                    {
                        id: 3,
                        date: '2026-03-10 14:12:45',
                        month: 'February',
                        year: '2026',
                        user_id: 'OM2837461990',
                        position: 'Senior Executive',
                        salary: '22000.00',
                        diamond_first_leg: '2800000.00',
                        diamond_second_leg: '2400000.00',
                        diamond_balance_leg: '1900000.00'
                    },

                    {
                        id: 4,
                        date: '2026-02-08 11:45:22',
                        month: 'January',
                        year: '2026',
                        user_id: 'OM8374629102',
                        position: 'Sales Executive',
                        salary: '18000.00',
                        diamond_first_leg: '2200000.00',
                        diamond_second_leg: '1800000.00',
                        diamond_balance_leg: '1500000.00'
                    }

                ];


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

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

                    columns: [

                        {
                            data: 'id'
                        },

                        {
                            data: 'date'
                        },

                        {
                            data: 'month'
                        },

                        {
                            data: 'year'
                        },

                        {
                            data: 'user_id'
                        },

                        {
                            data: 'position'
                        },

                        {
                            data: 'salary',
                            render: function (data) {
                                return '₹' + data;
                            }
                        },

                        {
                            data: 'diamond_first_leg',
                            render: function (data) {
                                return '₹' + data;
                            }
                        },

                        {
                            data: 'diamond_second_leg',
                            render: function (data) {
                                return '₹' + data;
                            }
                        },

                        {
                            data: 'diamond_balance_leg',
                            render: function (data) {
                                return '<span class="fw-bold text-info">₹' + data + '</span>';
                            }
                        }

                    ],


                pageLength: 10,


            });

        });

    </script>



@endsection
