umkm-app/application/controllers/Kelurahan.php

240 lines
10 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Kelurahan extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model("UserModel");
$this->load->model("LaporanModel");
$this->load->model("KategoriModel");
$this->load->model("JenisModel");
$this->load->model("KelurahanModel");
$this->load->model("AbsensiModel");
$this->load->model("UmkmModel");
}
public function index()
{
if($this->input->post()){
$post = $this->input->post();
$kelurahan = $post['kelurahan'];
} else {
$kelurahan = 'Rejowinangun Selatan';
}
//cek ada laporan atau tidak
$countlaporan = $this->LaporanModel->getLaporanCount();
if($countlaporan>0){
$year = $this->LaporanModel->getLastYearLaporan()->tahun;
} else {
redirect(site_url('admin/laporan'));die();
}
//cek ada laporan kelurahan atau tidak
$countlaporankel = $this->LaporanModel->getCountByTahunByKelurahan($year,$kelurahan);
if($countlaporankel>0){
$data['msg'] = 'found';
$listlapkel = $this->LaporanModel->getLaporanByTahunAndKelurahan($year,$kelurahan);
$lap[$kelurahan]['kelurahan']='';
$lap[$kelurahan]['aset']=0;
$lap[$kelurahan]['omset']=0;
$lap[$kelurahan]['karyawan_jenis1']=0;
$lap[$kelurahan]['karyawan_jenis2']=0;
$lap[$kelurahan]['karyawan_jenis3']=0;
$lap[$kelurahan]['omset_jenis1']=0;
$lap[$kelurahan]['omset_jenis2']=0;
$lap[$kelurahan]['omset_jenis3']=0;
$lap[$kelurahan]['aset_jenis1']=0;
$lap[$kelurahan]['aset_jenis2']=0;
$lap[$kelurahan]['aset_jenis3']=0;
$lap[$kelurahan]['karyawan_jen1_l']=0;
$lap[$kelurahan]['karyawan_jen2_l']=0;
$lap[$kelurahan]['karyawan_jen3_l']=0;
$lap[$kelurahan]['karyawan_jen1_p']=0;
$lap[$kelurahan]['karyawan_jen2_p']=0;
$lap[$kelurahan]['karyawan_jen3_p']=0;
$lap[$kelurahan]['umkm_jen1_kat1']=0;
$lap[$kelurahan]['umkm_jen1_kat2']=0;
$lap[$kelurahan]['umkm_jen1_kat3']=0;
$lap[$kelurahan]['umkm_jen2_kat1']=0;
$lap[$kelurahan]['umkm_jen2_kat2']=0;
$lap[$kelurahan]['umkm_jen2_kat3']=0;
$lap[$kelurahan]['umkm_jen3_kat1']=0;
$lap[$kelurahan]['umkm_jen3_kat2']=0;
$lap[$kelurahan]['umkm_jen3_kat3']=0;
foreach($listlapkel as $lapkel){
$lap[$kelurahan]['kelurahan']=$lapkel->kelurahan;
$lap[$lapkel->kelurahan]['aset']=$lapkel->aset;
$lap[$lapkel->kelurahan]['omset']=$lap[$lapkel->kelurahan]['omset']+$lapkel->omset;
$lap[$lapkel->kelurahan]['karyawan_jenis1']=$lapkel->karyawan_jenis1;
$lap[$lapkel->kelurahan]['karyawan_jenis2']=$lapkel->karyawan_jenis2;
$lap[$lapkel->kelurahan]['karyawan_jenis3']=$lapkel->karyawan_jenis3;
$lap[$lapkel->kelurahan]['omset_jenis1']=$lap[$lapkel->kelurahan]['omset_jenis1']+$lapkel->omset_jenis1;
$lap[$lapkel->kelurahan]['omset_jenis2']=$lap[$lapkel->kelurahan]['omset_jenis2']+$lapkel->omset_jenis2;
$lap[$lapkel->kelurahan]['omset_jenis3']=$lap[$lapkel->kelurahan]['omset_jenis3']+$lapkel->omset_jenis3;
$lap[$lapkel->kelurahan]['aset_jenis1']=$lapkel->aset_jenis1;
$lap[$lapkel->kelurahan]['aset_jenis2']=$lapkel->aset_jenis2;
$lap[$lapkel->kelurahan]['aset_jenis3']=$lapkel->aset_jenis3;
$lap[$lapkel->kelurahan]['karyawan_jen1_l']=$lapkel->karyawan_jen1_l;
$lap[$lapkel->kelurahan]['karyawan_jen2_l']=$lapkel->karyawan_jen2_l;
$lap[$lapkel->kelurahan]['karyawan_jen3_l']=$lapkel->karyawan_jen3_l;
$lap[$lapkel->kelurahan]['karyawan_jen1_p']=$lapkel->karyawan_jen1_p;
$lap[$lapkel->kelurahan]['karyawan_jen2_p']=$lapkel->karyawan_jen2_p;
$lap[$lapkel->kelurahan]['karyawan_jen3_p']=$lapkel->karyawan_jen3_p;
$lap[$lapkel->kelurahan]['umkm_jen1_kat1']=$lapkel->umkm_jen1_kat1;
$lap[$lapkel->kelurahan]['umkm_jen1_kat2']=$lapkel->umkm_jen1_kat2;
$lap[$lapkel->kelurahan]['umkm_jen1_kat3']=$lapkel->umkm_jen1_kat3;
$lap[$lapkel->kelurahan]['umkm_jen2_kat1']=$lapkel->umkm_jen2_kat1;
$lap[$lapkel->kelurahan]['umkm_jen2_kat2']=$lapkel->umkm_jen2_kat2;
$lap[$lapkel->kelurahan]['umkm_jen2_kat3']=$lapkel->umkm_jen2_kat3;
$lap[$lapkel->kelurahan]['umkm_jen3_kat1']=$lapkel->umkm_jen3_kat1;
$lap[$lapkel->kelurahan]['umkm_jen3_kat2']=$lapkel->umkm_jen3_kat2;
$lap[$lapkel->kelurahan]['umkm_jen3_kat3']=$lapkel->umkm_jen3_kat3;
if($lapkel->bulan==12){
$lap[$lapkel->kelurahan]['omset'] = $lap[$lapkel->kelurahan]['omset']/12;
$lap[$lapkel->kelurahan]['omset_jenis1'] = $lap[$lapkel->kelurahan]['omset_jenis1']/12;
$lap[$lapkel->kelurahan]['omset_jenis2'] = $lap[$lapkel->kelurahan]['omset_jenis2']/12;
$lap[$lapkel->kelurahan]['omset_jenis3'] = $lap[$lapkel->kelurahan]['omset_jenis3']/12;
$lap[$lapkel->kelurahan]['umkm_jenis1'] = $lap[$lapkel->kelurahan]['umkm_jen1_kat1']+$lap[$lapkel->kelurahan]['umkm_jen1_kat2']+$lap[$lapkel->kelurahan]['umkm_jen1_kat3'];
$lap[$lapkel->kelurahan]['umkm_jenis2'] = $lap[$lapkel->kelurahan]['umkm_jen2_kat1']+$lap[$lapkel->kelurahan]['umkm_jen2_kat2']+$lap[$lapkel->kelurahan]['umkm_jen2_kat3'];
$lap[$lapkel->kelurahan]['umkm_jenis3'] = $lap[$lapkel->kelurahan]['umkm_jen3_kat1']+$lap[$lapkel->kelurahan]['umkm_jen3_kat2']+$lap[$lapkel->kelurahan]['umkm_jen3_kat3'];
}
}
$aset=0;
$omset=0;
$karyawan_jenis1=0;
$karyawan_jenis2=0;
$karyawan_jenis3=0;
$omset_jenis1=0;
$omset_jenis2=0;
$omset_jenis3=0;
$aset_jenis1=0;
$aset_jenis2=0;
$aset_jenis3=0;
$karyawan_jen1_l=0;
$karyawan_jen2_l=0;
$karyawan_jen3_l=0;
$karyawan_jen1_p=0;
$karyawan_jen2_p=0;
$karyawan_jen3_p=0;
$umkm_jen1_kat1=0;
$umkm_jen1_kat2=0;
$umkm_jen1_kat3=0;
$umkm_jen2_kat1=0;
$umkm_jen2_kat2=0;
$umkm_jen2_kat3=0;
$umkm_jen3_kat1=0;
$umkm_jen3_kat2=0;
$umkm_jen3_kat3=0;
$umkm_jenis1=0;
$umkm_jenis2=0;
$umkm_jenis3=0;
foreach($lap as $laporan){
$aset=$aset+$laporan['aset'];
$omset=$omset+$laporan['omset'];
$karyawan_jenis1=$karyawan_jenis1+$laporan['karyawan_jenis1'];
$karyawan_jenis2=$karyawan_jenis2+$laporan['karyawan_jenis2'];
$karyawan_jenis3=$karyawan_jenis3+$laporan['karyawan_jenis3'];
$omset_jenis1=$omset_jenis1+$laporan['omset_jenis1'];
$omset_jenis2=$omset_jenis2+$laporan['omset_jenis2'];
$omset_jenis3=$omset_jenis3+$laporan['omset_jenis3'];
$aset_jenis1=$aset_jenis1+$laporan['aset_jenis1'];
$aset_jenis2=$aset_jenis2+$laporan['aset_jenis2'];
$aset_jenis3=$aset_jenis3+$laporan['aset_jenis3'];
$karyawan_jen1_l=$karyawan_jen1_l+$laporan['karyawan_jen1_l'];
$karyawan_jen2_l=$karyawan_jen2_l+$laporan['karyawan_jen2_l'];
$karyawan_jen3_l=$karyawan_jen3_l+$laporan['karyawan_jen3_l'];
$karyawan_jen1_p=$karyawan_jen1_p+$laporan['karyawan_jen1_p'];
$karyawan_jen2_p=$karyawan_jen2_p+$laporan['karyawan_jen2_p'];
$karyawan_jen3_p=$karyawan_jen3_p+$laporan['karyawan_jen3_p'];
$umkm_jen1_kat1=$umkm_jen1_kat1+$laporan['umkm_jen1_kat1'];
$umkm_jen1_kat2=$umkm_jen1_kat2+$laporan['umkm_jen1_kat2'];
$umkm_jen1_kat3=$umkm_jen1_kat3+$laporan['umkm_jen1_kat3'];
$umkm_jen2_kat1=$umkm_jen2_kat1+$laporan['umkm_jen2_kat1'];
$umkm_jen2_kat2=$umkm_jen2_kat2+$laporan['umkm_jen2_kat2'];
$umkm_jen2_kat3=$umkm_jen2_kat3+$laporan['umkm_jen2_kat3'];
$umkm_jen3_kat1=$umkm_jen3_kat1+$laporan['umkm_jen3_kat1'];
$umkm_jen3_kat2=$umkm_jen3_kat2+$laporan['umkm_jen3_kat2'];
$umkm_jen3_kat3=$umkm_jen3_kat3+$laporan['umkm_jen3_kat3'];
$umkm_jenis1=$umkm_jenis1+$laporan['umkm_jenis1'];
$umkm_jenis2=$umkm_jenis2+$laporan['umkm_jenis2'];
$umkm_jenis3=$umkm_jenis3+$laporan['umkm_jenis3'];
$umkm = $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;
$karyawan = $karyawan_jenis1+$karyawan_jenis2+$karyawan_jenis3;
$umkm_kat1 = $umkm_jen1_kat1+$umkm_jen1_kat1+$umkm_jen1_kat1;
$umkm_kat2 = $umkm_jen1_kat2+$umkm_jen1_kat2+$umkm_jen1_kat2;
$umkm_kat3 = $umkm_jen1_kat3+$umkm_jen1_kat3+$umkm_jen1_kat3;
}
$data['listlaporan']=$lap;
$data['aset']=$aset;
$data['omset']=$omset;
$data['karyawan_jenis1']=$karyawan_jenis1;
$data['karyawan_jenis2']=$karyawan_jenis2;
$data['karyawan_jenis3']=$karyawan_jenis3;
$data['omset_jenis1']=$omset_jenis1;
$data['omset_jenis2']=$omset_jenis2;
$data['omset_jenis3']=$omset_jenis3;
$data['aset_jenis1']=$aset_jenis1;
$data['aset_jenis2']=$aset_jenis2;
$data['aset_jenis3']=$aset_jenis3;
$data['karyawan_jen1_l']=$karyawan_jen1_l;
$data['karyawan_jen2_l']=$karyawan_jen2_l;
$data['karyawan_jen3_l']=$karyawan_jen3_l;
$data['karyawan_jen1_p']=$karyawan_jen1_p;
$data['karyawan_jen2_p']=$karyawan_jen2_p;
$data['karyawan_jen3_p']=$karyawan_jen3_p;
$data['umkm_jen1_kat1']=$umkm_jen1_kat1;
$data['umkm_jen1_kat2']=$umkm_jen1_kat2;
$data['umkm_jen1_kat3']=$umkm_jen1_kat3;
$data['umkm_jen2_kat1']=$umkm_jen2_kat1;
$data['umkm_jen2_kat2']=$umkm_jen2_kat2;
$data['umkm_jen2_kat3']=$umkm_jen2_kat3;
$data['umkm_jen3_kat1']=$umkm_jen3_kat1;
$data['umkm_jen3_kat2']=$umkm_jen3_kat2;
$data['umkm_jen3_kat3']=$umkm_jen3_kat3;
$data['umkm_jenis1']=$umkm_jenis1;
$data['umkm_jenis2']=$umkm_jenis2;
$data['umkm_jenis3']=$umkm_jenis3;
$data['umkm']= $umkm;
$data['karyawan']= $karyawan;
$data['umkm_kat1']= $umkm_kat1;
$data['umkm_kat2']= $umkm_kat2;
$data['umkm_kat3']= $umkm_kat3;
} else {
$data['msg'] = 'empty';
}
$data['user_logged'] = $this->session->userdata('user_logged');
$kelurahanlist = $this->KelurahanModel->getKelurahan();
$umkmlist = $this->AbsensiModel->getDesemberAbsensiByYearAndByKelurahan($year,$kelurahan);
//var_dump($umkmlist);die();
$data['umkmlist'] = $umkmlist;
$data['kelurahan_list']= $kelurahanlist;
$data['kelurahan'] = $kelurahan;
$data['tahun'] = $year;
$this->load->view('kelurahan',$data);
}
}