@extends('layouts.admin.main')

@section('content')
<div class="col-md-12">
    <div class="card">
        <div class="card-header">
            Configuration Générale
        </div>
        <div class="card-body">
            <div class="row form-group">
                <div class="col-md-6">
                    <div class="col col-md-8"><label for="text-input" class=" form-control-label">Horaire publique</label><small class="form-text text-muted">L'horaire est t-il disponible publique sur la page d'accueil du site</small></div>
                    <div class="col col-md-4" style="margin: auto;">
                        <label for="disabled-input" class=" form-control-label"></label>
                        <label class="switch switch-3d switch-primary mr-3" style="margin-left: 3rem;"><input id="is_schedule_public" name="is_schedule_public" class="switch-input" @if($configs->where('name','is_schedule_public')->first()->state == 1) checked="true" @endif type="checkbox" onchange="saveChange('is_schedule_public')"><span class="switch-label"></span><span class="switch-handle"></span></label>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="col col-md-8"><label for="text-input" class=" form-control-label">Horaire complet</label><small class="form-text text-muted">L'horaire est t-il complet ? Si cette option est désactivé les utilisateurs ne reseverons pas de notification concernant l'horaire</small></div>
                    <div class="col col-md-4" style="margin: auto;">
                        <label for="disabled-input" class=" form-control-label"></label>
                        <label class="switch switch-3d switch-primary mr-3" style="margin-left: 3rem;"><input id="is_schedule_build" name="is_schedule_build" class="switch-input" @if($configs->where('name','is_schedule_build')->first()->state == 1) checked="true" @endif type="checkbox" onchange="saveChange('is_schedule_build')"><span class="switch-label"></span><span class="switch-handle"></span></label>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('breadcrumb')
    <div class="breadcrumbs">
        <div class="col-sm-4">
            <div class="page-header float-left">
                <div class="page-title">
                    <h1>Configuration Générale</h1>
                </div>
            </div>
        </div>
        <div class="col-sm-8">
            <div class="page-header float-right">
                <div class="page-title">
                    <ol class="breadcrumb text-right">
                        <li class="active">Configuration/Générale</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('custom_scripts')
<script>
    function saveChange(pPerm) {
        (function($) {
		var myswitch = document.getElementById(pPerm);
		$.post('/api/config/general/save?api_token='+api_token, { value: myswitch.checked,perm: pPerm } , function(data) {
            swal({
            title: 'Modification enregistré !',
            type: 'success',
            }).then((result) => {
            if (result.value) {
                location.reload();
            }
            })
          });
	    })(jQuery);
    }
</script>
@endsection
