132 lines
3.8 KiB
PHP
132 lines
3.8 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManagePihakKe3 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);
|
|
$datPihakKe3 = $this->Dashboard->getData_PihakKe3();
|
|
$datKota = $this->Dashboard->getData_Kota();
|
|
|
|
$no = 0;
|
|
foreach ($datPihakKe3 as $key) {
|
|
$datPpk = $this->Dashboard->getData_PiutangPihakKe3_byPIHAKKE3($key['ID_PIHAKKE3']);
|
|
if ($datPpk==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$datPihakKe3[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
if ($datShm[0]['PIHAKKE3_SHM']==0) {
|
|
$akses = "Tidak Berhak";
|
|
$datPihakKe3 = NULL;
|
|
} else if ($datShm[0]['PIHAKKE3_SHM']==1) {
|
|
$akses = "Hanya Baca";
|
|
} else if ($datShm[0]['PIHAKKE3_SHM']==2) {
|
|
$akses = "Akses Penuh";
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "dashboard",
|
|
'navChild' => "",
|
|
'pihakke3' => $datPihakKe3,
|
|
'kota' => $datKota,
|
|
'hak' => $datShm[0]['PIHAKKE3_SHM'],
|
|
'akses' => $akses,
|
|
];
|
|
$this->load->view('master/PihakKe3', $data);
|
|
}
|
|
|
|
public function simpan() {
|
|
$method = $this->input->post('method');
|
|
$id_pihakke3 = $this->input->post('id');
|
|
$id_kota = $this->input->post('id_kota');
|
|
$nama_pihakke3 = $this->input->post('nama_pihakke3');
|
|
$alamat_pihakke3 = $this->input->post('alamat_pihakke3');
|
|
$telp_pihakke3 = $this->input->post('telp_pihakke3');
|
|
|
|
$alamat_pihakke3 = preg_replace('/\R+/', " " , $alamat_pihakke3);
|
|
$input = [
|
|
'NAMA_PIHAKKE3' => $nama_pihakke3,
|
|
'ALAMAT_PIHAKKE3' => $alamat_pihakke3,
|
|
'TELP_PIHAKKE3' => $telp_pihakke3,
|
|
'KOTA_ID' => $id_kota
|
|
];
|
|
$action = $this->Dashboard->create('pihakke3', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect('ManagePihakKe3');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect('ManagePihakKe3');
|
|
}
|
|
|
|
}
|
|
|
|
public function ubah() {
|
|
$method = $this->input->post('method');
|
|
$id_pihakke3 = $this->input->post('id_pihakke3ed');
|
|
$id_kota = $this->input->post('id_kotaed');
|
|
$nama_pihakke3 = $this->input->post('nama_pihakke3ed');
|
|
$alamat_pihakke3 = $this->input->post('alamat_pihakke3ed');
|
|
$telp_pihakke3 = $this->input->post('telp_pihakke3ed');
|
|
|
|
$alamat_pihakke3 = preg_replace('/\R+/', " " , $alamat_pihakke3);
|
|
$update = [
|
|
'NAMA_PIHAKKE3' => $nama_pihakke3,
|
|
'ALAMAT_PIHAKKE3' => $alamat_pihakke3,
|
|
'TELP_PIHAKKE3' => $telp_pihakke3,
|
|
'KOTA_ID' => $id_kota
|
|
];
|
|
$action = $this->Dashboard->update('pihakke3', $update,'ID_PIHAKKE3',$id_pihakke3);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect('ManagePihakKe3');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect('ManagePihakKe3');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id_pihakke3del');
|
|
|
|
$datPpk = $this->Dashboard->getData_PiutangPihakKe3_byPIHAKKE3($id);
|
|
if ($datPpk==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect('ManagePihakKe3');
|
|
}
|
|
|
|
$action = $this->Dashboard->delete('pihakke3', $id, 'ID_PIHAKKE3');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect('ManagePihakKe3');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect('ManagePihakKe3');
|
|
}
|
|
}
|
|
|
|
}
|