<div class="page_title d-flex justify-content-between align-items-start">
    <div class="flex-grow-1">
        <h2>Pengaturan</h2>
        <p>Tambahan</p>
    </div>
</div>

<?php if($this -> session -> mart_demo == 0) : ?>
    <form class="card">
        <div class="card-body pt-4">
            <div class="row">
                <div class="col-md-8">
                    <ul class="list-group list-group-flush">
                        <li class="list-group-list d-flex justify-content-between align-items-start">
                            <div class="flex-grow-1">
                                <strong>
                                    Kertas Thermal
                                </strong>
                                <span class="d-block text-muted">
                                    Pilih ukuran default kertas Thermal
                                </span>
                            </div>
                            <div>
                                <?php 
                                    $app = $this->db->get('app')->row();
                                    
                                ?>
                                <select id="thermal" class="form-select select2-nosrc">
                                    <option <?= $app->thermal_size == '52' ? 'selected' : '' ?>>52</option>
                                    <option <?= $app->thermal_size == '58' ? 'selected' : '' ?>>58</option>
                                    <option <?= $app->thermal_size == '72' ? 'selected' : '' ?>>72</option>
                                </select>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </form>

    <script>
        $(document).on('change', '#thermal', function() {
            let val = this.value;

            $.post({
                url: base_url + 'proses/update_thermal_size', 
                data: {val: val},
                dataType: 'json',
                success: function(json) {
                    if(json.success == 1) {
                        toast({
                            title: json.msg,
                            icon: 'success',
                        })

                    } 
                },
                error: function(xhr, status, error) {
                    toast({
                        title: 'Ada yang salah, coba lagi',
                        icon: 'error'
                    })
                }
            });
        })

    </script>
<?php else: ?>
    <div class="msg warning">
        <i class="fa fa-info-circle me-1"></i>
        Halaman ini tidak tersedia untuk akun demo
    </div>
<?php endif ?>