@extends('admin.master')
@section('title') Settings | SHOP @endsection
@section('setting') active @endsection
@section('styles')
@endsection
@section('main_content_section')

<div class="app-content content min-vh-100">
    <div class="content-overlay"></div>
    <div class="header-navbar-shadow"></div>
    <div class="content-wrapper p-0">
        <div class="content-header row ps-2">
            <div class="content-header-left col-md-9 col-12">
                <div class="row breadcrumbs-top">
                    <div class="col-12">
                        <h3 class="content-header-title float-start my-3 mb-0">General Settings</h3>
                    </div>
                </div>
            </div>
        </div>

        <div class="content-body mt-2">
            <div class="row">
                <div class="col-12">

                    <!-- profile -->
                    <div class="card">
                        @if(isset($logo) && $logo->logo_image != null)
                        <form method="POST" action="{{route('logo.update', $logo->id)}}" enctype="multipart/form-data">
                            @csrf
                            @else
                            <form method="POST" action="{{route('logo.store')}}" enctype="multipart/form-data">
                                @csrf
                                @endif

                                <div class="card-header border-bottom">
                                    <h4 class="card-title">Sidebar</h4>
                                </div>
                                <div class="card-body py-2 my-25">
                                    <div class="row">
                                        <div class="col-md-6 h-100">
                                            <div class="col mb-3">

                                                <div id="card_body_5"
                                                    class=" mb-3 position-relative custom-soft-setting">
                                                    <div class="select_imgWith_preview">
                                                        <label class="fw-bolder" for="name">Sidebar Logo <span
                                                                class=" text-danger">(Recommanded
                                                                W:250px,H:150px)</span></label> <br>
                                                        @if(isset($logo) && $logo->logo_image != null)
                                                        <img id="uploadPreview1"
                                                            src="{{ asset('backend/uploads/logoImg/'.$logo->logo_image) }}">
                                                        @else
                                                        <img id="uploadPreview1"
                                                            src="{{ asset('backend/template-assets/') }}/images/img_preview.png">
                                                        @endif
                                                        <input id="uploadImage1" type="file" name="logo_image"
                                                            onchange="PreviewImage('uploadImage1','uploadPreview1');"
                                                            required />
                                                        <span onclick="cancelPreview('uploadImage1','uploadPreview1')"
                                                            class="material-symbols-outlined" id="image_remove_buttton">
                                                            close </span>
                                                    </div>
                                                </div>

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

                                        <div class="col-md-6 h-100">
                                            <div class="col mb-2">
                                                <span>
                                                    <div class="form-group custom-select2-form">
                                                        <label for="logo_width">Logo Width <span
                                                                class=" text-danger">(In pixel)</span></label>

                                                        <input type="number" class="form-control" name="logo_width"
                                                            id="logo_width" value="250" placeholder="Width" required>
                                                    </div>

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

                                            <div class="col mb-2">
                                                <span>
                                                    <div class="form-group custom-select2-form">
                                                        <label for="logo_height">Logo Height <span
                                                                class=" text-danger">(In pixel)</span></label>

                                                        <input type="number" class="form-control" name="logo_height"
                                                            id="logo_height" value="150" placeholder="Height" required>
                                                    </div>

                                                    @error('logo_height')
                                                    <span class=text-danger>{{$message}}</span>
                                                    @enderror
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-footer">
                                    <div class="row">
                                        <div class="col-12 text-end">
                                            <input type="submit" name="submit" id="formSubmit"
                                                class="btn btn btn-success" value="Update Logo">
                                        </div>
                                    </div>
                                </div>
                            </form>
                    </div>

                    <div class="card mt-5">
                        @if(isset($invoiceLogo) && $invoiceLogo->logo_image != null)
                        <form method="POST" action="{{route('invoice-logo.update', $invoiceLogo->id)}}"
                            enctype="multipart/form-data" onsubmit="return validateFU()">
                            @csrf
                            @else
                            <form method="POST" action="{{route('invoice-logo.store')}}" enctype="multipart/form-data"
                                onsubmit="return validate()">
                                @csrf
                                @endif

                                <div class="card-header border-bottom">
                                    <h4 class="card-title">Invoice</h4>
                                </div>
                                <div class="card-body py-2 my-25">
                                    <div class="row">
                                        <div class="col-md-6 h-100">
                                            <div class="col mb-3">

                                                <div id="card_body_5"
                                                    class=" mb-3 position-relative custom-soft-setting">
                                                    <label class="fw-bolder w-100" for="name">Invoice Logo <span
                                                            class=" text-danger">(Recommanded
                                                            W:200px,H:100px)</span></label> <br>
                                                    <div class="select_imgWith_preview">
                                                        @if(isset($invoiceLogo) && $invoiceLogo->logo_image != null)
                                                        <img id="uploadPreview2"
                                                            src="{{ asset('backend/uploads/invoiceLogoImg/'.$invoiceLogo->logo_image) }}">
                                                        @else
                                                        <img id="uploadPreview2"
                                                            src="{{ asset('backend/template-assets/') }}/images/img_preview.png">
                                                        @endif
                                                        <input id="uploadImage2" type="file" name="logo_image"
                                                            onchange="PreviewImage('uploadImage2','uploadPreview2');" required/>
                                                        <span onclick="cancelPreview('uploadImage2','uploadPreview2')"
                                                            class="material-symbols-outlined" id="image_remove_buttton">
                                                            close </span>
                                                    </div>
                                                </div>

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

                                        <div class="col-md-6 h-100">
                                            <div class="col mb-2">
                                                <span>
                                                    <div class="form-group custom-select2-form">
                                                        <label for="logo_width">Logo Width <span
                                                                class=" text-danger">(In
                                                                pixel)</span></label>

                                                        <input type="number" class="form-control" name="logo_width"
                                                            id="logo_width" value="250" placeholder="Width" required>
                                                    </div>

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

                                            <div class="col mb-2">
                                                <span>
                                                    <div class="form-group custom-select2-form">
                                                        <label for="logo_height">Logo Height <span
                                                                class=" text-danger">(In
                                                                pixel)</span></label>

                                                        <input type="number" class="form-control" name="logo_height"
                                                            id="logo_height" value="100" placeholder="Height" required>
                                                    </div>

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

                                    <div class="row">
                                        <div class="col-md-12 mb-2">
                                            <div>
                                                <span>
                                                    <div class="form-group custom-select2-form">
                                                        <label for="invoice_back_color">Invoice Back Color <span
                                                                class=" text-danger fw-bolder">(required)</span></label>
                                                        @if(isset($invoiceLogo) && $invoiceLogo->invoice_back_color !=
                                                        null)
                                                        <input type="color"
                                                            class="form-control custom-cursor-pointer custom-h-40"
                                                            name="invoice_back_color" id="invoice_back_color"
                                                            placeholder="Width"
                                                            value="{{$invoiceLogo->invoice_back_color}}" required>
                                                        @else
                                                        <input type="color"
                                                            class="form-control custom-cursor-pointer custom-h-40"
                                                            name="invoice_back_color" id="invoice_back_color"
                                                            placeholder="Width" value="#ffffff" required>
                                                        @endif
                                                    </div>

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

                                        <div class="col-md-12 mb-2">
                                            <div>
                                                <div class="form-group">
                                                    <label for="invoice_terms">Invoice Terms<span
                                                            class="text-danger fw-bolder">(required)</span>
                                                    </label>
                                                    <textarea type="text" name="invoice_terms" id="invoice_terms"
                                                        class="form-control form-control-solid" value=""
                                                        placeholder="Invoice Terms" rows="2"
                                                        cols="2">{!! $invoiceLogo != null ? $invoiceLogo->invoice_terms : '' !!}</textarea>
                                                </div>
                                                <span id="warnTextDesc1" class="text-danger warn d-none">Invoice Terms
                                                    is required</span>

                                                @error('invoice_terms')
                                                <span class=text-danger>{{$message}}</span>
                                                @enderror
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-footer">
                                    <div class="row">
                                        <div class="col-12 text-end">
                                            <input type="submit" name="submit" id="formSubmit"
                                                class="btn btn btn-success" value="Update Logo">
                                        </div>
                                    </div>
                                </div>
                            </form>
                    </div>


                    <div class="card mt-5">
                        <form action="{{route('footer-text-submit',$footerText->id)}}" method="post">
                            @csrf
                            <div class="card-header border-bottom">
                                <h4 class="card-title">Footer Text</h4>
                            </div>
                            <div class="card-body py-2">
                                <div class="row">
                                    <div class="com-md-12 mb-3">
                                        <div class="form-group">
                                            <label for="text">Footer Text <span
                                                    class=" text-danger fw-bolder">(required)</span></label>

                                            <textarea class="form-control" name="text" id="text" cols="2" rows="2"
                                                placeholder=" Footer Text" required>{!! $footerText->text !!}</textarea>
                                        </div>

                                        @error('text')
                                        <span class=text-danger>{{$message}}</span>
                                        @enderror
                                    </div>
                                </div>
                            </div>
                            <div class="card-footer">
                                <div class="row">
                                    <div class="col-12 text-end">
                                        <input type="submit" name="submit" id="formSubmit" class="btn btn btn-success"
                                            value="Update Text">
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>
            </div>

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

@endsection

@section('scripts')
<script>
    //For package description...
    tinymce.init({
      selector: '#invoice_terms',
      plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern textcolor"
      ],
      toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image | forecolor backcolor",
    });

    function validate(){
        if ((tinymce.EditorManager.get('invoice_terms').getContent()) == ''){
            event.preventDefault();
            document.getElementById('warnTextDesc1').classList.add('active')
            return false;
        }
    };
    function validateFU(){
        if ((tinymce.EditorManager.get('invoice_terms').getContent()) == ''){
            event.preventDefault();
            document.getElementById('warnTextDesc1').classList.add('active')
            return false;
        }
    };
</script>
@endsection