@extends('layouts.app')
@section('content')
<?php
$posturl = url("location/nationality");
$successurl = url("location/nationality");
$successurlnxt = url('location/nationality');
$gotosuccess = true; $successmessage = $failureurl = $name = "";
$name = $code = ""; $id = null;
if (!empty($details)){
    $id = $details['uuid'] ?? $details['id'];
    $name = $details['name'];
    $code = $details['code'];
}
?>
<div class="pcoded-content">
    <div class="pcoded-inner-content">

        <div class="main-body">
            <div class="page-wrapper">
                <!-- Page-header start -->
                <div class="page-header card page-body">
                    <div class="row align-items-end">
                        <div class="col-lg-8">
                            <div class="page-header-title">
                                <i class="icofont icofont icofont icofont-file-document bg-c-pink"></i>
                                <div class="d-inline">
                                    <h4>Nationality</h4>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-4">
                            <div class="page-header-breadcrumb">
                                <ul class="breadcrumb-title">
                                    <li class="breadcrumb-item">
                                        <a href="#">
                                            <i class="icofont icofont-home"></i>
                                        </a>
                                    </li>
                                    <li class="breadcrumb-item"><a href="#!">Location</a>
                                    </li>
                                    <li class="breadcrumb-item"><a href="#!">Nationality</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <hr>
                    <div class="row">
                        <div class="col-sm-12">
                            @if (session('success_message'))
                                <div class="alert alert-success alert-dismissible fade show" role="alert">
                                    {{ session('success_message') }}
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            @endif

                            @if (session('error_message'))
                                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                    {{ session('error_message') }}
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            @endif

                            @if ($errors->any())
                                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                    <ul class="mb-0">
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            @endif

                            <form method="POST" action="<?= $posturl ?>">
                                @csrf
                                <input type="hidden" id="id" name="id" value="<?= $id; ?>" />
                                <input name="entityname" id="entityname" type="hidden" value="Nationality" />
                                <input type="hidden" id="action" name="action"value="" />
                                <input type="hidden" id="<?php echo "SUCCESS_MESSAGE"; ?>" name="<?php echo "SUCCESS_MESSAGE"; ?>" value="<?php echo $successmessage; ?>" />
                                <input type="hidden" id="<?php echo "URL_SUCCESS"; ?>" name="successurl" value="<?php echo base64_encode($successurl); ?>" />
                                <input type="hidden" id="<?php echo "URL_FAILURE"; ?>" name="failureurl" value="<?php echo base64_encode($failureurl); ?>" />

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">Name</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="name" class="form-control" value="<?= $name ?>" required placeholder="Nationality Name">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">Code</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="code" class="form-control" value="<?= $code ?>" required placeholder="Nationality Code">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-10 col-form-label"></label>
                                    <button type="submit" class="col-sm-2 btn btn-primary">Submit</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
