<script>
    var data_1 = false;
    var data_2 = false;
    var data_3 = false;
    var data_4 = false;
    var data_5 = false;
    var data_6 = false;
    var data_7 = false;
    var data_8 = false;
    var data_9 = false;
    var data_10 = false;
    var data_11 = false;
    var data_12 = false;
    var data_13 = false;

    function disabledButton() {
        $('#synct1').prop("disabled", true);
        $('#synct_2').prop("disabled", true);
        $('#synct_3').prop("disabled", true);
        $('#synct_4').prop("disabled", true);
        $('#synct_5').prop("disabled", true);
        $('#synct_6').prop("disabled", true);
        $('#synct_7').prop("disabled", true);
        $('#synct_8').prop("disabled", true);
        $('#synct_9').prop("disabled", true);
        $('#synct_10').prop("disabled", true);
        $('#synct_11').prop("disabled", true);
        $('#synct_12').prop("disabled", true);
        $('#synct_13').prop("disabled", true);
    }
</script>
<!--main-container-part-->
<div id="content">
    <!--breadcrumbs-->
    <div id="content-header">
        <div id="breadcrumb"> <a href="<?php echo site_url('admin'); ?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a></div>
    </div>
    <!--End-breadcrumbs-->

    <!--Action boxes-->
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"> <span class="icon"> <i class="icon-refresh"></i> </span>
                        <h5><?php echo $judul_halaman; ?></h5>
                    </div>
                    <div class="widget-content">
                        <hr/>
                        <div class="row-fluid">
                            <div class="span6">
                                <button class="btn btn-primary" id="mulaiSync" type="button">Periksa Data Sinkronisasi</button> <span id="syncKeterangan" class="pull-right"></span>
                                <br/>
                                <br/>
                                <div class="alert alert-success">Operasi ini akan melakukan kalkulasi pengecekan data data yang perlu di download</div>
                                <br/>
                            </div>
                            <div class="span6">
                                <button id="reset_data" type="button" class="btn btn-warning">RESET DATA</button>
                                <br/>
                                <br/>
                                <div class="alert alert-danger">Operasi ini akan menghapus History Ujian!</div>
                                <br/>
                            </div>
                        </div>
                        <?php
                        $this->load->view('admin/sync/sync_1');
                        $this->load->view('admin/sync/sync_2');
                        $this->load->view('admin/sync/sync_3');
                        $this->load->view('admin/sync/sync_4');
                        $this->load->view('admin/sync/sync_5');
                        $this->load->view('admin/sync/sync_6');
                        $this->load->view('admin/sync/sync_7');
                        $this->load->view('admin/sync/sync_8');
                        $this->load->view('admin/sync/sync_9');
                        $this->load->view('admin/sync/sync_10');
                        $this->load->view('admin/sync/sync_11');
                        $this->load->view('admin/sync/sync_12');
                        $this->load->view('admin/sync/sync_13');
                        ?>
                    </div>
                </div>
            </div>
        </div>
        <hr/>
    </div>
</div>
<script>
    $('#reset_data').click(function (e) {
        var r = confirm("Anda Yakin?");
        if (r === true) {
            $.ajax({
                type: "GET",
                crossDomain: true,
                url: "<?php echo site_url('admin/reset_data/' . $status_cbt->token_cbt . '/'); ?>",
                success: function (result) {
                    alert("RESET DATA BERHASIL");
                    location.reload();
                }
            });
        }
    });

<?php
$data_sincron = $this->db->from('tabel_sync')->get()->result();
if ($data_sincron) {
    ?>
        $('#mulaiSync').prop("disabled", true);
    <?php
} else {
    ?>
        disabledButton();

        $('#mulaiSync').click(function (e) {
            $('#mulaiSync').prop("disabled", true);
            $('#syncKeterangan').html('<i class="icon icon-spinner icon-spin icon-2x"></i>');
            $.ajax({
                type: "POST",
                url: "<?php echo site_url('admin/data_sinkron'); ?>",
                success: function (result) {
                    if (result === "OK") {
                        location.reload();
                    }
                    $('#syncKeterangan').html("" + result);

                    $('#mulaiSync').prop("disabled", false);
                    //                    $('#syncKeterangan').html('<i class="icon icon-check icon-3x text-green"></i>');
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $('#syncKeterangan').html("Error: " + errorThrown);

                    $('#mulaiSync').prop("disabled", false);
                    //                    $('#syncKeterangan').html('<i class="icon icon-warning icon-3x text-red"></i>');
                }
            });
        });
    <?php
}
?>
</script>
































