@extends('template.app')

@section('meta')
@endsection

@section('title')
Settings
@endsection

@section('styles')
<link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet">
@endsection

@section('content')
@php
$tab = 'general';

if(\Session::has('tab'))
$tab = \Session::get('tab');
@endphp
<div class="page-breadcrumb">
    <div class="row">
        <div class="col-7 align-self-center">
            <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">Settings</h4>
            <div class="d-flex align-items-center">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb m-0 p-0">
                        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('settings') }}" class="text-muted">Settings</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">Update</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="col-5 align-self-center">
            <div class="customize-input float-right"></div>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="tab-content">
                        <div class="tab-pane @if($tab == 'general') active show @else fade @endif" id="general" aria-expanded="true">
                            <form action="{{ route('settings.update') }}" method="post">
                                <div class="row m-2">
                                    @method('post')
                                    @csrf
                                    <input type="hidden" name="tab" value="general">
                                    @if(isset($general) && $general->isNotEmpty())
                                        @foreach($general as $row)

                                        @if(isset($row->key) && ($row->key == 'MINIMUM_CASH_RECEIPT_BALANCE' || $row->key == 'MAXIMUM_CASH_RECEIPT_BALANCE'))
                                        <div class="form-group col-sm-6">
                                            <label><b>{{ strtoupper(str_replace('_', ' ', $row->key)) }}</b></label>
                                            <input type="text" name="{{ $row->id }}" class="form-control" value="{{ $row->value }}" placeholder="{{ strtoupper(str_replace('_', ' ', $row->key)) }}" />
                                        </div>
                                        @elseif(isset($row->key) && ($row->key == 'TERMS_AND_CONDITIONS'))
                                        <div class="form-group col-sm-12">
                                            <label><b>{{ strtoupper(str_replace('_', ' ', $row->key)) }}</b></label>
                                            <textarea name="{{ $row->id }}" class="form-control" placeholder="{{ strtoupper(str_replace('_', ' ', $row->key)) }}" rows="8">{{ $row->value }}</textarea>  
                                        </div>
                                        @endif

                                        @endforeach
                                    @endif
                                    <input type="submit" value="Save" class="btn waves-effect waves-light btn-rounded btn-outline-primary mb-3 ml-3">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('scripts')
<script src="{{ asset('assets/js/dropify.min.js') }}"></script>
<script src="{{ asset('assets/js/promise.min.js') }}"></script>
<script src="{{ asset('assets/js/sweetalert2.bundle.js') }}"></script>

<script>
    $(document).ready(function() {
        $('.dropify').dropify({
            messages: {
                'default': 'Drag and drop profile image here or click',
                'remove': 'Remove',
                'error': 'Ooops, something wrong happended.'
            }
        });

        var drEvent = $('.dropify').dropify();
    });
</script>
@endsection