umkm-app/application/models/LaporanModel.php

191 lines
7.8 KiB
PHP

<?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());
}
public function getCountByTahunByBulanByKelurahan($tahun,$bulan,$kelurahan){
$this->db->where('tahun',$tahun);
$this->db->where('bulan',$bulan);
$this->db->where('kelurahan',$kelurahan);
return $laporan = count($this->db->get($this->_table)->result());
}
public function getCountByTahunByKelurahan($tahun,$kelurahan){
$this->db->where('tahun',$tahun);
$this->db->where('kelurahan',$kelurahan);
return $laporan = count($this->db->get($this->_table)->result());
}
public function getCountByTahunByKecamatan($tahun,$kecamatan){
$this->db->where('tahun',$tahun);
$this->db->where('kecamatan',$kecamatan);
return $laporan = count($this->db->get($this->_table)->result());
}
public function getLaporanByBulanByYearByKelurahan($bulan,$year,$kelurahan){
$this->db->where('tahun',$year);
$this->db->where('bulan',$bulan);
$this->db->where('kelurahan',$kelurahan);
return $laporan = $this->db->get($this->_table)->row();
}
public function getLaporanCount(){
$this->db->select('tahun');
$this->db->distinct('tahun');
$this->db->order_by('tahun','DESC');
return $laporan = count($this->db->get($this->_table)->result());
}
public function getLaporanBeforeCount(){
$this->db->select('tahun');
$this->db->distinct('tahun');
$this->db->order_by('tahun','DESC');
$this->db->limit(2,1);
return $laporan = count($this->db->get($this->_table)->result());
}
public function getLastYearLaporan(){
$this->db->select('tahun');
$this->db->distinct('tahun');
$this->db->order_by('tahun','DESC');
$this->db->limit(1);
return $laporan =$this->db->get($this->_table)->row();
}
public function getLaporanByTahunAndKelurahan($tahun,$kelurahan){
$this->db->where('tahun',$tahun);
$this->db->where('kelurahan',$kelurahan);
$this->db->order_by('bulan','ASC');
return $laporan =$this->db->get($this->_table)->result();
}
public function getKelurahanByTahunAndKecamatan($tahun,$kecamatan){
$this->db->select('kelurahan');
$this->db->distinct('kelurahan');
$this->db->where('tahun',$tahun);
$this->db->where('kecamatan',$kecamatan);
$this->db->order_by('kelurahan','ASC');
return $laporan =$this->db->get($this->_table)->result();
}
public function getLastMonthLaporan($tahun){
$this->db->select('bulan');
$this->db->where('tahun',$tahun);
$this->db->distinct('bulan');
$this->db->order_by('bulan','DESC');
$this->db->limit(1);
return $laporan =$this->db->get($this->_table)->row();
}
public function getBulanLaporanByYear($tahun){
$this->db->select('bulan');
$this->db->where('tahun',$tahun);
$this->db->distinct('bulan');
$this->db->order_by('id_laporan','ASC');
return $laporan =$this->db->get($this->_table)->result();
}
public function getKelurahanByBulanAndYear($bulan,$year){
$this->db->select('kelurahan');
$this->db->where('tahun',$year);
$this->db->where('bulan',$bulan);
$this->db->distinct('kelurahan');
$this->db->order_by('id_laporan','ASC');
return $laporan =$this->db->get($this->_table)->result();
}
public function getLastYearLaporanBefore(){
$this->db->select('tahun');
$this->db->distinct('tahun');
$this->db->order_by('tahun','DESC');
$this->db->limit(2,1);
return $laporan =$this->db->get($this->_table)->row();
}
public function save($tahun,$bulan,$kelurahan,$kecamatan,$aset,$omset,$jumlah_umkm,$karyawan_jenis1,$karyawan_jenis2,$karyawan_jenis3,$omset_jenis1,$omset_jenis2,$omset_jenis3,$aset_jenis1,$aset_jenis2,$aset_jenis3,$karyawan_jen1_l,$karyawan_jen1_p,$karyawan_jen2_l,$karyawan_jen2_p,$karyawan_jen3_l,$karyawan_jen3_p,$umkm_jen1_kat1,$umkm_jen1_kat2,$umkm_jen1_kat3,$umkm_jen2_kat1,$umkm_jen2_kat2,$umkm_jen2_kat3,$umkm_jen3_kat1,$umkm_jen3_kat2,$umkm_jen3_kat3)
{
$this->tahun = $tahun;
$this->bulan = $bulan;
$this->kelurahan = $kelurahan;
$this->kecamatan = $kecamatan;
$this->aset = $aset;
$this->omset = $omset;
$this->jumlah_umkm = $jumlah_umkm;
$this->karyawan_jenis1 = $karyawan_jenis1;
$this->karyawan_jenis2 = $karyawan_jenis2;
$this->karyawan_jenis3 = $karyawan_jenis3;
$this->omset_jenis1 = $omset_jenis1;
$this->omset_jenis2 = $omset_jenis2;
$this->omset_jenis3 = $omset_jenis3;
$this->aset_jenis1 = $aset_jenis1;
$this->aset_jenis2 = $aset_jenis2;
$this->aset_jenis3 = $aset_jenis3;
$this->karyawan_jen1_l = $karyawan_jen1_l;
$this->karyawan_jen1_p = $karyawan_jen1_p;
$this->karyawan_jen2_l = $karyawan_jen2_l;
$this->karyawan_jen2_p = $karyawan_jen2_p;
$this->karyawan_jen3_l = $karyawan_jen3_l;
$this->karyawan_jen3_p = $karyawan_jen3_p;
$this->umkm_jen1_kat1 = $umkm_jen1_kat1;
$this->umkm_jen1_kat2 = $umkm_jen1_kat2;
$this->umkm_jen1_kat3 = $umkm_jen1_kat3;
$this->umkm_jen2_kat1 = $umkm_jen2_kat1;
$this->umkm_jen2_kat2 = $umkm_jen2_kat2;
$this->umkm_jen2_kat3 = $umkm_jen2_kat3;
$this->umkm_jen3_kat1 = $umkm_jen3_kat1;
$this->umkm_jen3_kat2 = $umkm_jen3_kat2;
$this->umkm_jen3_kat3 = $umkm_jen3_kat3;
//var_dump($this);die();
return $this->db->insert($this->_table, $this);
}
public function update($id_laporan,$tahun,$bulan,$kelurahan,$kecamatan,$aset,$omset,$jumlah_umkm,$karyawan_jenis1,$karyawan_jenis2,$karyawan_jenis3,$omset_jenis1,$omset_jenis2,$omset_jenis3,$aset_jenis1,$aset_jenis2,$aset_jenis3,$karyawan_jen1_l,$karyawan_jen1_p,$karyawan_jen2_l,$karyawan_jen2_p,$karyawan_jen3_l,$karyawan_jen3_p,$umkm_jen1_kat1,$umkm_jen1_kat2,$umkm_jen1_kat3,$umkm_jen2_kat1,$umkm_jen2_kat2,$umkm_jen2_kat3,$umkm_jen3_kat1,$umkm_jen3_kat2,$umkm_jen3_kat3)
{
$this->tahun = $tahun;
$this->bulan = $bulan;
$this->kelurahan = $kelurahan;
$this->kecamatan = $kecamatan;
$this->aset = $aset;
$this->omset = $omset;
$this->jumlah_umkm = $jumlah_umkm;
$this->karyawan_jenis1 = $karyawan_jenis1;
$this->karyawan_jenis2 = $karyawan_jenis2;
$this->karyawan_jenis3 = $karyawan_jenis3;
$this->omset_jenis1 = $omset_jenis1;
$this->omset_jenis2 = $omset_jenis2;
$this->omset_jenis3 = $omset_jenis3;
$this->aset_jenis1 = $aset_jenis1;
$this->aset_jenis2 = $aset_jenis2;
$this->aset_jenis3 = $aset_jenis3;
$this->karyawan_jen1_l = $karyawan_jen1_l;
$this->karyawan_jen1_p = $karyawan_jen1_p;
$this->karyawan_jen2_l = $karyawan_jen2_l;
$this->karyawan_jen2_p = $karyawan_jen2_p;
$this->karyawan_jen3_l = $karyawan_jen3_l;
$this->karyawan_jen3_p = $karyawan_jen3_p;
$this->umkm_jen1_kat1 = $umkm_jen1_kat1;
$this->umkm_jen1_kat2 = $umkm_jen1_kat2;
$this->umkm_jen1_kat3 = $umkm_jen1_kat3;
$this->umkm_jen2_kat1 = $umkm_jen2_kat1;
$this->umkm_jen2_kat2 = $umkm_jen2_kat2;
$this->umkm_jen2_kat3 = $umkm_jen2_kat3;
$this->umkm_jen3_kat1 = $umkm_jen3_kat1;
$this->umkm_jen3_kat2 = $umkm_jen3_kat2;
$this->umkm_jen3_kat3 = $umkm_jen3_kat3;
//var_dump($this);die();
return $this->db->update($this->_table, $this, array('id_laporan' => $id_laporan));
}
}