@extends('admin.layouts.app')
@section('panel')
    <div class="row mb-none-30">
        <div class="col-lg-12 col-md-12 mb-30">
            <div class="card">
                <form action="{{ route('admin.setting.update') }}" method="POST">
                    @csrf
                    <div class="card-body">
                        <div class="card">
                            <div class="card-header mb-3">
                                <h4 class="card-title">@lang('Site Setting')</h4>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group ">
                                            <label> @lang('Site Title')</label>
                                            <input class="form-control" type="text" name="site_name" required
                                                value="{{ $general->site_name }}">
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group ">
                                            <label>@lang('Currency')</label>
                                            <input class="form-control" type="text" name="cur_text" required
                                                value="{{ __($general->cur_text) }}">
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group ">
                                            <label>@lang('Currency Symbol')</label>
                                            <input class="form-control" type="text" name="cur_sym" required
                                                value="{{ $general->cur_sym }}">
                                        </div>
                                    </div>
                                    <div class="form-group col-sm-6">
                                        <label> @lang('Timezone')</label>
                                        <select class="select2-basic" name="timezone">
                                            @foreach ($timezones as $timezone)
                                                <option value="'{{ @$timezone }}'">{{ __($timezone) }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-group col-sm-6">
                                        <label> @lang('Site Base Color')</label>
                                        <div class="input-group">
                                            <span class="input-group-text p-0 border-0">
                                                <input type='text' class="form-control colorPicker"
                                                    value="{{ $general->base_color }}" />
                                            </span>
                                            <input type="text" class="form-control colorCode" name="base_color"
                                                value="{{ $general->base_color }}" />
                                        </div>
                                    </div>

                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group">
                                            <label>@lang('E-Pin Generate Charge')</label>
                                            <div class="input-group">
                                                <input type="text" id="epin_charge" class="form-control form-control-lg"
                                                    value="{{ getAmount($general->epin_charge) }}" name="epin_charge"
                                                    aria-describedby="basic-addon2" required="">
                                                <div class="input-group-text">%</div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group">
                                            <label>@lang('Balance Transfer Percent Charge')</label>
                                            <div class="input-group">
                                                <input type="text" id="balance_transfer_percent_charge"
                                                    class="form-control form-control-lg"
                                                    value="{{ getAmount($general->balance_transfer_percent_charge) }}"
                                                    name="balance_transfer_percent_charge" aria-describedby="basic-addon2"
                                                    required="">
                                                <div class="input-group-text">
                                                    %
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-md-4 col-sm-6">
                                        <div class="form-group">
                                            <label>@lang('Balance Transfer Fixed Charge ')</label>
                                            <div class="input-group mb-3">
                                                <input type="text" id="price" class="form-control form-control-lg"
                                                    value="{{ getAmount($general->balance_transfer_fixed_charge) }}"
                                                    name="balance_transfer_fixed_charge" required>
                                                <div class="input-group-text">{{ __($general->cur_text) }}</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="card my-3">
                            <div class="card-body">
                                @csrf

                                <div class="card my-3">
                                    <div class="card-header">
                                        <h4>@lang('Company Adresss')</h4>
                                    </div>
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('Street Address')</label>
                                                    <input type="text" class="form-control" name="street_address"
                                                        value="{{ $general->street_address ?? '' }}" required>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('City')</label>
                                                    <input type="text" class="form-control" name="city"
                                                        value="{{ $general->city ?? '' }}" required>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('State')</label>
                                                    <input type="text" class="form-control" name="state"
                                                        value="{{ $general->state ?? '' }}" required>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('Pin Code')</label>
                                                    <input type="text" class="form-control" name="pin_code"
                                                        value="{{ $general->pin_code ?? '' }}" required>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('Country')</label>
                                                    <input type="text" class="form-control" name="country"
                                                        value="{{ $general->country ?? '' }}" required>
                                                </div>
                                            </div>

                                            {{-- <div class="col-md-6">
                                                <div class="form-group ">
                                                    <label>@lang('Country')</label>
                                                    <select name="country" class="form-control">
                                                        @foreach($countries as $key => $country)
                                                            <option data-mobile_code="{{ $country->dial_code }}" value="{{ $key }}">{{ __($country->country) }}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                            </div> --}}


                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('Contact Number')</label>
                                                    <input type="text" class="form-control" name="number"
                                                        value="{{ $general->number ?? '' }}" required>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>@lang('Email Address')</label>
                                                    <input type="text" class="form-control" name="email"
                                                        value="{{ $general->email ?? '' }}" required>
                                                </div>
                                            </div>

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

                                <div class="form-group">
                                    <button type="submit" class="btn btn--primary w-100 h-45">@lang('Submit')</button>
                                </div>

                            </div>
                        </div>
                    </div>
                </form>
            </div>
        @endsection

        @push('script-lib')
            <script src="{{ asset('assets/admin/js/spectrum.js') }}"></script>
        @endpush

        @push('style-lib')
            <link rel="stylesheet" href="{{ asset('assets/admin/css/spectrum.css') }}">
        @endpush

        @push('script')
            <script>
                (function($) {
                    "use strict";
                    $('.colorPicker').spectrum({
                        color: $(this).data('color'),
                        change: function(color) {
                            $(this).parent().siblings('.colorCode').val(color.toHexString().replace(/^#?/, ''));
                        }
                    });

                    $('.colorCode').on('input', function() {
                        var clr = $(this).val();
                        $(this).parents('.input-group').find('.colorPicker').spectrum({
                            color: clr,
                        });
                    });

                    $('select[name=timezone]').val("'{{ config('app.timezone') }}'").select2();
                    $('.select2-basic').select2({
                        dropdownParent: $('.card-body')
                    });
                })(jQuery);
            </script>
        @endpush
        {{-- @push('script')
        <script>
            (function($){
            "use strict"
                $('.bal-btn').click(function(){
                    var act = $(this).data('act');
                    $('#addSubModal').find('input[name=act]').val(act);
                    if (act == 'add') {
                        $('.type').text('Add');
                    }else{
                        $('.type').text('Subtract');
                    }
                });
                let mobileElement = $('.mobile-code');
                $('select[name=country]').change(function(){
                    mobileElement.text(`+${$('select[name=country] :selected').data('mobile_code')}`);
                });

                $('select[name=country]').val('{{@$general->country_code}}');
                let dialCode        = $('select[name=country] :selected').data('mobile_code');
                let mobileNumber    = `{{ $general->mobile }}`;
                mobileNumber        = mobileNumber.replace(dialCode,'');
                $('input[name=mobile]').val(mobileNumber);
                mobileElement.text(`+${dialCode}`);

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