@extends('backend.master')

@section('mainContent')
    {{generateBreadcrumb()}}

    <section class="mb-40 student-details">
        <div class="container-fluid p-0">
            <div class="row">

                <div class="col-lg-12">

                    <form class="form-horizontal" action="{{route('tax.setting.store')}}" method="POST"
                          enctype="multipart/form-data">

                        @csrf
                        <div class="white-box">

                            <div class="col-md-12 p-0">

                                <div class="row  ">
                                    <div class="col-md-12">

                                        <div class="row">

                                            <div class="col-xl-6">
                                                <div class="primary_input mb-25">
                                                    <div class="row">
                                                        <div class="col-md-12 mb-3">
                                                            <label class="primary_input_label"
                                                                   for="    "> {{__('tax.Apply TAX')}}  </label>
                                                        </div>

                                                        <div class="col-md-6">
                                                            <div class="row row-gap-24">
                                                                <div class="col-md-4">
                                                                    <input type="radio"
                                                                           class="common-radio "
                                                                           id="yes"
                                                                           name="status"
                                                                           {{$setting->status==1?'checked':''}}
                                                                           value="1">
                                                                    <label
                                                                        for="yes">{{__('common.Yes')}}</label>
                                                                </div>
                                                                <div class="col-md-4">

                                                                    <input type="radio"
                                                                           class="common-radio "
                                                                           id="no"
                                                                           name="status"
                                                                           value="0" {{$setting->status==0?'checked':''}}>
                                                                    <label
                                                                        for="no">{{__('common.No')}}</label>
                                                                </div>
                                                            </div>


                                                        </div>

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

                                            <div class="col-xl-6">
                                                <div class="primary_input mb-25">
                                                    <div class="row">
                                                        <div class="col-md-12 mb-3">
                                                            <label class="primary_input_label"
                                                                   for="    "> {{__('tax.TAX Type')}}  </label>
                                                        </div>

                                                        <div class="col-md-12">
                                                            <div class="row row-gap-24">
                                                                <div class="col-md-4">
                                                                    <input type="radio"
                                                                           class="common-radio type"
                                                                           id="type1"
                                                                           name="type"
                                                                           {{$setting->tax_type==1?'checked':''}}
                                                                           value="1">
                                                                    <label
                                                                        for="type1">{{__('tax.Common Tax')}}</label>
                                                                </div>
                                                                <div class="col-md-4">

                                                                    <input type="radio"
                                                                           class="common-radio type"
                                                                           id="type0"
                                                                           name="type"
                                                                           value="0" {{$setting->tax_type==0?'checked':''}}>
                                                                    <label class="text-nowrap"
                                                                           for="type0">{{__('tax.Country Wish Tax')}}</label>
                                                                </div>
                                                            </div>


                                                        </div>

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

                                            <div class="col-xl-4" id="commonPercentage">
                                                <div class="primary_input mb-25">
                                                    <label class="primary_input_label"
                                                           for="">{{ __('tax.Percentage') }}</label>
                                                    <input class="primary_input_field" placeholder="-" type="number"
                                                           min="0" max="100"
                                                           name="percentage"
                                                           value="{{$setting->percentage}}">
                                                </div>
                                            </div>
                                            <div class="col-xl-12 text-end" id="countryWishPercentage">
                                                <label class="primary_input_label"
                                                       for="">{{ __('tax.Update tax percentage from  Country Wish Tax section') }}</label>
                                            </div>

                                        </div>
                                    </div>

                                </div>
                            </div>

                            <div class="row  ">
                                <div class="col-lg-12 d-flex justify-content-center align-content-center">
                                    <button type="submit" class="primary-btn fix-gr-bg" data-bs-toggle="tooltip"
                                    >
                                        <i class="ti-check"></i>
                                        {{__('common.Update')}}
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
@endsection
@push('scripts')
    <script>
        (function ($) {
            "use strict";

            function readURL1(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();
                    reader.onload = function (e) {
                        $(".imagePreview1").attr('src', e.target.result);
                    }
                    reader.readAsDataURL(input.files[0]);
                }
            }

            $(".imgInput1").change(function () {
                readURL1(this);
            });

            $("body").on('change', '.type', function () {
                var type = $("input[name='type']:checked").val()
                if (type == 1) {
                    $('#commonPercentage').show();
                    $('#countryWishPercentage').hide();
                } else {
                    $('#commonPercentage').hide();
                    $('#countryWishPercentage').show();

                }
            });
            $('.type').trigger('change');

        })(jQuery);
    </script>
@endpush
