<div class="page_title">
	<h2>Profil</h2>
	<p>Profil saya</p>
</div>

<?php if($this -> session -> mart_demo == 0) : ?>
    <form method="POST" class="card">
        <div class="card-body">
            <div class="row mb-4">
                <div class="col-sm-3 mb-2">
                    <strong class="d-block">Posisi</strong>
                    <small class="text-muted">
                        Posisi saat ini sebagai
                    </small>
                </div>                    
                <div class="col-sm-9">
                    <input type="text" 
                            class="form-control" 
                            disabled 
                            value="<?= $this -> session -> mart_level ?>"
                    >
                </div>
            </div>
            <div class="row mb-4">
                <div class="col-sm-3 mb-2">
                    <strong class="d-block">Penempatan</strong>
                    <small class="text-muted">
                        Penempatan tugas saat ini
                    </small>
                </div>                    
                <div class="col-sm-9">
                    <input type="text" required 
                            class="form-control" 
                            disabled 
                            value="<?php print_r($this -> app -> get_toko($this -> session -> mart_toko, 'nama')) ?>"
                    >
                </div>
            </div>
            <div class="row mb-4">
                <div class="col-sm-3 mb-2">
                    <strong class="d-block">Nama Karyawan</strong>
                    <small class="text-muted">
                        Update nama karyawan
                    </small>
                </div>                    
                <div class="col-sm-9">
                    <input type="text" required 
                            class="form-control" 
                            autocomplete="off" 
                            name="nama"
                            value="<?= $this -> session -> mart_nama ?>" 
                    >
                </div>
            </div>
            <div class="row mb-4">
                <div class="col-sm-3 mb-2">
                    <strong class="d-block">Email</strong>
                    <small class="text-muted">
                        Email yang digunakan untuk login
                    </small>
                </div>                    
                <div class="col-sm-9">
                    <input type="text" required 
                            class="form-control" 
                            name="email"
                            value="<?= $this -> session -> mart_email ?>"
                    >
                </div>
            </div>
            
        </div>
        <div class="text-end card-footer">
            <button class="btn btn-primary px-3">
                Simpan
            </button>
            <a href="javascript:history.back()" class="btn px-3">
                kembali
            </a>
        </div>
    </form>

    <script>
        $('form').on('submit', function(e) {
            e.preventDefault()
            $.post({
                url: base_url + 'profil/update',
                data: $(this).serialize(),
                dataType: 'json',
                success: json => {
                    if(json.success == 1) {
                        toast({
                            icon: 'success',
                            title: 'Profil sudah diupdate'
                        })
                    }
                }
            })
        })
    </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 ?>