<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Pengaturan Umum</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="<?php echo base_url('beranda') ?>">Beranda</a></li>
                        <li class="breadcrumb-item">Pengaturan</li>
                        <li class="breadcrumb-item active"><a href="#">Umum</a></li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">
        <div class="container">
            <div id="peringatan"></div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="card card-success card-outline">
                        <form action="" id="formdata" method="post">
                            <div class="card-body">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Nama Toko</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="toko" name="toko" value="<?php echo @$toko ?>" required>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Telepon</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="telepon" name="telepon" value="<?php echo @$telepon ?>">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Alamat</label>
                                    <div class="col-sm-9">
                                        <textarea class="form-control" id="alamat" name="alamat"><?php echo @$alamat ?></textarea>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Minimal Belanja Untuk Mendapat 1 Poin</label>
                                    <div class="col-sm-9">
                                        <input type="number" class="form-control" id="dapatpoin" name="dapatpoin" value="<?php echo @$dapatpoin ?>">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Nilai Rupiah 1 Poin</label>
                                    <div class="col-sm-9">
                                        <input type="number" class="form-control" id="nilaipoin" name="nilaipoin" value="<?php echo @$nilaipoin ?>">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label"></label>
                                    <label class="col-sm-3 col-form-label">
                                        Perhitungan PKM
                                    </label>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Rata-Rata Penjualan</label>
                                    <div class="col-sm-3">
                                        <div class="input-group mb-3">
                                            <input type="number" class="form-control" id="ratajual" name="ratajual" value="<?php echo @$ratajual ?>">
                                            <span class="input-group-text">Hari</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">Lead Time</label>
                                    <div class="col-sm-3">
                                        <div class="input-group mb-3">
                                            <input type="number" class="form-control" id="lt" name="lt" value="<?php echo @$lt ?>">
                                            <span class="input-group-text">Hari</span>
                                        </div>
                                        <span style="font-size: 8pt; color: red;">Rentang waktu pemesanan barang hingga tiba di toko</span>
                                    </div>
                                </div>
                            </div>
                            <div class="card-footer">
                                <button type="submit" value="Simpan" class="btn btn-success"><i class="fa fa-save"></i> Simpan</button>
                                <a href="<?php echo base_url('beranda') ?>" class="btn btn-danger"><i class="fa fa-times"></i> Batal</a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End #main -->
<?php @$this->load->view($footer) ?>
<!-- Page specific script -->
<script type="text/javascript">
$(function(){
    $("#formdata").submit(function(event){
        event.preventDefault();
        $.ajax({
            url:"<?php echo base_url('pengaturan/simpan_umum') ?>",
            cache: false,
            type:"POST",
            data:$(this).serialize(),
            dataType:"JSON",
            success:function(result) {
                $("#peringatan").html(result.pesan);
                if (result.ikon=='success') {
                    toastr.success(result.toas);
                } else if (result.ikon=='warning') {
                    toastr.warning(result.toas);
                } else if (result.ikon=='error') {
                    toastr.error(result.toas);
                }
            }
        });
    });
});
</script>
<!-- Page specific script -->
<?php @$this->load->view($footerend) ?>