@extends('layouts.main') 
@section('title', 'Outreach Input Ageing Report')
@section('content')
    <!-- push external head elements to head -->
    @push('head')
        <link rel="stylesheet" href="{{ asset('plugins/DataTables/datatables.min.css') }}">
        <link rel="stylesheet" href="{{ asset('plugins/jquery-ui/jquery-ui.css') }}">
    @endpush

    
    <div class="container-fluid">
        <div class="page-header">
            <div class="row align-items-end">
                <div class="col-lg-8">
                    <div class="page-header-title">
                        <i class="ik ik-pie-chart bg-blue"></i>
                        <div class="d-inline">
                            <h5>{{ __('Outreach Input Ageing Report') }}</h5>
                            <!-- <span>{{ __('EJAF.') }}</span> -->
                        </div>
                    </div>
                </div>
                <div class="col-lg-4">
                    <nav class="breadcrumb-container" aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="{{route('dashboard')}}"><i class="ik ik-home"></i></a>
                            </li>
                            
                           <li class="breadcrumb-item active" aria-current="page">{{ __('Outreach Input')}}</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
        
        <div class="row clearfix">
            <div class="col-md-12">
                
                <form class="forms-sample"  method='POST' action="{{ route('getfilteredoutreachageingreport') }}" >
                @csrf
                    <div class="form-group row">
                        <div class="col-3">
                            <label>Month</label>
                            <select name='month' id='month' class='form-control' required>
                                <option value="">Select Month</option>
                                @for($i=1;$i<=12;$i++)
                                <option value="{{str_pad($i, 2, '0', STR_PAD_LEFT)}}" {{ $month == str_pad($i, 2, '0', STR_PAD_LEFT) ? 'selected' : '' }}>{{str_pad($i, 2, '0', STR_PAD_LEFT)}}</option>
                                @endfor
                            </select>
                        </div>
                        <div class="col-3">
                            <label>Year</label>
                            <select name='year' id='year' class='form-control' required>
                                <option value="">Select Month</option>
                                @for($i=2022;$i<=2030;$i++)
                                <option value="{{$i}}" {{ $year == $i ? 'selected' : '' }}>{{$i}}</option>
                                @endfor
                            </select>
                        </div>
                        <div class="col-2 mt-25">
                            <button type="submit" id="submit" class="btn btn-primary mr-2">{{ __('Submit')}}</button>
                        </div>
                    </div>
                </form>
                <div class="card">
                    <div class="card-header">
                        <h3>{{ __('Outreach Input Ageing Report') }}</h3>
                    </div>
                    <div class="card-body table-responsive">
                        <table id="myAdvancedTable" class="table p-3">
                            <thead>
                                <tr>
                                    <th>{{ __('STAFF CODE') }}</th>
                                    <th>{{ __('STATE CODE') }}</th>
                                    <th>{{ __('DIST CODE') }}</th>
                                    <th>{{ __('Client ART Center Code') }}</th>
                                    <th>{{ __('Client Mobile') }}</th>
                                    <th>{{ __('Pre ART REG Number') }}</th>
                                    <th>{{ __('ART REG Number') }}</th>
                                    <th>{{ __('Client Name') }}</th>
                                    <th>{{ __('Linelist Received Date') }}</th>
                                    <th>{{ __('CONTACT VISIT') }}</th>
                                    <th>{{ __('Activity') }}</th>
                                    <th>{{ __('Ageing Days') }}</th>
                                </tr>
                            </thead>
                            <tbody>
                                 @foreach ($getdata as $getdatas)
                                <tr>
                                    <td>{{ $getdatas->emp_code }}</td>
                                    <td>{{ $getdatas->state_code }}</td>
                                    <td>{{ $getdatas->dist_code }}</td>
                                    
                                    <?php
                                    $getpatregdata = DB::table('patient_register')->where(['id'=>$getdatas->pat_uid])->first();
                                    ?>
                                    <td>{{ $getpatregdata->art_centre_code ?? '' }}</td>
                                    <td>{{ $getpatregdata->pat_mobile ?? '' }}</td>
                                    <td>{{ $getpatregdata->pre_art_reg_num ?? '' }}</td>
                                    <td>{{ $getpatregdata->art_reg_num ?? '' }}</td>
                                    <td>{{ $getpatregdata->pat_name ?? '' }}</td>
                                    <td>{{ date('d-m-Y',strtotime($getdatas->linelist_date)) }}</td>
                                    <td>{{ $getdatas->contact_visit }}</td>
                                    <td>
                                        @if($getdatas->linelist_reason_v1 == 1)
                                        {{ $getdatas->linelist_reason_v1.'- LFU' }}
                                        
                                        @elseif($getdatas->linelist_reason_v1 == 2)
                                        {{ $getdatas->linelist_reason_v1.'- MIS' }}
                                        
                                        @elseif($getdatas->linelist_reason_v1 == 3)
                                        {{ $getdatas->linelist_reason_v1.'- Home Delivery' }}
                                        
                                        @else
                                        {{ $getdatas->linelist_reason_v1.'- VL' }}
                                        @endif
                                    </td>
                                    <?php
                                        $earlier = new DateTime($getdatas->linelist_date);
                                        $later = new DateTime(date('Y-m-d'));
                                        $days = $earlier->diff($later)->format("%a Days");
                                    ?>
                                    <td>{{ $days }}</td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div> 
            </div>
        </div>
    </div>

    <!-- push external js -->
    @push('script')
    <script src="{{ asset('plugins/jquery-ui/jquery-ui.min.js') }}"></script>
    <script src="{{ asset('plugins/DataTables/datatables.min.js') }}"></script>
    <!--get editable datatable script-->
    <script src="{{ asset('js/editable-datatable.js') }}"></script>
    @endpush
@endsection
