@extends('admin.master')
@section('title') Member | Rent Car @endsection
@section('member') active @endsection
@section('styles')
@endsection
@section('main_content_section')

<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start heading-margin-bottom-minus">
        <h3 class="mb-0 pb-0"><span>Member Create</span></h3>
    </div>
</div>

<!-- BEGIN: Content-->
<div class="app-content content ">
    <div class="table_wrapper card">

        <div class="card-body">
            <form action="{{route('member.store')}}" method="post" onsubmit="return checkValidate(event)" enctype="multipart/form-data">
                @csrf
                <div class="row">
                    <div class="col-12 mb-4">
                        <div class="card-header border-bottom-0">
                            <h3 class="my-2 text-center">Bio Data</h3>
                        </div>
                    </div>

                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="member_name">Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="member_name" id="member_name" class="form-control form-control-solid" 
                                value="{{old('member_name')}}" placeholder="Name" required>
                        </div>
                    
                        @error('member_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="father_name">Father/Husband's Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="father_name" id="father_name" class="form-control form-control-solid" 
                                value="{{old('father_name')}}" placeholder="Father/Husband's Name" required>
                        </div>
                    
                        @error('father_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="mother_name">Mother's Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="mother_name" id="mother_name" class="form-control form-control-solid" 
                                value="{{old('mother_name')}}" placeholder="Mother's Name" required>
                        </div>
                    
                        @error('mother_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="present_address">Present Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="present_address" id="present_address" class="form-control form-control-solid" 
                                value="{{old('present_address')}}" placeholder="Present Address" required>
                        </div>
                    
                        @error('present_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="permanent_address">Permanent Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="permanent_address" id="permanent_address" class="form-control form-control-solid"
                                value="{{old('permanent_address')}}" placeholder="Permanent Address" required>
                        </div>
                    
                        @error('permanent_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="profession">Profession<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="profession" id="profession" class="form-control form-control-solid" 
                                value="{{old('profession')}}" placeholder="Profession" required>
                        </div>
                    
                        @error('profession')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>

                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="birth_of_date">Birth Date<span class=" text-danger">(required)</span> </label>
                    
                            <input type="text" class=" form-control flatpickr-basic custom-date-picker" name="birth_of_date" id="birth_of_date"
                                placeholder="DD-MM-YYYY" value="{{old('birth_of_date')}}" required>
                        </div>
                    
                        @error('birth_of_date')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nationality">Nationality<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nationality" id="nationality" class="form-control form-control-solid" 
                                value="{{old('nationality')}}" placeholder="Nationality" required>
                        </div>
                    
                        @error('nationality')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="professional_address">Professional Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="professional_address" id="professional_address" class="form-control form-control-solid"
                                value="{{old('professional_address')}}" placeholder="Professional Address" required>
                        </div>
                    
                        @error('professional_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="member_phone">Phone<span class="text-danger">(required)</span>
                            </label>
                            <input type="number" name="member_phone" id="member_phone" class="form-control form-control-solid" 
                                value="{{old('member_phone')}}" placeholder="Phone" required>
                        </div>
                    
                        @error('member_phone')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-12 mb-3">
                        <div class="form-group">
                            <label for="nid_no">National ID No<span class="text-danger">(required)</span>
                            </label>
                            <input type="number" name="nid_no" id="nid_no" class="form-control form-control-solid" 
                                value="{{old('nid_no')}}" placeholder="National ID No" required>
                        </div>
                    
                        @error('nid_no')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>

                    <div class="col-md-12 mb-3">
                        <div class="form-group">
                            <label for="name">Profile Photo<span class=" text-danger">(required)</span></label> <br>
                            <div class=" position-relative custom-soft-setting dropzone">
                                <div class="select_imgWith_preview custom-product-img py-2">
                                    <img id="uploadPreview" src="{{ asset('backend/template-assets/') }}/images/img_preview.png">
                    
                                    <div id="dropzone-block" class="custom-media-upload-block mt-3">
                                        <span class="dropzone-label fw-bolder">Upload Photo</span>
                                    </div>
                                    <input id="uploadImage" type="file" name="member_photo"
                                        onchange="PreviewImage('uploadImage','uploadPreview');" required />
                    
                                    <span onclick="cancelPreview('uploadImage','uploadPreview')" class="material-symbols-outlined"
                                        id="image_remove_buttton">
                                        close </span>
                                </div>
                            </div>

                            @error('member_photo')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                    </div>

                </div>

                {{-- //For Nomini Bio Data... --}}
                <div class="row mt-4">

                    <div class="col-12 mb-4">
                        <div class="card-header border-bottom-0">
                            <h3 class="my-2 text-center">Bio of Nomini</h3>
                        </div>
                    </div>

                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_name">Nomini Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_name" id="nomini_name" class="form-control form-control-solid" 
                                value="{{old('nomini_name')}}" placeholder="Nomini Name" required>
                        </div>
                    
                        @error('nomini_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_father_name">Nomini Father/Husband's Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_father_name" id="nomini_father_name" class="form-control form-control-solid"
                                value="{{old('nomini_father_name')}}" placeholder="Father/Husband's Name" required>
                        </div>
                    
                        @error('nomini_father_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_mother_name">Nomini Mother's Name<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_mother_name" id="nomini_mother_name" class="form-control form-control-solid"
                                value="{{old('nomini_mother_name')}}" placeholder="Mother's Name" required>
                        </div>
                    
                        @error('nomini_mother_name')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_present_address">Nomini Present Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_present_address" id="nomini_present_address"
                                class="form-control form-control-solid" value="{{old('nomini_present_address')}}" 
                                placeholder="Present Address" required>
                        </div>
                    
                        @error('nomini_present_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_permanent_address">Nomini Permanent Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_permanent_address" id="nomini_permanent_address"
                                class="form-control form-control-solid" value="{{old('nomini_permanent_address')}}" 
                                placeholder="Permanent Address" required>
                        </div>
                    
                        @error('nomini_permanent_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_profession">Nomini Profession<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_profession" id="nomini_profession" class="form-control form-control-solid"
                                value="{{old('nomini_profession')}}" placeholder="Nomini Profession" required>
                        </div>
                    
                        @error('nomini_profession')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_birth_of_date">Nomini Birth Date<span class="text-danger">(required)</span> </label>
                    
                            <input type="text" class=" form-control flatpickr-basic custom-date-picker" name="nomini_birth_of_date"
                                id="nomini_birth_of_date" placeholder="DD-MM-YYYY" value="{{old('nomini_birth_of_date')}}" required>
                        </div>
                    
                        @error('nomini_birth_of_date')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_nationality">Nomini Nationality<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_nationality" id="nomini_nationality" class="form-control form-control-solid"
                                value="{{old('nomini_nationality')}}" placeholder="Nomini Nationality" required>
                        </div>
                    
                        @error('nomini_nationality')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_professional_address">Nomini Professional Address<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="nomini_professional_address" id="nomini_professional_address"
                                class="form-control form-control-solid" value="{{old('nomini_professional_address')}}" 
                                placeholder="Professional Address" required>
                        </div>
                    
                        @error('nomini_professional_address')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_phone">Nomini Phone<span class="text-danger">(required)</span>
                            </label>
                            <input type="number" name="nomini_phone" id="nomini_phone" class="form-control form-control-solid" 
                                value="{{old('nomini_phone')}}" placeholder="Nomini Phone" required>
                        </div>
                    
                        @error('nomini_phone')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="relation">Relation<span class="text-danger">(required)</span>
                            </label>
                            <input type="text" name="relation" id="relation" class="form-control form-control-solid" 
                                value="{{old('relation')}}" placeholder="Relation" required>
                        </div>
                    
                        @error('relation')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-6 mb-3">
                        <div class="form-group">
                            <label for="nomini_nid_no">Nomini National ID No<span class="text-danger">(required)</span>
                            </label>
                            <input type="number" name="nomini_nid_no" id="nomini_nid_no" class="form-control form-control-solid"
                                value="{{old('nomini_nid_no')}}" placeholder="National ID No" required>
                        </div>
                    
                        @error('nomini_nid_no')
                        <span class=text-danger>{{$message}}</span>
                        @enderror
                    </div>
                    
                    <div class="col-md-12 mb-2">
                        <div class="form-group">
                            <label for="name">Profile Image<span class=" text-danger">(required)</span></label> <br>
                            <div class=" position-relative custom-soft-setting dropzone">
                                <div class="select_imgWith_preview custom-product-img py-2">
                                    <img id="uploadPreviewfnc" src="{{ asset('backend/template-assets/') }}/images/img_preview.png">
                    
                                    <div id="dropzone-block" class="custom-media-upload-block mt-3">
                                        <span class="dropzone-label fw-bolder">Upload Photo</span>
                                    </div>
                                    <input id="uploadImagefnc" type="file" name="nomini_photo"
                                        onchange="PreviewImageFNC('uploadImagefnc','uploadPreviewfnc');" required />
                    
                                    <span onclick="cancelPreviewFNC('uploadImagefnc','uploadPreviewfnc')" class="material-symbols-outlined"
                                        id="image_remove_buttton">
                                        close </span>
                                </div>
                            </div>

                            @error('nomini_photo')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-12 d-flex align-items-center" style="margin-top: 15px;">
                        <input type="submit" name="submit" class="btn btn btn-success" value="Save Mamber">
                    </div>

                </div>
            </form>
        </div>

    </div>

</div>
<!-- END: Content-->

@endsection

@section('scripts')
<script>
    $(document).ready(function(){
        $("#birth_of_date, #nomini_birth_of_date").flatpickr({
            allowInput: true,
            dateFormat: "d-m-Y",
        });
    });

    function checkValidate(event) {
        var mobileNumber1 = $("#member_phone").val();
        if (mobileNumber1 != '' && mobileNumber1.length != 11) { 
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit."); 
        }
        
        var mobileNumber2 = $("#nomini_phone").val();
        if (mobileNumber2 != '' && mobileNumber2.length != 11) { 
            event.preventDefault();
            toastr.error("Nomini mobile number must be 11 digit."); 
        }

        return true;
    }

    //For image preview...
    function PreviewImage(selectFile, previewImg) {
        var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById(selectFile).files[0]);

        oFReader.onload = function (oFREvent) {
            document.getElementById(previewImg).src = oFREvent.target.result;
        };
    }

    function cancelPreview(selectFile, previewImg) {
        const img = document.getElementById(previewImg);
        img.src = window.location.origin + "/backend/template-assets/images/img_preview.png";
        $("#" + selectFile).val('');
    }
    
    //For image preview...
    function PreviewImageFNC(selectFile, previewImg) {
        var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById(selectFile).files[0]);

        oFReader.onload = function (oFREvent) {
            document.getElementById(previewImg).src = oFREvent.target.result;
        };
    }

    function cancelPreviewFNC(selectFile, previewImg) {
        const img = document.getElementById(previewImg);
        img.src = window.location.origin + "/backend/template-assets/images/img_preview.png";
        $("#" + selectFile).val('');
    }
</script>
@endsection