<?= $this->extend('backend/layout/main'); ?>
<?= $this->section('title'); ?>Settings<?= $this->endSection(); ?>
<?= $this->section('content'); ?>
<div class="dashboard-influence">
    <div class="container-fluid dashboard-content">
        <div class="row">
            <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                <div class="page-header">
                    <h3 class="mb-2">Edit Settings </h3>
                    <div class="page-breadcrumb">
                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="<?= url_to('admin_home') ?>" class="breadcrumb-link">Dashboard</a></li>
                                <li class="breadcrumb-item"><a href="<?= url_to('settings') ?>" class="breadcrumb-link">Settings</a></li>
                                <li class="breadcrumb-item active" aria-current="page">Edit Settings</li>
                            </ol>
                        </nav>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                <div class="card">
                    <h5 class="card-header">Fill the form to edit settings</h5>
                    <div class="card-body">
                        <?= view_cell('AlertCell') ?>
                        <?php $validation = service('validation'); ?>
                        <?= form_open(route_to('edit_settings', $id), [
                            'csrf_id' => 'csrf_id',
                            'novalidate' => '',
                            'data-parsley-validate' => '',
                            'id' => 'settings-form'
                        ]) ?>
                        <div class="form-group row">
                            <?= form_label('Email Address <span class="text-danger">*</span>', 'email', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'email',
                                        'id' => 'email',
                                        'required' => true,
                                        'placeholder' => 'Enter email address',
                                        'data-parsley-type' => 'email',
                                        'class' => 'form-control',
                                    ],
                                    set_value('email', $setup->email),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('email') ?></p>
                            </div>

                        </div>

                        <div class="form-group row">
                            <?= form_label('Phone Number <span class="text-danger">*</span>', 'phone', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'phone',
                                        'id' => 'last_name',
                                        'required' => true,
                                        'placeholder' => 'Enter phone number',
                                        'class' => 'form-control',
                                    ],
                                    set_value('phone', $setup->phone),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('phone') ?></p>
                            </div>

                        </div>

                        <div class="form-group row">
                            <?= form_label('Street <span class="text-danger">*</span>', 'street', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'street',
                                        'id' => 'street',
                                        'required' => true,
                                        'placeholder' => 'Enter street',
                                        'class' => 'form-control',
                                    ],
                                    set_value('street', $setup->street),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('street') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('District <span class="text-danger">*</span>', 'district', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'district',
                                        'id' => 'district',
                                        'required' => true,
                                        'placeholder' => 'Enter district',
                                        'class' => 'form-control',
                                    ],
                                    set_value('district', $setup->district),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('district') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Region <span class="text-danger">*</span>', 'region', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'region',
                                        'id' => 'region',
                                        'required' => true,
                                        'placeholder' => 'Enter region',
                                        'class' => 'form-control',
                                    ],
                                    set_value('region', $setup->region),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('region') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Twitter URL <span class="text-danger">*</span>', 'twitter', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'twitter',
                                        'id' => 'twitter',
                                        'required' => true,
                                        'placeholder' => 'Enter twitter URL',
                                        'class' => 'form-control',
                                    ],
                                    set_value('twitter', $setup->twitter),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('twitter') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Facebook URL <span class="text-danger">*</span>', 'facebook', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'facebook',
                                        'id' => 'facebook',
                                        'required' => true,
                                        'placeholder' => 'Enter facebook URL',
                                        'class' => 'form-control',
                                    ],
                                    set_value('facebook', $setup->facebook),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('facebook') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Instagram URL <span class="text-danger">*</span>', 'instagram', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'instagram',
                                        'id' => 'instagram',
                                        'required' => true,
                                        'placeholder' => 'Enter instagram URL',
                                        'class' => 'form-control',
                                    ],
                                    set_value('instagram', $setup->instagram),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('instagram') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Opening Hours Mon -  Sat <span class="text-danger">*</span>', 'opening_hrs_mon_sat', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'opening_hrs_mon_sat',
                                        'id' => 'opening_hrs_mon_sat',
                                        'required' => true,
                                        'placeholder' => 'Enter opening hours',
                                        'class' => 'form-control',
                                    ],
                                    set_value('opening_hrs_mon_sat', $setup->opening_hrs_mon_sat),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('opening_hrs_mon_sat') ?></p>
                            </div>

                        </div>
                        <div class="form-group row">
                            <?= form_label('Opening Hours Sunday <span class="text-danger">*</span>', 'opening_hrs_sun', ['class' => 'col-12 col-sm-3 col-form-label text-sm-right']) ?>
                            <div class="col-12 col-sm-8 col-lg-6">
                                <?= form_input(
                                    [
                                        'name' => 'opening_hrs_sun',
                                        'id' => 'opening_hrs_sun',
                                        'required' => true,
                                        'placeholder' => 'Enter opening hours',
                                        'class' => 'form-control',
                                    ],
                                    set_value('opening_hrs_sun', $setup->opening_hrs_sun),
                                ) ?>
                                <p class="text-danger small pt-2"><?= $validation->getError('opening_hrs_sun') ?></p>
                            </div>

                        </div>

                        <div class="form-group row text-right">
                            <div class="col col-sm-10 col-lg-9 offset-sm-1 offset-lg-0">
                                <?= form_button(
                                    [
                                        'type' => 'submit',
                                        'class' => 'btn btn-space btn-primary',
                                    ],
                                    'Validate and Submit',
                                ) ?>
                                <a href="<?= url_to('settings') ?>" class="btn btn-space btn-secondary">Cancel</a>
                            </div>
                        </div>
                        <?= form_close(); ?>
                    </div>
                </div>
            </div>

        </div>


    </div>
</div>
<?= $this->endSection(); ?>

<?= $this->section('js'); ?>
<script src="<?= base_url() ?>assets/backend/vendor/parsley/parsley.js"></script>
<?= $this->endSection(); ?>

<?= $this->section('scripts'); ?>
<script>
    $('#settings-form').parsley();
    (function() {
        'use strict';
        window.addEventListener('load', function() {
            // Fetch all the forms we want to apply custom Bootstrap validation styles to
            var forms = document.getElementsByClassName('needs-validation');
            // Loop over them and prevent submission
            var validation = Array.prototype.filter.call(forms, function(form) {
                form.addEventListener('submit', function(event) {
                    if (form.checkValidity() === false) {
                        event.preventDefault();
                        event.stopPropagation();
                    }
                    form.classList.add('was-validated');
                }, false);
            });
        }, false);
    })();
</script>
<?= $this->endSection(); ?>