107 lines
3.5 KiB
PHP
107 lines
3.5 KiB
PHP
<?php
|
|
|
|
use LDAP\Result;
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
class ShiftModel extends CI_Model
|
|
{
|
|
public function create($table, $data, $batch = false)
|
|
{
|
|
if ($batch === false) {
|
|
$insert = $this->db->insert($table, $data);
|
|
} else {
|
|
$insert = $this->db->insert_batch($table, $data);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function update($table, $data, $pk, $id = null, $batch = false)
|
|
{
|
|
if ($batch === false) {
|
|
$insert = $this->db->update($table, $data, array($pk => $id));
|
|
} else {
|
|
$insert = $this->db->update_batch($table, $data, $pk);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function delete($table, $data, $pk)
|
|
{
|
|
$this->db->where_in($pk, $data);
|
|
return $this->db->delete($table);
|
|
}
|
|
|
|
public function getDataShift()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('shift a');
|
|
$this->db->join('cabang b', 'b.KODE_CABANG=a.CABANG_KODE');
|
|
$this->db->order_by('a.TANGGAL_SHIFT DESC');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getDataShiftByKodeCabang($kode)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('shift a');
|
|
$this->db->where(['a.CABANG_KODE' => $kode]);
|
|
$this->db->order_by('a.TANGGAL_SHIFT DESC');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getDataDetailByIdShift($id)
|
|
{
|
|
$this->db->select('a.ID_DETAIL_SHIFT, b.ID_KARYAWAN, b.NAMA_KARYAWAN');
|
|
$this->db->from('detail_shift a');
|
|
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.KARYAWAN_ID');
|
|
$this->db->where(['a.SHIFT_ID' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getDataKaryawanByKodeCabang($id_cabang)
|
|
{
|
|
$this->db->select('a.ID_KARYAWAN, a.NAMA_KARYAWAN');
|
|
$this->db->from('karyawan a');
|
|
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
|
|
$this->db->where(['b.CABANG_KODE' => $id_cabang]);
|
|
$this->db->where(['a.STATUS_KARYAWAN' => 1]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function cekDetailByIdKarShift($idKar, $idShift)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('detail_shift');
|
|
$this->db->where(['KARYAWAN_ID' => $idKar, 'SHIFT_ID' => $idShift]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getIdShiftTerakhir($cabang)
|
|
{
|
|
$this->db->select('ID_SHIFT');
|
|
$this->db->from('shift');
|
|
$this->db->like('ID_SHIFT', $cabang, 'after');
|
|
$this->db->order_by('IS DESC');
|
|
$this->db->limit(1);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getIdDetailShiftTerakhir($cabang)
|
|
{
|
|
$this->db->select('ID_DETAIL_SHIFT');
|
|
$this->db->from('detail_shift');
|
|
$this->db->like('ID_DETAIL_SHIFT', $cabang, 'after');
|
|
$this->db->order_by('IDS DESC');
|
|
$this->db->limit(1);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getDataShiftById($id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('shift');
|
|
$this->db->where(['ID_SHIFT' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
public function getDataDetailShiftById($id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('detail_shift');
|
|
$this->db->where(['ID_DETAIL_SHIFT' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|