435 lines
16 KiB
PHP
435 lines
16 KiB
PHP
<!doctype html>
|
|
<html class="fixed sidebar-left-collapsed">
|
|
|
|
<head>
|
|
|
|
<!-- Basic -->
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Sinkron</title>
|
|
<meta name="keywords" content="HTML5 Admin Template" />
|
|
<meta name="description" content="Porto Admin - Responsive HTML5 Template">
|
|
<meta name="author" content="okler.net">
|
|
<link rel="icon" type="image/png" href="<?php echo base_url('')?>assets/images/logoPcmBaru3.png" />
|
|
|
|
<!-- Mobile Metas -->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
|
|
<!-- Vendor CSS -->
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap/css/bootstrap.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/font-awesome/css/font-awesome.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/magnific-popup/magnific-popup.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap-datepicker/css/datepicker3.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap-timepicker/css/bootstrap-timepicker.css" />
|
|
|
|
<!-- Specific Page Vendor CSS -->
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/select2/select2.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/pnotify/pnotify.custom.css" />
|
|
|
|
<!-- Theme CSS -->
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/theme.css" />
|
|
|
|
<!-- Skin CSS -->
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/skins/default.css" />
|
|
|
|
<!-- Theme Custom CSS -->
|
|
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/theme-custom.css">
|
|
|
|
<!-- Head Libs -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/modernizr/modernizr.js"></script>
|
|
|
|
</head>
|
|
<script src="<?= base_url() ?>assets/bower_components/jquery/jquery-3.3.1.min.js"></script>
|
|
<script src="<?= base_url() ?>assets/bower_components/sweetalert2/sweetalert2.all.min.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
let base_url = '<?= base_url() ?>';
|
|
</script>
|
|
|
|
<body>
|
|
<section class="body">
|
|
|
|
<!-- start: header -->
|
|
<?php $this->load->view('template/header'); ?>
|
|
<!-- end: header -->
|
|
|
|
<div class="inner-wrapper">
|
|
<!-- start: sidebar -->
|
|
<?php $this->load->view('template/sidebar'); ?>
|
|
<!-- end: sidebar -->
|
|
|
|
<section role="main" class="content-body">
|
|
<header class="page-header">
|
|
<h2>Sinkron</h2>
|
|
|
|
<div class="right-wrapper pull-right">
|
|
<ol class="breadcrumbs">
|
|
<li>
|
|
<a href="index.html">
|
|
<i class="fa fa-home"></i>
|
|
</a>
|
|
</li>
|
|
<li><span>Sinkron</span></li>
|
|
</ol>
|
|
|
|
<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
|
|
</div>
|
|
</header>
|
|
<div class="panel-body tab-content">
|
|
<div style="text-align: center;">
|
|
<img id="picload" style="margin-bottom: 20px;" src="<?php echo base_url('') ?>assets/images/centang.png" width="200 ">
|
|
</div>
|
|
<div style="text-align:center;">
|
|
<p id="labelPersentasi"></p>
|
|
</div>
|
|
<div style="text-align:center;">
|
|
<button class="button btn btn-primary" id="sync">Sinkron</button>
|
|
<?php if ($this->session->userdata("id_karyawan") == 1) { ?>
|
|
<button type="button" class="button btn btn-primary" data-toggle="modal" data-target="#modal-ip">Ip Server</button>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</section>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<!-- Modal Tambah -->
|
|
<div class="modal fade" id="modal-ip">
|
|
<?= form_open('Sinkron/setIpServer', array('id' => 'formabsensi'), array('method' => 'add')); ?>
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<header class="panel-heading">
|
|
<h4 class="panel-title"><strong>Tambah IP SERVER</strong></h4>
|
|
</header>
|
|
<div class="modal-body ">
|
|
<div class="form-group">
|
|
<label class="col-md-3 control-label" for="ip_server">Ip</label>
|
|
<div class="col-md-8">
|
|
<input type="hidden" name="id_ip" value="<?php if ($server != null) {
|
|
echo $server[0]['ID_IP'];
|
|
} ?>">
|
|
<input type="text" class="form-control" name="ip_server" id="ip_server" value="<?php if ($server != null) {
|
|
echo $server[0]['IP'];
|
|
} ?>">
|
|
<small class="help-block"></small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="panel-footer">
|
|
<div class="row">
|
|
<div class="col-md-12 text-right">
|
|
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
|
|
<button type="submit" name="SubmitButton" id="SubmitButton" class="btn btn-success"><strong>Tambah</strong> <i class="fa fa-plus"></i></button>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
<!-- /.modal-content -->
|
|
</div>
|
|
<!-- /.modal-dialog -->
|
|
<?= form_close(); ?>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery/jquery.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/bootstrap/js/bootstrap.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/nanoscroller/nanoscroller.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/magnific-popup/magnific-popup.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>
|
|
|
|
<!-- Specific Page Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/select2/select2.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
|
|
<!-- Specific Page Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/pnotify/pnotify.custom.js"></script>
|
|
|
|
<!-- Theme Base, Components and Settings -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.js"></script>
|
|
|
|
<!-- Theme Custom -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.custom.js"></script>
|
|
|
|
<!-- Theme Initialization Files -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.init.js"></script>
|
|
|
|
|
|
<!-- Examples -->
|
|
<!-- Examples -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.default.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.tabletools.js"></script>
|
|
<!-- <script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.editable.js"></script> -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/ui-elements/examples.notifications.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
var ip = '<?= $server[0]['IP'] ?>';
|
|
var total = 0;
|
|
var total_Selesai = 0;
|
|
var datasync;
|
|
const tabel = ['cabang', 'jabatan', 'karyawan', 'shift', 'detail_shift', 'absensi'];
|
|
$("#picload").attr("src", base_url + "assets/images/loader-blue.gif");
|
|
var btnsync = document.getElementById('sync');
|
|
btnsync.disabled = true;
|
|
loadscan();
|
|
|
|
function loadscan() {
|
|
$.ajax({
|
|
url: base_url + 'index.php/Sinkron/scan',
|
|
type: 'POST',
|
|
data: {
|
|
|
|
},
|
|
success: function(response) {
|
|
datasync = response.data;
|
|
if (response.total == 0) {
|
|
$("#picload").attr("src", base_url + "assets/images/centang.png");
|
|
btnsync.disabled = true;
|
|
} else {
|
|
$("#picload").attr("src", base_url + "assets/images/sync.png");
|
|
btnsync.disabled = false;
|
|
total = response.total;
|
|
}
|
|
// console.log(response.data);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
|
|
function update_lokal(id_u, variabel_u, tabel_u) {
|
|
$.ajax({
|
|
url: base_url + 'index.php/Sinkron/sync_true',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
id: id_u,
|
|
variabel: variabel_u,
|
|
tabel: tabel_u,
|
|
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
total_Selesai++;
|
|
var tampil = ((total_Selesai / total) * 100).toFixed(2);
|
|
document.getElementById('labelPersentasi').innerHTML = tampil + "%";
|
|
// console.log(tampil);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#sync').on('click', function() {
|
|
total_Selesai = 0;
|
|
if (ip == null || ip == '' || ip == 0) {
|
|
document.getElementById('labelPersentasi').innerHTML = "IP server belum ditentukan";
|
|
} else {
|
|
$("#picload").attr("src", base_url + "assets/images/loader-blue.gif");
|
|
// console.log(datasync['cabang']);
|
|
|
|
for (i = 0; i < tabel.length; i++) {
|
|
|
|
if (tabel[i] == "cabang") {
|
|
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_cabang',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
kode_cabang: datasync[tabel[i]][x]['KODE_CABANG'],
|
|
nama_cabang: datasync[tabel[i]][x]['NAMA_CABANG'],
|
|
alamat: datasync[tabel[i]][x]['ALAMAT'],
|
|
waktu: datasync[tabel[i]][x]['WAKTU'],
|
|
sync: datasync[tabel[i]][x]['SYNC']
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['KODE_CABANG'] + "";
|
|
update_lokal(a, 'KODE_CABANG', 'cabang')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} else if (tabel[i] == "jabatan") {
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_jabatan',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
cabang_kode: datasync[tabel[i]][x]['CABANG_KODE'],
|
|
id_jabatan: datasync[tabel[i]][x]['ID_JABATAN'],
|
|
ij: datasync[tabel[i]][x]['IJ'],
|
|
nama_jabatan: datasync[tabel[i]][x]['NAMA_JABATAN'],
|
|
waktu_jabatan: datasync[tabel[i]][x]['WAKTU_JABATAN']
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['ID_JABATAN'] + "";
|
|
update_lokal(a, 'ID_JABATAN', 'jabatan')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} else if (tabel[i] == "karyawan") {
|
|
// console.log(datasync[tabel[i]]);
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_karyawan',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
id_karyawan: datasync[tabel[i]][x]['ID_KARYAWAN'],
|
|
ik: datasync[tabel[i]][x]['IK'],
|
|
jabatan_id: datasync[tabel[i]][x]['JABATAN_ID'],
|
|
jk_karyawan: datasync[tabel[i]][x]['JK_KARYAWAN'],
|
|
kota_karyawan: datasync[tabel[i]][x]['KOTA_KARYAWAN'],
|
|
nama_karyawan: datasync[tabel[i]][x]['NAMA_KARYAWAN'],
|
|
nama_panggilan_karyawan: datasync[tabel[i]][x]['NAMA_PANGGILAN_KARYAWAN'],
|
|
password: datasync[tabel[i]][x]['PASSWORD'],
|
|
status_karyawan: datasync[tabel[i]][x]['STATUS_KARYAWAN'],
|
|
tgllhr_karyawan: datasync[tabel[i]][x]['TGLLHR_KARYAWAN'],
|
|
username: datasync[tabel[i]][x]['USERNAME'],
|
|
waktu_karyawan: datasync[tabel[i]][x]['WAKTU_KARYAWAN']
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['ID_KARYAWAN'] + "";
|
|
update_lokal(a, 'ID_KARYAWAN', 'karyawan')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} else if (tabel[i] == "shift") {
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
// console.log(datasync[tabel[i]])
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_shift',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
cabang_kode: datasync[tabel[i]][x]['CABANG_KODE'],
|
|
id_shift: datasync[tabel[i]][x]['ID_SHIFT'],
|
|
is: datasync[tabel[i]][x]['IS'],
|
|
jam_keluar: datasync[tabel[i]][x]['JAM_KELUAR'],
|
|
jam_masuk: datasync[tabel[i]][x]['JAM_MASUK'],
|
|
nama_shift: datasync[tabel[i]][x]['NAMA_SHIFT'],
|
|
tanggal_shift: datasync[tabel[i]][x]['TANGGAL_SHIFT'],
|
|
waktu_shift: datasync[tabel[i]][x]['WAKTU_SHIFT']
|
|
},
|
|
success: function(response) {
|
|
// console.log(response)
|
|
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['ID_SHIFT'] + "";
|
|
update_lokal(a, 'ID_SHIFT', 'shift')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} else if (tabel[i] == "detail_shift") {
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
// console.log(datasync[tabel[i]])
|
|
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_detail_shift',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
id_detail_shift: datasync[tabel[i]][x]['ID_DETAIL_SHIFT'],
|
|
shift_id: datasync[tabel[i]][x]['SHIFT_ID'],
|
|
ids: datasync[tabel[i]][x]['IDS'],
|
|
karyawan_id: datasync[tabel[i]][x]['KARYAWAN_ID'],
|
|
waktu_detail_shift: datasync[tabel[i]][x]['WAKTU_DETAIL_SHIFT'],
|
|
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['ID_DETAIL_SHIFT'] + "";
|
|
update_lokal(a, 'ID_DETAIL_SHIFT', 'detail_shift')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} else if (tabel[i] == "absensi") {
|
|
for (x = 0; x < datasync[tabel[i]].length; x++) {
|
|
|
|
//kirim ke db server
|
|
$.ajax({
|
|
url: 'http://' + ip + '/pc-master/index.php/Sinkron/sync_absensi',
|
|
type: 'POST',
|
|
async: false,
|
|
data: {
|
|
detail_shift_id: datasync[tabel[i]][x]['DETAIL_SHIFT_ID'],
|
|
id_absensi: datasync[tabel[i]][x]['ID_ABSENSI'],
|
|
ia: datasync[tabel[i]][x]['IA'],
|
|
jam_keluar: datasync[tabel[i]][x]['JAM_KELUAR'],
|
|
jam_masuk: datasync[tabel[i]][x]['JAM_MASUK'],
|
|
status_absensi: datasync[tabel[i]][x]['STATUS_ABSENSI'],
|
|
telat: datasync[tabel[i]][x]['TELAT'],
|
|
tgl_absensi: datasync[tabel[i]][x]['TGL_ABSENSI']
|
|
|
|
},
|
|
success: function(response) {
|
|
if (response.value == true) {
|
|
// update sync local
|
|
var a = "" + datasync[tabel[i]][x]['ID_ABSENSI'] + "";
|
|
update_lokal(a, 'ID_ABSENSI', 'absensi')
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
loadscan();
|
|
|
|
$("#picload").attr("src", base_url + "assets/images/centang.png");
|
|
}
|
|
});
|
|
|
|
|
|
<?php if ($this->session->flashdata('success')) { ?> new PNotify({
|
|
title: 'Notifikasi',
|
|
text: 'Data berhasil <?= $this->session->flashdata('success'); ?>.',
|
|
type: 'success',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if ($this->session->flashdata('failed')) { ?> new PNotify({
|
|
title: 'Notifikasi',
|
|
text: 'Data gagal <?= $this->session->flashdata('failed'); ?>, hubungi Administrator',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|