@extends('layouts.main') 
@section('title', 'District Master')
@section('content')

<?php 
    $getstatecodedata = DB::table('state_master')->get();
?>
    <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-edit bg-blue"></i>
                        <div class="d-inline">
                            <h5>{{ __('District Master')}}</h5>
                        </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"><a href="#">{{ __('Forms')}}</a></li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-7 mx-auto">
                <div class="card">
                    <div class="card-header"><h3>{{ __('District Master Form')}}</h3></div>
                    <div class="card-body">
                        <form class="forms-sample"  method='POST' @if(!empty($showdata)) action='{{ url('updatedistrict') }}' @else action='{{ url('districtinsert') }}' @endif name='districtmaster'>
                            @csrf
                            
                            @if(!empty($showdata))
                            <input type='hidden' name='id' value='{{$showdata[0]->id}}'>
                            @endif
                            
                            <div class="form-group">
                                <label for="district_code">{{ __('Districe Code')}}</label>
                                <input type="text" class="form-control" id="district_code" name='district_code' <?php if(!empty($showdata)){ ?> value='{{$showdata[0]->district_code}}' <?php } ?> placeholder="Enter district code" required>
                            </div>
                            <div class="form-group">
                                <label for="district_name">{{ __('District name')}}</label>
                                <input type="text" class="form-control" id="district_name" name='district_name' <?php if(!empty($showdata)){ ?> value='{{$showdata[0]->district_name}}' <?php } ?> placeholder="Enter District Name" required>
                            </div>
                            <div class="form-group">
                                <label for="state_code">{{ __('State Code')}}</label>
                                <select name='state_code' class='form-control'>
                                    <option>Select State Code</option>
                                    <?php foreach($getstatecodedata as $getstatecode){ ?>
                                     <option value='<?php echo $getstatecode->state_code; ?>' @if(!empty($showdata)){{ $showdata[0]->state_code == $getstatecode->state_code ? 'selected' : '' }} @endif><?php echo $getstatecode->state_code; ?></option>
                                     <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="status">{{ __('District Status')}}</label>
                                <select name='status'  class='form-control' value='Select Option'>
                                    <option>Select Status</option>
                                    <option value="Yes" @if(!empty($showdata)){{ $showdata[0]->status == "Yes" ? 'selected' : '' }} @endif >Yes</option>
                                    <option value="No" @if(!empty($showdata)){{ $showdata[0]->status == "No" ? 'selected' : '' }} @endif >No</option>
                                </select>
                            </div>
                            <br><br>
                            <button type="submit" class="btn btn-primary mr-2">{{ __('Submit')}}</button>
                            @if(empty($showdata))
                            <a href='{{'district-master'}}' class="btn btn-light">{{ __('Cancel')}}</a>
                            @endif
                          </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- push external js -->
    @push('script')
        <script src="{{ asset('js/form-components.js') }}"></script>
    @endpush
@endsection