496 lines
16 KiB
PHP
496 lines
16 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Sinkron extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE');
|
|
header('Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding');
|
|
header('Access-Control-Allow-Credentials: *');
|
|
if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) {
|
|
die();
|
|
}
|
|
parent::__construct();
|
|
$this->load->model('ModelDashboard', 'Dashboard');
|
|
$this->load->model('AbsensiModel', 'AbsensiM');
|
|
$this->load->model('SinkronModel', 'SinkronM');
|
|
$this->load->model('ShiftModel', 'ShiftM');
|
|
$this->load->model('AbsensiModel', 'AbsensiM');
|
|
$this->load->model('KaryawanModel', 'KaryawanM');
|
|
$this->load->library(['datatables', 'form_validation']);
|
|
$this->form_validation->set_error_delimiters('', '');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$server = $this->SinkronM->getIpServer();
|
|
$data = [
|
|
'sidebar' => "sinkron",
|
|
'navChild' => "data absensi",
|
|
'server' => $server
|
|
];
|
|
// var_dump()
|
|
$this->load->view('sinkron', $data);
|
|
}
|
|
public function setIpServer()
|
|
{
|
|
$id_ip = $this->input->post('id_ip');
|
|
$ip = $this->input->post('ip_server');
|
|
|
|
$input = [
|
|
'ip' => $ip
|
|
];
|
|
|
|
if ($id_ip == null) {
|
|
$action = $this->SinkronM->create('ip_server', $input);
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect('Sinkron');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect('Sinkron');
|
|
}
|
|
} else {
|
|
$action = $this->SinkronM->update('ip_server', $input, 'id_ip', $id_ip);
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diupdate');
|
|
redirect('Sinkron');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diupdate');
|
|
redirect('Sinkron');
|
|
}
|
|
}
|
|
}
|
|
public function scan()
|
|
{
|
|
$tabel = ['absensi'];
|
|
$tot = 0;
|
|
|
|
$data = [];
|
|
for ($i = 0; $i < sizeof($tabel); $i++) {
|
|
$cektabel = $this->SinkronM->cekTabel($tabel[$i]);
|
|
$tot += sizeof($cektabel);
|
|
$data += [
|
|
'' . $tabel[$i] . '' => $cektabel,
|
|
];
|
|
}
|
|
$this->output_json([
|
|
'value' => true,
|
|
'total' => $tot,
|
|
'data' => $data,
|
|
]);
|
|
}
|
|
|
|
public function sync_true()
|
|
{
|
|
$id = $this->input->post('id');
|
|
$variabel = $this->input->post('variabel');
|
|
$tabel = $this->input->post('tabel');
|
|
|
|
$input = [
|
|
'SYNC' => true,
|
|
];
|
|
$action = $this->SinkronM->update($tabel, $input, $variabel, $id);
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function sync_cabang()
|
|
{
|
|
$kode_cabang = $this->input->post('kode_cabang');
|
|
$nama_cabang = $this->input->post('nama_cabang');
|
|
$alamat = $this->input->post('alamat');
|
|
$waktu = $this->input->post('waktu');
|
|
$sync = $this->input->post('sync');
|
|
|
|
$cek = $this->SinkronM->getDataCabangByKode($kode_cabang);
|
|
$input = [
|
|
'NAMA_CABANG' => $nama_cabang,
|
|
'ALAMAT' => $alamat,
|
|
'WAKTU' => $waktu,
|
|
'SYNC' => true
|
|
];
|
|
if ($cek == null) {
|
|
$input += [
|
|
'KODE_CABANG' => $kode_cabang
|
|
];
|
|
$action = $this->SinkronM->create('cabang', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('cabang', $input, 'KODE_CABANG', $kode_cabang);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
]);
|
|
}
|
|
}
|
|
public function sync_jabatan()
|
|
{
|
|
$kode_cabang = $this->input->post('cabang_kode');
|
|
$id_jabatan = $this->input->post('id_jabatan');
|
|
$ij = $this->input->post('ij');
|
|
$nama_jabatan = $this->input->post('nama_jabatan');
|
|
$waktu_jabatan = $this->input->post('waktu_jabatan');
|
|
|
|
$cek = $this->SinkronM->getDataJabatan($id_jabatan);
|
|
$input = [
|
|
'CABANG_KODE' => $kode_cabang,
|
|
'IJ' => $ij,
|
|
'NAMA_JABATAN' => $nama_jabatan,
|
|
'WAKTU_JABATAN' => $waktu_jabatan,
|
|
'SYNC' => true
|
|
];
|
|
|
|
if ($cek == null) {
|
|
$input += [
|
|
'ID_JABATAN' => $id_jabatan
|
|
];
|
|
$action = $this->SinkronM->create('jabatan', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('jabatan', $input, 'ID_JABATAN', $id_jabatan);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
]);
|
|
}
|
|
}
|
|
public function sync_karyawan()
|
|
{
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$ik = $this->input->post('ik');
|
|
$jabatan_id = $this->input->post('jabatan_id');
|
|
$jk_karyawan = $this->input->post('jk_karyawan');
|
|
$kota_karyawan = $this->input->post('kota_karyawan');
|
|
$nama_karyawan = $this->input->post('nama_karyawan');
|
|
$nama_panggilan_karyawan = $this->input->post('nama_panggilan_karyawan');
|
|
$password = $this->input->post('password');
|
|
$status_karyawan = $this->input->post('status_karyawan');
|
|
$tgllhr_karyawan = $this->input->post('tgllhr_karyawan');
|
|
$username = $this->input->post('username');
|
|
$waktu_karyawan = $this->input->post('waktu_karyawan');
|
|
|
|
$cek = $this->KaryawanM->getDataKaryawan($id_karyawan);
|
|
|
|
$input = [
|
|
'IK' => $ik,
|
|
'JABATAN_ID' => $jabatan_id,
|
|
'JK_KARYAWAN' => $jk_karyawan,
|
|
'KOTA_KARYAWAN' => $kota_karyawan,
|
|
'NAMA_KARYAWAN' => $nama_karyawan,
|
|
'NAMA_PANGGILAN_KARYAWAN' => $nama_panggilan_karyawan,
|
|
'PASSWORD' => $password,
|
|
'STATUS_KARYAWAN' => $status_karyawan,
|
|
'TGLLHR_KARYAWAN' => $tgllhr_karyawan,
|
|
'USERNAME' => $username,
|
|
'WAKTU_KARYAWAN' => $waktu_karyawan,
|
|
'SYNC' => true
|
|
];
|
|
|
|
if ($cek == null) {
|
|
$input += [
|
|
'ID_KARYAWAN' => $id_karyawan
|
|
];
|
|
$action = $this->SinkronM->create('karyawan', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('karyawan', $input, 'ID_KARYAWAN', $id_karyawan);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
]);
|
|
}
|
|
}
|
|
public function sync_shift()
|
|
{
|
|
$cabang_kode = $this->input->post('cabang_kode');
|
|
$id_shift = $this->input->post('id_shift');
|
|
$is = $this->input->post('is');
|
|
$jam_keluar = $this->input->post('jam_keluar');
|
|
$jam_masuk = $this->input->post('jam_masuk');
|
|
$nama_shift = $this->input->post('nama_shift');
|
|
$tanggal_shift = $this->input->post('tanggal_shift');
|
|
$waktu_shift = $this->input->post('waktu_shift');
|
|
|
|
$cek = $this->ShiftM->getDataShiftById($id_shift);
|
|
|
|
$input = [
|
|
'CABANG_KODE' => $cabang_kode,
|
|
'IS' => $is,
|
|
'JAM_KELUAR' => $jam_keluar,
|
|
'JAM_MASUK' => $jam_masuk,
|
|
'NAMA_SHIFT' => $nama_shift,
|
|
'TANGGAL_SHIFT' => $tanggal_shift,
|
|
'WAKTU_SHIFT' => $waktu_shift,
|
|
'SYNC' => true
|
|
];
|
|
if ($cek == null) {
|
|
$input += [
|
|
'ID_SHIFT' => $id_shift
|
|
];
|
|
$action = $this->SinkronM->create('shift', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('shift', $input, 'ID_SHIFT', $id_shift);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
]);
|
|
}
|
|
}
|
|
public function sync_detail_shift()
|
|
{
|
|
$ids = $this->input->post('ids');
|
|
$id_detail_shift = $this->input->post('id_detail_shift');
|
|
$karyawan_id = $this->input->post('karyawan_id');
|
|
$shift_id = $this->input->post('shift_id');
|
|
$waktu_detail_shift = $this->input->post('waktu_detail_shift');
|
|
|
|
$cek = $this->ShiftM->getDataDetailShiftById($id_detail_shift);
|
|
|
|
$input = [
|
|
'IDS' => $ids,
|
|
'KARYAWAN_ID' => $karyawan_id,
|
|
'SHIFT_ID' => $shift_id,
|
|
'SYNC' => true,
|
|
'WAKTU_DETAIL_SHIFT' => $waktu_detail_shift
|
|
];
|
|
|
|
if ($cek == null) {
|
|
$input += [
|
|
'ID_DETAIL_SHIFT' => $id_detail_shift
|
|
];
|
|
$action = $this->SinkronM->create('detail_shift', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('detail_shift', $input, 'ID_DETAIL_SHIFT', $id_detail_shift);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
|
|
]);
|
|
}
|
|
}
|
|
public function sync_absensi()
|
|
{
|
|
$detail_shift_id = $this->input->post('detail_shift_id');
|
|
$ia = $this->input->post('ia');
|
|
$id_absensi = $this->input->post('id_absensi');
|
|
$jam_keluar = $this->input->post('jam_keluar');
|
|
$jam_masuk = $this->input->post('jam_masuk');
|
|
$status_absensi = $this->input->post('status_absensi');
|
|
$telat = $this->input->post('telat');
|
|
$tgl_absensi = $this->input->post('tgl_absensi');
|
|
|
|
$cek = $this->AbsensiM->getDataAbsensiById($id_absensi);
|
|
|
|
$input = [
|
|
'IA' => $ia,
|
|
'DETAIL_SHIFT_ID' => $detail_shift_id,
|
|
'TGL_ABSENSI' => $tgl_absensi,
|
|
'JAM_MASUK' => $jam_masuk,
|
|
'JAM_KELUAR' => $jam_keluar,
|
|
'TELAT' => $telat,
|
|
'STATUS_ABSENSI' => $status_absensi,
|
|
'SYNC' => true
|
|
];
|
|
|
|
if ($cek == null) {
|
|
$input += [
|
|
'ID_ABSENSI' => $id_absensi
|
|
];
|
|
$action = $this->SinkronM->create('absensi', $input);
|
|
} else {
|
|
$action = $this->SinkronM->update('absensi', $input, 'ID_ABSENSI', $id_absensi);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function sync_absensi_server6() {
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$tgl_absensi = $this->input->post('tgl_absensi');
|
|
$jam_masuk = $this->input->post('jam_masuk');
|
|
$jam_keluar = $this->input->post('jam_keluar');
|
|
$telat = $this->input->post('telat');
|
|
$lokasi_absensi = $this->input->post('lokasi_absensi');
|
|
$pulang_absensi = $this->input->post('pulang_absensi');
|
|
$id_absensi = $this->input->post('id_absensi');
|
|
|
|
$cek = $this->AbsensiM->getData_Absensi_byKARYAWAN_byTGL_forSync($id_karyawan, $tgl_absensi);
|
|
if ($cek==null) {
|
|
$input = [
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'TGL_ABSENSI' => $tgl_absensi,
|
|
'JAM_MASUK' => $jam_masuk,
|
|
'JAM_KELUAR' => $jam_keluar,
|
|
'TELAT' => $telat,
|
|
'LOKASI_ABSENSI' => $lokasi_absensi,
|
|
'PULANG_ABSENSI' => $pulang_absensi,
|
|
];
|
|
$action = $this->AbsensiM->create('absensi', $input);
|
|
}
|
|
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
'data' => $id_absensi,
|
|
]);
|
|
|
|
}
|
|
|
|
public function sync_pulang_server6() {
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$tgl_absensi = $this->input->post('tgl_absensi');
|
|
$jam_keluar = $this->input->post('jam_keluar');
|
|
$pulang_absensi = $this->input->post('pulang_absensi');
|
|
$id_absensi = $this->input->post('id_absensi');
|
|
|
|
$cek = $this->AbsensiM->getData_Absensi_byKARYAWAN_byTGL_forSync($id_karyawan, $tgl_absensi);
|
|
$update = [
|
|
'JAM_KELUAR' => $jam_keluar,
|
|
'PULANG_ABSENSI' => $pulang_absensi,
|
|
];
|
|
$action = $this->AbsensiM->update('absensi', $update, 'ID_ABSENSI', $cek[0]['ID_ABSENSI']);
|
|
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
'data' => $id_absensi,
|
|
]);
|
|
|
|
}
|
|
|
|
public function sync_bintangvisit() {
|
|
$datSales = $this->AbsensiM->getData_SalesVisit_groupSALES_status0();
|
|
$tgl = date('Y-m-d H:i:s');
|
|
|
|
$no = 0;
|
|
foreach ($datSales as $dat) {
|
|
$datSav = $this->AbsensiM->getData_SalesVisit_bySALES_status0($dat['SALES_ID']);
|
|
$stat01 = 0; $stat02 = 0; $stat03 = 0; $stat04 = 0; $stat05 = 0;
|
|
$stat06 = 0; $stat07 = 0; $stat08 = 0; $stat09 = 0; $stat10 = 0;
|
|
foreach ($datSav as $key) {
|
|
$datDsav = $this->AbsensiM->getData_DaftarSalesVisit_bySAV_orderDESC_limit1($key['ID_SAV']);
|
|
if ($datDsav[0]['STATUS_DSAV']=="1") {
|
|
$stat01++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="2") {
|
|
$stat02++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="3") {
|
|
$stat03++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="4") {
|
|
$stat04++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="5") {
|
|
$stat05++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="6") {
|
|
$stat06++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="7") {
|
|
$stat07++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="8") {
|
|
$stat08++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="9") {
|
|
$stat09++;
|
|
} else if ($datDsav[0]['STATUS_DSAV']=="10") {
|
|
$stat10++;
|
|
}
|
|
}
|
|
|
|
$data[$no++] = [
|
|
'KARYAWAN_ID' => $dat['SALES_ID'],
|
|
'NILAI_BVS_1' => $stat01,
|
|
'NILAI_BVS_2' => $stat02,
|
|
'NILAI_BVS_3' => $stat03,
|
|
'NILAI_BVS_4' => $stat04,
|
|
'NILAI_BVS_5' => $stat05,
|
|
'NILAI_BVS_6' => $stat06,
|
|
'NILAI_BVS_7' => $stat07,
|
|
'NILAI_BVS_8' => $stat08,
|
|
'NILAI_BVS_9' => $stat09,
|
|
'TGL_BVS' => $tgl,
|
|
];
|
|
}
|
|
|
|
if ($datSales!=null) {
|
|
$this->output_json([
|
|
'value' => true,
|
|
'message' => 'Berhasil',
|
|
'data' => $data,
|
|
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => false,
|
|
'message' => 'Gagal',
|
|
'data' => $data,
|
|
]);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|