<?= $this->extend('backend/layout/template_admin'); ?>

<?= $this->section('content'); ?>



<!-- /.content-header -->

<!-- Main content -->
<section class="content">
    <div class="container-fluid">


        <div class="row">

            <div class="col-md-12">

                <div class="row">
                    <div class="col-md-2">
                        <p>Tanggal Buka</p>
                    </div>
                    <div class="col-md-8 tampiltglbuka">
                        <p><?= $tglbuka['tglbuka']; ?></p>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-2">

                    </div>
                    <div class="col-md-8">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#editTanggalModal">
                            Edit Tanggal
                        </button>
                    </div>
                </div>


                <div class="overlay asal-divisi-overlay" style="display: none;">
                    <!-- <i class="fas fa-sync fa-spin"></i> -->
                    <div id='loading-img'></div>
                </div>

                <!-- Modal Edit -->
                <div class="modal fade" id="editTanggalModal" tabindex="-1" aria-labelledby="editTanggalModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="editTanggalModalLabel">Edit Tanggal Buka PPDB</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <form method="post" action="" id="edittanggalform">
                                    <?= csrf_field(); ?>
                                    <input type="hidden" name="idtanggal" value="<?= $tglbuka['id']; ?>">
                                    <div class="form-group row">
                                        <label for="tglbuka" class="col-sm-2 col-form-label">Tanggal Buka</label>
                                        <div class="col-sm-10">
                                            <input type="datetime-local" class="form-control" name="tglbuka" value="<?= $tglbuka['tglbuka']; ?>">
                                        </div>
                                    </div>

                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="submit" class="btn btn-primary">Updates</button>
                            </div>
                            </form>
                        </div>
                    </div>
                </div>



            </div>
        </div>



    </div><!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->

<script>
    $(document).ready(function() {


        // edit tanggal
        $("#edittanggalform").submit(function(event) {
            event.preventDefault();
            // $('#tambahmenuform')[0].reset();
            $.ajax({
                url: '<?= base_url(); ?>/setting/edittanggal',
                type: 'post',
                data: $(this).serialize(),
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    if (data.responce == "success") {
                        $('#editTanggalModal').modal('hide');
                        $(".tampiltglbuka").html("<p>" + data.update.tglbuka + "</p>");

                        toastr["success"](data.pesan);
                    } else {
                        toastr["error"](data.pesan);
                    }

                }

            });
        })






    })
</script>

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