<?php echo $this->extend('/template'); ?>
<?php echo $this->section('content') ?>

<head>
    <title>TUJUAN MUDIK</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>

</head>
<div class="rows">
<div class="col-sm-7">
<h3>
    <img src="<?php echo base_url(); ?>/assets/images/pemprovsmr/header_icon.png" width="35px">&nbsp;<b>KELOLA TUJUAN MUDIK & POTENSI PEMUDIK</b>
</h3>
</div>
<div class="col-sm-5">
    <span id="potensitotal"></span>
</div>

<div class="container">

    <table id="dg" title="KELOLA KOTA TUJUAN & POTENSI WARGA MUDIK" class="easyui-datagrid" style="width:100%;height:auto" url="/tujuandata" rownumbers="true" fitColumns="true" singleSelect="true" data-options="
            pagination:false,
            scrollbarSize:0,
            pageSize:20,
            noWrap:false,
            queryParams: {'<?php echo csrf_token() ?>': '<?php echo csrf_hash() ?>'},
            ">
        <thead>
            <tr>
            <th field="wilayah_id" width="10" align="center" sortable="true">WID</th>
                <th field="kode" width="10" align="center" sortable="true">KODE</th>
                <th field="nama" width="50" sortable="true">KOTA TUJUAN</th>
                <th field="relasi" width="20" align="center" sortable="true">RELASI ARMADA</th>
                <th field="statust" width="20" align="center"  sortable="true">AKTIF/INAKTIF</th>
                <th field="potensi" width="20" align="center"  sortable="true" data-options="formatter:cellStyler"">POTENSI<BR/>JML PEMUDIK</th>
            </tr>
        </thead>
    </table>

</div>

<script>
$(document).ready(function() {
      potensitotal();  
    });

    function potensitotal() {
        $.ajax({
            type: 'post',
            url: "<?php echo base_url(); ?>/potensitotal",
            data: {
                "<?= csrf_token() ?>": "<?= csrf_hash() ?>"
            },
            success: function(data) {
                var respon = $.parseJSON(data);
                console.log(respon);
                $('#potensitotal').html('Jumlah potensi Pemudik : '+respon.total);
            }

        });

    }



    function statusupdate(id, st) {
        $.ajax({
            type: 'post',
            url: "<?php echo base_url(); ?>/statusupdate",
            data: {
                id: id,
                st: st,
                "<?= csrf_token() ?>": "<?= csrf_hash() ?>"
            },
            success: function(data) {
                var respon = $.parseJSON(data);
                console.log(respon);
                $('#dg').datagrid('reload'); // reload the user data

            }

        });

    }



function cellStyler(val,row){
        return '<span style="color:red;font-size:24px;font-weight:bold">'+val+'</span>';
        }
</script>

<style>
    #potensitotal {
        font-size:30px;
        font-weight: bold;
        color:#ad7a0d;
        float:right;
        padding-right: 10px;
    }

<?php echo $this->endSection() ?>