copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageSupplier 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);
|
||||
$datKota = $this->Dashboard->getData_Kota();
|
||||
$datSupLatest = $this->Dashboard->getData_Supplier_orderDESC_limit10();
|
||||
$tgl_now = date('d/m/Y');
|
||||
|
||||
$datShk = $this->Dashboard->getData_SetSupplier_byKARYAWAN($id_karyawan);
|
||||
if ($datShk==FALSE) {
|
||||
$id_kota = 1;
|
||||
$nama_ssu = NULL;
|
||||
} else {
|
||||
$id_kota = $datShk[0]['KOTA_ID'];
|
||||
$nama_ssu = $datShk[0]['NAMA_SSU'];
|
||||
}
|
||||
|
||||
$datSupplier = $this->Dashboard->getData_Supplier_byNAMA_byKOTA($nama_ssu, $id_kota);
|
||||
|
||||
$no = 0;
|
||||
foreach ($datSupplier as $key) {
|
||||
$datDkpr = $this->Dashboard->getData_DaftarKlaimProgram_bySUPPLIER($key['ID_SUPPLIER']);
|
||||
$datDpb = $this->Dashboard->getData_DpPembelian_bySUPPLIER($key['ID_SUPPLIER']);
|
||||
$datHda = $this->Dashboard->getData_HutangDagang_bySUPPLIER($key['ID_SUPPLIER']);
|
||||
$datPembelian = $this->Dashboard->getData_Pembelian_bySUPPLIER($key['ID_SUPPLIER']);
|
||||
if ($datDkpr==TRUE OR $datDpb==TRUE OR $datHda==TRUE OR $datPembelian==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datSupplier[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['SUPPLIER_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datSupplier = NULL;
|
||||
$datSupLatest = NULL;
|
||||
} else if ($datShm[0]['SUPPLIER_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['SUPPLIER_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'supplier' => $datSupplier,
|
||||
'sup_latest' => $datSupLatest,
|
||||
'kota' => $datKota,
|
||||
'id_kota' => $id_kota,
|
||||
'nama_ssu' => $nama_ssu,
|
||||
'tgl_now' => $tgl_now,
|
||||
'hak' => $datShm[0]['SUPPLIER_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Supplier', $data);
|
||||
}
|
||||
|
||||
public function simpanset_AA1() {
|
||||
$method = $this->input->post('method');
|
||||
$id_kota = $this->input->post('id_kota');
|
||||
$nama_ssu = $this->input->post('nama_ssu');
|
||||
$id_karyawan = $this->session->userdata('id_karyawan');
|
||||
$tgl = date('Y-m-d H:i:s');
|
||||
|
||||
$nama_ssu = strtoupper($nama_ssu);
|
||||
|
||||
$datShk = $this->Dashboard->getData_SetSupplier_byKARYAWAN($id_karyawan);
|
||||
if ($datShk==FALSE) {
|
||||
$input = [
|
||||
'KOTA_ID' => $id_kota,
|
||||
'NAMA_SSU' => $nama_ssu,
|
||||
'KARYAWAN_ID' => $id_karyawan,
|
||||
'LAST_SSU' => $tgl,
|
||||
];
|
||||
$action = $this->Dashboard->create('set_supplier', $input);
|
||||
$set = 1;
|
||||
} else {
|
||||
$update = [
|
||||
'KOTA_ID' => $id_kota,
|
||||
'NAMA_SSU' => $nama_ssu,
|
||||
'LAST_SSU' => $tgl,
|
||||
];
|
||||
$action = $this->Dashboard->update('set_supplier', $update, 'ID_SSU', $datShk[0]['ID_SSU']);
|
||||
$set = 2;
|
||||
}
|
||||
|
||||
if ($set==1) {
|
||||
$this->session->set_flashdata('filter_success', 'ditambah');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
} else if ($set==2) {
|
||||
$this->session->set_flashdata('filter_success', 'diperbaruhi');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->session->set_flashdata('filter_failed', 'ditambah');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id_supplier = $this->input->post('id');
|
||||
$id_kota = $this->input->post('id_kota');
|
||||
$nama_supplier = $this->input->post('nama_supplier');
|
||||
$alamat_supplier = $this->input->post('alamat_supplier');
|
||||
$telp_supplier = $this->input->post('telp_supplier');
|
||||
$npwp_supplier = $this->input->post('npwp_supplier');
|
||||
$top_supplier = $this->input->post('top_supplier');
|
||||
$email_supplier = $this->input->post('email_supplier');
|
||||
$pic_supplier = $this->input->post('pic_supplier');
|
||||
|
||||
$input = [
|
||||
'NAMA_SUPPLIER' => $nama_supplier,
|
||||
'ALAMAT_SUPPLIER' => $alamat_supplier,
|
||||
'TELP_SUPPLIER' => $telp_supplier,
|
||||
'NPWP_SUPPLIER' => $npwp_supplier,
|
||||
'TOP_SUPPLIER' => $top_supplier,
|
||||
'EMAIL_SUPPLIER' => $email_supplier,
|
||||
'PIC_SUPPLIER' => $pic_supplier,
|
||||
'KOTA_ID' => $id_kota
|
||||
];
|
||||
$action = $this->Dashboard->create('supplier', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageSupplier');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageSupplier');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_supplier = $this->input->post('id_suppliered');
|
||||
$id_kota = $this->input->post('id_kotaed');
|
||||
$nama_supplier = $this->input->post('nama_suppliered');
|
||||
$alamat_supplier = $this->input->post('alamat_suppliered');
|
||||
$telp_supplier = $this->input->post('telp_suppliered');
|
||||
$npwp_supplier = $this->input->post('npwp_suppliered');
|
||||
$top_supplier = $this->input->post('top_suppliered');
|
||||
$email_supplier = $this->input->post('email_suppliered');
|
||||
$pic_supplier = $this->input->post('pic_suppliered');
|
||||
|
||||
$update = [
|
||||
'NAMA_SUPPLIER' => $nama_supplier,
|
||||
'ALAMAT_SUPPLIER' => $alamat_supplier,
|
||||
'TELP_SUPPLIER' => $telp_supplier,
|
||||
'NPWP_SUPPLIER' => $npwp_supplier,
|
||||
'TOP_SUPPLIER' => $top_supplier,
|
||||
'EMAIL_SUPPLIER' => $email_supplier,
|
||||
'PIC_SUPPLIER' => $pic_supplier,
|
||||
'KOTA_ID' => $id_kota
|
||||
];
|
||||
$action = $this->Dashboard->update('supplier', $update, 'ID_SUPPLIER', $id_supplier);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageSupplier');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageSupplier');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$id = $this->input->post('id_supplierdel');
|
||||
$datPembelian = $this->Dashboard->getData_Pembelian_bySUPPLIER($id);
|
||||
$datHda = $this->Dashboard->getData_HutangDagang_bySUPPLIER($id);
|
||||
$datDpb = $this->Dashboard->getData_DpPembelian_bySUPPLIER($id);
|
||||
$datDkpr = $this->Dashboard->getData_DaftarKlaimProgram_bySUPPLIER($id);
|
||||
|
||||
if ($datPembelian==TRUE OR $datHda==TRUE OR $datDpb==TRUE OR $datDkpr==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageSupplier');
|
||||
}
|
||||
|
||||
$action = $this->Dashboard->delete('supplier', $id, 'ID_SUPPLIER');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageSupplier');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageSupplier');
|
||||
}
|
||||
}
|
||||
|
||||
public function simpan_excel_supplier() {
|
||||
$id_karyawan = $this->session->userdata('id_karyawan');
|
||||
$pilih_tabel = array('No', 'Nama', 'Kota' ,'TOP', 'Telepon', 'Alamat', 'NPWP', 'Email', 'PIC');
|
||||
$tgl = date('d/m/Y');
|
||||
|
||||
$datShk = $this->Dashboard->getData_SetSupplier_byKARYAWAN($id_karyawan);
|
||||
if ($datShk==FALSE) {
|
||||
$id_kota = 1;
|
||||
$nama_ssu = NULL;
|
||||
} else {
|
||||
$id_kota = $datShk[0]['KOTA_ID'];
|
||||
$nama_ssu = $datShk[0]['NAMA_SSU'];
|
||||
}
|
||||
|
||||
$dataExcel = $this->Dashboard->getData_Supplier_byNAMA_byKOTA($nama_ssu, $id_kota);
|
||||
|
||||
$data = [
|
||||
'title' => '',
|
||||
'jumlah_kolom' => count($pilih_tabel),
|
||||
'nama_tabel' => $pilih_tabel,
|
||||
'laporan' => $dataExcel,
|
||||
'tgl' => $tgl,
|
||||
];
|
||||
$this->load->view('cetak/excel_supplier', $data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user