174 lines
5.4 KiB
PHP
174 lines
5.4 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageKaryawan 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);
|
|
$datKaryawan = $this->Dashboard->getData_Karyawan();
|
|
$datJabatan = $this->Dashboard->getData_Jabatan();
|
|
|
|
$no = 0;
|
|
foreach ($datKaryawan as $key) {
|
|
$datAbsensi = $this->Dashboard->getData_Absensi_byKARYAWAN($key['ID_KARYAWAN']);
|
|
$datSo = $this->Dashboard->getData_SalesOrder_byKARYAWAN($key['ID_KARYAWAN']);
|
|
$datPka = $this->Dashboard->getData_PiutangKaryawan_byKARYAWAN($key['ID_KARYAWAN']);
|
|
$datQc = $this->Dashboard->getData_QualityControl_byKARYAWAN($key['ID_KARYAWAN']);
|
|
if ($datAbsensi==TRUE OR $datSo==TRUE OR $datPka==TRUE OR $datQc==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$datKaryawan[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
if ($datShm[0]['KARYAWAN_SHM']==0) {
|
|
$akses = "Tidak Berhak";
|
|
$datKaryawan = NULL;
|
|
} else if ($datShm[0]['KARYAWAN_SHM']==1) {
|
|
$akses = "Hanya Baca";
|
|
} else if ($datShm[0]['KARYAWAN_SHM']==2) {
|
|
$akses = "Akses Penuh";
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "dashboard",
|
|
'navChild' => "",
|
|
'karyawan' => $datKaryawan,
|
|
'jabatan' => $datJabatan,
|
|
'hak' => $datShm[0]['KARYAWAN_SHM'],
|
|
'akses' => $akses,
|
|
];
|
|
$this->load->view('master/Karyawan', $data);
|
|
}
|
|
|
|
public function simpan() {
|
|
$method = $this->input->post('method');
|
|
$id_karyawan = $this->input->post('id');
|
|
$id_jabatan = $this->input->post('id_jabatan');
|
|
$nama_karyawan = $this->input->post('nama_karyawan');
|
|
$nama_panggilan_karyawan = $this->input->post('nama_panggilan_karyawan');
|
|
$username = $this->input->post('username');
|
|
$password = $this->input->post('password');
|
|
|
|
$input = [
|
|
'JABATAN_ID' => $id_jabatan,
|
|
'NAMA_KARYAWAN' => $nama_karyawan,
|
|
'NAMA_PANGGILAN_KARYAWAN' => $nama_panggilan_karyawan,
|
|
'USERNAME' => $username,
|
|
'PASSWORD' => $password,
|
|
'STATUS_KARYAWAN' => '1'
|
|
];
|
|
$action = $this->Dashboard->create('karyawan', $input);
|
|
|
|
$id_karyawan = $this->Dashboard->getID_KaryawanMax();
|
|
$id_karyawan = $id_karyawan[0]['ID_KARYAWAN'];
|
|
|
|
$input = [
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'AKUN_SHM' => '0',
|
|
'BANK_SHM' => '0',
|
|
'BARANG_SHM' => '0',
|
|
'CORP_SHM' => '0',
|
|
'CUSTOMER_SHM' => '0',
|
|
'JABATAN_SHM' => '0',
|
|
'JENIS_SHM' => '0',
|
|
'KARYAWAN_SHM' => '0',
|
|
'KAS_SHM' => '0',
|
|
'KELOMPOK_SHM' => '0',
|
|
'KENDARAAN_SHM' => '0',
|
|
'KONTAK_SHM' => '0',
|
|
'KOTA_SHM' => '0',
|
|
'MERK_SHM' => '0',
|
|
'MODEL_SHM' => '0',
|
|
'PART_SHM' => '0',
|
|
'PELANGGAN_SHM' => '0',
|
|
'PERKIRAAN_SHM' => '0',
|
|
'PIHAKKE3_SHM' => '0',
|
|
'POSISI_SHM' => '0',
|
|
'PROGRAM_SHM' => '0',
|
|
'SERVICECENTER_SHM' => '0',
|
|
'SUPPLIER_SHM' => '0',
|
|
'UNITSERVICE_SHM' => '0'
|
|
];
|
|
$action = $this->Dashboard->create('set_hakmaster', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect('ManageKaryawan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect('ManageKaryawan');
|
|
}
|
|
|
|
}
|
|
|
|
public function ubah() {
|
|
$method = $this->input->post('method');
|
|
$id_karyawan = $this->input->post('id_karyawaned');
|
|
$id_jabatan = $this->input->post('id_jabataned');
|
|
$nama_karyawan = $this->input->post('nama_karyawaned');
|
|
$nama_panggilan_karyawan = $this->input->post('nama_panggilan_karyawaned');
|
|
$username = $this->input->post('usernameed');
|
|
$password = $this->input->post('passworded');
|
|
|
|
$update = [
|
|
'JABATAN_ID' => $id_jabatan,
|
|
'NAMA_KARYAWAN' => $nama_karyawan,
|
|
'NAMA_PANGGILAN_KARYAWAN' => $nama_panggilan_karyawan,
|
|
'USERNAME' => $username,
|
|
'PASSWORD' => $password
|
|
];
|
|
$action = $this->Dashboard->update('karyawan', $update, 'ID_KARYAWAN', $id_karyawan);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect('ManageKaryawan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect('ManageKaryawan');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id_karyawandel');
|
|
|
|
$datAbsensi = $this->Dashboard->getData_Absensi_byKARYAWAN($id);
|
|
$datSo = $this->Dashboard->getData_SalesOrder_byKARYAWAN($id);
|
|
$datPkar = $this->Dashboard->getData_PiutangKaryawan_byKARYAWAN($id);
|
|
$datQc = $this->Dashboard->getData_QualityControl_byKARYAWAN($id);
|
|
|
|
if ($datAbsensi==TRUE OR $datSo==TRUE OR $datPkar==TRUE OR $datQc==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect('ManageKaryawan');
|
|
}
|
|
|
|
$action = $this->Dashboard->delete('set_hakmaster', $id, 'KARYAWAN_ID');
|
|
$action = $this->Dashboard->delete('karyawan', $id, 'ID_KARYAWAN');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect('ManageKaryawan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect('ManageKaryawan');
|
|
}
|
|
}
|
|
}
|