@extends('backend.layouts.app')

@section('content')
    <style>
        .sorting_disabled {
            text-align: center;
        }
    </style>
    <div class="row page-titles">
        <div class="col-md-5 align-self-center">
            <h4 class="text-themecolor">Reports Manager</h4>
        </div>
        <div class="col-md-7 align-self-center text-right">
            <div class="d-flex justify-content-end align-items-center">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                    <li class="breadcrumb-item">Reports Manager</li>
                    <li class="breadcrumb-item active">Lead analysis via Area members</li>
                </ol>
            </div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="content-wrapper">
            @if (session('status'))
                <div class="alert alert-success alert-dismissible fade show" role="alert"><i
                        class="far fa-check-circle"></i>
                    {{ session('status') }}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            @endif
            @if (session('error'))
                <div class="alert alert-danger alert-dismissible fade show" role="alert"><i
                        class="far fa-check-circle"></i>
                    {{ session('error') }}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            @endif

            <section class="content">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4>Lead analysis via Area members<p style="font-size: 10px; color:gray"></p>
                                </h4>
                                <br>
                                <div class="table-responsive">
                                    <table id="active-leads-subscribe-report-table"
                                        class="table table-bordered table-hover w-100">
                                        <thead>
                                            <tr class="text-center">
                                                <th>S.No</th>
                                                <th>Code</th>
                                                <th>Name</th>
                                                <th>Total Members</th>
                                                <th>Active Members</th>
                                                <th>Lead Subscribed</th>
                                                <th>Average Leads</th>
                                                <th>Credits Total</th>
                                                <th>Credit per Member</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @php $sno = 1; @endphp
                                            @foreach ($data as $row)
                                                @if ($row->Area_Name !== 'Total')
                                                    <tr class="text-center">
                                                        <td>{{ $sno++ }}</td>
                                                        <td class="text-left">{{ $row->Area_Code }}</td>
                                                        <td class="text-left">{{ $row->Area_Name }}</td>
                                                        <td>{{ $row->Total_Members }}</td>
                                                        <td>{{ $row->Active_Members }}</td>
                                                        <td>{{ $row->Active_Leads_Subscribed }}</td>
                                                        <td>{{ $row->Average_Leads }}</td>
                                                        <td>{{ $row->Credits_Total }}</td>
                                                        <td>{{ $row->Credit_Per_Member }}</td>
                                                    </tr>
                                                @endif
                                            @endforeach
                                        </tbody>
                                        <tfoot>
                                            @php $total = $data->last(); @endphp
                                            <tr style="font-weight: bold; background-color: #f8f9fa;" class="text-center">
                                                <td colspan="3" style="text-align: left;">Total</td>
                                                <td class="fw-bold">{{ $total->Total_Members }}</td>
                                                <td class="fw-bold">{{ $total->Active_Members }}</td>
                                                <td class="fw-bold">{{ $total->Active_Leads_Subscribed }}</td>
                                                <td class="fw-bold">{{ $total->Average_Leads }}</td>
                                                <td class="fw-bold">{{ $total->Credits_Total }}</td>
                                                <td class="fw-bold">{{ $total->Credit_Per_Member }}</td>
                                            </tr>
                                        </tfoot>
                                    </table>


                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
@endsection

@push('custom-script')
    {{-- {!! $dataTable->scripts() !!} --}}
    <script>
        $(document).ready(function() {
            $('#active-leads-subscribe-report-table').DataTable({
                ordering: true,
                searching: true,
                paging: false,
                info: false,
                fixedHeader: true
            });
        });
    </script>
@endpush
