umkm-app/application/models/AbsensiModel.php

208 lines
7.6 KiB
PHP
Raw Normal View History

2021-09-15 21:00:06 +07:00
<?php
class AbsensiModel extends CI_Model
{
private $_table = "tb_absensi";
public function getAbsensiByAbsenId($id_absen){
$this->db->where('id_absen', $id_absen);
return $absensi = $this->db->get($this->_table)->result();
}
2021-09-18 16:44:12 +07:00
public function getAbsenIdByAbsensiId($id_absensi){
$this->db->select('id_absen');
$this->db->where('id_absensi', $id_absensi);
return $absensi = $this->db->get($this->_table)->row();
}
2021-09-16 15:37:22 +07:00
public function getAbsensiByAbsenIdAndUmkmId($id_umkm,$id_absen){
$this->db->where('id_absen', $id_absen);
$this->db->where('id_umkm', $id_umkm);
return $absensi = $this->db->get($this->_table)->row();
}
public function getCountAbsensiByAbsenIdAndUmkmId($id_umkm,$id_absen){
$this->db->where('id_absen', $id_absen);
$this->db->where('id_umkm', $id_umkm);
return $absensi = count($this->db->get($this->_table)->result());
}
2021-09-16 15:37:22 +07:00
public function update($id_absensi){
$post = $this->input->post();
$this->aset = $post["aset"];
$this->omset = $post["omset"];
$this->karyawan_l = $post["karyawan_l"];
$this->karyawan_p = $post["karyawan_p"];
$this->signed = 1;
return $this->db->update($this->_table, $this, array('id_absensi' => $id_absensi));
}
2021-09-17 21:26:28 +07:00
public function getAbsensiByBulanAndTahun($bulan,$tahun){
$this->db->where('bulan', $bulan);
$this->db->where('tahun', $tahun);
return $absensi = count($this->db->get($this->_table)->result());
}
public function getAbsensiByTahunAndUmkmId($tahun,$id_umkm){
$this->db->where('id_umkm', $id_umkm);
$this->db->where('tahun', $tahun);
return $absensi = $this->db->get($this->_table)->result();
}
2021-09-18 16:44:12 +07:00
public function getAbsensByTahunByBulanAndKelurahan($tahun,$bulan,$kelurahan){
2021-09-17 21:26:28 +07:00
$this->db->where('kelurahan', $kelurahan);
2021-09-18 16:44:12 +07:00
$this->db->where('bulan', $bulan);
2021-09-17 21:26:28 +07:00
$this->db->where('tahun', $tahun);
2021-09-18 16:44:12 +07:00
$this->db->order_by('id_absensi','ASC');
2021-09-17 21:26:28 +07:00
return $absensi = $this->db->get($this->_table)->result();
}
public function getAbsensiByBulanAndThn($bulan,$tahun){
$this->db->where('bulan', $bulan);
$this->db->where('tahun', $tahun);
return $absensi = $this->db->get($this->_table)->result();
}
public function getAbsensiByTahunAndKelurahan($tahun,$kelurahan){
$this->db->where('tahun', $tahun);
$this->db->where('kelurahan', $kelurahan);
return $absensi = count($this->db->get($this->_table)->result());
}
public function absenBySystem($id_absensi){
$this->signed = 3;
return $this->db->update($this->_table, $this, array('id_absensi' => $id_absensi));
}
public function getDesemberAbsensiByYearAndByKelurahan($tahun,$kelurahan){
$this->db->join('tb_user','tb_user.id_user = tb_absensi.id_pemilik');
$this->db->where('bulan', 12);
$this->db->where('tahun', $tahun);
$this->db->where('tb_absensi.kelurahan', $kelurahan);
//$this->db->limit(1);
return $absensi = $this->db->get($this->_table)->result();
}
2021-09-15 21:00:06 +07:00
public function getLastMonthAbsensi($bulan,$tahun){
$bulan = $bulan-1;
$this->db->where('bulan', $bulan);
$this->db->where('tahun', $tahun);
return $absensi = $this->db->get($this->_table)->result();
}
public function getLatestAbsensi($bulan,$tahun,$id_umkm){
$bulan = $bulan-1;
$this->db->where('bulan', $bulan);
$this->db->where('tahun', $tahun);
$this->db->where('id_umkm', $id_umkm);
return $absensi = $this->db->get($this->_table)->row();
}
public function getAbsensiCountByUmkmId($id_umkm){
$this->db->where('id_umkm', $id_umkm);
return $user = count($this->db->get($this->_table)->result());
}
public function getAbsensiCountByAbsenId($id_absen){
$this->db->where('id_absen', $id_absen);
return $user = count($this->db->get($this->_table)->result());
}
public function getUnsignedAbsensiCountByAbsenId($id_absen){
$this->db->where('signed', false);
$this->db->where('id_absen', $id_absen);
return $user = count($this->db->get($this->_table)->result());
}
public function getSignedAbsensiCountByAbsenId($id_absen){
$this->db->where('signed', true);
$this->db->where('id_absen', $id_absen);
return $user = count($this->db->get($this->_table)->result());
}
public function getLatestSignedAbsensiCountByUmkmId($id_umkm){
2021-09-17 21:26:28 +07:00
$this->db->where('signed', 1);
2021-09-15 21:00:06 +07:00
$this->db->where('id_umkm', $id_umkm);
$this->db->where('tahun', date('Y'));
$this->db->order_by('bulan', 'DESC');
return $absensi = count($this->db->get($this->_table)->result());
}
2021-09-18 16:44:12 +07:00
2021-09-15 21:00:06 +07:00
public function getLatestSignedAbsensiByUmkmId($id_umkm){
$this->db->where('signed', true);
$this->db->where('id_umkm', $id_umkm);
$this->db->where('tahun', date('Y'));
$this->db->order_by('bulan', 'DESC');
return $absensi = $this->db->get($this->_table)->row();
}
public function getSignedAbsensiCountByUmkmId($id_umkm){
$this->db->where('signed', true);
$this->db->where('id_umkm', $id_umkm);
$this->db->order_by('bulan', 'DESC');
$this->db->order_by('tahun', 'DESC');
return $user = count($this->db->get($this->_table)->result());
}
public function getSignedAbsensiByUmkmId($id_umkm){
2021-09-18 16:44:12 +07:00
$this->db->where_in('signed', array(1,3));
2021-09-17 21:26:28 +07:00
// $this->db->where('signed', 3);
2021-09-15 21:00:06 +07:00
$this->db->where('id_umkm', $id_umkm);
$this->db->order_by('tahun', 'DESC');
2021-09-18 16:44:12 +07:00
$this->db->order_by('id_absensi', 'DESC');
return $user = $this->db->get($this->_table)->result();
}
public function getAllSignedAbsensiByUmkmId($id_umkm){
$this->db->where_in('signed', array(1,3));
$this->db->where('id_umkm', $id_umkm);
$this->db->order_by('tahun', 'DESC');
$this->db->order_by('id_absensi', 'DESC');
2021-09-15 21:00:06 +07:00
return $user = $this->db->get($this->_table)->result();
}
public function getUnsignedAbsensiByAbsenId($id_absen){
$this->db->join('tb_umkm','tb_umkm.id_umkm = tb_absensi.id_umkm');
$this->db->where('signed', false);
$this->db->where('id_absen', $id_absen);
return $absensi = $this->db->get($this->_table)->result();
}
public function getSignedAbsensiByAbsenId($id_absen){
$this->db->join('tb_umkm','tb_umkm.id_umkm = tb_absensi.id_umkm');
$this->db->where('signed', true);
$this->db->where('id_absen', $id_absen);
return $absensi = $this->db->get($this->_table)->result();
}
2021-09-17 21:26:28 +07:00
public function save($id_absen,$id_umkm,$id_pemilik,$id_jenis,$id_kategori,$kecamatan,$kelurahan,$bulan_absen,$tahun_absen,$omset_absensi,$aset_absensi,$karyawan_absensi_l,$karyawan_absensi_p)
2021-09-15 21:00:06 +07:00
{
$this->id_absen = $id_absen;
$this->id_umkm = $id_umkm;
$this->id_pemilik = $id_pemilik;
2021-09-17 21:26:28 +07:00
$this->id_jenis = $id_jenis;
$this->id_kategori = $id_kategori;
2021-09-15 21:00:06 +07:00
$this->kecamatan = $kecamatan;
$this->kelurahan = $kelurahan;
$this->bulan = $bulan_absen;
$this->tahun = $tahun_absen;
$this->karyawan_l = $karyawan_absensi_l;
$this->karyawan_p = $karyawan_absensi_p;
$this->omset = $omset_absensi;
$this->aset = $aset_absensi;
$this->signed = false;
return $this->db->insert($this->_table, $this);
}
public function delete($id_absensi)
{
return $this->db->delete($this->_table, array("id_absensi" => $id_absensi));
}
}