<?php $tahun2 = date('Y');
$rentang_tahun = range($tahun2, 2022);
$hariini = date('d-m-y');
$datapaycomp = "[";
foreach ($PoC as $rowp) {
    $datapaycomp = $datapaycomp . "{name : 'Jmlbln : " . $rowp->JMLBULAN . "',y: " . $rowp->JMLWP . ",j:" .
        $rowp->JMLBULAN . "},";
}
$datapaycomp = $datapaycomp . "]";



?>

<div class="main-content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12 mb-2">
                <div class="card">
                    <div class="card-header">
                        <h3>Pilih :</h3>
                        <div class="card-header-right">
                            <ul class="list-unstyled card-option">
                                <li><i class="ik ik-chevron-left action-toggle"></i></li>
                                <li><i class="ik ik-minus minimize-card"></i></li>
                                <li><i class="ik ik-x close-card"></i></li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">

                        <form class="form-sample" action="<?php base_url('Kanwil/index') ?>" method="post">



                            <?php if (session('tpkantor') == 'KPDJP') {
                                $disabledslct = "";
                            } else {
                                $disabledslct = "disabled";
                            }

                            if (session('tpkantor') == 'KPP') {
                                $disableslckpp = "disabled";
                            } else {
                                $disableslckpp = "";
                            }
                            ?>
                            <div class="row row-cols-1 row-cols-md-2">
                                <div class="col-md-6 col-sm-12">
                                    <label class="my-1 mr-2">Kanwil </label>
                                    <select class="custom-select my-1 mr-sm-2" id="kwl" name="kwl" <?php echo $disabledslct ?>>
                                        <option value="SEMUA">Nasional</option>
                                        <?php
                                        foreach ($selkwl as $row) {
                                            if ($row->KODE == $kwlx) {
                                                $sel = "selected";
                                            } else {
                                                $sel = "";
                                            }
                                            echo "<option value=\"" . $row->KODE . "\" " . $sel . ">" . $row->KODE . " - " . $row->NAMA . "</option>";
                                        }


                                        ?>
                                    </select>
                                    <label class="my-1 mr-2">KPP </label>
                                    <select class="custom-select my-1 mr-sm-2" id="kpp" name="kpp" <?php echo $disableslckpp ?>>
                                    </select>
                                    <label class="my-1 mr-2">Seksi </label>
                                    <select class="custom-select my-1 mr-sm-2" id="seksi" name="seksi">
                                    </select>

                                    <label class="my-1 mr-2">AR </label>
                                    <select class="custom-select my-1 mr-sm-2" id="nip" name="nip">
                                    </select>

                                </div>

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

                                    <label class="my-1 mr-2">MAP </label>
                                    <select class="custom-select my-1 mr-sm-2" id="kdmap" name="kdmap">
                                        <option value='SEMUA'>Semua</option>
                                        <?php
                                        foreach ($selmap as $map) {
                                            if ($map->KD_MAP == $mapx) {
                                                $sel = "selected";
                                            } else {
                                                $sel = "";
                                            }
                                            echo "<option value=\"" . $map->KD_MAP . "\" " . $sel . ">" . $map->NM_MAP . "</option>";
                                        }
                                        ?>
                                    </select>

                                    <label class="my-1 mr-2">KJS </label>
                                    <select class="custom-select my-1 mr-sm-2" id="kjs" name="kjs">
                                        <option value='SEMUA'>Semua</option>
                                        <?php
                                        foreach ($selkjs as $kjs) {
                                            if ($kjs->KJS == $kjsx) {
                                                $sel = "selected";
                                            } else {
                                                $sel = "";
                                            }
                                            echo "<option value=\"" . $kjs->KJS . "\" " . $sel . ">" . $kjs->KJS . "</option>";
                                        }
                                        ?>
                                    </select>
                                    <label class="my-1 mr-2">Kategori </label>
                                    <select class="custom-select my-1 mr-sm-2" id="kategori" name="kategori">
                                        <option value='SEMUA'>Semua</option>
                                        <?php
                                        foreach ($selklu as $d) {
                                            if ($d->KATEGORI == $kategorix) {
                                                $sel = "selected";
                                            } else {
                                                $sel = "";
                                            }
                                            echo "<option value=\"" . $d->KATEGORI . "\" " . $sel . ">" . $d->NAMA . "</option>";
                                        }
                                        ?>
                                    </select>

                                    <label class="my-1 mr-2">Tahun </label>
                                    <select class="custom-select my-1 mr-sm-2" id="tahun" name="tahun">
                                        <?php
                                        foreach ($rentang_tahun as $tahun) {
                                            if ($tahun == $tahunx) {
                                                $sel = "selected";
                                            } else {
                                                $sel = "";
                                            }
                                            echo "<option value=\"" . $tahun . "\" " . $sel . ">" . $tahun . "</option>";
                                        }
                                        ?>
                                    </select>


                                    <button type="submit"
                                        class="btn btn-primary btn-lg active mt-5 float-right">Proses</button>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
        </div>
        <div class="row">

            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3>Payment Compliance</h3>
                        <div class="card-header-right">
                            <ul class="list-unstyled card-option">
                                <li><i class="ik ik-chevron-left action-toggle"></i></li>
                                <li><i class="ik ik-minus minimize-card"></i></li>
                                <li><i class="ik ik-x close-card"></i></li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div id="PoCKJS"></div>

                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3>Strength of Figure</h3>
                        <div class="card-header-right">
                            <ul class="list-unstyled card-option">
                                <li><i class="ik ik-chevron-left action-toggle"></i></li>
                                <li><i class="ik ik-minus minimize-card"></i></li>
                                <li><i class="ik ik-x close-card"></i></li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <table class="table table-sm">
                            <thead>
                                <tr>
                                    <th class="text-center" rowspan="2">No</th>
                                    <th class="text-center" rowspan="2">Strength of Figure</th>
                                    <th class="text-center" colspan="2">Jml Wajib Pajak</th>
                                    <th class="text-center" colspan="2">Jml Bayar <?php echo $tahunx; ?></th>
                                </tr>
                                <tr>
                                    <th class="text-center">Jumlah</th>
                                    <th class="text-center">%</th>
                                    <th class="text-center">Jumlah</th>
                                    <th class="text-center">%</th>
                                </tr>
                            </thead>
                            <?php
                            $jumlah["0"]["1"] = 0;
                            $jumlah["9"]["1"] = 0;
                            $jumlah["1"]["1"] = 0;
                            $jumlah["2"]["1"] = 0;
                            $jumlah["3"]["1"] = 0;
                            $jumlah["4"]["1"] = 0;
                            $jumlah["5"]["1"] = 0;
                            $jumlah["6"]["1"] = 0;
                            $jumlah["7"]["1"] = 0;
                            $jumlah["8"]["1"] = 0;
                            $jumlah["0"]["2"] = 0;
                            $jumlah["9"]["2"] = 0;
                            $jumlah["1"]["2"] = 0;
                            $jumlah["2"]["2"] = 0;
                            $jumlah["3"]["2"] = 0;
                            $jumlah["4"]["2"] = 0;
                            $jumlah["5"]["2"] = 0;
                            $jumlah["6"]["2"] = 0;
                            $jumlah["7"]["2"] = 0;
                            $jumlah["8"]["2"] = 0;
                            foreach ($SoF as $_junk => $data) {
                                if ($data->TOTAL < 0) {
                                    $jumlah["9"]["1"] += 1;
                                    $jumlah["9"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 5000) {
                                    $jumlah["1"]["1"] += 1;
                                    $jumlah["1"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 10000) {
                                    $jumlah["2"]["1"] += 1;
                                    $jumlah["2"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 100000) {
                                    $jumlah["3"]["1"] += 1;
                                    $jumlah["3"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 500000) {
                                    $jumlah["4"]["1"] += 1;
                                    $jumlah["4"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 1000000) {
                                    $jumlah["5"]["1"] += 1;
                                    $jumlah["5"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 5000000) {
                                    $jumlah["6"]["1"] += 1;
                                    $jumlah["6"]["2"] += $data->TOTAL;
                                } elseif ($data->TOTAL < 10000000) {
                                    $jumlah["7"]["1"] += 1;
                                    $jumlah["7"]["2"] += $data->TOTAL;
                                } else {
                                    $jumlah["8"]["1"] += 1;
                                    $jumlah["8"]["2"] += $data->TOTAL;
                                }
                                $jumlah["0"]["1"] += 1;
                                $jumlah["0"]["2"] += $data->TOTAL;
                            }
                            ?>
                            <tbody>
                                <tr>
                                    <td class='text-center'>1</td>
                                    <td class='text-left'>Lapisan 0</td>
                                    <td class='text-right'><?= number_format(($jumlah["9"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?= number_format(($jumlah["9"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["9"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?= number_format(($jumlah["9"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>2</td>
                                    <td class='text-left'>Lapisan 1 - 5.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["1"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["1"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["1"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["1"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>3</td>
                                    <td class='text-left'>Lapisan 5.000 - 10.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["2"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["2"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["2"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["2"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>4</td>
                                    <td class='text-left'>Lapisan 10.000 - 100.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["3"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["3"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["3"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["3"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>5</td>
                                    <td class='text-left'>Lapisan 100.000 - 500.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["4"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["4"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["4"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["4"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>6</td>
                                    <td class='text-left'>Lapisan 500.000 - 1.000.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["5"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["5"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["5"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["5"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>7</td>
                                    <td class='text-left'>Lapisan 1.000.000 - 5.000.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["6"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["6"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["6"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["6"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>8</td>
                                    <td class='text-left'>Lapisan 5.000.000 - 10.000.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["7"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["7"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["7"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["7"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class='text-center'>9</td>
                                    <td class='text-left'>Lapisan >= 10.000.000</td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["8"]["1"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["8"]["1"] / ($jumlah["0"]["1"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                    <td class='text-right'><?= number_format(($jumlah["8"]["2"]), 0, ',', '.') ?>
                                    </td>
                                    <td class='text-right'>
                                        <?=
                                            number_format(($jumlah["8"]["2"] / ($jumlah["0"]["2"] ?: 1)) * 100, 2, ',', '.') ?>
                                    </td>
                                </tr>

                            </tbody>
                        </table>
                        <small class="text-primary">*) Nilai Persentase dibawah 0% berwarna merah</small>

                    </div>
                </div>
            </div>

        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <h3>Grafik MAP KJS</h3>
                        <div class="card-header-right">
                            <ul class="list-unstyled card-option">
                                <li><i class="ik ik-chevron-left action-toggle"></i></li>
                                <li><i class="ik ik-minus minimize-card"></i></li>
                                <li><i class="ik ik-x close-card"></i></li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div id="grafMAPKJS"></div>

                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <h3>Table MAP KJS</h3>
                        <div class="card-header-right">
                            <ul class="list-unstyled card-option">
                                <li><i class="ik ik-chevron-left action-toggle"></i></li>
                                <li><i class="ik ik-minus minimize-card"></i></li>
                                <li><i class="ik ik-x close-card"></i></li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <table class="table  table-hover table-striped table-bordered tablesorter" id="tablekat">
                            <thead class='thead-dark'>
                                <tr class="table-active">
                                    <th class="text-center">Bulan</th>
                                    <th class="text-center">Populasi</th>
                                    <th class="text-center">Wp Bayar <?= $tahunx ?></th>
                                    <th class="text-center">Wp Bayar <?= $tahunx - 1 ?></th>
                                    <th class="text-center">Coverage Ratio(%)</th>
                                    <th class="text-center">gw WP Bayar (%)</th>
                                    <th class="text-center">Pembayaran <?= $tahunx ?></th>
                                    <th class="text-center">Pembayaran <?= $tahunx - 1 ?></th>
                                    <th class="text-center">gw Penerimaan (%)</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($dtmapkjs as $row) {
                                    if ($row->WPBYRPAST != 0) {
                                        $gwwp = (($row->WPBYRNOW - $row->WPBYRPAST) / ($row->WPBYRPAST ?: 1)) * 100;
                                    } else {
                                        $gwwp = 0;
                                    }
                                    if ($row->JMLBYRNOW != 0) {
                                        $gwkat = (($row->JMLBYRNOW - $row->JMLBYRPAST) / ($row->JMLBYRPAST ?: 1)) * 100;
                                    } else {
                                        $gwkat = 0;
                                    }

                                    if ($gwwp < 0) {
                                        $markgww = "text-danger";
                                        $markgwwic = "<ion-icon name='arrow-down-outline'></ion-icon>";
                                    } else {
                                        $markgww = "text-success";
                                        $markgwwic = "<ion-icon name='arrow-up-outline'></ion-icon>";
                                    }

                                    if ($gwkat < 0) {
                                        $markgwk = "text-danger";
                                        $markgwkic = "<ion-icon name='arrow-down-outline'></ion-icon>";
                                    } else {
                                        $markgwk = "text-success";
                                        $markgwkic = "<ion-icon name='arrow-up-outline'></ion-icon>";
                                    }
                                    $covratio = $row->WPBYRNOW / ($row->POPULASI ?: 1) * 100;
                                    ?>

                                    <tr>
                                        <td class="text-center"><?= $row->BLNBYR ?></td>
                                        <td class="text-right"><?= number_format($row->POPULASI, 0, ',', '.') ?></td>
                                        <td class="text-right"><?= number_format($row->WPBYRNOW, 0, ',', '.') ?></td>
                                        <td class="text-right"><?= number_format($row->WPBYRPAST, 0, ',', '.') ?></td>
                                        <td class="text-center"><?= number_format($covratio, 2) ?> </td>
                                        <td class="text-center <?= $markgww ?>"><?= number_format($gwwp, 2) ?>
                                            <?php echo $markgwwic ?>
                                        </td>
                                        <td class="text-right"><?= number_format($row->JMLBYRNOW, 0, ',', '.') ?></td>
                                        <td class="text-right"><?= number_format($row->JMLBYRPAST, 0, ',', '.') ?></td>
                                        <td class="text-center <?= $markgwk ?>"><?= number_format($gwkat, 2) ?>
                                            <?php echo $markgwkic ?>
                                        </td>
                                    </tr>

                                <?php } ?>
                            </tbody>
                        </table>
                        <p>*) Populasi berdasarkan Wajib Pajak dengan status Normal</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </d>

    <?php echo view('inc/js.php') ?>
    <script>
        $(document).ready(function () {

            $('#kwl').change(function () {

                var kwl = $('#kwl').val();
                var kpp = $('#kpp').val();
                if (kwl == '' || kwl == 'SEMUA') {
                    $('#kpp').attr('disabled', true);
                } else {
                    $('#kpp').attr('disabled', false);
                }

                if (kwl != '') {
                    $.ajax({
                        url: "<?php echo base_url('/ref/getKPP'); ?>",
                        method: "POST",
                        data: {
                            kwl: kwl
                        },
                        dataType: "JSON",
                        success: function (data) {
                            $('select[name="kpp"]').empty();
                            $('select[name="kpp"]').append('<option value="SEMUA">Semua</option>');
                            $.each(data, function (key, value) {
                                $('select[name="kpp"]').append('<option value="' + value.KD_KPP + '">' + value.NM_KANTOR + '</option>');
                            });
                            <?php
                            if ($kppx != '') { ?>

                                $('#kpp').val('<?php echo $kppx ?>').change();
                                $('#seksi').change();

                            <?php } ?>


                        }
                    });
                } else {
                    $('#kpp').val('');
                }
            });
            <?php
            if ($kwlx != '') { ?>

                $('#kwl').val('<?php echo $kwlx ?>').change();

            <?php } ?>


            $('#kpp').change(function () {
                var kpp = $('#kpp').val();
                if (kpp == '' || kpp == 'SEMUA') {
                    $('#seksi').attr('disabled', true);
                } else {
                    $('#seksi').attr('disabled', false);
                }
                if (seksi != '') {
                    $.ajax({
                        url: "<?php echo base_url('/ref/getSeksi'); ?>",
                        method: "POST",
                        data: {
                            kpp: kpp,
                        },
                        dataType: "JSON",
                        success: function (datas) {
                            $('select[name="seksi"]').empty();
                            $('select[name="seksi"]').append('<option value="SEMUA">Semua</option>');
                            $.each(datas, function (key, value) {
                                $('select[name="seksi"]').append('<option value="' + value.KODESIE + '">' + value.SEKSI + ' - ' + value.NAMA + '</option>');
                            });
                            <?php
                            if ($seksix != '') { ?>

                                $('#seksi').val('<?php echo $seksix ?>').change();
                                $('#nip').change();

                            <?php } ?>
                        }
                    });
                } else {
                    $('#seksi').val('');
                }
            });
            <?php
            if ($kppx != '') { ?>
                $('#kpp').change();

            <?php } ?>


            $('#seksi').change(function () {

                var kpp = $('#kpp').val();
                var seksi = $('#seksi').val();
                var nip = $('#nip').val()

                if (seksi == '' || seksi == 'SEMUA') {
                    $('#nip').attr('disabled', true);
                } else {
                    $('#nip').attr('disabled', false);
                }
                if (seksi != '') {
                    $.ajax({
                        url: "<?php echo base_url('/ref/getAR'); ?>",
                        method: "POST",
                        data: {
                            kpp: kpp,
                            seksi: seksi
                        },
                        dataType: "JSON",
                        success: function (datas) {
                            $('select[name="nip"]').empty();
                            $('select[name="nip"]').append('<option value="SEMUA">Semua</option>');
                            $.each(datas, function (key, value) {
                                $('select[name="nip"]').append('<option value="' + value.NIP + '">' + value.NIP + ' - ' + value.NAMA + '</option>');
                            });
                            <?php
                            if ($nipx != '') { ?>

                                $('#nip').val('<?php echo $nipx ?>').change();

                            <?php } ?>
                        }
                    });
                } else {
                    $('#nip').val('');
                }
            });
            <?php
            if ($seksix != '') { ?>
                $('#seksi').change();

            <?php } ?>
        });
    </script>

    <script type="text/javascript">
        Highcharts.setOptions({
            lang: {
                numericSymbols: ['R', 'J', 'M', 'T', 'P', 'K']
            }
        });

        var options = {
            chart: {
                renderTo: 'grafMAPKJS',
                zoomType: 'xy'
            },
            title: {
                text: ''
            },
            subtitle: {
                text: ''
            },
            xAxis: [{
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Ags', 'Sep', 'Okt', 'Nov', 'Des'],
                crosshair: true
            }],
            yAxis: [{ // Primary yAxis
                labels: {
                    // format: 'M',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                },
                title: {
                    text: 'Nilai',
                    style: {
                        color: Highcharts.getOptions().colors[1]
                    }
                }
            }, { // Secondary yAxis
                title: {
                    text: '',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                },
                labels: {
                    // format: '%',
                    style: {
                        color: Highcharts.getOptions().colors[0]
                    }
                },
                opposite: true
            }],
            tooltip: {
                shared: true
            },
            legend: {
                enabled: true,
                // floating: true,
                verticalAlign: 'top',
                align: 'center',
                y: 0,
                margin: 0
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            plotOptions: {
                series: {
                    pointWidth: 100

                }
            },
            series: []

        }

        $.getJSON("<?php echo base_url("home/grafMAPKJS/$kwlx/$kppx/$seksix/$nipx/$tahunx/$mapx/$kjsx/$kategorix"); ?>", function (json) {

            options.xAxis.categories = json[0];
            options.series[1] = json[1]; //jmlwpn
            options.series[3] = json[2]; //jmlwpp
            options.series[5] = json[3]; //byrn
            options.series[6] = json[4]; //bytp
            options.series[4] = json[5]; //gwwp
            options.series[7] = json[6]; //gwpem
            options.series[0] = json[7]; //pop
            options.series[2] = json[8]; //covrat
            chart = new Highcharts.Chart(options);
        });
    </script>


    <script>
        // Build the chart
        Highcharts.chart('PoCKJS', {
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                type: 'pie'
            },
            title: {
                text: '',
                align: ''
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.2f}%</b> <br> Jml WP : {point.y}'
            },
            accessibility: {
                point: {
                    valueSuffix: '%'
                }
            },
            credits: {
                enabled: false
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<span style="font-size: 1.2em"><b>{point.name}</b></span><br>' +
                            '<span style="opacity: 0.6">{point.percentage:.2f} %</span>',
                        connectorColor: 'rgba(128,128,128,0.5)'
                    },
                    point: {
                        events: {
                            click: function () {
                                window.open('<?php echo base_url("seksiar/detpaycomp/$kwlx/$kppx/$seksix/$nipx/$tahunx/"); ?>' + this.j, '_blank');
                            }
                        }
                    }
                }
            },
            series: [{
                name: 'WP Byr',
                data: <?php echo $datapaycomp ?>
            }]
        });
    </script>