copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
use Restserver\Libraries\REST_Controller;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
require APPPATH . 'libraries/REST_Controller.php';
|
||||
require APPPATH . 'libraries/Format.php';
|
||||
|
||||
class ManageAkun extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelDashboard', 'Dashboard');
|
||||
$this->load->model('AllModels', 'Amod');
|
||||
$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);
|
||||
$datAkun = $this->Dashboard->getData_Akun();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datAkun as $key) {
|
||||
$datKontak = $this->Dashboard->getData_Kontak_byAKUN($key['ID_AKUN']);
|
||||
$datSav = $this->Dashboard->getData_SalesVisit_byAKUN($key['ID_AKUN']);
|
||||
if ($datKontak==TRUE OR $datSav==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datAkun[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['AKUN_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datAkun = NULL;
|
||||
} else if ($datShm[0]['AKUN_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['AKUN_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'akun' => $datAkun,
|
||||
'hak' => $datShm[0]['AKUN_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Akun', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_akun');
|
||||
$nama_akun = $this->input->post('nama_akun');
|
||||
|
||||
$nama_akun = strtoupper($nama_akun);
|
||||
|
||||
$input = [
|
||||
'NAMA_AKUN' => $nama_akun
|
||||
];
|
||||
$action = $this->Dashboard->create('akun', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageAkun');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageAkun');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_akun = $this->input->post('id_akuned');
|
||||
$nama_akun = $this->input->post('nama_akuned');
|
||||
|
||||
$nama_akun = strtoupper($nama_akun);
|
||||
|
||||
$update = [
|
||||
'NAMA_AKUN' => $nama_akun
|
||||
];
|
||||
$action = $this->Dashboard->update('akun', $update, 'ID_AKUN', $id_akun);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageAkun');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageAkun');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_akundel');
|
||||
|
||||
$datKontak = $this->Dashboard->getData_Kontak_byAKUN($id);
|
||||
$datSav = $this->Dashboard->getData_SalesVisit_byAKUN($id);
|
||||
if ($datKontak==TRUE OR $datSav==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageAkun');
|
||||
}
|
||||
|
||||
$action = $this->Dashboard->delete('akun', $id, 'ID_AKUN');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageAkun');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageAkun');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user