umkm-app/application/controllers/admin/LaporanBulanan.php

226 lines
6.2 KiB
PHP
Raw Permalink Normal View History

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class LaporanBulanan extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model("UserModel");
$this->load->model("LaporanModel");
$this->load->model("KategoriModel");
$this->load->model("JenisModel");
if($this->UserModel->isNotLogin()) {
redirect(site_url('login'));
} elseif(!($this->UserModel->isAdmin())) {
redirect(site_url('dashboard'));
}
}
public function index()
{
//cek ada laporan tahunan atau tidak
$countlaporan = $this->LaporanModel->getLaporanCount();
if($countlaporan>0){
$year = $this->LaporanModel->getLastYearLaporan()->tahun;
//cek ada laporan bulanan atau tidak
$countlaporanbulan = $this->LaporanModel->getLaporanCountByYear($year);
if($countlaporanbulan>0){
$data['tahun'] = $year;
if($this->input->post()){
$post = $this->input->post();
$month = $post['bulan'];
} else {
$month = $this->LaporanModel->getLastMonthLaporan($year)->bulan;
}
$data['bulan'] = $month;
$omset_jen1=0;
$omset_jen2=0;
$omset_jen3=0;
$umkm_jen1=0;
$umkm_jen2=0;
$umkm_jen3=0;
$umkm_jen1_ket1=0;
$umkm_jen1_ket2=0;
$umkm_jen1_ket3=0;
$umkm_jen2_ket1=0;
$umkm_jen2_ket2=0;
$umkm_jen2_ket3=0;
$umkm_jen3_ket1=0;
$umkm_jen3_ket2=0;
$umkm_jen3_ket3=0;
$aset_jen1=0;
$aset_jen2=0;
$aset_jen3=0;
$naker_jen1_l=0;
$naker_jen1_p=0;
$naker_jen2_l=0;
$naker_jen2_p=0;
$naker_jen3_l=0;
$naker_jen3_p=0;
$lap_kelurahan = $this->LaporanModel->getKelurahanByBulanAndYear($month,$year);
foreach($lap_kelurahan as $kelurahan){
$laporan = $this->LaporanModel->getLaporanByBulanByYearByKelurahan($month,$year,$kelurahan->kelurahan);
$umkm_jen1= $umkm_jen1+$laporan->umkm_jen1_kat1+$laporan->umkm_jen1_kat2+$laporan->umkm_jen1_kat3;
$umkm_jen2= $umkm_jen2+$laporan->umkm_jen2_kat1+$laporan->umkm_jen2_kat2+$laporan->umkm_jen2_kat3;
$umkm_jen3= $umkm_jen3+$laporan->umkm_jen3_kat1+$laporan->umkm_jen3_kat2+$laporan->umkm_jen3_kat3;
$omset_jen1= $omset_jen1+$laporan->omset_jenis1;
$omset_jen2= $omset_jen2+$laporan->omset_jenis2;
$omset_jen3= $omset_jen3+$laporan->omset_jenis3;
$aset_jen1= $aset_jen1+$laporan->aset_jenis1;
$aset_jen2= $aset_jen2+$laporan->aset_jenis2;
$aset_jen3= $aset_jen3+$laporan->aset_jenis3;
$naker_jen1_l = $naker_jen1_l + $laporan->karyawan_jen1_l;
$naker_jen1_p = $naker_jen1_p + $laporan->karyawan_jen1_p;
$naker_jen2_l = $naker_jen2_l + $laporan->karyawan_jen2_l;
$naker_jen2_p = $naker_jen2_p + $laporan->karyawan_jen2_p;
$naker_jen3_l = $naker_jen3_l + $laporan->karyawan_jen3_l;
$naker_jen3_p = $naker_jen3_p + $laporan->karyawan_jen3_p;
$umkm_jen1_ket1=$umkm_jen1_ket1+$laporan->umkm_jen1_kat1;
$umkm_jen1_ket2=$umkm_jen1_ket2+$laporan->umkm_jen1_kat2;
$umkm_jen1_ket3=$umkm_jen1_ket3+$laporan->umkm_jen1_kat3;
$umkm_jen2_ket1=$umkm_jen2_ket1+$laporan->umkm_jen2_kat1;
$umkm_jen2_ket2=$umkm_jen2_ket2+$laporan->umkm_jen2_kat2;
$umkm_jen2_ket3=$umkm_jen2_ket3+$laporan->umkm_jen2_kat3;
$umkm_jen3_ket1=$umkm_jen3_ket1+$laporan->umkm_jen3_kat1;
$umkm_jen3_ket2=$umkm_jen3_ket2+$laporan->umkm_jen3_kat2;
$umkm_jen3_ket3=$umkm_jen3_ket3+$laporan->umkm_jen3_kat3;
}
$data['umkm_jen1_ket1']=$umkm_jen1_ket1;
$data['umkm_jen1_ket2']=$umkm_jen1_ket2;
$data['umkm_jen1_ket3']=$umkm_jen1_ket3;
$data['umkm_jen2_ket1']=$umkm_jen2_ket1;
$data['umkm_jen2_ket2']=$umkm_jen2_ket2;
$data['umkm_jen2_ket3']=$umkm_jen2_ket3;
$data['umkm_jen3_ket1']=$umkm_jen3_ket1;
$data['umkm_jen3_ket2']=$umkm_jen3_ket2;
$data['umkm_jen3_ket3']=$umkm_jen3_ket3;
$omset_bln_jen1= $omset_jen1;
$omset_bln_jen2= $omset_jen2;
$omset_bln_jen3= $omset_jen3;
$data['umkm_jen1']=$umkm_jen1;
$data['umkm_jen2']=$umkm_jen2;
$data['umkm_jen3']=$umkm_jen3;
$data['omset_bln_jen1'] = $omset_bln_jen1;
$data['omset_bln_jen2'] = $omset_bln_jen2;
$data['omset_bln_jen3'] = $omset_bln_jen3;
$data['aset_jen1'] = $aset_jen1;
$data['aset_jen2'] = $aset_jen2;
$data['aset_jen3'] = $aset_jen3;
$data['naker_jen1_l'] = $naker_jen1_l;
$data['naker_jen1_p'] = $naker_jen1_p;
$data['naker_jen2_l'] = $naker_jen2_l;
$data['naker_jen2_p'] = $naker_jen2_p;
$data['naker_jen3_l'] = $naker_jen3_l;
$data['naker_jen3_p'] = $naker_jen3_p;
//komulatif
$data['omset_1'] = $omset_bln_jen1+$omset_bln_jen2+$omset_bln_jen3;
$data['aset_1'] = $aset_jen1+$aset_jen2+$aset_jen3;
$data['umkm_1'] = $umkm_jen1+$umkm_jen2+$umkm_jen3;
$naker_1 = $naker_jen1_l+$naker_jen2_l+$naker_jen3_l;
$data['naker_1'] = $naker_1+$naker_jen1_p+$naker_jen2_p+$naker_jen3_p;
$data['mikro_1'] = $umkm_jen1_ket1+$umkm_jen2_ket1+$umkm_jen3_ket1;
$data['kecil_1'] = $umkm_jen1_ket2+$umkm_jen2_ket2+$umkm_jen3_ket2;
$data['menengah_1'] = $umkm_jen1_ket3+$umkm_jen2_ket3+$umkm_jen3_ket3;
$data['msg'] = 'found';
}
} else {
$data['msg'] = 'empty';
}
$data['user_logged'] = $this->session->userdata('user_logged');
$bulanlist = array(
array(
'bulan'=>'1',
'text'=>'Januari'
),
array(
'bulan'=>'2',
'text'=>'Februari'
),
array(
'bulan'=>'3',
'text'=>'Maret'
),
array(
'bulan'=>'4',
'text'=>'April'
),
array(
'bulan'=>'5',
'text'=>'Mei'
),
array(
'bulan'=>'6',
'text'=>'Juni'
),
array(
'bulan'=>'7',
'text'=>'Juli'
),
array(
'bulan'=>'8',
'text'=>'Agustus'
),
array(
'bulan'=>'9',
'text'=>'September'
),
array(
'bulan'=>'10',
'text'=>'Oktober'
),
array(
'bulan'=>'11',
'text'=>'November'
),
array(
'bulan'=>'12',
'text'=>'Desember'
)
);
$data['bulan_list']= $bulanlist;
$this->load->view('admin/laporanbulanan',$data);
}
}