1057 lines
32 KiB
PHP
1057 lines
32 KiB
PHP
<?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 ManageKonfigurasi extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelKonfigurasi', 'Konfigurasi');
|
|
$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);
|
|
}
|
|
|
|
//Controller Untuk Konfigurasi
|
|
public function dataHakMaster_Admin_A1($id_karyawan=null) { // Konfigurasi = [1]
|
|
$datShm = $this->Konfigurasi->getData_SetHakMaster_groupKARYAWAN();
|
|
|
|
if ($id_karyawan==NULL) {
|
|
$title = "Belum Terpilih*";
|
|
$konfigurasi = NULL;
|
|
} else {
|
|
$datKaryawan = $this->Konfigurasi->getData_Karyawan_byID($id_karyawan);
|
|
$nama_karyawan = $datKaryawan[0]['NAMA_PANGGILAN_KARYAWAN'];
|
|
$title = $nama_karyawan;
|
|
$konfigurasi = $this->Konfigurasi->getData_SetHakMaster_byKARYAWAN($id_karyawan);
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi hakmaster",
|
|
'konfigurasi' => $konfigurasi,
|
|
'shm' => $datShm,
|
|
'title' => $title,
|
|
'id_karyawan' => $id_karyawan
|
|
];
|
|
$this->load->view('proses/KonfigurasiHakMaster_Admin_A1', $data);
|
|
}
|
|
|
|
public function get_dataHakMaster() { // Konfigurasi = [2]
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
|
|
$konfigurasi = $this->Konfigurasi->getData_SetHakMaster_byKARYAWAN($id_karyawan);
|
|
|
|
$data = array(
|
|
'akun_shm' => $konfigurasi[0]['AKUN_SHM'],
|
|
'bank_shm' => $konfigurasi[0]['BANK_SHM'],
|
|
'barang_shm' => $konfigurasi[0]['BARANG_SHM'],
|
|
'corp_shm' => $konfigurasi[0]['CORP_SHM'],
|
|
'customer_shm' => $konfigurasi[0]['CUSTOMER_SHM'],
|
|
'jabatan_shm' => $konfigurasi[0]['JABATAN_SHM'],
|
|
'jenis_shm' => $konfigurasi[0]['JENIS_SHM'],
|
|
'karyawan_shm' => $konfigurasi[0]['KARYAWAN_SHM'],
|
|
'kas_shm' => $konfigurasi[0]['KAS_SHM'],
|
|
'kelompok_shm' => $konfigurasi[0]['KELOMPOK_SHM'],
|
|
'kendaraan_shm' => $konfigurasi[0]['KENDARAAN_SHM'],
|
|
'kontak_shm' => $konfigurasi[0]['KONTAK_SHM'],
|
|
'kota_shm' => $konfigurasi[0]['KOTA_SHM'],
|
|
'merk_shm' => $konfigurasi[0]['MERK_SHM'],
|
|
'model_shm' => $konfigurasi[0]['MODEL_SHM'],
|
|
'part_shm' => $konfigurasi[0]['PART_SHM'],
|
|
'pelanggan_shm' => $konfigurasi[0]['PELANGGAN_SHM'],
|
|
'perkiraan_shm' => $konfigurasi[0]['PERKIRAAN_SHM'],
|
|
'pihakke3_shm' => $konfigurasi[0]['PIHAKKE3_SHM'],
|
|
'posisi_shm' => $konfigurasi[0]['POSISI_SHM'],
|
|
'program_shm' => $konfigurasi[0]['PROGRAM_SHM'],
|
|
'servicecenter_shm' => $konfigurasi[0]['SERVICECENTER_SHM'],
|
|
'supplier_shm' => $konfigurasi[0]['SUPPLIER_SHM'],
|
|
'unitproyek_shm' => $konfigurasi[0]['UNITPROYEK_SHM'],
|
|
'unitservice_shm' => $konfigurasi[0]['UNITSERVICE_SHM'],
|
|
);
|
|
$this->output_json($data);
|
|
}
|
|
|
|
public function simpanhakmaster_AA1() { // Konfigurasi = [3]
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$akun_shm = $this->input->post('akun_shm');
|
|
$bank_shm = $this->input->post('bank_shm');
|
|
$barang_shm = $this->input->post('barang_shm');
|
|
$corp_shm = $this->input->post('corp_shm');
|
|
$customer_shm = $this->input->post('customer_shm');
|
|
$jabatan_shm = $this->input->post('jabatan_shm');
|
|
$jenis_shm = $this->input->post('jenis_shm');
|
|
$karyawan_shm = $this->input->post('karyawan_shm');
|
|
$kas_shm = $this->input->post('kas_shm');
|
|
$kelompok_shm = $this->input->post('kelompok_shm');
|
|
$kendaraan_shm = $this->input->post('kendaraan_shm');
|
|
$kontak_shm = $this->input->post('kontak_shm');
|
|
$kota_shm = $this->input->post('kota_shm');
|
|
$merk_shm = $this->input->post('merk_shm');
|
|
$model_shm = $this->input->post('model_shm');
|
|
$part_shm = $this->input->post('part_shm');
|
|
$pelanggan_shm = $this->input->post('pelanggan_shm');
|
|
$perkiraan_shm = $this->input->post('perkiraan_shm');
|
|
$pihakke3_shm = $this->input->post('pihakke3_shm');
|
|
$posisi_shm = $this->input->post('posisi_shm');
|
|
$program_shm = $this->input->post('program_shm');
|
|
$servicecenter_shm = $this->input->post('servicecenter_shm');
|
|
$supplier_shm = $this->input->post('supplier_shm');
|
|
$unitproyek_shm = $this->input->post('unitproyek_shm');
|
|
$unitservice_shm = $this->input->post('unitservice_shm');
|
|
|
|
if ($id_karyawan==NULL) {
|
|
$this->session->set_flashdata('empty table', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datShm = $this->Konfigurasi->getData_SetHakMaster_byKARYAWAN($id_karyawan);
|
|
|
|
$update = [
|
|
'AKUN_SHM' => $akun_shm,
|
|
'BANK_SHM' => $bank_shm,
|
|
'BARANG_SHM' => $barang_shm,
|
|
'CORP_SHM' => $corp_shm,
|
|
'CUSTOMER_SHM' => $customer_shm,
|
|
'JABATAN_SHM' => $jabatan_shm,
|
|
'JENIS_SHM' => $jenis_shm,
|
|
'KARYAWAN_SHM' => $karyawan_shm,
|
|
'KAS_SHM' => $kas_shm,
|
|
'KELOMPOK_SHM' => $kelompok_shm,
|
|
'KENDARAAN_SHM' => $kendaraan_shm,
|
|
'KONTAK_SHM' => $kontak_shm,
|
|
'KOTA_SHM' => $kota_shm,
|
|
'MERK_SHM' => $merk_shm,
|
|
'MODEL_SHM' => $model_shm,
|
|
'PART_SHM' => $part_shm,
|
|
'PELANGGAN_SHM' => $pelanggan_shm,
|
|
'PERKIRAAN_SHM' => $perkiraan_shm,
|
|
'PIHAKKE3_SHM' => $pihakke3_shm,
|
|
'POSISI_SHM' => $posisi_shm,
|
|
'PROGRAM_SHM' => $program_shm,
|
|
'SERVICECENTER_SHM' => $servicecenter_shm,
|
|
'SUPPLIER_SHM' => $supplier_shm,
|
|
'UNITPROYEK_SHM' => $unitproyek_shm,
|
|
'UNITSERVICE_SHM' => $unitservice_shm
|
|
];
|
|
$action = $this->Konfigurasi->update('set_hakmaster', $update, 'ID_SHM', $datShm[0]['ID_SHM']);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diperbaruhi');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diperbaruhi');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataHariLibur_Admin_A1() { // Konfigurasi = [4]
|
|
$konfigurasi = $this->Konfigurasi->getData_SetHariLibur();
|
|
$tgl = date('Y-m-d');
|
|
$tgl_now = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($konfigurasi as $key) {
|
|
if (strtotime($key['TGL_SHL'])<strtotime($tgl)) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$konfigurasi[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi harilibur",
|
|
'konfigurasi' => $konfigurasi,
|
|
'tgl' => $tgl,
|
|
'tgl_now' => $tgl_now,
|
|
];
|
|
$this->load->view('proses/KonfigurasiHariLibur_Admin_A1', $data);
|
|
}
|
|
|
|
public function simpanlibur_AA1() { // Konfigurasi = [5]
|
|
$method = $this->input->post('method');
|
|
$tgl_shl = $this->input->post('tgl_shl');
|
|
$nama_shl = $this->input->post('nama_shl');
|
|
|
|
$input = [
|
|
'TGL_SHL' => $tgl_shl,
|
|
'NAMA_SHL' => $nama_shl
|
|
];
|
|
$action = $this->Konfigurasi->create('set_harilibur', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'disimpan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'disimpan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahlibur_AA1() { // Konfigurasi = [6]
|
|
$id_shl = $this->input->post('id_shled');
|
|
$tgl_shl = $this->input->post('tgl_shled');
|
|
$nama_shl = $this->input->post('nama_shled');
|
|
|
|
$datShl = $this->Konfigurasi->getData_SetHariLibur_byID($id_shl);
|
|
if ($datShl==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'TGL_SHL' => $tgl_shl,
|
|
'NAMA_SHL' => $nama_shl
|
|
];
|
|
$action = $this->Konfigurasi->update('set_harilibur', $update, 'ID_SHL', $id_shl);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapuslibur_AA1() { // Konfigurasi = [7]
|
|
$id_shl = $this->input->post('id_shldel');
|
|
|
|
$datShl = $this->Konfigurasi->getData_SetHariLibur_byID($id_shl);
|
|
if ($datShl==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Konfigurasi->delete('set_harilibur', $id_shl, 'ID_SHL');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataBiayaService_Admin_A1() { // Konfigurasi = [8]
|
|
$konfigurasi = $this->Konfigurasi->getData_Komisi();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi biayaservice",
|
|
'konfigurasi' => $konfigurasi,
|
|
'tgl' => $tgl,
|
|
];
|
|
$this->load->view('proses/KonfigurasiBiayaService_Admin_A1', $data);
|
|
}
|
|
|
|
public function ubahbiayaservice_AA1() { // Konfigurasi = [9]
|
|
$method = $this->input->post('method');
|
|
$id_jenis = $this->input->post('id_jenised');
|
|
$biaya_service = $this->input->post('biaya_serviceed');
|
|
|
|
$datJenis = $this->Konfigurasi->getData_Jenis_byID($id_jenis);
|
|
if ($datJenis==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$checkBiaya = is_numeric($biaya_service);
|
|
if ($checkBiaya==FALSE) {
|
|
$biaya_service = 0;
|
|
}
|
|
|
|
$update = [
|
|
'BIAYA_SERVICE' => $biaya_service,
|
|
];
|
|
$action = $this->Konfigurasi->update('jenis', $update, 'ID_JENIS', $id_jenis);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataKomisiNonGp_Admin_A1() { // Konfigurasi = [10]
|
|
$konfigurasi = $this->Konfigurasi->getData_Komisi();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi komisi",
|
|
'konfigurasi' => $konfigurasi,
|
|
'tgl' => $tgl,
|
|
];
|
|
$this->load->view('proses/KonfigurasiKomisiNonGp_Admin_A1', $data);
|
|
}
|
|
|
|
public function ubahkomisinongp_AA1() { // Konfigurasi = [11]
|
|
$method = $this->input->post('method');
|
|
$id_jenis = $this->input->post('id_jenised');
|
|
$komisi_dealer = $this->input->post('komisi_dealered');
|
|
$komisi_user = $this->input->post('komisi_usered');
|
|
$tgl = date('d/m/Y H:i:s');
|
|
|
|
$datJenis = $this->Konfigurasi->getData_Jenis_byID($id_jenis);
|
|
if ($datJenis==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$checkDealer = is_numeric($komisi_dealer);
|
|
if ($checkDealer==FALSE) {
|
|
$komisi_dealer = 0;
|
|
}
|
|
|
|
$checkUser = is_numeric($komisi_user);
|
|
if ($checkUser==FALSE) {
|
|
$komisi_user = 0;
|
|
}
|
|
|
|
$update = [
|
|
'KOMISI_DEALER' => $komisi_dealer,
|
|
'KOMISI_USER' => $komisi_user,
|
|
'LAST_UPDATE' => $tgl
|
|
];
|
|
$action = $this->Konfigurasi->update('jenis', $update, 'ID_JENIS', $id_jenis);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataPeriodeKuartal_Admin_A1() { // Konfigurasi = [12]
|
|
$konfigurasi = $this->Konfigurasi->getData_Kuartal();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$no = 0;
|
|
foreach ($konfigurasi as $key) {
|
|
$datRq = $this->Konfigurasi->getData_RekapKuartal_byKUARTAL($key['ID_KUARTAL']);
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL($key['ID_KUARTAL']);
|
|
if ($datRq==TRUE OR $datSts==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$konfigurasi[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi periodekuartal",
|
|
'konfigurasi' => $konfigurasi,
|
|
'tgl' => $tgl,
|
|
];
|
|
$this->load->view('proses/KonfigurasiPeriodeKuartal_Admin_A1', $data);
|
|
}
|
|
|
|
public function simpankuartal_AA1() { // Konfigurasi = [13]
|
|
$method = $this->input->post('method');
|
|
$id = $this->input->post('id_kuartal');
|
|
$nama_kuartal = $this->input->post('nama_kuartal');
|
|
$awal_kuartal = $this->input->post('awal_kuartal');
|
|
$akhir_kuartal = $this->input->post('akhir_kuartal');
|
|
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal();
|
|
$periode = 0;
|
|
foreach ($datKuartal as $key) {
|
|
if (strtotime($awal_kuartal)>=strtotime($key['AWAL_KUARTAL']) AND strtotime($awal_kuartal)<=strtotime($key['AKHIR_KUARTAL'])) {
|
|
$periode++;
|
|
}
|
|
if (strtotime($akhir_kuartal)>=strtotime($key['AWAL_KUARTAL']) AND strtotime($akhir_kuartal)<=strtotime($key['AKHIR_KUARTAL'])) {
|
|
$periode++;
|
|
}
|
|
}
|
|
|
|
if ($periode>0) {
|
|
$this->session->set_flashdata('period_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$tahun_kuartal = date_format(date_create($awal_kuartal), "Y");
|
|
$input = [
|
|
'TAHUN_KUARTAL' => $tahun_kuartal,
|
|
'NAMA_KUARTAL' => $nama_kuartal,
|
|
'AWAL_KUARTAL' => $awal_kuartal,
|
|
'AKHIR_KUARTAL' => $akhir_kuartal
|
|
];
|
|
$action = $this->Konfigurasi->create('kuartal', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahkuartal_AA1() { // Konfigurasi = [14]
|
|
$id_kuartal = $this->input->post('id_kuartaled');
|
|
$nama_kuartal = $this->input->post('nama_kuartaled');
|
|
$awal_kuartal = $this->input->post('awal_kuartaled');
|
|
$akhir_kuartal = $this->input->post('akhir_kuartaled');
|
|
|
|
$dataKuartal = $this->Konfigurasi->getData_Kuartal($id_kuartal);
|
|
if ($dataKuartal==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal();
|
|
$periode = 0;
|
|
foreach ($datKuartal as $key) {
|
|
if ($key['ID_KUARTAL']!=$id_kuartal) {
|
|
if (strtotime($awal_kuartal)>=strtotime($key['AWAL_KUARTAL']) AND strtotime($awal_kuartal)<=strtotime($key['AKHIR_KUARTAL'])) {
|
|
$periode++;
|
|
}
|
|
if (strtotime($akhir_kuartal)>=strtotime($key['AWAL_KUARTAL']) AND strtotime($akhir_kuartal)<=strtotime($key['AKHIR_KUARTAL'])) {
|
|
$periode++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($periode>0) {
|
|
$this->session->set_flashdata('period_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$tahun_kuartal = date_format(date_create($awal_kuartal), "Y");
|
|
$update = [
|
|
'TAHUN_KUARTAL' => $tahun_kuartal,
|
|
'NAMA_KUARTAL' => $nama_kuartal,
|
|
'AWAL_KUARTAL' => $awal_kuartal,
|
|
'AKHIR_KUARTAL' => $akhir_kuartal
|
|
];
|
|
$action = $this->Konfigurasi->update('kuartal', $update, 'ID_KUARTAL', $id_kuartal);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapuskuartal_AA1() { // Konfigurasi = [15]
|
|
$id = $this->input->post('id_kuartaldel');
|
|
|
|
$datRq = $this->Konfigurasi->getData_RekapKuartal_byKUARTAL($id);
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL($id);
|
|
if ($datRq==TRUE OR $datSts==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Konfigurasi->delete('kuartal', $id, 'ID_KUARTAL');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function kuncikuartal_AA1() { // Konfigurasi = [16]
|
|
$id_kuartal = $this->input->post('id_kuartallock');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal($id_kuartal);
|
|
if ($datKuartal==FALSE OR $datKuartal[0]['STATUS_KUARTAL']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_KUARTAL' => '1',
|
|
'KUNCI_KUARTAL' => $tgl
|
|
];
|
|
$action = $this->Konfigurasi->update('kuartal', $update, 'ID_KUARTAL', $id_kuartal);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function bukakuartal_AA1() { // Konfigurasi = [17]
|
|
$id_kuartal = $this->input->post('id_kuartalun');
|
|
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal($id_kuartal);
|
|
if ($datKuartal==FALSE OR $datKuartal[0]['STATUS_KUARTAL']!="1") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_KUARTAL' => NULL,
|
|
'KUNCI_KUARTAL' => NULL
|
|
];
|
|
$action = $this->Konfigurasi->update('kuartal', $update, 'ID_KUARTAL', $id_kuartal);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dibuka');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dibuka');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataRumusGp_Admin_A1() { // Konfigurasi = [18]
|
|
$konfigurasi = $this->Konfigurasi->getData_RumusKuartal();
|
|
|
|
$no = 0;
|
|
foreach ($konfigurasi as $key) {
|
|
$datDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ($key['ID_RMQ']);
|
|
if ($datDrmq==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$konfigurasi[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi rumusgp",
|
|
'konfigurasi' => $konfigurasi,
|
|
];
|
|
$this->load->view('proses/KonfigurasiRumusGp_Admin_A1', $data);
|
|
}
|
|
|
|
public function simpanrumuskuartalgp_AA1() { // Konfigurasi = [19]
|
|
$id = $this->input->post('id_rmq');
|
|
$nama_rmq = $this->input->post('nama_rmq');
|
|
|
|
$input = [
|
|
'NAMA_RMQ' => $nama_rmq,
|
|
];
|
|
$action = $this->Konfigurasi->create('rumus_kuartal', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahrumuskuartalgp_AA1() { // Konfigurasi = [20]
|
|
$id_rmq = $this->input->post('id_rmqed');
|
|
$nama_rmq = $this->input->post('nama_rmqed');
|
|
|
|
$datRmq = $this->Konfigurasi->getData_RumusKuartal($id_rmq);
|
|
if ($datRmq==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'NAMA_RMQ' => $nama_rmq,
|
|
];
|
|
$action = $this->Konfigurasi->update('rumus_kuartal', $update, 'ID_RMQ', $id_rmq);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapusrumuskuartalgp_AA1() { // Konfigurasi = [21]
|
|
$id_rmq = $this->input->post('id_rmqdel');
|
|
|
|
$datDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ($id_rmq);
|
|
if ($datDrmq==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Konfigurasi->delete('rumus_kuartal', $id_rmq, 'ID_RMQ');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataRumusGp_Admin_A2($id) { // Konfigurasi = [22]
|
|
$konfigurasi = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ($id);
|
|
$datRmq = $this->Konfigurasi->getData_RumusKuartal($id);
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi rumusgp",
|
|
'konfigurasi' => $konfigurasi,
|
|
'id_rmq' => $id,
|
|
'nama_rmq' => $datRmq[0]['NAMA_RMQ'],
|
|
];
|
|
$this->load->view('proses/KonfigurasiRumusGp_Admin_A2', $data);
|
|
}
|
|
|
|
public function simpanrumuskuartalgp_AA2() { // Konfigurasi = [23]
|
|
$id = $this->input->post('id_drmq');
|
|
$bawah_drmq = $this->input->post('bawah_drmq');
|
|
$atas_drmq = $this->input->post('atas_drmq');
|
|
$rate = $this->input->post('rate');
|
|
$id_rmq = $this->input->post('id_rmq');
|
|
|
|
$datRmq = $this->Konfigurasi->getData_RumusKuartal($id_rmq);
|
|
if ($datRmq==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$checkBawah = is_numeric($bawah_drmq);
|
|
if ($checkBawah==FALSE) {
|
|
$bawah_drmq = 0;
|
|
}
|
|
|
|
$checkAtas = is_numeric($atas_drmq);
|
|
if ($checkAtas==FALSE) {
|
|
$atas_drmq = 0;
|
|
}
|
|
|
|
$checkRate = is_numeric($rate);
|
|
if ($checkRate==FALSE) {
|
|
$rate = 0;
|
|
}
|
|
|
|
$datDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ($id_rmq);
|
|
if ($datDrmq==FALSE) {
|
|
$bawah_drmq = 0;
|
|
}
|
|
|
|
$rate_rmq = ($rate/100);
|
|
$input = [
|
|
'RMQ_ID' => $id_rmq,
|
|
'BAWAH_DRMQ' => $bawah_drmq,
|
|
'ATAS_DRMQ' => $atas_drmq,
|
|
'RATE_DRMQ' => $rate_rmq,
|
|
];
|
|
$action = $this->Konfigurasi->create('daftar_rumuskuartal', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahrumuskuartalgp_AA2() { // Konfigurasi = [24]
|
|
$id_drmq = $this->input->post('id_drmqed');
|
|
$bawah_drmq = $this->input->post('bawah_drmqed');
|
|
$atas_drmq = $this->input->post('atas_drmqed');
|
|
$rate = $this->input->post('rateed');
|
|
$id_rmq = $this->input->post('id_rmqed');
|
|
|
|
$datRmq = $this->Konfigurasi->getData_RumusKuartal($id_rmq);
|
|
if ($datRmq==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$checkDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byID($id_rmq);
|
|
if ($checkDrmq==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$checkBawah = is_numeric($bawah_drmq);
|
|
if ($checkBawah==FALSE) {
|
|
$bawah_drmq = 0;
|
|
}
|
|
|
|
$checkAtas = is_numeric($atas_drmq);
|
|
if ($checkAtas==FALSE) {
|
|
$atas_drmq = 0;
|
|
}
|
|
|
|
$checkRate = is_numeric($rate);
|
|
if ($checkRate==FALSE) {
|
|
$rate = 0;
|
|
}
|
|
|
|
$datDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ($id_rmq);
|
|
if (count($datDrmq)==1) {
|
|
$bawah_drmq = 0;
|
|
}
|
|
|
|
$rate_rmq = ($rate/100);
|
|
$update = [
|
|
'BAWAH_DRMQ' => $bawah_drmq,
|
|
'ATAS_DRMQ' => $atas_drmq,
|
|
'RATE_DRMQ' => $rate_rmq,
|
|
];
|
|
$action = $this->Konfigurasi->update('daftar_rumuskuartal', $update, 'ID_DRMQ', $id_drmq);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapusrumuskuartalgp_AA2() { // Konfigurasi = [25]
|
|
$id_drmq = $this->input->post('id_drmqdel');
|
|
$id_rmq = $this->input->post('id_rmqdel');
|
|
|
|
$datRmq = $this->Konfigurasi->getData_RumusKuartal($id_rmq);
|
|
if ($datRmq==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDrmq = $this->Konfigurasi->getData_DaftarRumusKuartal_byRMQ_orderDESC_limit1($id_rmq);
|
|
if ($datDrmq[0]['ID_DRMQ']!=$id_drmq) {
|
|
$this->session->set_flashdata('order_late', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Konfigurasi->delete('daftar_rumuskuartal', $id_drmq, 'ID_DRMQ');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataTargetSales_Admin_A1() { // Konfigurasi = [26]
|
|
$konfigurasi = $this->Konfigurasi->getData_ListSalesTarget();
|
|
$year = date('Y');
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal_byTAHUN($year);
|
|
|
|
$no = 0;
|
|
foreach ($konfigurasi as $key) {
|
|
$noku = 0;
|
|
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($datKuartal[$noku++]['ID_KUARTAL'], $key['KARYAWAN_ID']);
|
|
if ($datSts==FALSE) {
|
|
$nilai_target1 = 0;
|
|
} else {
|
|
$nilai_target1 = $datSts[0]['TARGET_STS'];
|
|
}
|
|
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($datKuartal[$noku++]['ID_KUARTAL'], $key['KARYAWAN_ID']);
|
|
if ($datSts==FALSE) {
|
|
$nilai_target2 = 0;
|
|
} else {
|
|
$nilai_target2 = $datSts[0]['TARGET_STS'];
|
|
}
|
|
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($datKuartal[$noku++]['ID_KUARTAL'], $key['KARYAWAN_ID']);
|
|
if ($datSts==FALSE) {
|
|
$nilai_target3 = 0;
|
|
} else {
|
|
$nilai_target3 = $datSts[0]['TARGET_STS'];
|
|
}
|
|
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($datKuartal[$noku++]['ID_KUARTAL'], $key['KARYAWAN_ID']);
|
|
if ($datSts==FALSE) {
|
|
$nilai_target4 = 0;
|
|
} else {
|
|
$nilai_target4 = $datSts[0]['TARGET_STS'];
|
|
}
|
|
|
|
$konfigurasi[$no] += ['NITA1' => $nilai_target1];
|
|
$konfigurasi[$no] += ['NITA2' => $nilai_target2];
|
|
$konfigurasi[$no] += ['NITA3' => $nilai_target3];
|
|
$konfigurasi[$no++] += ['NITA4' => $nilai_target4];
|
|
}
|
|
|
|
$checkYear = $this->Konfigurasi->getData_SetTargetSales_byTAHUN($year);
|
|
if ($checkYear==FALSE) {
|
|
$konfigurasi = NULL;
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi targetsales",
|
|
'konfigurasi' => $konfigurasi,
|
|
'head' => $datKuartal,
|
|
'year' => $year,
|
|
];
|
|
$this->load->view('proses/KonfigurasiTargetSales_Admin_A1', $data);
|
|
}
|
|
|
|
public function mulaitargetsales_AA1() { // Konfigurasi = [27]
|
|
$year = $this->input->post('year');
|
|
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget();
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal_byTAHUN($year);
|
|
foreach ($datLst as $key) {
|
|
foreach ($datKuartal as $dat) {
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($dat['ID_KUARTAL'], $key['KARYAWAN_ID']);
|
|
if ($datSts==FALSE) {
|
|
$input = [
|
|
'KUARTAL_ID' => $dat['ID_KUARTAL'],
|
|
'KARYAWAN_ID' => $key['KARYAWAN_ID'],
|
|
'TARGET_STS' => '0'
|
|
];
|
|
$action = $this->Konfigurasi->create('set_targetsales', $input);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dimulai');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dimulai');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahtargetsales_AA1() { // Konfigurasi = [28]
|
|
$id_karyawan = $this->input->post('id_karyawaned');
|
|
$nita1 = $this->input->post('nita1ed');
|
|
$nita2 = $this->input->post('nita2ed');
|
|
$nita3 = $this->input->post('nita3ed');
|
|
$nita4 = $this->input->post('nita4ed');
|
|
$year = date('Y');
|
|
|
|
$check1 = is_numeric($nita1);
|
|
if ($check1==FALSE) {
|
|
$nita1 = 0;
|
|
}
|
|
|
|
$check2 = is_numeric($nita2);
|
|
if ($check2==FALSE) {
|
|
$nita2 = 0;
|
|
}
|
|
|
|
$check3 = is_numeric($nita3);
|
|
if ($check3==FALSE) {
|
|
$nita3 = 0;
|
|
}
|
|
|
|
$check4 = is_numeric($nita4);
|
|
if ($check4==FALSE) {
|
|
$nita4 = 0;
|
|
}
|
|
|
|
$nilai_target = [$nita1, $nita2, $nita3, $nita4];
|
|
|
|
$datKuartal = $this->Konfigurasi->getData_Kuartal_byTAHUN($year);
|
|
$no = 0;
|
|
foreach ($datKuartal as $key) {
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget_byKARYAWAN($id_karyawan);
|
|
if ($datLst[0]['TEAM_LST']!=NULL) {
|
|
$dataLst = $this->Konfigurasi->getData_ListSalesTarget_byTEAM($datLst[0]['TEAM_LST']);
|
|
foreach ($dataLst as $dat) {
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($key['ID_KUARTAL'], $dat['KARYAWAN_ID']);
|
|
$update = [
|
|
'TARGET_STS' => $nilai_target[$no]
|
|
];
|
|
$action = $this->Konfigurasi->update('set_targetsales', $update, 'ID_STS', $datSts[0]['ID_STS']);
|
|
}
|
|
} else {
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKUARTAL_byKARYAWAN($key['ID_KUARTAL'], $id_karyawan);
|
|
$update = [
|
|
'TARGET_STS' => $nilai_target[$no]
|
|
];
|
|
$action = $this->Konfigurasi->update('set_targetsales', $update, 'ID_STS', $datSts[0]['ID_STS']);
|
|
}
|
|
$no++;
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diperbaruhi');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diperbaruhi');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataSalesNonGp_Admin_A1() { // Konfigurasi = [29]
|
|
$konfigurasi = $this->Konfigurasi->getData_ListSalesTarget();
|
|
$datSales = $this->Konfigurasi->getData_Karyawan_SALES();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($konfigurasi as $key) {
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKARYAWAN($key['KARYAWAN_ID']);
|
|
if ($datSts==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$konfigurasi[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datSales as $dat) {
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget_byKARYAWAN($dat['ID_KARYAWAN']);
|
|
if ($datLst==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$datSales[$no++] += ['LOCKIN' => $lock];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu konfigurasi",
|
|
'navChild' => "konfigurasi salesnongp",
|
|
'konfigurasi' => $konfigurasi,
|
|
'sales' => $datSales,
|
|
'tgl' => $tgl,
|
|
];
|
|
$this->load->view('proses/KonfigurasiSalesNonGp_Admin_A1', $data);
|
|
}
|
|
|
|
public function simpansalesnongp_AA1() { // Konfigurasi = [30]
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$team_lst = $this->input->post('team_lst');
|
|
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget_byKARYAWAN($id_karyawan);
|
|
if ($datLst==TRUE) {
|
|
$this->session->set_flashdata('data_same', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($team_lst=="") {
|
|
$team_lst = NULL;
|
|
} else {
|
|
$team_lst = strtoupper($team_lst);
|
|
}
|
|
|
|
$input = [
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'TEAM_LST' => $team_lst
|
|
];
|
|
$action = $this->Konfigurasi->create('list_sales_target', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahsalesnongp_AA1() { // Konfigurasi = [31]
|
|
$id_lst = $this->input->post('id_lsted');
|
|
$team_lst = $this->input->post('team_lsted');
|
|
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget($id_lst);
|
|
if ($datLst==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($team_lst=="") {
|
|
$team_lst = NULL;
|
|
} else {
|
|
$team_lst = strtoupper($team_lst);
|
|
}
|
|
|
|
$update = [
|
|
'TEAM_LST' => $team_lst
|
|
];
|
|
$action = $this->Konfigurasi->update('list_sales_target', $update, 'ID_LST', $id_lst);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapussalesnongp_AA1() { // Konfigurasi = [32]
|
|
$id_lst = $this->input->post('id_lstdel');
|
|
|
|
$datLst = $this->Konfigurasi->getData_ListSalesTarget($id_lst);
|
|
if ($datLst==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSts = $this->Konfigurasi->getData_SetTargetSales_byKARYAWAN($datLst[0]['KARYAWAN_ID']);
|
|
if ($datSts==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Konfigurasi->delete('list_sales_target', $id_lst, 'ID_LST');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
} |