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

<?php 
    $getstatecodedata = DB::table('state_master')->get();
    $getdistrictcodedata = DB::table('district_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>{{ __('Employee 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>{{ __('Employee Master form')}}</h3></div>
                    <div class="card-body">
                        <form class="forms-sample" method='POST' @if(!empty($showdata)) action='{{ url('updateemployee') }}' @else action='{{ url('employeeinsert') }}' @endif name='employeemaster'>
                            @csrf
                            
                            @if(!empty($showdata))
                            <input type='hidden' name='id' value='{{$showdata[0]->id}}'>
                            @endif
                            
                            <div class="form-group">
                                <label for="emp_code">{{ __('Employee Code')}}</label>
                                <input type="text" class="form-control" id="emp_code" name='emp_code' <?php if(!empty($showdata)){ ?> value='{{$showdata[0]->emp_code}}' <?php } ?> placeholder="Enter Employee Code" required>
                            </div>
                            <div class="form-group">
                                <label for="emp_name">{{ __('Employee Name')}}</label>
                                <input type="text" class="form-control" id="emp_name" name='emp_name' <?php if(!empty($showdata)){ ?> value='{{$showdata[0]->emp_name}}' <?php } ?> placeholder="Enter Employee Name" required>
                            </div>
                            <div class="form-group">
                                <label for="dist_code">{{ __('District Code')}}</label>
                                <select name='dist_code'  class='form-control' value='Select Option'>
                                    <option>Select State Code</option>
                                    <?php foreach($getdistrictcodedata as $getdistrictcode){ ?>
                                     <option value='<?php echo $getdistrictcode->district_code; ?>' @if(!empty($showdata)){{ $showdata[0]->dist_code == $getdistrictcode->district_code ? 'selected' : '' }} @endif ><?php echo $getdistrictcode->district_code; ?></option>
                                     <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="state_code">{{ __('State Code')}}</label>
                                <select name='state_code'  class='form-control' value='Select Option'>
                                    <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>
                            <br><br>
                            <button type="submit" class="btn btn-primary mr-2">{{ __('Submit')}}</button>
                            @if(empty($showdata))
                            <a href='{{'employee-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