121 lines
3.3 KiB
PHP
121 lines
3.3 KiB
PHP
|
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class DetailUmkm extends CI_Controller {
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
|
||
|
parent::__construct();
|
||
|
$this->load->model("UserModel");
|
||
|
$this->load->model("UmkmModel");
|
||
|
$this->load->model("KategoriModel");
|
||
|
$this->load->model("AbsensiModel");
|
||
|
$this->load->model("AbsenModel");
|
||
|
|
||
|
if($this->UserModel->isNotLogin()) {
|
||
|
redirect(site_url('login'));
|
||
|
} elseif(!($this->UserModel->isPemilik())) {
|
||
|
redirect(site_url('admin/dashboard'));
|
||
|
}
|
||
|
|
||
|
$get = $this->input->get();
|
||
|
if($get['id_umkm']==NULL){
|
||
|
redirect(site_url('user/dashboard'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function index()
|
||
|
{
|
||
|
|
||
|
$get = $this->input->get();
|
||
|
|
||
|
|
||
|
$umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']);
|
||
|
$pemilik = $this->UserModel->getUsersById($umkm->id_pemilik);
|
||
|
$daftarkategori = $this->KategoriModel->getKategori();
|
||
|
|
||
|
// var_dump($this->input->post());die();
|
||
|
|
||
|
if($this->input->post()){
|
||
|
|
||
|
$post = $this->input->post();
|
||
|
if($this->AbsensiModel->update($post['id_absensi'])){
|
||
|
redirect(site_url('user/detailumkm?id_umkm='.$umkm->id_umkm.'&msg=success'));
|
||
|
} else {
|
||
|
$data['msg']="error!";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
$cekabsensiakhir = $this->AbsensiModel->getLatestSignedAbsensiCountByUmkmId($umkm->id_umkm);
|
||
|
|
||
|
if($cekabsensiakhir > 0 ){
|
||
|
$absensiakhir = $this->AbsensiModel->getLatestSignedAbsensiByUmkmId($umkm->id_umkm);
|
||
|
$aset = $absensiakhir->aset;
|
||
|
$karyawan_l = $absensiakhir->karyawan_l;
|
||
|
$karyawan_p = $absensiakhir->karyawan_p;
|
||
|
$data['listabsensi'] = $this->AbsensiModel->getSignedAbsensiByUmkmId($umkm->id_umkm);
|
||
|
} else {
|
||
|
$aset = $umkm->aset_awal;
|
||
|
$karyawan_l = $umkm->karyawan_l;
|
||
|
$karyawan_p = $umkm->karyawan_p;
|
||
|
$data['listabsensi'] = array();
|
||
|
}
|
||
|
|
||
|
|
||
|
$data['omset'] = $umkm->omset_awal;
|
||
|
$data['karyawan_l'] = $karyawan_l;
|
||
|
$data['karyawan_p'] = $karyawan_p;
|
||
|
$data['aset'] = $aset;
|
||
|
$data['daftarkategori'] = $daftarkategori;
|
||
|
$data['umkm'] = $umkm;
|
||
|
$data['pemilik'] = $pemilik;
|
||
|
$data['user_logged'] = $this->session->userdata('user_logged');
|
||
|
|
||
|
if($this->AbsenModel->getCountActiveAbsen()>0){
|
||
|
$data['data_absen'] = $this->AbsenModel->getActiveAbsen();
|
||
|
if($data['data_absen']->bulan=='1'){
|
||
|
$bulan = 'Januari';
|
||
|
} elseif($data['data_absen']->bulan=='2'){
|
||
|
$bulan = 'Februari';
|
||
|
} elseif($data['data_absen']->bulan=='3'){
|
||
|
$bulan = 'Maret';
|
||
|
} elseif($data['data_absen']->bulan=='4'){
|
||
|
$bulan = 'April';
|
||
|
} elseif($data['data_absen']->bulan=='5'){
|
||
|
$bulan = 'Mei';
|
||
|
} elseif($data['data_absen']->bulan=='6'){
|
||
|
$bulan = 'Juni';
|
||
|
} elseif($data['data_absen']->bulan=='7'){
|
||
|
$bulan = 'Juli';
|
||
|
} elseif($data['data_absen']->bulan=='8'){
|
||
|
$bulan = 'Agustus';
|
||
|
} elseif($data['data_absen']->bulan=='9'){
|
||
|
$bulan = 'September';
|
||
|
} elseif($data['data_absen']->bulan=='10'){
|
||
|
$bulan = 'Oktober';
|
||
|
} elseif($data['data_absen']->bulan=='11'){
|
||
|
$bulan = 'November';
|
||
|
} elseif($data['data_absen']->bulan=='12'){
|
||
|
$bulan = 'Desember';
|
||
|
}
|
||
|
$data['bulan'] = $bulan;
|
||
|
|
||
|
$data['active_absen'] = true;
|
||
|
|
||
|
$data['absenisiaktif'] = $this->AbsensiModel->getAbsensiByAbsenIdAndUmkmId($umkm->id_umkm,$data['data_absen']->id_absen);
|
||
|
} else {
|
||
|
$data['data_absen'] = '';
|
||
|
$data['active_absen'] = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
$this->load->view('user/detailumkm',$data);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|