First Commit
This commit is contained in:
114
application/models/AbsenModel.php
Normal file
114
application/models/AbsenModel.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class AbsenModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_absen";
|
||||
|
||||
public function getAbsens(){
|
||||
//$this->db->order_by('status_absen', 'DESC');
|
||||
$this->db->order_by('bulan', 'ASC');
|
||||
return $absen = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getAbsensByTahun($tahun){
|
||||
//$this->db->order_by('status_absen', 'DESC');
|
||||
$this->db->where('tahun', $tahun);
|
||||
$this->db->order_by('bulan', 'ASC');
|
||||
return $absen = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getAbsenById($id_absen){
|
||||
$this->db->where('id_absen', $id_absen);
|
||||
return $absen = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
public function getAbsenTahun(){
|
||||
$this->db->select('tahun');
|
||||
$this->db->distinct('tahun');
|
||||
return $tahun = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getCountActiveAbsen(){
|
||||
$this->db->where('status_absen', 'open');
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getActiveAbsen(){
|
||||
$this->db->where('status_absen', 'open');
|
||||
return $absen = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
public function getAbsenCountByBulanAndYear($bulan,$tahun){
|
||||
$this->db->where('tahun',$tahun);
|
||||
$this->db->where('bulan',$bulan);
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getLastMonthAbsenCountByBulanAndYear($bulan,$tahun){
|
||||
$bulan = $bulan-1;
|
||||
$this->db->where('tahun',$tahun);
|
||||
$this->db->where('bulan',$bulan);
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getAbsenCountByYear($tahun){
|
||||
$this->db->where('tahun',$tahun);
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getAbsenByBulanAndYear($bulan,$tahun){
|
||||
$this->db->where('tahun',$tahun);
|
||||
$this->db->where('bulan',$bulan);
|
||||
return $absen = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
public function getAbsenCountByUmkmId($id_umkm){
|
||||
$this->db->where('id_umkm', $id_umkm);
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getOpenAbsenCount(){
|
||||
$this->db->where('status_absen', 'open');
|
||||
return $absen = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getOpenAbsen(){
|
||||
$this->db->where('status_absen', 'open');
|
||||
return $absen = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function setCloseAbsen($id_absen)
|
||||
{
|
||||
$this->status_absen = "close";
|
||||
return $this->db->update($this->_table, $this, array('id_absen' => $id_absen));
|
||||
}
|
||||
|
||||
public function setOpenAbsen($id_absen)
|
||||
{
|
||||
$this->status_absen = "open";
|
||||
return $this->db->update($this->_table, $this, array('id_absen' => $id_absen));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function save($jumlahumkm,$omset,$aset,$karyawan_l,$karyawan_p)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->bulan = $post["bulan"];
|
||||
$this->tahun = $post["tahun"];
|
||||
$this->jumlah_umkm = $jumlahumkm;
|
||||
$this->omset = $omset;
|
||||
$this->aset = $aset;
|
||||
$this->karyawan_l = $karyawan_l;
|
||||
$this->karyawan_p = $karyawan_p;
|
||||
$this->status_absen = 'close';
|
||||
|
||||
return $this->db->insert($this->_table, $this);
|
||||
}
|
||||
|
||||
public function delete($id_absen)
|
||||
{
|
||||
return $this->db->delete($this->_table, array("id_absen" => $id_absen));
|
||||
}
|
||||
|
||||
}
|
||||
121
application/models/AbsensiModel.php
Normal file
121
application/models/AbsensiModel.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
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){
|
||||
$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 = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
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){
|
||||
$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 = $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();
|
||||
}
|
||||
|
||||
public function save($id_absen,$id_umkm,$id_pemilik,$kecamatan,$kelurahan,$bulan_absen,$tahun_absen,$omset_absensi,$aset_absensi,$karyawan_absensi_l,$karyawan_absensi_p)
|
||||
{
|
||||
$this->id_absen = $id_absen;
|
||||
$this->id_umkm = $id_umkm;
|
||||
$this->id_pemilik = $id_pemilik;
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
application/models/JenisModel.php
Normal file
20
application/models/JenisModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class JenisModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_jenis";
|
||||
|
||||
|
||||
public function getJenis(){
|
||||
return $user = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getJenisById($id_jenis){
|
||||
$this->db->where('id_jenis', $id_jenis);
|
||||
return $user = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
20
application/models/KategoriModel.php
Normal file
20
application/models/KategoriModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class KategoriModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_kategori";
|
||||
|
||||
|
||||
public function getKategori(){
|
||||
return $user = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getKategoriById($id_kategori){
|
||||
$this->db->where('id_kategori', $id_kategori);
|
||||
return $user = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
application/models/KelurahanModel.php
Normal file
21
application/models/KelurahanModel.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class KelurahanModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_kelurahan";
|
||||
|
||||
|
||||
public function getKelurahan(){
|
||||
$this->db->order_by('kelurahan', 'ASC');
|
||||
return $user = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getKecamatanByKelurahan($kelurahan){
|
||||
$this->db->where('kelurahan', $kelurahan);
|
||||
return $user = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
13
application/models/LaporanModel.php
Normal file
13
application/models/LaporanModel.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class LaporanModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_laporan";
|
||||
|
||||
public function getLaporanCountByYear($tahun){
|
||||
$this->db->where('tahun',$tahun);
|
||||
return $laporan = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
136
application/models/UmkmModel.php
Normal file
136
application/models/UmkmModel.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
class UmkmModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_umkm";
|
||||
|
||||
public function save($id_pemilik)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->id_pemilik = $id_pemilik;
|
||||
$this->nama = $post["nama"];
|
||||
$this->omset_awal = $post["omset"];
|
||||
$this->aset_awal = $post["aset"];
|
||||
|
||||
$this->karyawan_l = $post["karyawan_l"];
|
||||
$this->karyawan_p = $post["karyawan_p"];
|
||||
|
||||
if($post["aset"]>500000000){
|
||||
$id_kategori = 3;
|
||||
} else{
|
||||
if($post["omset"]>2500000000){
|
||||
$id_kategori = 3;
|
||||
} elseif($post["omset"]>300000000){
|
||||
$id_kategori = 2;
|
||||
} else {
|
||||
$id_kategori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->id_kategori = $id_kategori;
|
||||
$this->id_jenis = $post["jenis"];
|
||||
|
||||
if($post['kelurahan']!=='luar'){
|
||||
$kelurahan = $post['kelurahan'];
|
||||
$kecamatan = $this->KelurahanModel->getKecamatanByKelurahan($post['kelurahan']);
|
||||
} else {
|
||||
$kelurahan = 'Luar Kota Magelang';
|
||||
$kecamatan = 'Luar Kota Magelang';
|
||||
}
|
||||
$this->kelurahan = $kelurahan;
|
||||
$this->kecamatan = $kecamatan;
|
||||
|
||||
$this->alamat = $post["alamat"];
|
||||
$this->telp = $post["telp"];
|
||||
$this->deskripsi = $post["deskripsi"];
|
||||
$this->foto_umkm = "umkm.png";
|
||||
return $this->db->insert($this->_table, $this);
|
||||
}
|
||||
|
||||
public function setFirstImage($id_umkm,$foto_umkm)
|
||||
{
|
||||
$this->foto_umkm = $foto_umkm;
|
||||
return $this->db->update($this->_table, $this, array('id_umkm' => $id_umkm));
|
||||
}
|
||||
|
||||
public function getUmkm(){
|
||||
return $user = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getUmkmsById($id_umkm){
|
||||
$this->db->join('tb_jenis','tb_jenis.id_jenis = tb_umkm.id_jenis');
|
||||
$this->db->join('tb_kategori','tb_kategori.id_kategori = tb_umkm.id_kategori');
|
||||
$this->db->where('id_umkm', $id_umkm);
|
||||
return $umkm = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
public function getUmkmsByIdPemilik($id_pemilik){
|
||||
$this->db->join('tb_kategori','tb_kategori.id_kategori = tb_umkm.id_kategori');
|
||||
$this->db->where('id_pemilik', $id_pemilik);
|
||||
return $umkm = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getLastUmkmByIdPemilik($id_pemilik){
|
||||
$this->db->where('id_pemilik', $id_pemilik);
|
||||
$this->db->order_by('id_umkm', 'DESC');
|
||||
return $umkm = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
|
||||
public function getUmkmCountByUserId($id_pemilik){
|
||||
$this->db->where('id_pemilik', $id_pemilik);
|
||||
return $user = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function getUmkmCount(){
|
||||
return $user = count($this->db->get($this->_table)->result());
|
||||
}
|
||||
|
||||
public function update($id_umkm,$foto_umkm)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->nama = $post["nama"];
|
||||
$this->omset_awal = $post["omset"];
|
||||
$this->aset_awal = $post["aset"];
|
||||
$this->karyawan_l = $post["karyawan_l"];
|
||||
$this->karyawan_p = $post["karyawan_p"];
|
||||
|
||||
if($post["aset"]>500000000){
|
||||
$id_kategori = 3;
|
||||
} else{
|
||||
if($post["omset"]>2500000000){
|
||||
$id_kategori = 3;
|
||||
} elseif($post["omset"]>300000000){
|
||||
$id_kategori = 2;
|
||||
} else {
|
||||
$id_kategori = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->id_kategori = $id_kategori;
|
||||
$this->id_jenis = $post["jenis"];
|
||||
|
||||
if($post['kelurahan']!=='luar'){
|
||||
$kelurahan = $post['kelurahan'];
|
||||
$kecamatan = $this->KelurahanModel->getKecamatanByKelurahan($post['kelurahan']);
|
||||
} else {
|
||||
$kelurahan = 'Luar Kota Magelang';
|
||||
$kecamatan = 'Luar Kota Magelang';
|
||||
}
|
||||
$this->kelurahan = $kelurahan;
|
||||
$this->kecamatan = $kecamatan;
|
||||
|
||||
$this->alamat = $post["alamat"];
|
||||
$this->telp = $post["telp"];
|
||||
$this->deskripsi = $post["deskripsi"];
|
||||
$this->foto_umkm = $foto_umkm;
|
||||
return $this->db->update($this->_table, $this, array('id_umkm' => $id_umkm));
|
||||
}
|
||||
|
||||
public function delete($id_umkm)
|
||||
{
|
||||
return $this->db->delete($this->_table, array("id_umkm" => $id_umkm));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
118
application/models/UserModel.php
Normal file
118
application/models/UserModel.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
class UserModel extends CI_Model
|
||||
{
|
||||
private $_table = "tb_user";
|
||||
|
||||
public function doLogin(){
|
||||
$post = $this->input->post();
|
||||
|
||||
// cari user berdasarkan email dan username
|
||||
$this->db->where('username', $post["username"]);
|
||||
$user = $this->db->get($this->_table)->row();
|
||||
|
||||
// jika user terdaftar
|
||||
if($user){
|
||||
// periksa password-nya
|
||||
|
||||
$isPasswordTrue = md5($post["password"])==$user->password;
|
||||
// jika password benar dan dia admin
|
||||
if($isPasswordTrue){
|
||||
// login sukses yay!
|
||||
$this->session->set_userdata(['user_logged' => $user]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// login gagal
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUsers(){
|
||||
$this->db->where('level', 'pemilik');
|
||||
return $user = $this->db->get($this->_table)->result();
|
||||
}
|
||||
|
||||
public function getUsersById($id_user){
|
||||
$this->db->where('id_user', $id_user);
|
||||
return $user = $this->db->get($this->_table)->row();
|
||||
}
|
||||
|
||||
public function isNotLogin(){
|
||||
return $this->session->userdata('user_logged') === null;
|
||||
|
||||
}
|
||||
|
||||
public function isAdmin(){
|
||||
return $this->session->userdata('user_logged')->level === 'admin';
|
||||
}
|
||||
|
||||
public function isPemilik(){
|
||||
return $this->session->userdata('user_logged')->level === 'pemilik';
|
||||
}
|
||||
|
||||
public function save($foto_user)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->nama = $post["nama"];
|
||||
$this->username = $post["username"];
|
||||
$this->password = md5($post["password"]);
|
||||
$this->alamat_user = $post["alamat"];
|
||||
if($post['kelurahan']!=='luar'){
|
||||
$kelurahan = $post['kelurahan'];
|
||||
$kecamatan = $this->KelurahanModel->getKecamatanByKelurahan($post['kelurahan']);
|
||||
$kota = 'Kota Magelang';
|
||||
} else {
|
||||
$kelurahan = 'Luar Kota Magelang';
|
||||
$kecamatan = 'Luar Kota Magelang';
|
||||
$kota = 'Luar Kota Magelang';
|
||||
}
|
||||
$this->kelurahan_user = $kelurahan;
|
||||
$this->kecamatan_user = $kecamatan;
|
||||
$this->kota_user = $kota;
|
||||
$this->telp_user = $post["telp"];
|
||||
$this->npwp = $post["npwp"];
|
||||
$this->foto_user = $foto_user;
|
||||
$this->level = 'pemilik';
|
||||
|
||||
return $this->db->insert($this->_table, $this);
|
||||
}
|
||||
|
||||
public function update($id_pemilik,$foto_user)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->nama = $post["nama"];
|
||||
$this->alamat_user = $post["alamat"];
|
||||
if($post['kelurahan']!=='luar'){
|
||||
$kelurahan = $post['kelurahan'];
|
||||
$kecamatan = $this->KelurahanModel->getKecamatanByKelurahan($post['kelurahan']);
|
||||
$kota = 'Kota Magelang';
|
||||
} else {
|
||||
$kelurahan = 'Luar Kota Magelang';
|
||||
$kecamatan = 'Luar Kota Magelang';
|
||||
$kota = 'Luar Kota Magelang';
|
||||
}
|
||||
$this->kelurahan_user = $kelurahan;
|
||||
$this->kecamatan_user = $kecamatan;
|
||||
$this->kota_user = $kota;
|
||||
$this->telp_user = $post["telp"];
|
||||
$this->npwp = $post["npwp"];
|
||||
$this->foto_user = $foto_user;
|
||||
return $this->db->update($this->_table, $this, array('id_user' => $id_pemilik));
|
||||
}
|
||||
|
||||
public function resetPassword($id_user)
|
||||
{
|
||||
$post = $this->input->post();
|
||||
$this->password = md5($post["password"]);
|
||||
return $this->db->update($this->_table, $this, array('id_user' => $id_user));
|
||||
}
|
||||
|
||||
public function delete($id_pemilik)
|
||||
{
|
||||
return $this->db->delete($this->_table, array("id_user" => $id_pemilik));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
application/models/index.html
Normal file
11
application/models/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user