copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageKas extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelDashboard', 'Dashboard');
|
||||
$this->load->library(['datatables', 'form_validation']);
|
||||
$this->form_validation->set_error_delimiters('', '');
|
||||
$this->Dashboard->ceklogin();
|
||||
}
|
||||
public function output_json($data, $encode = true)
|
||||
{
|
||||
if ($encode) $data = json_encode($data);
|
||||
$this->output->set_content_type('application/json')->set_output($data);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$id_karyawan = $this->session->userdata('id_karyawan');
|
||||
$datShm = $this->Dashboard->getData_SetHakMaster_byKARYAWAN($id_karyawan);
|
||||
$datKas = $this->Dashboard->getData_Kas();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datKas as $key) {
|
||||
$datKasbank = $this->Dashboard->getData_Kasbank_byKAS($key['ID_KAS']);
|
||||
$datSk = $this->Dashboard->getData_SaldoKas_byKAS($key['ID_KAS']);
|
||||
if ($datKasbank==TRUE OR $datSk==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datKas[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['KAS_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datKas = NULL;
|
||||
} else if ($datShm[0]['KAS_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['KAS_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'kas' => $datKas,
|
||||
'hak' => $datShm[0]['KAS_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Kas', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id_kas = $this->input->post('id');
|
||||
$kode_kas = $this->input->post('kode_kas');
|
||||
$nama_kas = $this->input->post('nama_kas');
|
||||
|
||||
$kode_kas = strtoupper($kode_kas);
|
||||
$nama_kas = strtoupper($nama_kas);
|
||||
|
||||
$input = [
|
||||
'NAMA_KAS' => $nama_kas,
|
||||
'KODE_KAS' => $kode_kas
|
||||
];
|
||||
$action = $this->Dashboard->create('kas', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageKas');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageKas');
|
||||
}
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_kas = $this->input->post('id_kased');
|
||||
$kode_kas = $this->input->post('kode_kased');
|
||||
$nama_kas = $this->input->post('nama_kased');
|
||||
|
||||
$kode_kas = strtoupper($kode_kas);
|
||||
$nama_kas = strtoupper($nama_kas);
|
||||
|
||||
$update = [
|
||||
'NAMA_KAS' => $nama_kas,
|
||||
'KODE_KAS' => $kode_kas
|
||||
];
|
||||
$action = $this->Dashboard->update('kas', $update, 'ID_KAS', $id_kas);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageKas');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageKas');
|
||||
}
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$id = $this->input->post('id_kasdel');
|
||||
|
||||
$datSaldoKas = $this->Dashboard->getData_SaldoKas_byKAS($id);
|
||||
$datKasbank = $this->Dashboard->getData_Kasbank_byKAS($id);
|
||||
if ($datSaldoKas==TRUE OR $datKasbank==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageKas');
|
||||
}
|
||||
|
||||
$action = $this ->Dashboard->delete('kas', $id, 'ID_KAS');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageKas');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageKas');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user