5862 lines
194 KiB
PHP
5862 lines
194 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 ManagePersediaan extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelDashboard', 'Dashboard');
|
|
$this->load->model('ModelPersediaan', 'Persediaan');
|
|
$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 Transaksi Keluar Masuk
|
|
public function dataIo_Gudang_A1($level) { // [1]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$datPersediaan = $this->Persediaan->getData_TransaksiStock_AllJenis_byGUDANG_Null($id_karyawan);
|
|
$datBarang0 = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datBarang1 = $this->Persediaan->getBarang_TransaksiStock1();
|
|
$datHpar = $this->Persediaan->getData_HargaPart_byPART();
|
|
$datSo = $this->Persediaan->getData_SalesOrder_byID();
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_byID($id_karyawan);
|
|
$tgl = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
if ($key['JENIS_IO']==0) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock0($key['ID_IO']);
|
|
} else if ($key['JENIS_IO']==1) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock1($key['ID_IO']);
|
|
}
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
if ($level==0) {
|
|
$navChild = "persediaan keluarmasuk1";
|
|
$judul = "PCM";
|
|
} else if ($level==1) {
|
|
$navChild = "persediaan keluarmasuk2";
|
|
$judul = "ITP";
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => $navChild,
|
|
'persediaan' => $datPersediaan,
|
|
'barang0' => $datBarang0,
|
|
'barang1' => $datBarang1,
|
|
'hpar' => $datHpar,
|
|
'so' => $datSo,
|
|
'nama_karyawan' => $datKaryawan[0]['NAMA_PANGGILAN_KARYAWAN'],
|
|
'id_gudang' => $id_karyawan,
|
|
'tgl' => $tgl,
|
|
'level' => $level,
|
|
'judul' => $judul
|
|
];
|
|
$this->load->view('proses/PersediaanIo_Gudang_A1', $data);
|
|
}
|
|
|
|
public function loginadmin_KeluarMasuk_GA1() { // [2]
|
|
$username = $this->input->post('username');
|
|
$password = $this->input->post('password');
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_forLogin($username, $password);
|
|
$username_login = $this->session->userdata('username');
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
|
|
if ($datKaryawan == TRUE and $datKaryawan[0]['NAMA_JABATAN'] == "ADMIN GUDANG") {
|
|
$this->session->set_flashdata('username_pass_success', 'login');
|
|
redirect('ManagePersediaan/dataIo_Gudang_B1');
|
|
} else if ($datKaryawan == TRUE and $datKaryawan[0]['NAMA_JABATAN'] == "ADMINISTRATOR") {
|
|
$this->session->set_flashdata('username_pass_success', 'login');
|
|
redirect('ManagePersediaan/dataIo_Gudang_B1');
|
|
} else if ($datKaryawan == TRUE and $datKaryawan[0]['USERNAME'] == "helda") {
|
|
$this->session->set_flashdata('username_pass_success', 'login');
|
|
redirect('ManagePersediaan/dataIo_Gudang_B1');
|
|
} else {
|
|
$this->session->set_flashdata('username_pass_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function simpanio_GA1() { // [3]
|
|
$method = $this->input->post('method');
|
|
$id_io = $this->input->post('id');
|
|
$jenis_io = $this->input->post('jenis_io');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_io = $this->input->post('qty_io');
|
|
$id_gudang = $this->input->post('id_gudang');
|
|
$ket_io = $this->input->post('ket_io');
|
|
$id_hpar = $this->input->post('id_hpar');
|
|
$harga_io = $this->input->post('harga_io');
|
|
$level = $this->input->post('level');
|
|
|
|
if ($qty_io<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($jenis_io==1) {
|
|
if ($id_hpar=="" AND $harga_io=="") {
|
|
$this->session->set_flashdata('price_null', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
if ($id_hpar!="" AND $harga_io!="") {
|
|
$this->session->set_flashdata('price_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($jenis_io==0) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_io) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_io) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$ket_io = preg_replace('/\R+/', " " , $ket_io);
|
|
if ($jenis_io==1) {
|
|
|
|
$harga_io = str_replace(',', '.', $harga_io);
|
|
|
|
$check_nilai = is_numeric($harga_io);
|
|
if ($check_nilai==FALSE) {
|
|
$harga_io = 0;
|
|
}
|
|
|
|
if ($id_hpar!="") {
|
|
$datHpar = $this->Persediaan->getData_HargaPart_byID($id_hpar);
|
|
$harga_io = $datHpar[0]['HPP_HPAR']/2;
|
|
$input = [
|
|
'JENIS_IO' => $jenis_io,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_IO' => $qty_io,
|
|
'KET_IO' => $ket_io,
|
|
'HPAR_ID' => $id_hpar,
|
|
'HARGA_IO' => $harga_io
|
|
];
|
|
$action = $this->Persediaan->create('transaksi_stock', $input);
|
|
} else {
|
|
$input = [
|
|
'JENIS_IO' => $jenis_io,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_IO' => $qty_io,
|
|
'KET_IO' => $ket_io,
|
|
'HARGA_IO' => $harga_io
|
|
];
|
|
$action = $this->Persediaan->create('transaksi_stock', $input);
|
|
}
|
|
} else if ($jenis_io==0) {
|
|
$input = [
|
|
'JENIS_IO' => $jenis_io,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_IO' => $qty_io,
|
|
'KET_IO' => $ket_io
|
|
];
|
|
$action = $this->Persediaan->create('transaksi_stock', $input);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$qty_io;
|
|
$proses = $proses_kuantiti+$qty_io;
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$itp = $itp_kuantiti-$qty_io;
|
|
$proses = $proses_kuantiti+$qty_io;
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
}
|
|
}
|
|
|
|
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 hapusio_GA1() { // [4]
|
|
$method = $this->input->post('method');
|
|
$id_io = $this->input->post('id_io');
|
|
$level = $this->input->post('level');
|
|
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_Null($id_io);
|
|
if ($datIo==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO($id_io);
|
|
if ($datSnIo==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($datIo[0]['JENIS_IO']==0) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($datIo[0]['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$pcm = $pcm_kuantiti + $datIo[0]['QTY_IO'];
|
|
$proses = $proses_kuantiti - $datIo[0]['QTY_IO'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datIo[0]['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$itp = $itp_kuantiti + $datIo[0]['QTY_IO'];
|
|
$proses = $proses_kuantiti - $datIo[0]['QTY_IO'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datIo[0]['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('transaksi_stock', $id_io, 'ID_IO');
|
|
|
|
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 kodeTransaksiStock() { // [5]
|
|
$kk = $this->Persediaan->getKode_TransaksiStock();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KM".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 2, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "KM".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 9 - strlen($str);
|
|
$data = "KM".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function kunciio_GA1() { // [6]
|
|
$method = $this->input->post('method');
|
|
$id_gudang = $this->input->post('id_gudang');
|
|
$id_so = $this->input->post('id_so');
|
|
$level = $this->input->post('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
if ($id_so!="") {
|
|
$datSo = $this->Persediaan->getData_SalesOrder_byID($id_so);
|
|
if ($datSo==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_AllJenis_byGUDANG_Null($id_gudang);
|
|
foreach ($datIo as $key) {
|
|
if ($key['JENIS_IO']==0) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock0($key['ID_IO']);
|
|
if ($qtyReal<$key['QTY_IO']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO_0($key['ID_IO']);
|
|
foreach ($datSnIo as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNIO']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="13") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
} else if ($key['JENIS_IO']==1) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock1($key['ID_IO']);
|
|
if ($qtyReal<$key['QTY_IO']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO_1($key['ID_IO']);
|
|
foreach ($datSnIo as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNIO']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!=0) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($id_so!="") {
|
|
$kode_bukti = $datSo[0]['KODE_SO'];
|
|
} else {
|
|
$kode_bukti = $this->kodeTransaksiStock();
|
|
}
|
|
|
|
foreach ($datIo as $key) {
|
|
if ($key['JENIS_IO']==0) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$proses = $proses_kuantiti-$key['QTY_IO'];
|
|
$global = $global_kuantiti-$key['QTY_IO'];
|
|
$update = [
|
|
'PROSES_KUANTITI' => $proses,
|
|
'GLOBAL_KUANTITI' => $global
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byBARANG_orderDESC_limit1($key['BARANG_ID']);
|
|
$sisa_hq = $datHq[0]['SISA_HQ']-$key['QTY_IO'];
|
|
if ($sisa_hq==0) {
|
|
$persediaan_hq = 0;
|
|
} else {
|
|
$persediaan_hq = round(($datHq[0]['PERSEDIAAN_HQ']-($datHq[0]['AVG_HQ']*$key['QTY_IO'])),2);
|
|
}
|
|
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'PERSEDIAAN_HQ' => $persediaan_hq,
|
|
'SISA_HQ' => $sisa_hq,
|
|
'AVG_HQ' => $datHq[0]['AVG_HQ'],
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_HQ' => '0',
|
|
'KELUAR_HQ' => $key['QTY_IO'],
|
|
'IO_ID' => $key['ID_IO']
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
if ($id_so!="") {
|
|
$update = [
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'TGL_IO' => $tgl,
|
|
'SO_ID' => $id_so,
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $key['ID_IO']);
|
|
} else {
|
|
$update = [
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'TGL_IO' => $tgl,
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $key['ID_IO']);
|
|
}
|
|
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO_0($key['ID_IO']);
|
|
foreach ($datSnIo as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_13($dat['NAMA_SNIO']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '3'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
}
|
|
}
|
|
}
|
|
} else if ($key['JENIS_IO']==1) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$key['QTY_IO'];
|
|
$global = $global_kuantiti+$key['QTY_IO'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'GLOBAL_KUANTITI' => $global
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$itp = $itp_kuantiti+$key['QTY_IO'];
|
|
$global = $global_kuantiti+$key['QTY_IO'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'GLOBAL_KUANTITI' => $global
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
|
|
$nilai_hq = $key['QTY_IO']*$key['HARGA_IO'];
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byBARANG_orderDESC_limit1($key['BARANG_ID']);
|
|
if ($datHq==FALSE) {
|
|
$persediaan_hq = $nilai_hq;
|
|
$sisa_hq = $key['QTY_IO'];
|
|
$avg_hq = $key['HARGA_IO'];
|
|
} else {
|
|
$persediaan_hq = $datHq[0]['PERSEDIAAN_HQ']+$nilai_hq;
|
|
$sisa_hq = $datHq[0]['SISA_HQ']+$key['QTY_IO'];
|
|
$avg_hq = round(($persediaan_hq/$sisa_hq),2);
|
|
}
|
|
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_HQ' => $key['QTY_IO'],
|
|
'KELUAR_HQ' => '0',
|
|
'IO_ID' => $key['ID_IO'],
|
|
'NILAI_HQ' => $nilai_hq,
|
|
'PERSEDIAAN_HQ' => $persediaan_hq,
|
|
'SISA_HQ' => $sisa_hq,
|
|
'AVG_HQ' => $avg_hq,
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
if ($id_so!="") {
|
|
$update = [
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'TGL_IO' => $tgl,
|
|
'SO_ID' => $id_so,
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $key['ID_IO']);
|
|
} else {
|
|
$update = [
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'TGL_IO' => $tgl,
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $key['ID_IO']);
|
|
}
|
|
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO_1($key['ID_IO']);
|
|
foreach ($datSnIo as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_0($dat['NAMA_SNIO']);
|
|
if ($datSnStock==TRUE) {
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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 klaimio_GA1() { // [128]
|
|
$method = $this->input->post('method');
|
|
$id_gudang = $this->input->post('id_gudang');
|
|
$kode_bukti1 = $this->kodeTransaksiStock();
|
|
$kode_bukti2 = $this->kodeTransaksiStock();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_AllJenis_byGUDANG_Null($id_gudang);
|
|
foreach ($datIo as $key) {
|
|
$nilai_hq = $key['QTY_IO']*$key['HARGA_IO'];
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti1,
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_HQ' => $key['QTY_IO'],
|
|
'KELUAR_HQ' => '0',
|
|
'IO_ID' => $key['ID_IO'],
|
|
'NILAI_HQ' => $nilai_hq,
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
$update = [
|
|
'KODE_BUKTI' => $kode_bukti1,
|
|
'TGL_IO' => $tgl,
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $key['ID_IO']);
|
|
|
|
$ket_io_out = $key['KET_IO'];
|
|
$ket_io_out = str_replace('Input', 'Output', $ket_io_out);
|
|
$input = [
|
|
'KODE_BUKTI' => $kode_bukti2,
|
|
'TGL_IO' => $tgl,
|
|
'KET_IO' => $ket_io_out,
|
|
'STATUS_IO' => '1',
|
|
'JENIS_IO' => '0',
|
|
'GUDANG_ID' => '1',
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'QTY_IO' => $key['QTY_IO'],
|
|
];
|
|
$action = $this->Persediaan->create('transaksi_stock', $input);
|
|
|
|
$id_io_out = $this->Persediaan->getID_TransaksiStockMax();
|
|
$id_io_out = $id_io_out[0]['ID_IO'];
|
|
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti2,
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_HQ' => '0',
|
|
'KELUAR_HQ' => $key['QTY_IO'],
|
|
'IO_ID' => $id_io_out
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnIo = $this->Persediaan->getData_SnIo_byIO_1($key['ID_IO']);
|
|
foreach ($datSnIo as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_0($dat['NAMA_SNIO']);
|
|
if ($datSnStock==TRUE) {
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti1,
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $kode_bukti2,
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
|
|
$input = [
|
|
'NAMA_SNIO' => $dat['NAMA_SNIO'],
|
|
'JENIS_SNIO' => '0',
|
|
'IO_ID' => $id_io_out
|
|
];
|
|
$action = $this->Persediaan->create('sn_io', $input);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '3'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
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 dataIo_Gudang_A2_0($id, $level) { // [7]
|
|
$persediaan = $this->Persediaan->getData_TransaksiStock_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_TransaksiStock0($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan keluarmasuk",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_io' => $id,
|
|
'qty' => $persediaan[0]['QTY_IO'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanIo_Gudang_A2_0', $data);
|
|
}
|
|
|
|
public function viewSn_IO_0_Aktif() { // [8]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnIo_byIO_0($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_IO_0_Limit() { // [9]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnIo_byIO_0($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanio_GA2_0() { // [10]
|
|
$id = $this->input->post('id_snio');
|
|
$id_io = $this->input->post('id_io');
|
|
$nama_snio = $this->input->post('nama_snio');
|
|
$nama_snio = strtoupper($nama_snio);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnIo_byNAMA_AllStatus($nama_snio);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$datSnio = $this->Persediaan->getData_SnIo_SnStock_byNAMA_0_13($nama_snio);
|
|
if ($datSnio==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_byID($id_io);
|
|
$barang_idIo = $datIo[0]['BARANG_ID'];
|
|
$barang_idSn = $datSnStock[0]['BARANG_ID'];
|
|
if ($barang_idIo!=$barang_idSn) {
|
|
$this->output_json(['value' => 5]);
|
|
} else {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock==0) {
|
|
$qtyRealBefore = $this->Persediaan->getQtyReal_TransaksiStock0($id_io);
|
|
if ($qtyRealBefore>=$datIo[0]['QTY_IO']) {
|
|
$this->output_json(['value' => 0]);
|
|
} else {
|
|
$input = [
|
|
'NAMA_SNIO' => $nama_snio,
|
|
'JENIS_SNIO' => '0',
|
|
'IO_ID' => $id_io
|
|
];
|
|
$action = $this->Persediaan->create('sn_io', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '13'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$qtyRealAfter = $this->Persediaan->getQtyReal_TransaksiStock0($id_io);
|
|
if ($datIo[0]['QTY_IO']==$qtyRealAfter) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
}
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapusio_GA2_0() { // [11]
|
|
$id = $this->input->post('id_snio');
|
|
$datSnIO = $this->Persediaan->getData_SnIo_byID($id);
|
|
$nama_snio = $datSnIO[0]['NAMA_SNIO'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock0($datSnIO[0]['IO_ID']);
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_Null($datSnIO[0]['IO_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snio);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_io', $id, 'ID_SNIO');
|
|
|
|
if ($qtyReal==$datIo[0]['QTY_IO']){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataIo_Gudang_A2_1($id, $level) { // [12]
|
|
$persediaan = $this->Persediaan->getData_TransaksiStock_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_TransaksiStock1($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan keluarmasuk",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_io' => $id,
|
|
'qty' => $persediaan[0]['QTY_IO'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanIo_Gudang_A2_1', $data);
|
|
}
|
|
|
|
public function viewSn_IO_1_Aktif() { // [12]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnIo_byIO_1($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_IO_1_Limit() { // [13]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnIo_byIO_1($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanio_GA2_1() { // [14]
|
|
$id = $this->input->post('id_snio');
|
|
$id_io = $this->input->post('id_io');
|
|
$nama_snio = $this->input->post('nama_snio');
|
|
$nama_snio = strtoupper($nama_snio);
|
|
$level = $this->session->userdata('level');
|
|
|
|
if ($level == 0) {
|
|
$gudang_snstock = 1;
|
|
} else if ($level == 1) {
|
|
$gudang_snstock = 2;
|
|
}
|
|
|
|
$datSnStock1 = $this->Persediaan->getData_SnStock_SnIo_byNAMA_AllStatus($nama_snio);
|
|
$datSnStock2 = $this->Persediaan->getData_SnBeli_byNAMA_AllStatus($nama_snio);
|
|
if ($datSnStock1==TRUE OR $datSnStock2==TRUE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$datIo =$this->Persediaan->getData_TransaksiStock_Null($id_io);
|
|
$qtyRealBefore = $this->Persediaan->getQtyReal_TransaksiStock1($id_io);
|
|
if ($datIo[0]['QTY_IO']<=$qtyRealBefore) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
}
|
|
$input = [
|
|
'NAMA_SNIO' => $nama_snio,
|
|
'JENIS_SNIO' => '1',
|
|
'IO_ID' => $id_io
|
|
];
|
|
$action = $this->Persediaan->create('sn_io', $input);
|
|
$input = [
|
|
'NAMA_SNSTOCK' => $nama_snio,
|
|
'BARANG_ID' => $datIo[0]['BARANG_ID'],
|
|
'GUDANG_SNSTOCK' => $gudang_snstock,
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->create('sn_stock', $input);
|
|
$qtyRealAfter = $this->Persediaan->getQtyReal_TransaksiStock1($id_io);
|
|
if ($datIo[0]['QTY_IO']==$qtyRealAfter) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snio' => $nama_snio]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public function hapusio_GA2_1() { // [15]
|
|
$id = $this->input->post('id_snio');
|
|
$datSnIO = $this->Persediaan->getData_SnIo_byID($id);
|
|
$nama_snio = $datSnIO[0]['NAMA_SNIO'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_TransaksiStock1($datSnIO[0]['IO_ID']);
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_Null($datSnIO[0]['IO_ID']);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snio);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']==0) {
|
|
$value = 1;
|
|
} else {
|
|
$value = 0;
|
|
}
|
|
|
|
if ($value==0) {
|
|
$this->output_json(['value' => 0]);
|
|
} else if ($value==1) {
|
|
$action = $this->Persediaan->delete('sn_stock', $datSnStock[0]['ID_SNSTOCK'], 'ID_SNSTOCK');
|
|
$action = $this->Persediaan->delete('sn_io', $id, 'ID_SNIO');
|
|
}
|
|
|
|
if ($qtyReal==$datIo[0]['QTY_IO']){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataIo_Gudang_B1() { // [16]
|
|
$datPersediaan = $this->Persediaan->getData_TransaksiStock_1();
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$ket = substr($key['KET_IO'], 0, 64);
|
|
if (strlen($key['KET_IO'])>64) {
|
|
$ket = "$ket ....";
|
|
}
|
|
$datPersediaan[$no++] += ['KET' => $ket];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan keluarmasuk",
|
|
'persediaan' => $datPersediaan
|
|
];
|
|
$this->load->view('proses/PersediaanIo_Gudang_B1', $data);
|
|
}
|
|
|
|
public function dataIo_Gudang_B2($id) { // [17]
|
|
$datPersediaan = $this->Persediaan->getData_TransaksiStock_1($id);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan keluarmasuk",
|
|
'persediaan' => $datPersediaan,
|
|
'id_io' => $id
|
|
];
|
|
$this->load->view('proses/PersediaanIo_Gudang_B2', $data);
|
|
}
|
|
|
|
public function ubahIo_GB2() { // [18]
|
|
$id_io = $this->input->post('id_io');
|
|
$harga_io = $this->input->post('harga_io');
|
|
$qty_io = $this->input->post('qty_io');
|
|
$ket_io = $this->input->post('ket_io');
|
|
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byIO($id_io);
|
|
if ($datHq==FALSE) {
|
|
$this->session->set_flashdata('histori_kuantiti_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$harga_io = str_replace(',', '.', $harga_io);
|
|
|
|
$checkNilai = is_numeric($harga_io);
|
|
if ($checkNilai==FALSE) {
|
|
$harga_io = 0;
|
|
}
|
|
|
|
$ket_io = preg_replace('/\R+/', " " , $ket_io);
|
|
|
|
$update = [
|
|
'KET_IO' => $ket_io,
|
|
'HARGA_IO' => $harga_io
|
|
];
|
|
$action = $this->Persediaan->update('transaksi_stock', $update, 'ID_IO', $id_io);
|
|
|
|
$nilai_hq = $qty_io * $harga_io;
|
|
$update = [
|
|
'NILAI_HQ' => $nilai_hq
|
|
];
|
|
$action = $this->Persediaan->update('histori_kuantiti', $update, 'ID_HQ', $datHq[0]['ID_HQ']);
|
|
|
|
if ($ket_io) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
//Controller Transaksi Operasional
|
|
public function dataOperasional_Gudang_A1() { // [19]
|
|
$datPersediaan = $this->Persediaan->getData_Operasional_Null();
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_Operasional();
|
|
$status = 0;
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan operasional",
|
|
'persediaan' => $datPersediaan,
|
|
'karyawan' => $datKaryawan,
|
|
'status' => $status
|
|
];
|
|
$this->load->view('proses/PersediaanOperasional_Gudang_A1', $data);
|
|
}
|
|
|
|
public function loginoperasional_GA1() { // [20]
|
|
$username = $this->input->post('username');
|
|
$password = $this->input->post('password');
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_forLogin($username, $password);
|
|
|
|
if ($datKaryawan == TRUE and $datKaryawan[0]['NAMA_JABATAN'] == "ADMIN GUDANG") {
|
|
$this->session->set_flashdata('username_pass_success', 'login');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1_Admin');
|
|
} else if ($datKaryawan == TRUE and $datKaryawan[0]['NAMA_JABATAN'] == "ADMINISTRATOR") {
|
|
$this->session->set_flashdata('username_pass_success', 'login');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1_Admin');
|
|
} else {
|
|
$this->session->set_flashdata('username_pass_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function kodeOperasional() { // [21]
|
|
$kk = $this->Persediaan->getKode_Operasional();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "OPR-000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 4, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 10 - strlen($str);
|
|
$data = "OPR-000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanoperasional_GA1() { // [22]
|
|
$method = $this->input->post('method');
|
|
$id_operasional = $this->input->post('id');
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$ket_operasional = $this->input->post('ket_operasional');
|
|
$kode_operasional = $this->kodeOperasional();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$ket_operasional = preg_replace('/\R+/', " " , $ket_operasional);
|
|
$input = [
|
|
'KODE_OPERASIONAL' => $kode_operasional,
|
|
'TGL_OPERASIONAL' => $tgl,
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'KET_OPERASIONAL' => $ket_operasional
|
|
];
|
|
$action = $this->Persediaan->create('operasional', $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 ubahoperasional_GA1() { // [23]
|
|
$method = $this->input->post('method');
|
|
$id_operasional = $this->input->post('id_operasional');
|
|
$id_karyawan = $this->input->post('id_karyawaned');
|
|
$ket_operasional = $this->input->post('ket_operasionaled');
|
|
|
|
$ket_operasional = preg_replace('/\R+/', " " , $ket_operasional);
|
|
$update = [
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'KET_OPERASIONAL' => $ket_operasional
|
|
];
|
|
$action = $this->Persediaan->update('operasional', $update, 'ID_OPERASIONAL', $id_operasional);
|
|
|
|
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 hapusoperasional_GA1() { // [24]
|
|
$method = $this->input->post('method');
|
|
$id_operasional = $this->input->post('id_operasional');
|
|
|
|
$datOperasional = $this->Persediaan->getData_Operasional_Null($id_operasional);
|
|
if ($datOperasional==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id_operasional);
|
|
if ($datDfo==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('operasional', $id_operasional, 'ID_OPERASIONAL');
|
|
|
|
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 dataOperasional_Gudang_A1_Admin() { // [25]
|
|
$datPersediaan = $this->Persediaan->getData_Operasional_0();
|
|
$status = 1;
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($key['ID_OPERASIONAL']);
|
|
$datPersediaan[$no++] += ['BAR' => $datDfo];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan operasional",
|
|
'persediaan' => $datPersediaan,
|
|
'status' => $status
|
|
];
|
|
$this->load->view('proses/PersediaanOperasional_Gudang_A1', $data);
|
|
}
|
|
|
|
public function dataOperasional_Gudang_A2($id) { // [26]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id);
|
|
$datOperasional = $this->Persediaan->getData_Operasional_byID($id);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_byID($datOperasional[0]['KARYAWAN_ID']);
|
|
$status = 0;
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarOperasional($key['ID_DFO']);
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan operasional",
|
|
'persediaan' => $datPersediaan,
|
|
'barang' => $datBarang,
|
|
'id_operasional' => $id,
|
|
'status' => $status,
|
|
'kode_operasional' => $datOperasional[0]['KODE_OPERASIONAL'],
|
|
'karyawan' => $datKaryawan[0]['NAMA_PANGGILAN_KARYAWAN'],
|
|
];
|
|
$this->load->view('proses/PersediaanOperasional_Gudang_A2', $data);
|
|
}
|
|
|
|
public function simpanoperasional_GA2() { // [27]
|
|
$method = $this->input->post('method');
|
|
$id_dfo = $this->input->post('id');
|
|
$id_operasional = $this->input->post('id_operasional');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dfo = $this->input->post('qty_dfo');
|
|
|
|
$datOperasional = $this->Persediaan->getData_Operasional_Null($id_operasional);
|
|
if ($datOperasional==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1');
|
|
}
|
|
|
|
if ($qty_dfo<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dfo) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id_operasional);
|
|
if ($id_barang==$datDfo[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'OPERASIONAL_ID' => $id_operasional,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DFO' => $qty_dfo
|
|
];
|
|
$action = $this->Persediaan->create('daftar_operasional', $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 hapusoperasional_GA2() { // [28]
|
|
$method = $this->input->post('method');
|
|
$id_dfo = $this->input->post('id');
|
|
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byID($id_dfo);
|
|
if ($datDfo[0]['TYPE_JENIS']=="1") {
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($id_dfo);
|
|
if ($datSnOperasional==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_operasional', $id_dfo, 'ID_DFO');
|
|
|
|
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 kuncioperasional_GA2() { // [29]
|
|
$method = $this->input->post('method');
|
|
$id_operasional = $this->input->post('id');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datOperasional = $this->Persediaan->getData_Operasional_Null($id_operasional);
|
|
if ($datOperasional==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1');
|
|
}
|
|
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id_operasional);
|
|
foreach ($datDfo as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarOperasional($key['ID_DFO']);
|
|
if ($qtyReal<$key['QTY_DFO']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($key['ID_DFO']);
|
|
foreach ($datSnOperasional as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNO']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="14") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDfo as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$key['QTY_DFO'];
|
|
$global = $global_kuantiti-$key['QTY_DFO'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'GLOBAL_KUANTITI' => $global
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byBARANG_orderDESC_limit1($key['BARANG_ID']);
|
|
$sisa_hq = $datHq[0]['SISA_HQ']-$key['QTY_DFO'];
|
|
$persediaan_hq = $datHq[0]['PERSEDIAAN_HQ']-($datHq[0]['AVG_HQ']*$key['QTY_DFO']);
|
|
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'PERSEDIAAN_HQ' => $persediaan_hq,
|
|
'SISA_HQ' => $sisa_hq,
|
|
'AVG_HQ' => $datHq[0]['AVG_HQ'],
|
|
'KODE_BUKTI' => $datOperasional[0]['KODE_OPERASIONAL'],
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_HQ' => '0',
|
|
'KELUAR_HQ' => $key['QTY_DFO']
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($key['ID_DFO']);
|
|
foreach ($datSnOperasional as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_14($dat['NAMA_SNO']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '4'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $datOperasional[0]['KODE_OPERASIONAL'],
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_OPERASIONAL' => '0',
|
|
'TGL_OPERASIONAL' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('operasional', $update, 'ID_OPERASIONAL', $id_operasional);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1');
|
|
}
|
|
|
|
}
|
|
|
|
public function dataOperasional_Gudang_A2_Admin($id) { // [30]
|
|
$datPersediaan = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id);
|
|
$datOperasional = $this->Persediaan->getData_Operasional_byID($id);
|
|
$datKaryawan = $this->Persediaan->getData_Karyawan_byID($datOperasional[0]['KARYAWAN_ID']);
|
|
$status = 1;
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($key['ID_DFO']);
|
|
$datPersediaan[$no++] += ['SN' => $datSnOperasional];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan operasional",
|
|
'persediaan' => $datPersediaan,
|
|
'id_operasional' => $id,
|
|
'status' => $status,
|
|
'kode_operasional' => $datOperasional[0]['KODE_OPERASIONAL'],
|
|
'karyawan' => $datKaryawan[0]['NAMA_PANGGILAN_KARYAWAN']
|
|
];
|
|
$this->load->view('proses/PersediaanOperasional_Gudang_A2', $data);
|
|
}
|
|
|
|
public function bataloperasional_GA2() { // [31]
|
|
$method = $this->input->post('method');
|
|
$id_operasional = $this->input->post('id');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datOperasional = $this->Persediaan->getData_Operasional_0($id_operasional);
|
|
if ($datOperasional==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1_View');
|
|
}
|
|
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byOPERASIONAL($id_operasional);
|
|
foreach ($datDfo as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($key['ID_DFO']);
|
|
foreach ($datSnOperasional as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNO']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="4") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$kode_operasional = $datOperasional[0]['KODE_OPERASIONAL'];
|
|
foreach ($datDfo as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_byDFO($key['ID_DFO']);
|
|
foreach ($datSnOperasional as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_4($dat['NAMA_SNO']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$key['QTY_DFO'];
|
|
$global = $global_kuantiti+$key['QTY_DFO'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'GLOBAL_KUANTITI' => $global
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('histori_kuantiti', $kode_operasional, 'KODE_BUKTI');
|
|
$action = $this->Persediaan->delete('histori_sn', $kode_operasional, 'KODE_BUKTI');
|
|
|
|
$update = [
|
|
'STATUS_OPERASIONAL' => '1',
|
|
'TGL_KEMBALI' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('operasional', $update, 'ID_OPERASIONAL', $id_operasional);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dibatalkan');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1_Admin');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dibatalkan');
|
|
redirect('ManagePersediaan/dataOperasional_Gudang_A1_Admin');
|
|
}
|
|
|
|
}
|
|
|
|
public function dataOperasional_Gudang_A3($id) { // [32]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarOperasional_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_DaftarOperasional($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan operasional",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dfo' => $id,
|
|
'qty' => $persediaan[0]['QTY_DFO'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanOperasional_Gudang_A3', $data);
|
|
}
|
|
|
|
public function viewSn_Operasional_Aktif() { // [33]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnOperasional_byDFO($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Operasional_Limit() { // [34]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnOperasional_byDFO($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanoperasional_GA3() { // [35]
|
|
$id = $this->input->post('id_sno');
|
|
$id_dfo = $this->input->post('id_dfo');
|
|
$nama_sno = $this->input->post('nama_sno');
|
|
$nama_sno = strtoupper($nama_sno);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnOperasional_byNAMA_AllStatus($nama_sno);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$id_snstock = $datSnStock[0]['ID_SNSTOCK'];
|
|
$datSnOperasional = $this->Persediaan->getData_SnOperasional_SnStock_byNAMA_14($nama_sno);
|
|
if ($datSnOperasional==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock=='0') {
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byID($id_dfo);
|
|
$qtyRealBefore = $this->Persediaan->getQtyReal_DaftarOperasional($id_dfo);
|
|
if ($datDfo[0]['QTY_DFO']<=$qtyRealBefore) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_sno' => $nama_sno]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
}
|
|
$input = [
|
|
'NAMA_SNO' => $nama_sno,
|
|
'DFO_ID' => $id_dfo
|
|
];
|
|
$action = $this->Persediaan->create('sn_operasional', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '14'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $id_snstock);
|
|
$qtyRealAfter = $this->Persediaan->getQtyReal_DaftarOperasional($id_dfo);
|
|
if ($datDfo[0]['QTY_DFO']==$qtyRealAfter) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_sno' => $nama_sno]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_sno' => $nama_sno]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_sno' => $nama_sno]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public function hapusoperasional_GA3() { // [36]
|
|
$id = $this->input->post('id_sno');
|
|
$datSno = $this->Persediaan->getData_SnOperasional_byID($id);
|
|
$nama_sno = $datSno[0]['NAMA_SNO'];
|
|
$datDfo = $this->Persediaan->getData_DaftarOperasional_byID($datSno[0]['DFO_ID']);
|
|
$qty_dfo = $datDfo[0]['QTY_DFO'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarOperasional($datSno[0]['DFO_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_sno);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_operasional', $id, 'ID_SNO');
|
|
|
|
if ($qtyReal==$qty_dfo){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Controller Transaksi Penggantian Barang SN
|
|
public function dataPenggantian_Gudang_A1() { // [37]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_Penjualan_forPenggantian($level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan penggantian",
|
|
'persediaan' => $datPersediaan,
|
|
'countData' => count($datPersediaan),
|
|
];
|
|
$this->load->view('proses/PersediaanPenggantian_Gudang_A1', $data);
|
|
}
|
|
|
|
public function dataPenggantian_Gudang_A2($id) { // [38]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_SnJual_forPenggantian($id);
|
|
$datSnj = $this->Persediaan->getData_SnJual_byPENJUALAN($id);
|
|
//$datSnStock = $this->Persediaan->getData_SnStock_Null($level); Dialihkan di dalam View
|
|
//$datSnIo = $this->Persediaan->getData_SnIo_byNAMA_1($datSnStock[0]['NAMA_SNSTOCK']); Dialihkan di dalam View
|
|
$datSo = $this->Persediaan->getData_SalesOrder_byPENJUALAN($id);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan penggantian",
|
|
'persediaan' => $datPersediaan,
|
|
'snj' => $datSnj,
|
|
'kode_so' => $datSo[0]['KODE_SO'],
|
|
'nama_pelanggan' => $datSo[0]['NAMA_PELANGGAN'],
|
|
'id_penjualan' => $id,
|
|
'level' => $level
|
|
];
|
|
$this->load->view('proses/PersediaanPenggantian_Gudang_A2', $data);
|
|
}
|
|
|
|
public function pilihsn_GA2() { // [39]
|
|
$method = $this->input->post('method');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
$snganti = $this->input->post('snganti');
|
|
|
|
$datPenjualan = $this->Persediaan->getData_Penjualan_byID_forPengantian($id_penjualan);
|
|
if ($datPenjualan==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
}
|
|
|
|
foreach ($snganti as $key) {
|
|
$datSnj = $this->Persediaan->getData_SnJual_byID($key);
|
|
if ($datSnj[0]['STATUS_SNJ']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
foreach ($snganti as $key) {
|
|
$update = [
|
|
'STATUS_SNJ' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('sn_jual', $update, 'ID_SNJ', $key);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dipilih');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dipilih');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapussn_GA2() { // [40]
|
|
$method = $this->input->post('method');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
$id_snj = $this->input->post('id');
|
|
|
|
$datPenjualan = $this->Persediaan->getData_Penjualan_byID_forPengantian($id_penjualan);
|
|
if ($datPenjualan==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
}
|
|
|
|
$datSnj = $this->Persediaan->getData_SnJual_byID($id_snj);
|
|
if ($datSnj[0]['SNSTOCK_GANTI']!=NULL OR $datSnj[0]['STATUS_SNJ']!="1") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_SNJ' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_jual', $update, 'ID_SNJ', $id_snj);
|
|
|
|
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 gantisn_GA2() { // [41]
|
|
$method = $this->input->post('method');
|
|
$id_snj = $this->input->post('id_snj');
|
|
$id_snstock = $this->input->post('id_snstock');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
|
|
$datPenjualan = $this->Persediaan->getData_Penjualan_byID_forPengantian($id_penjualan);
|
|
if ($datPenjualan==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
}
|
|
|
|
$datSnjSnstock = $this->Persediaan->getData_SnJual_bySNSTOCK($id_snstock);
|
|
if ($datSnjSnstock==TRUE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnj = $this->Persediaan->getData_SnJual_byID($id_snj);
|
|
if ($datSnj[0]['SNSTOCK_GANTI']!=NULL OR $datSnj[0]['STATUS_SNJ']==NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byID($id_snstock);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!=0) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($datSnj[0]['BARANG_ID']!=$datSnStock[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('barang_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'SNSTOCK_GANTI' => $id_snstock
|
|
];
|
|
$action = $this->Persediaan->update('sn_jual', $update, 'ID_SNJ', $id_snj);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $id_snstock);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diganti');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diganti');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function resetsn_GA2() { // [42]
|
|
$method = $this->input->post('method');
|
|
$id_snj = $this->input->post('id');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
|
|
$datPenjualan = $this->Persediaan->getData_Penjualan_byID_forPengantian($id_penjualan);
|
|
if ($datPenjualan==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
}
|
|
|
|
$datSnj = $this->Persediaan->getData_SnJual_byID($id_snj);
|
|
if ($datSnj[0]['SNSTOCK_GANTI']==NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnj[0]['SNSTOCK_GANTI']);
|
|
|
|
$update = [
|
|
'SNSTOCK_GANTI' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_jual', $update, 'ID_SNJ', $id_snj);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'direset');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'direset');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function kuncisn_GA2() { // [43]
|
|
$method = $this->input->post('method');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
|
|
$datPenjualan = $this->Persediaan->getData_Penjualan_byID_forPengantian($id_penjualan);
|
|
if ($datPenjualan==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
}
|
|
|
|
$datSnj = $this->Persediaan->getData_SnJual_forPenggantian($id_penjualan);
|
|
foreach ($datSnj as $key) {
|
|
if ($key['SNSTOCK_GANTI']==NULL) {
|
|
$this->session->set_flashdata('check_lock', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
foreach ($datSnj as $key) {
|
|
$datSnStockAwal = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($key['NAMA_SNJ']);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStockAwal[0]['ID_SNSTOCK']);
|
|
|
|
$datHsn = $this->Persediaan->getData_HistoriSn_byKODEBUKTI_bySNSTOCK($datPenjualan[0]['KODE_PENJUALAN'],$datSnStockAwal[0]['ID_SNSTOCK']);
|
|
$update = [
|
|
'SNSTOCK_ID' => $key['SNSTOCK_GANTI']
|
|
];
|
|
$action = $this->Persediaan->update('histori_sn', $update, 'ID_HSN', $datHsn[0]['ID_HSN']);
|
|
|
|
$datSnStockGanti = $this->Persediaan->getData_SnStock_byID($key['SNSTOCK_GANTI']);
|
|
$update = [
|
|
'STATUS_SNJ' => NULL,
|
|
'SNSTOCK_GANTI' => NULL,
|
|
'NAMA_SNJ' => $datSnStockGanti[0]['NAMA_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->update('sn_jual', $update, 'ID_SNJ', $key['ID_SNJ']);
|
|
}
|
|
|
|
$datCd = $this->Persediaan->getData_CetakDokumen_byPENJUALAN_forSJ($id_penjualan);
|
|
$update = [
|
|
'STATUS_CD' => NULL,
|
|
'KARYAWAN_ID' => NULL,
|
|
'LP_KARYAWAN' => NULL,
|
|
'ADMIN_ID' => NULL,
|
|
'LP_ADMIN' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('cetak_dokumen', $update, 'ID_CD', $datCd[0]['ID_CD']);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect('ManagePersediaan/dataPenggantian_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
//Controller Transaksi Stok Antik
|
|
public function dataStokAntik_Gudang_A1() { // [44]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_Kuantiti_Antik();
|
|
$datKuantitiNon1 = $this->Persediaan->getData_Kuantiti_Pcm_Non();
|
|
$datKuantitiNon2 = $this->Persediaan->getData_Kuantiti_Antik_Non();
|
|
$datSnStockNull = $this->Persediaan->getData_SnStock_Null($level);
|
|
$datSnStock5 = $this->Persediaan->getData_SnStock_5();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSna = $this->Persediaan->getData_SnAntik_byBARANG($key['ID_KUANTITI']);
|
|
$datPersediaan[$no++] += ['SN' => $datSna];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan stokantik",
|
|
'persediaan' => $datPersediaan,
|
|
'pcmnon' => $datKuantitiNon1,
|
|
'antiknon' => $datKuantitiNon2,
|
|
'pcmsn' => $datSnStockNull,
|
|
'antiksn' => $datSnStock5,
|
|
'tgl' => $tgl
|
|
];
|
|
$this->load->view('proses/PersediaanStokAntik_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodeStokAntik() { // [45]
|
|
$kk = $this->Persediaan->getKode_StokAntik();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "SA".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 2, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "SA".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 9 - strlen($str);
|
|
$data = "SA".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function prosesantiknon_GA1() { // [46]
|
|
$method = $this->input->post('method');
|
|
$id_sa = $this->input->post('id');
|
|
$jenis_sa = $this->input->post('jenis_sa');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_sa = $this->input->post('qty_sa');
|
|
$ket_sa = $this->input->post('ket_sa');
|
|
$id_gudang = $this->session->userdata('id_karyawan');
|
|
$kode_sa = $this->kodeStokAntik();
|
|
$tgl = date('Y-m-d');
|
|
|
|
if ($qty_sa<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($jenis_sa==0) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['ANTIK_KUANTITI']<$qty_sa) {
|
|
$this->session->set_flashdata('over_qty_antik', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($jenis_sa==1) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_sa) {
|
|
$this->session->set_flashdata('over_qty_pcm', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$input = [
|
|
'JENIS_SA' => $jenis_sa,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_SA' => $qty_sa,
|
|
'KET_SA' => $ket_sa,
|
|
'KODE_SA' => $kode_sa,
|
|
'TGL_SA' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('stok_antik', $input);
|
|
|
|
if ($jenis_sa==0) {
|
|
$antik_kuantiti = $datKuantiti[0]['ANTIK_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$antik = $antik_kuantiti-$qty_sa;
|
|
$pcm = $pcm_kuantiti+$qty_sa;
|
|
$update = [
|
|
'ANTIK_KUANTITI' => $antik,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
} else if ($jenis_sa==1) {
|
|
$antik_kuantiti = $datKuantiti[0]['ANTIK_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$antik = $antik_kuantiti+$qty_sa;
|
|
$pcm = $pcm_kuantiti-$qty_sa;
|
|
$update = [
|
|
'ANTIK_KUANTITI' => $antik,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function prosesantiksn_GA1() { // [47]
|
|
$method = $this->input->post('method');
|
|
$id_sa = $this->input->post('id');
|
|
$jenis_sa = $this->input->post('jenis_sa');
|
|
$id_snstock = $this->input->post('id_snstock');
|
|
$ket_sa = $this->input->post('ket_sa');
|
|
$id_gudang = $this->session->userdata('id_karyawan');
|
|
$kode_sa = $this->kodeStokAntik();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byID($id_snstock);
|
|
if ($jenis_sa==0) {
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="5") {
|
|
$this->session->set_flashdata('sn_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($jenis_sa==1) {
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!=NULL) {
|
|
$this->session->set_flashdata('sn_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$id_barang = $datSnStock[0]['BARANG_ID'];
|
|
if ($jenis_sa==0) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['ANTIK_KUANTITI']<1) {
|
|
$this->session->set_flashdata('over_qty_antik', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($jenis_sa==1) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<1) {
|
|
$this->session->set_flashdata('over_qty_pcm', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$input = [
|
|
'JENIS_SA' => $jenis_sa,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_SA' => '1',
|
|
'KET_SA' => $ket_sa,
|
|
'KODE_SA' => $kode_sa,
|
|
'TGL_SA' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('stok_antik', $input);
|
|
|
|
if ($jenis_sa==0) {
|
|
$action = $this->Persediaan->delete('sn_antik', $datSnStock[0]['NAMA_SNSTOCK'], 'NAMA_SNA');
|
|
$update = [
|
|
'STATUS_SNSTOCK' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $id_snstock);
|
|
|
|
$antik_kuantiti = $datKuantiti[0]['ANTIK_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$antik = $antik_kuantiti-1;
|
|
$pcm = $pcm_kuantiti+1;
|
|
$update = [
|
|
'ANTIK_KUANTITI' => $antik,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
} else if ($jenis_sa==1) {
|
|
$id_sa = $this->Persediaan->getID_SAMax();
|
|
$id_sa = $id_sa[0]['ID_SA'];
|
|
$input = [
|
|
'SA_ID' => $id_sa,
|
|
'NAMA_SNA' => $datSnStock[0]['NAMA_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('sn_antik', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '5'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $id_snstock);
|
|
|
|
$antik_kuantiti = $datKuantiti[0]['ANTIK_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$antik = $antik_kuantiti+1;
|
|
$pcm = $pcm_kuantiti-1;
|
|
$update = [
|
|
'ANTIK_KUANTITI' => $antik,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
//Controller Transaksi Konsinyasi
|
|
public function dataKonsinyasi_Gudang_A1() { // [48]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_Konsinyasi_Null(NULL, $level);
|
|
$datSales = $this->Persediaan->getData_SalesAll();
|
|
$datPelanggan = $this->Persediaan->getData_Pelanggan_byID();
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan konsigudang",
|
|
'persediaan' => $datPersediaan,
|
|
'sales' => $datSales,
|
|
'pelanggan' => $datPelanggan
|
|
];
|
|
$this->load->view('proses/PersediaanKonsinyasi_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodeKonsinyasi() { // [49]
|
|
$kk = $this->Persediaan->getKode_Konsinyasi();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KS".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 2, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "KS".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 9 - strlen($str);
|
|
$data = "KS".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpankonsinyasi_GA1() { // [50]
|
|
$method = $this->input->post('method');
|
|
$id_konsinyasi = $this->input->post('id');
|
|
$id_sales = $this->input->post('id_sales');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$kode_konsinyasi = $this->kodeKonsinyasi();
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$input = [
|
|
'SALES_ID' => $id_sales,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'KODE_KONSINYASI' => $kode_konsinyasi,
|
|
'TGL_KONSINYASI' => $tgl,
|
|
'JENIS_KONSINYASI' => $level
|
|
];
|
|
$action = $this->Persediaan->create('konsinyasi', $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 ubahkonsinyasi_GA1() { // [51]
|
|
$method = $this->input->post('method');
|
|
$id_konsinyasi = $this->input->post('id_konsinyasi');
|
|
$id_sales = $this->input->post('id_salesed');
|
|
$id_pelanggan = $this->input->post('id_pelangganed');
|
|
|
|
$datKonsinyasi = $this->Persediaan->getData_Konsinyasi_byID($id_konsinyasi);
|
|
if ($datKonsinyasi==FALSE OR $datKonsinyasi[0]['STATUS_KONSINYASI']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'SALES_ID' => $id_sales,
|
|
'PELANGGAN_ID' => $id_pelanggan
|
|
];
|
|
$action = $this->Persediaan->update('konsinyasi', $update, 'ID_KONSINYASI', $id_konsinyasi);
|
|
|
|
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 hapuskonsinyasi_GA1() { // [52]
|
|
$method = $this->input->post('method');
|
|
$id_konsinyasi = $this->input->post('id_konsinyasi');
|
|
|
|
$datKonsinyasi = $this->Persediaan->getData_Konsinyasi_Null($id_konsinyasi);
|
|
if ($datKonsinyasi==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byKONSINYASI($id_konsinyasi);
|
|
if ($datDfk==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('konsinyasi', $id_konsinyasi, 'ID_KONSINYASI');
|
|
|
|
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 dataKonsinyasi_Gudang_A2($id) { // [53]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarKonsi_byKONSINYASI($id);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datKonsinyasi = $this->Persediaan->getData_Konsinyasi_byID($id);
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarKonsi($key['ID_DFK']);
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan konsigudang",
|
|
'persediaan' => $datPersediaan,
|
|
'barang' => $datBarang,
|
|
'id_konsinyasi' => $id,
|
|
'level' => $level,
|
|
'kode_konsinyasi' => $datKonsinyasi[0]['KODE_KONSINYASI'],
|
|
'tgl_konsinyasi' => $datKonsinyasi[0]['TANGGAL'],
|
|
'nama_pelanggan' => $datKonsinyasi[0]['NAMA_PELANGGAN'],
|
|
'nama_kota' => $datKonsinyasi[0]['NAMA_KOTA']
|
|
];
|
|
$this->load->view('proses/PersediaanKonsinyasi_Gudang_A2', $data);
|
|
}
|
|
|
|
public function simpankonsinyasi_GA2() { // [54]
|
|
$method = $this->input->post('method');
|
|
$id_dfk = $this->input->post('id');
|
|
$id_konsinyasi = $this->input->post('id_konsinyasi');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dfk = $this->input->post('qty_dfk');
|
|
$level = $this->session->userdata('level');
|
|
|
|
$datKonsinyasi = $this->Persediaan->getData_Konsinyasi_Null($id_konsinyasi);
|
|
if ($datKonsinyasi==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_A1');
|
|
}
|
|
|
|
if ($qty_dfk<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dfk) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_dfk) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byKONSINYASI($id_konsinyasi);
|
|
if ($id_barang==$datDfk[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'KONSINYASI_ID' => $id_konsinyasi,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DFK' => $qty_dfk
|
|
];
|
|
$action = $this->Persediaan->create('daftar_konsi', $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 hapuskonsinyasi_GA2() { // [55]
|
|
$method = $this->input->post('method');
|
|
$id_dfk = $this->input->post('id');
|
|
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byID($id_dfk);
|
|
if ($datDfk[0]['TYPE_JENIS']=="1") {
|
|
$datSnKonsi = $this->Persediaan->getData_SnKonsi_byDFK($id_dfk);
|
|
if ($datSnKonsi==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_konsi', $id_dfk, 'ID_DFK');
|
|
|
|
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 kuncikonsinyasi_GA2() { // [56]
|
|
$method = $this->input->post('method');
|
|
$id_konsinyasi = $this->input->post('id');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datKonsinyasi = $this->Persediaan->getData_Konsinyasi_Null($id_konsinyasi);
|
|
if ($datKonsinyasi==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_A1');
|
|
}
|
|
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byKONSINYASI($id_konsinyasi);
|
|
foreach ($datDfk as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarKonsi($key['ID_DFK']);
|
|
if ($qtyReal<$key['QTY_DFK']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnKonsi = $this->Persediaan->getData_SnKonsi_byDFK($key['ID_DFK']);
|
|
foreach ($datSnKonsi as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNK']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="16") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
if ($key['TYPE_JENIS']!=2) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level==0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$key['QTY_DFK']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level==1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$key['QTY_DFK']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDfk as $key) {
|
|
//Check SN
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnKonsi = $this->Persediaan->getData_SnKonsi_byDFK($key['ID_DFK']);
|
|
foreach ($datSnKonsi as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_16($dat['NAMA_SNK']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '6'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Check Kuantiti
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$konsinyasi_kuantiti = $datKuantiti[0]['KONSINYASI_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$key['QTY_DFK'];
|
|
$konsinyasi = $konsinyasi_kuantiti+$key['QTY_DFK'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'KONSINYASI_KUANTITI' => $konsinyasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$konsinyasi_kuantiti = $datKuantiti[0]['KONSINYASI_KUANTITI'];
|
|
$itp = $itp_kuantiti-$key['QTY_DFK'];
|
|
$konsinyasi = $konsinyasi_kuantiti+$key['QTY_DFK'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'KONSINYASI_KUANTITI' => $konsinyasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_KONSINYASI' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('konsinyasi', $update, 'ID_KONSINYASI', $id_konsinyasi);
|
|
|
|
$input = [
|
|
'SJ_INV' => '0',
|
|
'TGL_CD' => $tgl,
|
|
'KONSINYASI_ID' => $id_konsinyasi,
|
|
'KODE_BUKTI' => $datKonsinyasi[0]['KODE_KONSINYASI']
|
|
];
|
|
$action = $this->Persediaan->create('cetak_dokumen', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_A1');
|
|
}
|
|
|
|
}
|
|
|
|
public function dataKonsinyasi_Gudang_A3($id) { // [57]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarKonsi_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_DaftarKonsi($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan konsigudang",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dfk' => $id,
|
|
'qty' => $persediaan[0]['QTY_DFK'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanKonsinyasi_Gudang_A3', $data);
|
|
}
|
|
|
|
public function viewSn_Konsinyasi_Aktif() { // [58]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnKonsi_byDFK($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Konsinyasi_Limit() { // [59]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnKonsi_byDFK($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpankonsinyasi_GA3() { // [60]
|
|
$id = $this->input->post('id_snk');
|
|
$id_dfk = $this->input->post('id_dfk');
|
|
$nama_snk = $this->input->post('nama_snk');
|
|
$nama_snk = strtoupper($nama_snk);
|
|
|
|
$dataDfk = $this->Persediaan->getData_DaftarKonsi_byID($id_dfk);
|
|
if ($dataDfk==FALSE) {
|
|
$this->output_json(['value' => 0]);
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value == 1) {
|
|
//Check apakah SN ada di list SN_STOCK
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnKonsi_byNAMA_AllStatus($nama_snk);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
//Check apakah SN sudah pernah dipilih
|
|
$id_snstock = $datSnStock[0]['ID_SNSTOCK'];
|
|
$datSnKonsi = $this->Persediaan->getData_SnKonsi_SnStock_byNAMA_16($nama_snk);
|
|
if ($datSnKonsi==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$barangSnStock = $datSnStock[0]['BARANG_ID'];
|
|
$barangDfk = $dataDfk[0]['BARANG_ID'];
|
|
if ($barangSnStock!=$barangDfk) {
|
|
$this->output_json(['value' => 6]);
|
|
} else {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
//Check apakah masih NULL SN_STOCK nya
|
|
if ($status_snstock=='0') {
|
|
$dataDfk = $this->Persediaan->getData_DaftarKonsi_byID($id_dfk);
|
|
$qtyRealBefore = $this->Persediaan->getQtyReal_DaftarKonsi($id_dfk);
|
|
if ($qtyRealBefore>=$dataDfk[0]['QTY_DFK']){
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snk' => $nama_snk]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
}
|
|
$input = [
|
|
'NAMA_SNK' => $nama_snk,
|
|
'DFK_ID' => $id_dfk
|
|
];
|
|
$action = $this->Persediaan->create('sn_konsi', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '16'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $id_snstock);
|
|
|
|
$qtyRealAfter = $this->Persediaan->getQtyReal_DaftarKonsi($id_dfk);
|
|
if ($qtyRealAfter==$dataDfk[0]['QTY_DFK']){
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snk' => $nama_snk]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snk' => $nama_snk]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snk' => $nama_snk]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapuskonsinyasi_GA3() { // [61]
|
|
$id = $this->input->post('id_snk');
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byID($id);
|
|
$nama_snk = $datSnk[0]['NAMA_SNK'];
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byID($datSnk[0]['DFK_ID']);
|
|
$qty_dfk = $datDfk[0]['QTY_DFK'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarKonsi($datSnk[0]['DFK_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snk);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_konsi', $id, 'ID_SNK');
|
|
|
|
if ($qtyReal==$qty_dfk){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataKonsinyasi_Gudang_B1() { // [62]
|
|
$level = $this->session->userdata('level');
|
|
$level++;
|
|
$datPersediaan = $this->Persediaan->getData_Konsinyasi_groupPELANGGAN($level);
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datDfk = $this->Persediaan->getData_Konsinyasi_byPELANGGAN_allStatus($key['PELANGGAN_ID']);
|
|
$totalAkhir = 0;
|
|
$noket = 0;
|
|
$ketsisa = [];
|
|
foreach ($datDfk as $dat) {
|
|
$awal = $dat['QTYDFK'];
|
|
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_status1($dat['BARANG_ID'], $key['PELANGGAN_ID']);
|
|
if ($datDpk==NULL) {
|
|
$dpk = 0;
|
|
} else {
|
|
$dpk = $datDpk[0]['QTYDPK'];
|
|
}
|
|
|
|
$datDpl = $this->Persediaan->getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_status1($dat['BARANG_ID'], $key['PELANGGAN_ID']);
|
|
if ($datDpl==NULL) {
|
|
$dpl = 0;
|
|
} else {
|
|
$dpl = $datDpl[0]['QTYDPL'];
|
|
}
|
|
|
|
$kode_barang = $dat['KODE_BARANG'];
|
|
$totalsisa = $awal - $dpk - $dpl;
|
|
|
|
if ($totalsisa>0) {
|
|
$ketsub = "$totalsisa EA $kode_barang";
|
|
array_push($ketsisa, $ketsub);
|
|
}
|
|
|
|
$totalAkhir = $totalAkhir + $awal - $dpk - $dpl;
|
|
}
|
|
$datPersediaan[$no] += ['KETSISA' => $ketsisa];
|
|
$datPersediaan[$no++] += ['TOTALAKHIR' => $totalAkhir];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan penarikankonsi",
|
|
'persediaan' => $datPersediaan,
|
|
'level' => $level,
|
|
];
|
|
$this->load->view('proses/PersediaanKonsinyasi_Gudang_B1', $data);
|
|
}
|
|
|
|
public function dataKonsinyasi_Gudang_B2($id) { // [63]
|
|
$datPersediaan = $this->Persediaan->getData_Konsinyasi_byPELANGGAN_allStatus($id);
|
|
$datPelanggan = $this->Persediaan->getData_Pelanggan_byID($id);
|
|
$datSnkAll = $this->Persediaan->getData_SnKonsi_byPELANGGAN_AllNull($id);
|
|
$datPenarikan = $this->Persediaan->getData_PenarikanKonsi_byPELANGGAN($id);
|
|
$tgl_now = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($datPenarikan as $key) {
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byBARANG_byPELANGGAN_forPenarikan($key['BARANG_ID'], $id);
|
|
$datPenarikan[$no++] += ['SN' => $datSnk];
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byBARANG_byPELANGGAN_forKonsinyasi($key['BARANG_ID'], $id);
|
|
$datPersediaan[$no] += ['SN' => $datSnk];
|
|
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_allStatus($key['BARANG_ID'], $id);
|
|
$datPersediaan[$no] += ['QTY1' => $datDpk];
|
|
|
|
$datDpl = $this->Persediaan->getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_allStatus($key['BARANG_ID'], $id);
|
|
$datPersediaan[$no++] += ['QTY2' => $datDpl];
|
|
}
|
|
|
|
if ($datPenarikan==FALSE) {
|
|
$kode_pk = NULL;
|
|
$tgl_pk = NULL;
|
|
$status_pk = NULL;
|
|
} else {
|
|
$kode_pk = $datPenarikan[0]['KODE_PK'];
|
|
$status_pk = $datPenarikan[0]['STATUS_PK'];
|
|
$tgl_pk = $datPenarikan[0]['TANGGAL'];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan penarikankonsi",
|
|
'persediaan' => $datPersediaan,
|
|
'penarikan' => $datPenarikan,
|
|
'snk' => $datSnkAll,
|
|
'nama_pelanggan' => $datPelanggan[0]['NAMA_PELANGGAN'],
|
|
'nama_kota' => $datPelanggan[0]['NAMA_KOTA'],
|
|
'tgl_now' => $tgl_now,
|
|
'id_pelanggan' => $id,
|
|
'kode_pk' => $kode_pk,
|
|
'status_pk' => $status_pk,
|
|
'tgl_pk' => $tgl_pk,
|
|
];
|
|
$this->load->view('proses/PersediaanKonsinyasi_Gudang_B2', $data);
|
|
}
|
|
|
|
public function kodePenarikanKonsi() { // [64]
|
|
$kk = $this->Persediaan->getKode_PenarikanKonsi();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "PK".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 2, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "PK".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 9 - strlen($str);
|
|
$data = "PK".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function tambahkonsinyasi_GB2() { // [65]
|
|
$method = $this->input->post('method');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$type_barang = $this->input->post('type_barang');
|
|
$sntarik = $this->input->post('sntarik');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dpk = $this->input->post('qty_dpk');
|
|
$status_pk = $this->input->post('status_pk');
|
|
$level = $this->session->userdata('level');
|
|
|
|
$datPk = $this->Persediaan->getData_PenarikanKonsi_byPELANGGAN_orderDESC($id_pelanggan);
|
|
if ($datPk==FALSE) {
|
|
$satpk = NULL;
|
|
} else if ($datPk[0]['STATUS_PK']=="0") {
|
|
$satpk = NULL;
|
|
} else {
|
|
$satpk = $datPk[0]['STATUS_PK'];
|
|
}
|
|
|
|
if ($satpk!=$status_pk AND $datPk==TRUE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_B1');
|
|
}
|
|
|
|
if ($type_barang==1) {
|
|
foreach ($sntarik as $key) {
|
|
$datSnKonsi = $this->Persediaan->getData_SnKonsi_byID($key);
|
|
foreach ($datSnKonsi as $dat) {
|
|
if ($dat['STATUS_SNK']!=NULL OR $dat['PK_ID']!=NULL OR $dat['PL_ID']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datPk = $this->Persediaan->getData_PenarikanKonsi_byPELANGGAN_Null($id_pelanggan, $level);
|
|
if ($datPk==FALSE) {
|
|
$kode_pk = $this->kodePenarikanKonsi();
|
|
$tgl = date('Y-m-d');
|
|
$input = [
|
|
'KODE_PK' => $kode_pk,
|
|
'JENIS_PK' => $level,
|
|
'TGL_PK' => $tgl,
|
|
'PELANGGAN_ID' => $id_pelanggan
|
|
];
|
|
$action = $this->Persediaan->create('penarikan_konsi', $input);
|
|
|
|
$id_pk = $this->Persediaan->getID_PKMax();
|
|
$id_pk = $id_pk[0]['ID_PK'];
|
|
} else {
|
|
$id_pk = $datPk[0]['ID_PK'];
|
|
}
|
|
|
|
foreach ($sntarik as $key) {
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byPK($id_pk);
|
|
foreach ($datDpk as $datkey) {
|
|
$datDfk = $this->Persediaan->getData_SnKonsi_byID_Null($key);
|
|
if ($datDfk[0]['BARANG_ID']==$datkey[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($sntarik as $key) {
|
|
$update = [
|
|
'PK_ID' => $id_pk,
|
|
'STATUS_SNK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_konsi', $update, 'ID_SNK', $key);
|
|
}
|
|
|
|
$datDfk = $this->Persediaan->getData_DaftarKonsi_byPELANGGAN_jenis1_groupBARANG($id_pelanggan);
|
|
foreach ($datDfk as $dat) {
|
|
$qty = 0;
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byPK_0($id_pk);
|
|
foreach ($datSnk as $keydat) {
|
|
if ($keydat['BARANG_ID']==$dat['BARANG_ID']) {
|
|
$qty++;
|
|
}
|
|
}
|
|
|
|
$checkDfk = $this->Persediaan->getData_DaftarPenarikanKonsi_byPK_byBARANG_Null($id_pk, $dat['BARANG_ID']);
|
|
if ($checkDfk==TRUE) {
|
|
$update = [
|
|
'QTY_DPK' => $qty
|
|
];
|
|
$action = $this->Persediaan->update('daftar_penarikankonsi', $update, 'ID_DPK', $checkDfk[0]['ID_DPK']);
|
|
} else {
|
|
if ($qty>0) {
|
|
$input = [
|
|
'PK_ID' => $id_pk,
|
|
'BARANG_ID' => $dat['BARANG_ID'],
|
|
'QTY_DPK' => $qty
|
|
];
|
|
$action = $this->Persediaan->create('daftar_penarikankonsi', $input);
|
|
}
|
|
}
|
|
}
|
|
} else if ($type_barang==0) {
|
|
$datDfk = $this->Persediaan->getData_Konsinyasi_byBARANG_byPELANGGAN($id_barang,$id_pelanggan);
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_status0($id_barang, $id_pelanggan);
|
|
$datDpl = $this->Persediaan->getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_status0($id_barang, $id_pelanggan);
|
|
if ($datDpk==FALSE) { $dpk = 0; } else { $dpk = $datDpk[0]['QTYDPK']; }
|
|
if ($datDpl==FALSE) { $dpl = 0; } else { $dpl = $datDpl[0]['QTYDPL']; }
|
|
$total = $datDfk[0]['QTYDFK']-$dpk-$dpl;
|
|
if ($total<$qty_dpk) {
|
|
$this->session->set_flashdata('qty_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datPk = $this->Persediaan->getData_PenarikanKonsi_byPELANGGAN_Null($id_pelanggan, $level);
|
|
if ($datPk==FALSE) {
|
|
$kode_pk = $this->kodePenarikanKonsi();
|
|
$tgl = date('Y-m-d');
|
|
$input = [
|
|
'KODE_PK' => $kode_pk,
|
|
'JENIS_PK' => $level,
|
|
'TGL_PK' => $tgl,
|
|
'PELANGGAN_ID' => $id_pelanggan
|
|
];
|
|
$action = $this->Persediaan->create('penarikan_konsi', $input);
|
|
|
|
$id_pk = $this->Persediaan->getID_PKMax();
|
|
$id_pk = $id_pk[0]['ID_PK'];
|
|
} else {
|
|
$id_pk = $datPk[0]['ID_PK'];
|
|
}
|
|
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byPK_byBARANG($id_pk,$id_barang);
|
|
if ($datDpk==TRUE) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'PK_ID' => $id_pk,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DPK' => $qty_dpk
|
|
];
|
|
$action = $this->Persediaan->create('daftar_penarikankonsi', $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 hapuskonsinyasi_GB2() { // [66]
|
|
$method = $this->input->post('method');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$id_dpk = $this->input->post('id_dpk');
|
|
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byID($id_dpk);
|
|
if ($datDpk==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($datDpk[0]['STATUS_PK']!=NULL) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_B1');
|
|
}
|
|
|
|
if ($datDpk[0]['TYPE_JENIS']=="1") {
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byPK_byBARANG($datDpk[0]['PK_ID'], $datDpk[0]['BARANG_ID']);
|
|
foreach ($datSnk as $key) {
|
|
$update = [
|
|
'PK_ID' => NULL,
|
|
'STATUS_SNK' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_konsi', $update, 'ID_SNK', $key['ID_SNK']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_penarikankonsi', $id_dpk, 'ID_DPK');
|
|
|
|
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 tarikkonsinyasi_GB2() { // [67]
|
|
$method = $this->input->post('method');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$id_gudang = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datPk = $this->Persediaan->getData_PenarikanKonsi_byPELANGGAN_orderDESC($id_pelanggan);
|
|
if ($datPk[0]['STATUS_PK']!=NULL) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataKonsinyasi_Gudang_B1');
|
|
}
|
|
|
|
$datDpk = $this->Persediaan->getData_DaftarPenarikanKonsi_byPK($datPk[0]['ID_PK']);
|
|
foreach ($datDpk as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byPK_byBARANG($datPk[0]['ID_PK'], $key['BARANG_ID']);
|
|
foreach ($datSnk as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNK']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="6") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($datKuantiti[0]['KONSINYASI_KUANTITI']<$key['QTY_DPK']) {
|
|
$this->session->set_flashdata('qty_error_all', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
foreach ($datDpk as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnk = $this->Persediaan->getData_SnKonsi_byPK_byBARANG($datPk[0]['ID_PK'], $key['BARANG_ID']);
|
|
foreach ($datSnk as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNK']);
|
|
$update = [
|
|
'STATUS_SNK' => '1'
|
|
];
|
|
$action = $this->Persediaan->update('sn_konsi', $update, 'ID_SNK', $dat['ID_SNK']);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$konsinyasi_kuantiti = $datKuantiti[0]['KONSINYASI_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$konsinyasi = $konsinyasi_kuantiti-$key['QTY_DPK'];
|
|
$pcm = $pcm_kuantiti+$key['QTY_DPK'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'KONSINYASI_KUANTITI' => $konsinyasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$konsinyasi_kuantiti = $datKuantiti[0]['KONSINYASI_KUANTITI'];
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$konsinyasi = $konsinyasi_kuantiti-$key['QTY_DPK'];
|
|
$itp = $itp_kuantiti+$key['QTY_DPK'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'KONSINYASI_KUANTITI' => $konsinyasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'GUDANG_ID' => $id_gudang,
|
|
'STATUS_PK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('penarikan_konsi', $update, 'ID_PK', $datPk[0]['ID_PK']);
|
|
|
|
$input = [
|
|
'SJ_INV' => '0',
|
|
'TGL_CD' => $tgl,
|
|
'PK_ID' => $datPk[0]['ID_PK'],
|
|
'KODE_BUKTI' => $datPk[0]['KODE_PK']
|
|
];
|
|
$action = $this->Persediaan->create('cetak_dokumen', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
//Controller Transaksi Peminjaman
|
|
public function dataPeminjaman_Gudang_A1() { // [68]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_Peminjaman_Null_0($level);
|
|
$datPeminjam = $this->Persediaan->getData_Karyawan_byID();
|
|
$datPelanggan = $this->Persediaan->getData_Pelanggan_byID();
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($key['ID_PEMINJAMAN']);
|
|
$datPersediaan[$no++] += ['BAR' => $datDfp];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan peminjaman",
|
|
'persediaan' => $datPersediaan,
|
|
'peminjam' => $datPeminjam,
|
|
'pelanggan' => $datPelanggan,
|
|
'level' => $level,
|
|
];
|
|
$this->load->view('proses/PersediaanPeminjaman_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodePeminjaman($level) { // [69]
|
|
$kk = $this->Persediaan->getKode_Peminjaman($level);
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
if ($level == 0) {
|
|
return "PIN/PCM/".$tgl."0001";
|
|
} else if ($level == 1) {
|
|
return "PIN/ITP/".$tgl."0001";
|
|
}
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 8, -4);
|
|
if ($tgl_lama!=$tgl) {
|
|
if ($level == 0) {
|
|
return "PIN/PCM/".$tgl."0001";
|
|
} else if ($level == 1) {
|
|
return "PIN/ITP/".$tgl."0001";
|
|
}
|
|
} else {
|
|
$panjang = 6;
|
|
$data = substr($str, 8, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 14 - strlen($str);
|
|
if ($level == 0) {
|
|
$data = "PIN/PCM/".$tgl."0000";
|
|
} else if ($level == 1) {
|
|
$data = "PIN/ITP/".$tgl."0000";
|
|
}
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanpeminjaman_GA1() { // [70]
|
|
$method = $this->input->post('method');
|
|
$id_peminjaman = $this->input->post('id');
|
|
$id_peminjam = $this->input->post('id_peminjam');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$id_pemberi = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$kode_peminjaman = $this->kodePeminjaman($level);
|
|
$tgl = date('Y-m-d');
|
|
|
|
if ($id_pelanggan==NULL) {
|
|
$input = [
|
|
'PEMINJAM_ID' => $id_peminjam,
|
|
'PEMBERI_ID' => $id_pemberi,
|
|
'JENIS_PEMINJAMAN' => $level,
|
|
'KODE_PEMINJAMAN' => $kode_peminjaman,
|
|
'TGL_PEMINJAMAN' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('peminjaman', $input);
|
|
} else if ($id_peminjam==NULL) {
|
|
$input = [
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'PEMBERI_ID' => $id_pemberi,
|
|
'JENIS_PEMINJAMAN' => $level,
|
|
'KODE_PEMINJAMAN' => $kode_peminjaman,
|
|
'TGL_PEMINJAMAN' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('peminjaman', $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 ubahpeminjaman_GA1() { // [71]
|
|
$method = $this->input->post('method');
|
|
$id_peminjaman = $this->input->post('id_peminjaman');
|
|
$id_peminjam = $this->input->post('id_peminjamed');
|
|
$id_pelanggan = $this->input->post('id_pelangganed');
|
|
$id_pemberi = $this->session->userdata('id_karyawan');
|
|
|
|
if ($id_pelanggan==NULL) {
|
|
$update = [
|
|
'PEMINJAM_ID' => $id_peminjam,
|
|
'PEMBERI_ID' => $id_pemberi
|
|
];
|
|
$action = $this->Persediaan->update('peminjaman', $update, 'ID_PEMINJAMAN', $id_peminjaman);
|
|
} else if ($id_peminjam==NULL) {
|
|
$update = [
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'PEMBERI_ID' => $id_pemberi
|
|
];
|
|
$action = $this->Persediaan->update('peminjaman', $update, 'ID_PEMINJAMAN', $id_peminjaman);
|
|
}
|
|
|
|
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 hapuspeminjaman_GA1() { // [72]
|
|
$method = $this->input->post('method');
|
|
$id_peminjaman = $this->input->post('id_peminjaman');
|
|
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_Null($id_peminjaman);
|
|
if ($datPeminjaman==FALSE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id_peminjaman);
|
|
if ($datDfp==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('peminjaman', $id_peminjaman, 'ID_PEMINJAMAN');
|
|
|
|
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 dataPeminjaman_Gudang_A2($id) { // [73]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_byID($id);
|
|
$status = 0;
|
|
|
|
if ($datPeminjaman[0]['PEMINJAM_ID']==NULL) {
|
|
$title = $datPeminjaman[0]['NAMA_PELANGGAN'];
|
|
} else if ($datPeminjaman[0]['PELANGGAN_ID']==NULL) {
|
|
$title = $datPeminjaman[0]['NAMA_PANGGILAN_KARYAWAN'];
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarPinjam($key['ID_DFP']);
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan peminjaman",
|
|
'persediaan' => $datPersediaan,
|
|
'barang' => $datBarang,
|
|
'id_peminjaman' => $id,
|
|
'level' => $level,
|
|
'status' => $status,
|
|
'title' => $title,
|
|
'kode_peminjaman' => $datPeminjaman[0]['KODE_PEMINJAMAN']
|
|
];
|
|
$this->load->view('proses/PersediaanPeminjaman_Gudang_A2', $data);
|
|
}
|
|
|
|
public function simpanpeminjaman_GA2() { // [74]
|
|
$method = $this->input->post('method');
|
|
$id_dfp = $this->input->post('id');
|
|
$id_peminjaman = $this->input->post('id_peminjaman');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dfp = $this->input->post('qty_dfp');
|
|
$level = $this->session->userdata('level');
|
|
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_Null($id_peminjaman);
|
|
if ($datPeminjaman==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataPeminjaman_Gudang_A1');
|
|
}
|
|
|
|
if ($qty_dfp<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dfp) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_dfp) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id_peminjaman);
|
|
if ($id_barang==$datDfp[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'PEMINJAMAN_ID' => $id_peminjaman,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DFP' => $qty_dfp
|
|
];
|
|
$action = $this->Persediaan->create('daftar_pinjam', $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 hapuspeminjaman_GA2() { // [75]
|
|
$method = $this->input->post('method');
|
|
$id_dfp = $this->input->post('id');
|
|
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byID($id_dfp);
|
|
if ($datDfp[0]['TYPE_JENIS']=="1") {
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($id_dfp);
|
|
if ($datSnPinjam==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_pinjam', $id_dfp, 'ID_DFP');
|
|
|
|
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 kuncipeminjaman_GA2() { // [76]
|
|
$method = $this->input->post('method');
|
|
$id_peminjaman = $this->input->post('id');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_Null($id_peminjaman);
|
|
if ($datPeminjaman==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id_peminjaman);
|
|
foreach ($datDfp as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarPinjam($key['ID_DFP']);
|
|
if ($qtyReal<$key['QTY_DFP']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($key['ID_DFP']);
|
|
foreach ($datSnPinjam as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNP']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="15") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDfp as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$peminjaman_kuantiti = $datKuantiti[0]['PEMINJAMAN_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$key['QTY_DFP'];
|
|
$peminjaman = $peminjaman_kuantiti+$key['QTY_DFP'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PEMINJAMAN_KUANTITI' => $peminjaman
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$peminjaman_kuantiti = $datKuantiti[0]['PEMINJAMAN_KUANTITI'];
|
|
$itp = $itp_kuantiti-$key['QTY_DFP'];
|
|
$peminjaman = $peminjaman_kuantiti+$key['QTY_DFP'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PEMINJAMAN_KUANTITI' => $peminjaman
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
foreach ($datDfp as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($key['ID_DFP']);
|
|
foreach ($datSnPinjam as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_15($dat['NAMA_SNP']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '5'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($level == 1) {
|
|
$input = [
|
|
'SJ_INV' => '0',
|
|
'KODE_BUKTI' => $datPeminjaman[0]['KODE_PEMINJAMAN'],
|
|
'PEMINJAMAN_ID' => $id_peminjaman,
|
|
'TGL_CD' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('cetak_dokumen', $input);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_PEMINJAMAN' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('peminjaman', $update, 'ID_PEMINJAMAN', $id_peminjaman);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect('ManagePersediaan/dataPeminjaman_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect('ManagePersediaan/dataPeminjaman_Gudang_A1');
|
|
}
|
|
|
|
}
|
|
|
|
public function dataPeminjaman_Gudang_A2_View($id) { // [77]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id);
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_byID($id);
|
|
$datPengembali = $this->Persediaan->getData_Karyawan_byID();
|
|
$status = 1;
|
|
|
|
if ($datPeminjaman[0]['PEMINJAM_ID']==NULL) {
|
|
$title = $datPeminjaman[0]['NAMA_PELANGGAN'];
|
|
} else if ($datPeminjaman[0]['PELANGGAN_ID']==NULL) {
|
|
$title = $datPeminjaman[0]['NAMA_PANGGILAN_KARYAWAN'];
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($key['ID_DFP']);
|
|
$datPersediaan[$no++] += ['SN' => $datSnPinjam];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan peminjaman",
|
|
'persediaan' => $datPersediaan,
|
|
'pengembali' => $datPengembali,
|
|
'id_peminjaman' => $id,
|
|
'level' => $level,
|
|
'status' => $status,
|
|
'title' => $title,
|
|
'kode_peminjaman' => $datPeminjaman[0]['KODE_PEMINJAMAN']
|
|
];
|
|
$this->load->view('proses/PersediaanPeminjaman_Gudang_A2', $data);
|
|
}
|
|
|
|
public function prosespeminjaman_GA2() { // [78]
|
|
$method = $this->input->post('method');
|
|
$id_peminjaman = $this->input->post('id_peminjaman');
|
|
$id_pengembali = $this->input->post('id_pengembali');
|
|
$id_penerima = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datPeminjaman = $this->Persediaan->getData_Peminjaman_0($id_peminjaman);
|
|
if ($datPeminjaman==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byPEMINJAMAN($id_peminjaman);
|
|
foreach ($datDfp as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($key['ID_DFP']);
|
|
foreach ($datSnPinjam as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNP']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="5") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDfp as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$peminjaman_kuantiti = $datKuantiti[0]['PEMINJAMAN_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$key['QTY_DFP'];
|
|
$peminjaman = $peminjaman_kuantiti-$key['QTY_DFP'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PEMINJAMAN_KUANTITI' => $peminjaman
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$peminjaman_kuantiti = $datKuantiti[0]['PEMINJAMAN_KUANTITI'];
|
|
$itp = $itp_kuantiti+$key['QTY_DFP'];
|
|
$peminjaman = $peminjaman_kuantiti-$key['QTY_DFP'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PEMINJAMAN_KUANTITI' => $peminjaman
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
foreach ($datDfp as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_byDFP($key['ID_DFP']);
|
|
foreach ($datSnPinjam as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_5($dat['NAMA_SNP']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($level == 0) {
|
|
$update = [
|
|
'STATUS_PEMINJAMAN' => '1',
|
|
'PENGEMBALI_ID' => $id_pengembali,
|
|
'PENERIMA_ID' => $id_penerima,
|
|
'TGL_KEMBALI' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('peminjaman', $update, 'ID_PEMINJAMAN', $id_peminjaman);
|
|
} else if ($level == 1) {
|
|
$update = [
|
|
'STATUS_PEMINJAMAN' => '1',
|
|
'PENERIMA_ID' => $id_penerima,
|
|
'TGL_KEMBALI' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('peminjaman', $update, 'ID_PEMINJAMAN', $id_peminjaman);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect('ManagePersediaan/dataPeminjaman_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect('ManagePersediaan/dataPeminjaman_Gudang_A1');
|
|
}
|
|
|
|
}
|
|
|
|
public function dataPeminjaman_Gudang_A3($id) { // [79]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarPinjam_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_DaftarPinjam($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan peminjaman",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dfp' => $id,
|
|
'qty' => $persediaan[0]['QTY_DFP'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanPeminjaman_Gudang_A3', $data);
|
|
}
|
|
|
|
public function viewSn_Peminjaman_Aktif() { // [80]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnPinjam_byDFP($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Peminjaman_Limit() { // [81]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnPinjam_byDFP($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanpeminjaman_GA3() { // [82]
|
|
$id = $this->input->post('id_snp');
|
|
$id_dfp = $this->input->post('id_dfp');
|
|
$nama_snp = $this->input->post('nama_snp');
|
|
$nama_snp = strtoupper($nama_snp);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnPinjam_byNAMA_AllStatus($nama_snp);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$id_snstock = $datSnStock[0]['ID_SNSTOCK'];
|
|
$datSnPinjam = $this->Persediaan->getData_SnPinjam_SnStock_byNAMA_15($nama_snp);
|
|
if ($datSnPinjam==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock=='0') {
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byID($id_dfp);
|
|
$qtyRealBefore = $this->Persediaan->getQtyReal_DaftarPinjam($id_dfp);
|
|
if ($datDfp[0]['QTY_DFP']<=$qtyRealBefore) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snp' => $nama_snp]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
}
|
|
$input = [
|
|
'NAMA_SNP' => $nama_snp,
|
|
'DFP_ID' => $id_dfp
|
|
];
|
|
$action = $this->Persediaan->create('sn_pinjam', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '15'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'NAMA_SNSTOCK', $nama_snp);
|
|
$qtyRealAfter = $this->Persediaan->getQtyReal_DaftarPinjam($id_dfp);
|
|
if ($datDfp[0]['QTY_DFP']==$qtyRealAfter) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snp' => $nama_snp]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snp' => $nama_snp]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snp' => $nama_snp]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapuspeminjaman_GA3() { // [83]
|
|
$id = $this->input->post('id_snp');
|
|
|
|
$datSnp = $this->Persediaan->getData_SnPinjam_byID($id);
|
|
$nama_snp = $datSnp[0]['NAMA_SNP'];
|
|
$datDfp = $this->Persediaan->getData_DaftarPinjam_byID($datSnp[0]['DFP_ID']);
|
|
$qty_dfp = $datDfp[0]['QTY_DFP'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarPinjam($datSnp[0]['DFP_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snp);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_pinjam', $id, 'ID_SNP');
|
|
|
|
if ($qtyReal==$qty_dfp){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Controller Transaksi Pending
|
|
public function dataPending_Gudang_A1() { // [84]
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_Pending_0(NULL, $level);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datSales = $this->Persediaan->getData_SalesAll();
|
|
$datPelanggan = $this->Persediaan->getData_Pelanggan_byID();
|
|
$tgl_now = date('d/m/Y');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan pending",
|
|
'persediaan' => $datPersediaan,
|
|
'barang' => $datBarang,
|
|
'level' => $level,
|
|
'sales' => $datSales,
|
|
'pelanggan' => $datPelanggan,
|
|
'tgl' => $tgl,
|
|
'tgl_now' => $tgl_now
|
|
];
|
|
$this->load->view('proses/PersediaanPending_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodePending() { // [85]
|
|
$kk = $this->Persediaan->getKode_Pending();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "PEN-000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 4, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 10 - strlen($str);
|
|
$data = "PEN-000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanpending_GA1() { // [86]
|
|
$method = $this->input->post('method');
|
|
$id_pending = $this->input->post('id');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$id_sales = $this->input->post('id_sales');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_pending = $this->input->post('qty_pending');
|
|
$nama_pending = $this->input->post('nama_pending');
|
|
$kode_pending = $this->kodePending();
|
|
$id_gudang = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
if ($qty_pending<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_pending) {
|
|
$this->session->set_flashdata('qty_less', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_pending) {
|
|
$this->session->set_flashdata('qty_less', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$pending_kuantiti = $datKuantiti[0]['PENDING_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$qty_pending;
|
|
$pending = $pending_kuantiti+$qty_pending;
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PENDING_KUANTITI' => $pending
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$pending_kuantiti = $datKuantiti[0]['PENDING_KUANTITI'];
|
|
$itp = $itp_kuantiti-$qty_pending;
|
|
$pending = $pending_kuantiti+$qty_pending;
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PENDING_KUANTITI' => $pending
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
}
|
|
|
|
$durasi_pending = $this->Persediaan->addTempoDay($tgl,7);
|
|
$input = [
|
|
'SALES_ID' => $id_sales,
|
|
'GUDANG_ID' => $id_gudang,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_PENDING' => $kode_pending,
|
|
'JENIS_PENDING' => $level,
|
|
'QTY_PENDING' => $qty_pending,
|
|
'NAMA_PENDING' => $nama_pending,
|
|
'TGL_PENDING' => $tgl,
|
|
'DURASI_PENDING' => $durasi_pending,
|
|
'STATUS_PENDING' => '0'
|
|
];
|
|
$action = $this->Persediaan->create('pending', $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 prosespending_GA1() { // [87]
|
|
$method = $this->input->post('method');
|
|
$id_pending = $this->input->post('id_pending');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datPending = $this->Persediaan->getData_Pending_0($id_pending);
|
|
if ($datPending==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($datPending[0]['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$pending_kuantiti = $datKuantiti[0]['PENDING_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$datPending[0]['QTY_PENDING'];
|
|
$pending = $pending_kuantiti-$datPending[0]['QTY_PENDING'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PENDING_KUANTITI' => $pending
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datPending[0]['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$pending_kuantiti = $datKuantiti[0]['PENDING_KUANTITI'];
|
|
$itp = $itp_kuantiti+$datPending[0]['QTY_PENDING'];
|
|
$pending = $pending_kuantiti-$datPending[0]['QTY_PENDING'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PENDING_KUANTITI' => $pending
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datPending[0]['BARANG_ID']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_PENDING' => '1',
|
|
'SELESAI_PENDING' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('pending', $update, 'ID_PENDING', $id_pending);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
//Controller Transaksi Proyek
|
|
public function dataProyek_Gudang_A1() { // [88]
|
|
$datSales = $this->Persediaan->getData_SalesAll();
|
|
$datPelanggan = $this->Persediaan->getData_Pelanggan_byID();
|
|
$username = $this->session->userdata('username');
|
|
|
|
if ($username=="fridho" OR $username=="ricky") {
|
|
$id_karyawan = 16;
|
|
$datPersediaan = $this->Persediaan->getData_Proyek_forSales_Null($id_karyawan);
|
|
} else if ($username=="mahfut") {
|
|
$id_karyawan = 17;
|
|
$datPersediaan = $this->Persediaan->getData_Proyek_forSales_Null($id_karyawan);
|
|
} else {
|
|
$datPersediaan = $this->Persediaan->getData_Proyek_Null();
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan proyek",
|
|
'persediaan' => $datPersediaan,
|
|
'countData' => count($datPersediaan),
|
|
'pelanggan' => $datPelanggan,
|
|
'sales' => $datSales
|
|
];
|
|
$this->load->view('proses/PersediaanProyek_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodeProyek() { // [89]
|
|
$kk = $this->Persediaan->getKode_Proyek();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "PR".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 2, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "PR".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 9 - strlen($str);
|
|
$data = "PR".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanproyek_GA1() { // [90]
|
|
$method = $this->input->post('method');
|
|
$id_proyek = $this->input->post('id');
|
|
$id_sales = $this->input->post('id_sales');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$po_proyek = $this->input->post('po_proyek');
|
|
$kode_proyek = $this->kodeProyek();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$po_proyek = strtoupper($po_proyek);
|
|
$datProyek = $this->Persediaan->getData_Proyek_byPO($po_proyek);
|
|
if ($datProyek==TRUE) {
|
|
$this->session->set_flashdata('po_same', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'KODE_PROYEK' => $kode_proyek,
|
|
'SALES_ID' => $id_sales,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'PO_PROYEK' => $po_proyek,
|
|
'TGL_PROYEK' => $tgl,
|
|
'NILAI_PROYEK' => '0'
|
|
];
|
|
$action = $this->Persediaan->create('proyek', $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 ubahproyek_GA1() { // [91]
|
|
$method = $this->input->post('method');
|
|
$id_proyek = $this->input->post('id_proyek');
|
|
$id_sales = $this->input->post('id_salesed');
|
|
$id_pelanggan = $this->input->post('id_pelangganed');
|
|
$po_proyek = $this->input->post('po_proyeked');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_byID($id_proyek);
|
|
if ($datProyek[0]['STATUS_PROYEK']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$po_proyek = strtoupper($po_proyek);
|
|
$dataProyek = $this->Persediaan->getData_Proyek_byPO($po_proyek);
|
|
if ($dataProyek==TRUE) {
|
|
$this->session->set_flashdata('po_same', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'SALES_ID' => $id_sales,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'PO_PROYEK' => $po_proyek
|
|
];
|
|
$action = $this->Persediaan->update('proyek', $update, 'ID_PROYEK', $id_proyek);
|
|
|
|
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 hapusproyek_GA1() { // [92]
|
|
$method = $this->input->post('method');
|
|
$id_proyek = $this->input->post('id_proyek');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_byID($id_proyek);
|
|
if ($datProyek[0]['STATUS_PROYEK']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byPROYEK($id_proyek);
|
|
if ($datDpr==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSm = $this->Persediaan->getData_SlipManual_byProyek_forCheck($id_proyek);
|
|
if ($datSm==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datIo = $this->Persediaan->getData_TransaksiStock_byPROYEK($id_proyek);
|
|
if ($datIo==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('proyek', $id_proyek, 'ID_PROYEK');
|
|
|
|
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 dataProyek_Gudang_A2($id) { // [93]
|
|
$datPersediaan = $this->Persediaan->getData_DaftarProyek_byPROYEK($id);
|
|
$datProyek = $this->Persediaan->getData_Proyek_byID($id);
|
|
$datHppProyek = $this->Persediaan->getData_HppProyek_byPROYEK($id);
|
|
$sumHppProyek = $this->Persediaan->getSum_HppProyek_byPROYEK($id);
|
|
$datBarangPcm = $this->Persediaan->getData_Kuantiti_Pcm_All();
|
|
$datSo = $this->Persediaan->getData_SalesOrder_forProyek();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
$total_hppbarang = 0;
|
|
foreach ($datPersediaan as $dat) {
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byBARANG_MasukLebih0($dat['BARANG_ID']);
|
|
$no2 = 0;
|
|
$totkeluar = 0 ;
|
|
$totpersediaan = 0;
|
|
$hargaavglama = 0;
|
|
foreach ($datHq as $key) {
|
|
//Kuantiti Sebelumnya
|
|
$sumHq = $this->Persediaan->getSum_HistoriKuantiti_byBARANG_byHQ($dat['BARANG_ID'], $key['ID_HQ']);
|
|
if ($totkeluar!=$sumHq[0]['KELUAR']) {
|
|
$totkeluar = $sumHq[0]['KELUAR'];
|
|
$datHqLimit = $this->Persediaan->getData_HistoriKuantiti_limitHQ($dat['BARANG_ID'], $key['ID_HQ']);
|
|
$limit = $this->Persediaan->getSum_HistoriKuantiti_byBARANG_byHQ1_byHQ2($dat['BARANG_ID'], $key['ID_HQ'], $datHqLimit[0]['ID_HQ']);
|
|
$keluar = $limit[0]['KELUAR'];
|
|
} else {
|
|
$keluar = 0;
|
|
$totkeluar = 0;
|
|
}
|
|
|
|
//Harga Per Item, DPP
|
|
$harga = $key['NILAI_HQ'] / $key['MASUK_HQ'];
|
|
//Nilai Total Persediaan Akhir
|
|
$nilaiPersediaanKeluar = $hargaavglama * $keluar;
|
|
$totpersediaan = $totpersediaan + ($harga * $key['MASUK_HQ']) - $nilaiPersediaanKeluar;
|
|
$hppakhir = round(($totpersediaan/$sumHq[0]['TOTAL']),2);
|
|
$hargaavglama = $hppakhir;
|
|
}
|
|
|
|
$hppsatuan = number_format($hppakhir, 2);
|
|
$subtot = $hppakhir * $dat['QTY_DPR'];
|
|
$hppakhirtot = number_format($subtot, 2);
|
|
$total_hppbarang = $total_hppbarang + $subtot;
|
|
|
|
$countSn = $this->Persediaan->getCount_SnProyek_byDPR($dat['ID_DPR']);
|
|
|
|
$datSnProyek = $this->Persediaan->getData_SnProyek_byDPR($dat['ID_DPR']);
|
|
|
|
$datPersediaan[$no] += ['REAL' => $countSn];
|
|
$datPersediaan[$no] += ['HARGAAVG' => $hppsatuan];
|
|
$datPersediaan[$no] += ['SN' => $datSnProyek];
|
|
$datPersediaan[$no++] += ['HARGATOTAVG' => $hppakhirtot];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan proyek",
|
|
'persediaan' => $datPersediaan,
|
|
'hpp_proyek' => $datHppProyek,
|
|
'barangpcm' => $datBarangPcm,
|
|
'so' => $datSo,
|
|
'kode_proyek' => $datProyek[0]['KODE_PROYEK'],
|
|
'nama_pelanggan' => $datProyek[0]['NAMA_PELANGGAN'],
|
|
'id_proyek' => $id,
|
|
'tgl' => $tgl,
|
|
'total_hppbarang' => $total_hppbarang,
|
|
'total_hpr' => $sumHppProyek[0]['TOTAL']
|
|
];
|
|
$this->load->view('proses/PersediaanProyek_Gudang_A2', $data);
|
|
}
|
|
|
|
public function simpanproyek_GA2() { // [94]
|
|
$method = $this->input->post('method');
|
|
$id_dpr = $this->input->post('id');
|
|
$id_proyek = $this->input->post('id_proyek');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dpr = $this->input->post('qty_dpr');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_Null($id_proyek);
|
|
if ($datProyek==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataProyek_Gudang_A1');
|
|
}
|
|
|
|
if ($qty_dpr<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dpr) {
|
|
$this->session->set_flashdata('qty_less', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byBARANG($id_barang, $id_proyek);
|
|
if ($datDpr==TRUE) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'PROYEK_ID' => $id_proyek,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DPR' => $qty_dpr
|
|
];
|
|
$action = $this->Persediaan->create('daftar_proyek', $input);
|
|
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proyek_kuantiti = $datKuantiti[0]['PROYEK_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$qty_dpr;
|
|
$proyek = $proyek_kuantiti+$qty_dpr;
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROYEK_KUANTITI' => $proyek
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $id_barang);
|
|
|
|
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 ubahproyek_GA2() { // [95]
|
|
$method = $this->input->post('method');
|
|
$id_dpr = $this->input->post('id_dpred');
|
|
$id_proyek = $this->input->post('id_proyeked');
|
|
$qty_dpr = $this->input->post('qty_dpred');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_Null($id_proyek);
|
|
if ($datProyek==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataProyek_Gudang_A1');
|
|
}
|
|
|
|
if ($qty_dpr<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byID($id_dpr);
|
|
if ($datDpr[0]['TYPE_JENIS']==1) {
|
|
$countSn = $this->Persediaan->getCount_SnProyek_byDPR($id_dpr);
|
|
if ($countSn>$qty_dpr) {
|
|
$this->session->set_flashdata('sn_counterror', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$qtyOld = $datDpr[0]['QTY_DPR'];
|
|
if ($qty_dpr==$qtyOld) {
|
|
$this->session->set_flashdata('qty_same', 'warning');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$qtySelisih = $qtyOld-$qty_dpr;
|
|
if ($qtySelisih<0) {
|
|
$qtyAkhir = $qty_dpr-$qtyOld;
|
|
$update = [
|
|
'QTY_DPR' => $qty_dpr
|
|
];
|
|
$action = $this->Persediaan->update('daftar_proyek', $update, 'ID_DPR', $id_dpr);
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($datDpr[0]['BARANG_ID']);
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proyek_kuantiti = $datKuantiti[0]['PROYEK_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$qtyAkhir;
|
|
$proyek = $proyek_kuantiti+$qtyAkhir;
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROYEK_KUANTITI' => $proyek
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datDpr[0]['BARANG_ID']);
|
|
} else if ($qtySelisih>0) {
|
|
$qtyAkhir = $qtyOld-$qty_dpr;
|
|
$update = [
|
|
'QTY_DPR' => $qty_dpr
|
|
];
|
|
$action = $this->Persediaan->update('daftar_proyek', $update, 'ID_DPR', $id_dpr);
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($datDpr[0]['BARANG_ID']);
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proyek_kuantiti = $datKuantiti[0]['PROYEK_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$qtyAkhir;
|
|
$proyek = $proyek_kuantiti-$qtyAkhir;
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROYEK_KUANTITI' => $proyek
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datDpr[0]['BARANG_ID']);
|
|
}
|
|
|
|
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 hapusproyek_GA2() { // [96]
|
|
$method = $this->input->post('method');
|
|
$id_dpr = $this->input->post('id_dprdel');
|
|
$id_proyek = $this->input->post('id_proyekdel');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_Null($id_proyek);
|
|
if ($datProyek==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataProyek_Gudang_A1');
|
|
}
|
|
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byID($id_dpr);
|
|
if ($datDpr[0]['TYPE_JENIS']==1) {
|
|
$countSpr = $this->Persediaan->getCount_SnProyek_byDPR($id_dpr);
|
|
if ($countSpr>0) {
|
|
$this->session->set_flashdata('sn_filled', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($datDpr[0]['BARANG_ID']);
|
|
if ($datKuantiti[0]['PROYEK_KUANTITI']<$datDpr[0]['QTY_DPR']) {
|
|
$this->session->set_flashdata('qty_less_sp', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proyek_kuantiti = $datKuantiti[0]['PROYEK_KUANTITI'];
|
|
$pcm = $pcm_kuantiti+$datDpr[0]['QTY_DPR'];
|
|
$proyek = $proyek_kuantiti-$datDpr[0]['QTY_DPR'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROYEK_KUANTITI' => $proyek
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $datDpr[0]['BARANG_ID']);
|
|
|
|
$action = $this->Persediaan->delete('daftar_proyek', $id_dpr, 'ID_DPR');
|
|
|
|
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 prosesproyek_GA2() { // [97]
|
|
$method = $this->input->post('method');
|
|
$id_proyek = $this->input->post('id_proyek');
|
|
$id_gudang = $this->session->userdata('id_karyawan');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datProyek = $this->Persediaan->getData_Proyek_Null($id_proyek);
|
|
if ($datProyek==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataProyek_Gudang_A1');
|
|
}
|
|
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byPROYEK($id_proyek);
|
|
//Mencari Harga HPP setiap Kode Barang
|
|
$no = 0;
|
|
$total_hppbarang = 0;
|
|
$datRekap = [];
|
|
foreach ($datDpr as $dat) {
|
|
$datHq = $this->Persediaan->getData_HistoriKuantiti_byBARANG_MasukLebih0($dat['BARANG_ID']);
|
|
$totkeluar = 0;
|
|
$totpersediaan = 0;
|
|
$hargaavglama = 0;
|
|
foreach ($datHq as $key) {
|
|
//Kuantiti Sebelumnya
|
|
$sumHq = $this->Persediaan->getSum_HistoriKuantiti_byBARANG_byHQ($dat['BARANG_ID'], $key['ID_HQ']);
|
|
if ($totkeluar!=$sumHq[0]['KELUAR']) {
|
|
$totkeluar = $sumHq[0]['KELUAR'];
|
|
$datHqLimit = $this->Persediaan->getData_HistoriKuantiti_limitHQ($dat['BARANG_ID'], $key['ID_HQ']);
|
|
$limit = $this->Persediaan->getSum_HistoriKuantiti_byBARANG_byHQ1_byHQ2($dat['BARANG_ID'], $key['ID_HQ'], $datHqLimit[0]['ID_HQ']);
|
|
$keluar = $limit[0]['KELUAR'];
|
|
} else {
|
|
$keluar = 0;
|
|
$totkeluar = 0;
|
|
}
|
|
|
|
//Harga Per Item, DPP
|
|
$harga = $key['NILAI_HQ'] / $key['MASUK_HQ'];
|
|
//Nilai Total Persediaan Akhir
|
|
$nilaiPersediaanKeluar = $hargaavglama * $keluar;
|
|
$totpersediaan = $totpersediaan + ($harga * $key['MASUK_HQ']) - $nilaiPersediaanKeluar;
|
|
$hppakhir = round(($totpersediaan/$sumHq[0]['TOTAL']),2);
|
|
$hargaavglama = $hppakhir;
|
|
}
|
|
|
|
$datRekap[$no++] = [
|
|
'HARGAAVG' => $hppakhir,
|
|
'BARANG_ID' => $dat['BARANG_ID'],
|
|
'ID_DPR' => $dat['ID_DPR'],
|
|
'QTY_DPR' => $dat['QTY_DPR'],
|
|
'TYPE_JENIS'=> $dat['TYPE_JENIS']
|
|
];
|
|
}
|
|
|
|
$kode_proyek = $datProyek[0]['KODE_PROYEK'];
|
|
$ket_io = "Plot Barang dari Kode Proyek $kode_proyek";
|
|
|
|
foreach ($datRekap as $key) {
|
|
$input = [
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'QTY_IO' => $key['QTY_DPR'],
|
|
'GUDANG_ID' => $id_gudang,
|
|
'PROYEK_ID' => $id_proyek,
|
|
'KET_IO' => $ket_io,
|
|
'KODE_BUKTI' => $kode_proyek,
|
|
'TGL_IO' => $tgl,
|
|
'JENIS_IO' => '0',
|
|
'STATUS_IO' => '1'
|
|
];
|
|
$action = $this->Persediaan->create('transaksi_stock', $input);
|
|
|
|
$id_io = $this->Persediaan->getID_TransaksiStockMax();
|
|
$id_io = $id_io[0]['ID_IO'];
|
|
|
|
if ($key['TYPE_JENIS']==1) {
|
|
$datSnpr = $this->Persediaan->getData_SnProyek_byDPR($key['ID_DPR']);
|
|
foreach ($datSnpr as $datkey) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_19($datkey['NAMA_SNPR']);
|
|
if ($datSnStock==TRUE) {
|
|
$input = [
|
|
'TGL_HSN' => $tgl,
|
|
'KODE_BUKTI' => $kode_proyek,
|
|
'SNSTOCK_ID' => $datSnStock[0]['ID_SNSTOCK']
|
|
];
|
|
$action = $this->Persediaan->create('histori_sn', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '14'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
$global_kuantiti = $datKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$proyek_kuantiti = $datKuantiti[0]['PROYEK_KUANTITI'];
|
|
$global = $global_kuantiti-$key['QTY_DPR'];
|
|
$proyek = $proyek_kuantiti-$key['QTY_DPR'];
|
|
$update = [
|
|
'GLOBAL_KUANTITI' => $global,
|
|
'PROYEK_KUANTITI' => $proyek
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
|
|
$input = [
|
|
'TGL_HQ' => $tgl,
|
|
'KODE_BUKTI' => $kode_proyek,
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'KELUAR_HQ' => $key['QTY_DPR'],
|
|
'MASUK_HQ' => '0',
|
|
'IO_ID' => $id_io
|
|
];
|
|
$action = $this->Persediaan->create('histori_kuantiti', $input);
|
|
|
|
$update = [
|
|
'HARGA_DPR' => $key['HARGAAVG']
|
|
];
|
|
$action = $this->Persediaan->update('daftar_proyek', $update, 'ID_DPR', $key['ID_DPR']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_PROYEK' => '0',
|
|
'PROSES_ID' => $id_gudang
|
|
];
|
|
$action = $this->Persediaan->update('proyek', $update, 'ID_PROYEK', $id_proyek);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'diproses');
|
|
redirect('ManagePersediaan/dataProyek_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataProyek_Gudang_A3($id) { // [128]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarProyek_byID($id);
|
|
$max = $this->Persediaan->getCount_SnProyek_byDPR($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan proyek",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dpr' => $id,
|
|
'qty' => $persediaan[0]['QTY_DPR'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanProyek_Gudang_A3', $data);
|
|
}
|
|
|
|
public function viewSn_Dpr_Aktif() { // [129]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnProyek_byDPR($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Dpr_Limit() { // [130]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnProyek_byDPR($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanproyek_GA3() { // [131]
|
|
$id = $this->input->post('id_snpr');
|
|
$id_dpr = $this->input->post('id_dpr');
|
|
$nama_snpr = $this->input->post('nama_snpr');
|
|
$nama_snpr = strtoupper($nama_snpr);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnProyek_byNAMA_AllStatus($nama_snpr);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$datSnpr = $this->Persediaan->getData_SnProyek_SnStock_byNAMA_19($nama_snpr);
|
|
if ($datSnpr==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byID($id_dpr);
|
|
$barang_idDpr = $datDpr[0]['BARANG_ID'];
|
|
$barang_idSn = $datSnStock[0]['BARANG_ID'];
|
|
if ($barang_idDpr!=$barang_idSn) {
|
|
$this->output_json(['value' => 5]);
|
|
} else {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock==NULL) {
|
|
$qtyRealBefore = $this->Persediaan->getCount_SnProyek_byDPR($id_dpr);
|
|
if ($qtyRealBefore>=$datDpr[0]['QTY_DPR']) {
|
|
$this->output_json(['value' => 0]);
|
|
} else {
|
|
$input = [
|
|
'NAMA_SNPR' => $nama_snpr,
|
|
'DPR_ID' => $id_dpr
|
|
];
|
|
$action = $this->Persediaan->create('sn_proyek', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '19'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$qtyRealAfter = $this->Persediaan->getCount_SnProyek_byDPR($id_dpr);
|
|
if ($datDpr[0]['QTY_DPR']==$qtyRealAfter) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snpr' => $nama_snpr]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snpr' => $nama_snpr]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snpr' => $nama_snpr]);
|
|
}
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapusproyek_GA3() { // [132]
|
|
$id = $this->input->post('id_snpr');
|
|
$datSnpr = $this->Persediaan->getData_SnProyek_byID($id);
|
|
$nama_snpr = $datSnpr[0]['NAMA_SNPR'];
|
|
$qtyReal = $this->Persediaan->getCount_SnProyek_byDPR($datSnpr[0]['DPR_ID']);
|
|
$datDpr = $this->Persediaan->getData_DaftarProyek_byID($datSnpr[0]['DPR_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snpr);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_proyek', $id, 'ID_SNPR');
|
|
|
|
if ($qtyReal==$datDpr[0]['QTY_DPR']){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Controller Transaksi Service
|
|
public function dataService_Gudang_A1() { // [98]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarService_byKARYAWAN_Null($id_karyawan);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$countService = $this->Persediaan->getCount_Service_byKARYAWAN_0($id_karyawan);
|
|
$tanggal = date('d/m/Y');
|
|
|
|
if ($datPersediaan==NULL) {
|
|
$id_service = NULL;
|
|
$kode_service = "Belum Dibuat*";
|
|
$datSnService = NULL;
|
|
} else {
|
|
$id_service = $datPersediaan[0]['ID_SERVICE'];
|
|
$kode_service = $datPersediaan[0]['KODE_SERVICE'];
|
|
$datSnService = $this->Persediaan->getData_SnService_bySERVICE($id_service);
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarService($key['ID_DFS']);
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan service input",
|
|
'persediaan' => $datPersediaan,
|
|
'barang' => $datBarang,
|
|
'sn_service' => $datSnService,
|
|
'kode_service' => $kode_service,
|
|
'nama_panggilan' => $nama_panggilan,
|
|
'tanggal' => $tanggal,
|
|
'id_service' => $id_service,
|
|
'countService' => $countService,
|
|
];
|
|
$this->load->view('proses/PersediaanService_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodeService() { // [99]
|
|
$kk = $this->Persediaan->getKode_Service();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "SRV".$tgl."00001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 3, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "SRV".$tgl."00001";
|
|
} else {
|
|
$panjang = 5;
|
|
$data = substr($str, 5, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 10 - strlen($str);
|
|
$data = "SRV".$tgl."00000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanservice_GA1() { // [100]
|
|
$method = $this->input->post('method');
|
|
$id_dfs = $this->input->post('id');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dfs = $this->input->post('qty_dfs');
|
|
$kel_dfs = $this->input->post('kel_dfs');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$kode_service = $this->kodeService();
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datService = $this->Persediaan->getData_Service_byKARYAWAN_Null($id_karyawan);
|
|
if ($datService==FALSE) {
|
|
$input = [
|
|
'KODE_SERVICE' => $kode_service,
|
|
'TGL_SERVICE' => $tgl,
|
|
'JENIS_SERVICE' => $level,
|
|
'PEMBUAT_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Persediaan->create('service', $input);
|
|
|
|
$id_service = $this->Persediaan->getID_ServiceMax();
|
|
$id_service = $id_service[0]['ID_SERVICE'];
|
|
} else {
|
|
$id_service = $datService[0]['ID_SERVICE'];
|
|
}
|
|
|
|
if ($qty_dfs<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dfs) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_dfs) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datDfs = $this->Persediaan->getData_DaftarService_bySERVICE($id_service);
|
|
foreach ($datDfs as $key) {
|
|
if ($id_barang==$key['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$kel_dfs = preg_replace('/\R+/', " " , $kel_dfs);
|
|
$datBarang = $this->Persediaan->getData_Barang_byID($id_barang);
|
|
if ($datBarang[0]['TYPE_JENIS']==1) {
|
|
$kel_dfs = "";
|
|
}
|
|
|
|
$input = [
|
|
'SERVICE_ID' => $id_service,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DFS' => $qty_dfs,
|
|
'KEL_DFS' => $kel_dfs
|
|
];
|
|
$action = $this->Persediaan->create('daftar_service', $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 hapusservice_GA1() { // [101]
|
|
$method = $this->input->post('method');
|
|
$id_dfs = $this->input->post('id');
|
|
|
|
$datDfs = $this->Persediaan->getData_DaftarService_byID($id_dfs);
|
|
$id_service = $datDfs[0]['SERVICE_ID'];
|
|
if ($datDfs[0]['TYPE_JENIS']=="1") {
|
|
$datSnService = $this->Persediaan->getData_SnService_byDFS($id_dfs);
|
|
if ($datSnService==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_service', $id_dfs, 'ID_DFS');
|
|
|
|
$datDfsAfter = $this->Persediaan->getData_DaftarService_bySERVICE($id_service);
|
|
if ($datDfsAfter==FALSE) {
|
|
$action = $this->Persediaan->delete('service', $id_service, 'ID_SERVICE');
|
|
}
|
|
|
|
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 kelservice_GA1() { // [102]
|
|
$method = $this->input->post('method');
|
|
$id_sns = $this->input->post('id');
|
|
$kel_sns = $this->input->post('kel_sns');
|
|
|
|
$datSns = $this->Persediaan->getData_SnService_byID($id_sns);
|
|
if ($datSns==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kel_sns = preg_replace('/\R+/', " " , $kel_sns);
|
|
$update = [
|
|
'KEL_SNS' => $kel_sns
|
|
];
|
|
$action = $this->Persediaan->update('sn_service', $update, 'ID_SNS', $id_sns);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('keluhan_update', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function resetsns_GA1() { // [103]
|
|
$method = $this->input->post('method');
|
|
$id_sns = $this->input->post('id');
|
|
|
|
$datSns = $this->Persediaan->getData_SnService_byID($id_sns);
|
|
if ($datSns==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datService = $this->Persediaan->getData_Service_Null($datSns[0]['SERVICE_ID']);
|
|
if ($datService==FALSE) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataService_Gudang_A1');
|
|
}
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_17($datSns[0]['NAMA_SNS']);
|
|
if ($datSnStock==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
|
|
$action = $this->Persediaan->delete('sn_service', $id_sns, 'ID_SNS');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'direset');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'direset');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function kunciservice_GA1() { // [108]
|
|
$method = $this->input->post('method');
|
|
$id_service = $this->input->post('id');
|
|
$level = $this->session->userdata('level');
|
|
|
|
$datService = $this->Persediaan->getData_Service_Null($id_service);
|
|
if ($datService==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDfs = $this->Persediaan->getData_DaftarService_bySERVICE($id_service);
|
|
foreach ($datDfs as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarService($key['ID_DFS']);
|
|
if ($qtyReal<$key['QTY_DFS']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnService = $this->Persediaan->getData_SnService_byDFS($key['ID_DFS']);
|
|
foreach ($datSnService as $dat) {
|
|
if ($dat['KEL_SNS']==NULL) {
|
|
$this->session->set_flashdata('keluhan_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNS']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="17") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$key['QTY_DFS']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$key['QTY_DFS']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDfs as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level==0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$pcm = $pcm_kuantiti-$key['QTY_DFS'];
|
|
$proses = $proses_kuantiti+$key['QTY_DFS'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level==1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$proses_kuantiti = $datKuantiti[0]['PROSES_KUANTITI'];
|
|
$itp = $itp_kuantiti-$key['QTY_DFS'];
|
|
$proses = $proses_kuantiti+$key['QTY_DFS'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_SERVICE' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('service', $update, 'ID_SERVICE', $id_service);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataService_Gudang_A2($id) { // [109]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarService_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_DaftarService($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan service input",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dfs' => $id,
|
|
'qty' => $persediaan[0]['QTY_DFS'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
|
|
$this->load->view('proses/PersediaanService_Gudang_A2', $data);
|
|
}
|
|
|
|
public function viewSn_Service_Aktif() { // [110]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnService_byDFS($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Service_Limit() { // [111]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnService_byDFS($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanservice_GA2() { // [112]
|
|
$id = $this->input->post('id_sns');
|
|
$id_dfs = $this->input->post('id_dfs');
|
|
$nama_sns = $this->input->post('nama_sns');
|
|
$nama_sns = strtoupper($nama_sns);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnService_byNAMA_AllStatus($nama_sns);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$id_snstock = $datSnStock[0]['ID_SNSTOCK'];
|
|
$datSnService = $this->Persediaan->getData_SnService_SnStock_byNAMA_17($nama_sns);
|
|
if ($datSnService==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock==0) {
|
|
$datDfs = $this->Persediaan->getData_DaftarService_byID($id_dfs);
|
|
$input = [
|
|
'NAMA_SNS' => $nama_sns,
|
|
'DFS_ID' => $id_dfs,
|
|
'SERVICE_ID' => $datDfs[0]['SERVICE_ID'],
|
|
'GARANSI_SNS' => '0'
|
|
];
|
|
$action = $this->Persediaan->create('sn_service', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '17'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'NAMA_SNSTOCK', $nama_sns);
|
|
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarService($id_dfs);
|
|
if ($datDfs[0]['QTY_DFS']==$qtyReal) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_sns' => $nama_sns]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_sns' => $nama_sns]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_sns' => $nama_sns]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapusservice_GA2() { // [113]
|
|
$id = $this->input->post('id_sns');
|
|
|
|
$datSns = $this->Persediaan->getData_SnService_byID($id);
|
|
$nama_sns = $datSns[0]['NAMA_SNS'];
|
|
$datDfs = $this->Persediaan->getData_DaftarService_byID($datSns[0]['DFS_ID']);
|
|
$qty_dfs = $datDfs[0]['QTY_DFS'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarService($datSns[0]['DFS_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_sns);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_service', $id, 'ID_SNS');
|
|
|
|
if ($qtyReal==$qty_dfs){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Controller Transaksi Mutasi Barang
|
|
public function dataMutasi_Gudang_A1() { // [114]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
$username = $this->session->userdata('username');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarMutasiBarang_byKARYAWAN_Null($id_karyawan);
|
|
$datBarang = $this->Persediaan->getBarang_TransaksiStock0($level);
|
|
$datMutasi0 = $this->Persediaan->getData_MutasiBarang_0_byJENIS(0);
|
|
$datMutasi1 = $this->Persediaan->getData_MutasiBarang_0_byJENIS(1);
|
|
|
|
if ($datPersediaan==NULL) {
|
|
$id_mb = NULL;
|
|
$kode_mb = NULL;
|
|
} else {
|
|
$id_mb = $datPersediaan[0]['ID_MB'];
|
|
$kode_mb = $datPersediaan[0]['KODE_MB'];
|
|
}
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarMutasiBarang($key['ID_DMB']);
|
|
$datPersediaan[$no++] += ['REAL' => $qtyReal];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan mutasi",
|
|
'persediaan' => $datPersediaan,
|
|
'mutasi0' => $datMutasi0,
|
|
'mutasi1' => $datMutasi1,
|
|
'barang' => $datBarang,
|
|
'kode_mb' => $kode_mb,
|
|
'nama_panggilan' => $nama_panggilan,
|
|
'username' => $username,
|
|
'id_mb' => $id_mb,
|
|
'level' => $level,
|
|
];
|
|
$this->load->view('proses/PersediaanMutasi_Gudang_A1', $data);
|
|
}
|
|
|
|
public function kodeMutasiBarang($level) { // [115]
|
|
$kk = $this->Persediaan->getKode_MutasiBarang($level);
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
if ($level == 0) {
|
|
return "MB/PCM/".$tgl."0001";
|
|
} else if ($level == 1) {
|
|
return "MB/ITP/".$tgl."0001";
|
|
}
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 7, -4);
|
|
if ($tgl_lama!=$tgl) {
|
|
if ($level == 0) {
|
|
return "MB/PCM/".$tgl."0001";
|
|
} else if ($level == 1) {
|
|
return "MB/ITP/".$tgl."0001";
|
|
}
|
|
} else {
|
|
$panjang = 6;
|
|
$data = substr($str, 7, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 13 - strlen($str);
|
|
if ($level == 0) {
|
|
$data = "MB/PCM/".$tgl."0000";
|
|
} else if ($level == 1) {
|
|
$data = "MB/ITP/".$tgl."0000";
|
|
}
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function simpanmutasi_GA1() { // [116]
|
|
$method = $this->input->post('method');
|
|
$id_dmb = $this->input->post('id');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dmb = $this->input->post('qty_dmb');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$kode_mb = $this->kodeMutasiBarang($level);
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datMb = $this->Persediaan->getData_MutasiBarang_byKARYAWAN_Null($id_karyawan);
|
|
if ($datMb==FALSE) {
|
|
$input = [
|
|
'KODE_MB' => $kode_mb,
|
|
'TGL_MB' => $tgl,
|
|
'JENIS_MB' => $level,
|
|
'ADMIN_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Persediaan->create('mutasi_barang', $input);
|
|
|
|
$id_mb = $this->Persediaan->getID_MutasiBarangMax();
|
|
$id_mb = $id_mb[0]['ID_MB'];
|
|
} else {
|
|
$id_mb = $datMb[0]['ID_MB'];
|
|
}
|
|
|
|
if ($qty_dmb<=0) {
|
|
$this->session->set_flashdata('not_zero_negative', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($id_barang);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$qty_dmb) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$qty_dmb) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id_mb);
|
|
if ($id_barang==$datDmb[0]['BARANG_ID']) {
|
|
$this->session->set_flashdata('twin_item', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$input = [
|
|
'MB_ID' => $id_mb,
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DMB' => $qty_dmb
|
|
];
|
|
$action = $this->Persediaan->create('daftar_mutasibarang', $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 hapusmutasi_GA1() { // [117]
|
|
$method = $this->input->post('method');
|
|
$id_dmb = $this->input->post('id');
|
|
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byID($id_dmb);
|
|
$id_mb = $datDmb[0]['MB_ID'];
|
|
if ($datDmb[0]['TYPE_JENIS']=="1") {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($id_dmb);
|
|
if ($datSnMutasiBarang==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_mutasibarang', $id_dmb, 'ID_DMB');
|
|
|
|
$datDmbAfter = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id_mb);
|
|
if ($datDmbAfter==FALSE) {
|
|
$action = $this->Persediaan->delete('mutasi_barang', $id_mb, 'ID_MB');
|
|
}
|
|
|
|
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 kuncimutasi_GA1() { // [118]
|
|
$method = $this->input->post('method');
|
|
$id_mb = $this->input->post('id');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datMb = $this->Persediaan->getData_MutasiBarang_Null($id_mb);
|
|
if ($datMb==FALSE) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id_mb);
|
|
foreach ($datDmb as $key) {
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarMutasiBarang($key['ID_DMB']);
|
|
if ($qtyReal<$key['QTY_DMB']) {
|
|
$this->session->set_flashdata('sn_check', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
foreach ($datSnMutasiBarang as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($dat['NAMA_SNMB']);
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!="17") {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
if ($datKuantiti[0]['PCM_KUANTITI']<$key['QTY_DMB']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
} else if ($level == 1) {
|
|
if ($datKuantiti[0]['ITP_KUANTITI']<$key['QTY_DMB']) {
|
|
$this->session->set_flashdata('over_qty', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($datDmb as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$mutasi_kuantiti = $datKuantiti[0]['MUTASI_KUANTITI'];
|
|
$pcm = $pcm_kuantiti - $key['QTY_DMB'];
|
|
$mutasi = $mutasi_kuantiti + $key['QTY_DMB'];
|
|
$update = [
|
|
'PCM_KUANTITI' => $pcm,
|
|
'MUTASI_KUANTITI' => $mutasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$mutasi_kuantiti = $datKuantiti[0]['MUTASI_KUANTITI'];
|
|
$itp = $itp_kuantiti - $key['QTY_DMB'];
|
|
$mutasi = $mutasi_kuantiti + $key['QTY_DMB'];
|
|
$update = [
|
|
'ITP_KUANTITI' => $itp,
|
|
'MUTASI_KUANTITI' => $mutasi
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
|
|
if ($key['TYPE_JENIS']=="1") {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
foreach ($datSnMutasiBarang as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnMutasiBarang_SnStock_byNAMA_17($dat['NAMA_SNMB']);
|
|
$levelgudang = $level + 1;
|
|
if ($datSnStock==TRUE AND $datSnStock[0]['GUDANG_SNSTOCK']==$levelgudang) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '18'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_MB' => '0',
|
|
'TGL_MB' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('mutasi_barang', $update, 'ID_MB', $id_mb);
|
|
|
|
$input = [
|
|
'SJ_INV' => '0',
|
|
'KODE_BUKTI' => $datMb[0]['KODE_MB'],
|
|
'MB_ID' => $id_mb,
|
|
'TGL_CD' => $tgl
|
|
];
|
|
$action = $this->Persediaan->create('cetak_dokumen', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_lock', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikunci');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function dataMutasi_Gudang_A2($id) { // [119]
|
|
$level = $this->session->userdata('level');
|
|
$persediaan = $this->Persediaan->getData_DaftarMutasiBarang_byID($id);
|
|
$max = $this->Persediaan->getQtyReal_DaftarMutasiBarang($id);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byBARANG_0($persediaan[0]['BARANG_ID'], $level);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan mutasi",
|
|
'persediaan' => $persediaan,
|
|
'snstock' => $datSnStock,
|
|
'count_snstock' => count($datSnStock),
|
|
'id_dmb' => $id,
|
|
'qty' => $persediaan[0]['QTY_DMB'],
|
|
'kode_barang' => $persediaan[0]['KODE_BARANG'],
|
|
'max' => $max,
|
|
];
|
|
$this->load->view('proses/PersediaanMutasi_Gudang_A2', $data);
|
|
}
|
|
|
|
public function viewSn_Mutasi_Aktif() { // [120]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnMutasiBarang_byDMB($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function viewSn_Mutasi_Limit() { // [121]
|
|
$id = $this->input->post('id');
|
|
$data = $this->Persediaan->getData_SnMutasiBarang_byDMB($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function simpanmutasi_GA2() { // [122]
|
|
$id = $this->input->post('id_snmb');
|
|
$id_dmb = $this->input->post('id_dmb');
|
|
$level = $this->session->userdata('level');
|
|
$nama_snmb = $this->input->post('nama_snmb');
|
|
$nama_snmb = strtoupper($nama_snmb);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnMutasiBarang_byNAMA_AllStatus($nama_snmb);
|
|
if ($datSnStock==FALSE) {
|
|
$value = 3;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==3) {
|
|
$this->output_json(['value' => $value]);
|
|
} else if ($value==1) {
|
|
$id_snstock = $datSnStock[0]['ID_SNSTOCK'];
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_SnStock_byNAMA_17($nama_snmb);
|
|
if ($datSnMutasiBarang==TRUE) {
|
|
$value = 4;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==4) {
|
|
$this->output_json(['value' => 4]);
|
|
} else if ($value==1) {
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byID($id_dmb);
|
|
$barang_id1 = $datSnStock[0]['BARANG_ID'];
|
|
$barang_id2 = $datDmb[0]['BARANG_ID'];
|
|
if ($barang_id1!=$barang_id2) {
|
|
$value = 6;
|
|
} else {
|
|
$value = 1;
|
|
}
|
|
|
|
if ($value==6) {
|
|
$this->output_json(['value' => 6]);
|
|
} else if ($value==1) {
|
|
$gudang_snstock = $datSnStock[0]['GUDANG_SNSTOCK'];
|
|
if ($level == ($gudang_snstock-1)) {
|
|
$status_snstock = $datSnStock[0]['STATUS_SNSTOCK'];
|
|
if ($status_snstock==NULL) {
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byID($id_dmb);
|
|
$input = [
|
|
'NAMA_SNMB' => $nama_snmb,
|
|
'DMB_ID' => $id_dmb,
|
|
'MB_ID' => $datDmb[0]['MB_ID']
|
|
];
|
|
$action = $this->Persediaan->create('sn_mutasibarang', $input);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '17'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'NAMA_SNSTOCK', $nama_snmb);
|
|
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarMutasiBarang($id_dmb);
|
|
if ($datDmb[0]['QTY_DMB']==$qtyReal) {
|
|
$this->output_json(['value' => 2, 'id' => $id, 'nama_snmb' => $nama_snmb]);
|
|
$this->session->set_flashdata('quota_full', 'warning');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'id' => $id, 'nama_snmb' => $nama_snmb]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'id' => $id, 'nama_snmb' => $nama_snmb]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 0]);
|
|
}
|
|
} else {
|
|
$this->output_json(['value' => 5]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hapusmutasi_GA2() { // [123]
|
|
$id = $this->input->post('id_snmb');
|
|
|
|
$datSnmb = $this->Persediaan->getData_SnMutasiBarang_byID($id);
|
|
$nama_snmb = $datSnmb[0]['NAMA_SNMB'];
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byID($datSnmb[0]['DMB_ID']);
|
|
$qty_dmb = $datDmb[0]['QTY_DMB'];
|
|
$qtyReal = $this->Persediaan->getQtyReal_DaftarMutasiBarang($datSnmb[0]['DMB_ID']);
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_AllStatus($nama_snmb);
|
|
|
|
$update = [
|
|
'STATUS_SNSTOCK' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
$action = $this->Persediaan->delete('sn_mutasibarang', $id, 'ID_SNMB');
|
|
|
|
if ($qtyReal==$qty_dmb){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('quota_free', 'warning');
|
|
} else {
|
|
if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataMutasi_Gudang_A3($id) { // [124]
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id);
|
|
$datMb = $this->Persediaan->getData_MutasiBarang_byID($id);
|
|
$tgl_now = date('d/m/Y H:i:s');
|
|
$status = 0;
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
$datPersediaan[$no++] += ['SN' => $datSnMutasiBarang];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan mutasi",
|
|
'persediaan' => $datPersediaan,
|
|
'kode_mb' => $datMb[0]['KODE_MB'],
|
|
'nama_pembuat' => $datMb[0]['NAMA_PANGGILAN_KARYAWAN'],
|
|
'tanggal' => $datMb[0]['TANGGAL'],
|
|
'nama_panggilan' => $nama_panggilan,
|
|
'tgl_now' => $tgl_now,
|
|
'status' => $status,
|
|
'id_mb' => $id,
|
|
];
|
|
$this->load->view('proses/PersediaanMutasi_Gudang_A3', $data);
|
|
}
|
|
|
|
public function terimamutasi_GA3() { // [125]
|
|
$id_mb = $this->input->post('id');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl_now = date('d/m/Y H:i:s');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datMb = $this->Persediaan->getData_MutasiBarang_byID($id_mb);
|
|
if ($datMb==FALSE OR $datMb[0]['STATUS_MB']!=0) {
|
|
$this->session->set_flashdata('not_valid', 'error');
|
|
redirect('ManagePersediaan/dataMutasi_Gudang_A1');
|
|
}
|
|
|
|
$datDmb = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id_mb);
|
|
foreach ($datDmb as $key) {
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($datKuantiti[0]['MUTASI_KUANTITI']<$key['QTY_DMB']) {
|
|
$this->session->set_flashdata('over_qty_mutasi', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($key['TYPE_JENIS']==1) {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
foreach ($datSnMutasiBarang as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_SnMutasiBarang_byNAMA_AllStatus($dat['NAMA_SNMB']);
|
|
$posisiSn = $level + 1;
|
|
if ($datSnStock[0]['STATUS_SNSTOCK']!=18 AND $posisiSn==$datSnStock[0]['GUDANG_SNSTOCK']) {
|
|
$this->session->set_flashdata('sn_error', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Set Gudang SN sesuai yang menerima
|
|
if ($level==0) {
|
|
$gudang_snstock = 1;
|
|
} else if ($level==1) {
|
|
$gudang_snstock = 2;
|
|
}
|
|
|
|
foreach ($datDmb as $key) {
|
|
if ($key['TYPE_JENIS']==1) {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
foreach ($datSnMutasiBarang as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_18($dat['NAMA_SNMB']);
|
|
if ($datSnStock==TRUE) {
|
|
$update = [
|
|
'STATUS_SNSTOCK' => NULL,
|
|
'GUDANG_SNSTOCK' => $gudang_snstock
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level == 0) {
|
|
$mutasi_kuantiti = $datKuantiti[0]['MUTASI_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$mutasi = $mutasi_kuantiti - $key['QTY_DMB'];
|
|
$pcm = $pcm_kuantiti + $key['QTY_DMB'];
|
|
$update = [
|
|
'MUTASI_KUANTITI' => $mutasi,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level == 1) {
|
|
$mutasi_kuantiti = $datKuantiti[0]['MUTASI_KUANTITI'];
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$mutasi = $mutasi_kuantiti - $key['QTY_DMB'];
|
|
$itp = $itp_kuantiti + $key['QTY_DMB'];
|
|
$update = [
|
|
'MUTASI_KUANTITI' => $mutasi,
|
|
'ITP_KUANTITI' => $itp
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'PENERIMA_ID' => $id_karyawan,
|
|
'TERIMA_MB' => $tgl_now,
|
|
'STATUS_MB' => '1',
|
|
];
|
|
$action = $this->Persediaan->update('mutasi_barang', $update, 'ID_MB', $id_mb);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('data_receive', 'diterima');
|
|
redirect('ManagePersediaan/dataMutasi_Gudang_A1');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diterima');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function dataMutasi_Gudang_A3_View($id) { // [126]
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarMutasiBarang_byMB($id);
|
|
$datMb = $this->Persediaan->getData_MutasiBarang_byID($id);
|
|
$status = 1;
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSnMutasiBarang = $this->Persediaan->getData_SnMutasiBarang_byDMB($key['ID_DMB']);
|
|
$datPersediaan[$no++] += ['SN' => $datSnMutasiBarang];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan mutasi",
|
|
'persediaan' => $datPersediaan,
|
|
'kode_mb' => $datMb[0]['KODE_MB'],
|
|
'nama_pembuat' => $datMb[0]['NAMA_PANGGILAN_KARYAWAN'],
|
|
'tanggal' => $datMb[0]['TANGGAL'],
|
|
'nama_panggilan' => $nama_panggilan,
|
|
'id_mb' => $id,
|
|
'status' => $status,
|
|
];
|
|
$this->load->view('proses/PersediaanMutasi_Gudang_A3', $data);
|
|
}
|
|
|
|
public function dataService_Gudang_B1() { // [127]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$nama_panggilan = $this->session->userdata('nama_panggilan');
|
|
$level = $this->session->userdata('level');
|
|
$datPersediaan = $this->Persediaan->getData_DaftarPenarikanService_statusNull_byKARYAWAN($id_karyawan);
|
|
$datServiceSn = $this->Persediaan->getData_SnService_SnsStatus2_SnstockStatus7_psvNull($level);
|
|
$datServiceNon = $this->Persediaan->getData_NonSnService_groupBARANG();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$no = 0;
|
|
foreach ($datPersediaan as $key) {
|
|
$datSns = $this->Persediaan->getData_SnService_byPSV_byBARANG($key['PSV_ID'], $key['BARANG_ID']);
|
|
$datPersediaan[$no++] += ['SN'=> $datSns];
|
|
}
|
|
|
|
if ($datPersediaan==NULL) {
|
|
$kode_psv = NULL;
|
|
} else {
|
|
$kode_psv = $datPersediaan[0]['KODE_PSV'];
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan service terima",
|
|
'persediaan' => $datPersediaan,
|
|
'servicesn' => $datServiceSn,
|
|
'servicenon' => $datServiceNon,
|
|
'tgl' => $tgl,
|
|
'nama_panggilan' => $nama_panggilan,
|
|
'kode_psv' => $kode_psv,
|
|
];
|
|
$this->load->view('proses/PersediaanService_Gudang_B1', $data);
|
|
}
|
|
|
|
public function kodePenarikanService() { // [128]
|
|
$kk = $this->Persediaan->getKode_PenarikanService();
|
|
$tgl = date('y');
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "PSV".$tgl."-0001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$tgl_lama = substr($str, 3, -5);
|
|
if ($tgl_lama!=$tgl) {
|
|
return "PSV".$tgl."-0001";
|
|
} else {
|
|
$panjang = 4;
|
|
$data = substr($str, 6, $panjang);
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
$panjang = 10 - strlen($str);
|
|
$data = "PSV".$tgl."-0000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function kembalikansn_GB1() { // [129]
|
|
$sns = $this->input->post('snskembaligudang');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
foreach ($sns as $key) {
|
|
$datSns = $this->Persediaan->getData_SnService_byID($key);
|
|
if ($datSns==FALSE OR $datSns[0]['PSV_ID']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
if ($datSns[0]['GUDANG_SNSTOCK']!=($level+1)) {
|
|
$this->session->set_flashdata('sn_error_gudang', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$datPsv = $this->Persediaan->getData_PenarikanService_byKARYAWAN_statusNull($id_karyawan);
|
|
if ($datPsv==FALSE) {
|
|
$kode_psv = $this->kodePenarikanService();
|
|
$input = [
|
|
'KODE_PSV' => $kode_psv,
|
|
'TGL_PSV' => $tgl,
|
|
'PENGAMBIL_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Persediaan->create('penarikan_service', $input);
|
|
$id_psv = $this->Persediaan->getID_PenarikanServiceMax();
|
|
$id_psv = $id_psv[0]['ID_PSV'];
|
|
} else {
|
|
$id_psv = $datPsv[0]['ID_PSV'];
|
|
}
|
|
|
|
foreach ($sns as $key) {
|
|
$update = [
|
|
'TGL_SNS' => $tgl,
|
|
'PSV_ID' => $id_psv,
|
|
];
|
|
$action = $this->Persediaan->update('sn_service', $update, 'ID_SNS', $key);
|
|
}
|
|
|
|
$datSnService = $this->Persediaan->getData_SnService_byPSV_groupBARANG($id_psv);
|
|
foreach ($datSnService as $key) {
|
|
$datSns = $this->Persediaan->getData_SnService_byPSV_byBARANG($id_psv, $key['BARANG_ID']);
|
|
$qty_dpsv = count($datSns);
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byPSV_byBARANG($id_psv, $key['BARANG_ID']);
|
|
if ($datDpsv==TRUE) {
|
|
$update = [
|
|
'QTY_DPSV' => $qty_dpsv
|
|
];
|
|
$action = $this->Persediaan->update('daftar_penarikanservice', $update, 'ID_DPSV', $datDpsv[0]['ID_DPSV']);
|
|
} else {
|
|
$input = [
|
|
'QTY_DPSV' => $qty_dpsv,
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'PSV_ID' => $id_psv
|
|
];
|
|
$action = $this->Persediaan->create('daftar_penarikanservice', $input);
|
|
}
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function kembalikannonsn_GB1() { // [130]
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_dpsv = $this->input->post('qty_dpsv');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$sumNon = $this->Persediaan->getSum_NonSnService_byBARANG($id_barang);
|
|
if ($sumNon[0]['TOTAL']<$qty_dpsv) {
|
|
$this->session->set_flashdata('qty_over', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datPsv = $this->Persediaan->getData_PenarikanService_byKARYAWAN_statusNull($id_karyawan);
|
|
if ($datPsv==FALSE) {
|
|
$kode_psv = $this->kodePenarikanService();
|
|
$input = [
|
|
'KODE_PSV' => $kode_psv,
|
|
'TGL_PSV' => $tgl,
|
|
'PENGAMBIL_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Persediaan->create('penarikan_service', $input);
|
|
$id_psv = $this->Persediaan->getID_PenarikanServiceMax();
|
|
$id_psv = $id_psv[0]['ID_PSV'];
|
|
} else {
|
|
$id_psv = $datPsv[0]['ID_PSV'];
|
|
}
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byPSV_byBARANG($id_psv, $id_barang);
|
|
if ($datDpsv==TRUE) {
|
|
$update = [
|
|
'QTY_DPSV' => $qty_dpsv
|
|
];
|
|
$action = $this->Persediaan->update('daftar_penarikanservice', $update, 'ID_DPSV', $datDpsv[0]['ID_DPSV']);
|
|
} else {
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'QTY_DPSV' => $qty_dpsv,
|
|
'PSV_ID' => $id_psv
|
|
];
|
|
$action = $this->Persediaan->create('daftar_penarikanservice', $input);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditarik');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function ubahtarik_GB1() { // [131]
|
|
$id_dpsv = $this->input->post('id_dpsved');
|
|
$qty_dpsv = $this->input->post('qty_dpsved');
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byID($id_dpsv);
|
|
if ($datDpsv==FALSE OR $datDpsv[0]['STATUS_PSV']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$sumNon = $this->Persediaan->getSum_NonSnService_byBARANG($datDpsv[0]['BARANG_ID']);
|
|
if ($sumNon[0]['TOTAL']<$qty_dpsv) {
|
|
$this->session->set_flashdata('qty_over', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$update = [
|
|
'QTY_DPSV' => $qty_dpsv
|
|
];
|
|
$action = $this->Persediaan->update('daftar_penarikanservice', $update, 'ID_DPSV', $id_dpsv);
|
|
|
|
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 hapustarik_GB1() { // [132]
|
|
$id_dpsv = $this->input->post('id_dpsvdel');
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byID($id_dpsv);
|
|
if ($datDpsv==FALSE OR $datDpsv[0]['STATUS_PSV']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($datDpsv[0]['TYPE_JENIS']==1) {
|
|
$datSns = $this->Persediaan->getData_SnService_byPSV_byBARANG($datDpsv[0]['PSV_ID'], $datDpsv[0]['BARANG_ID']);
|
|
foreach ($datSns as $key) {
|
|
$update = [
|
|
'TGL_SNS' => NULL,
|
|
'PSV_ID' => NULL
|
|
];
|
|
$action = $this->Persediaan->update('sn_service', $update, 'ID_SNS', $key['ID_SNS']);
|
|
}
|
|
}
|
|
|
|
$action = $this->Persediaan->delete('daftar_penarikanservice', $id_dpsv, 'ID_DPSV');
|
|
|
|
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 kuncitarik_GB1() { // [133]
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$level = $this->session->userdata('level');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datPsv = $this->Persediaan->getData_PenarikanService_byKARYAWAN_statusNull($id_karyawan);
|
|
if ($datPsv==FALSE OR $datPsv[0]['STATUS_PSV']!=NULL) {
|
|
$this->session->set_flashdata('latest', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byPSV($datPsv[0]['ID_PSV']);
|
|
foreach ($datDpsv as $key) {
|
|
if ($key['TYPE_JENIS']==1) {
|
|
$datSns = $this->Persediaan->getData_SnService_byPSV_byBARANG($key['PSV_ID'], $key['BARANG_ID']);
|
|
foreach ($datSns as $dat) {
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_7($dat['NAMA_SNS']);
|
|
if ($datSnStock==FALSE) {
|
|
$this->session->set_flashdata('failed', "ditarik disebabkan inkonsistensi data");
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
} else if ($key['TYPE_JENIS']==0) {
|
|
$sumNon = $this->Persediaan->getSum_NonSnService_byBARANG($key['BARANG_ID']);
|
|
if ($sumNon[0]['TOTAL']<$key['QTY_DPSV']) {
|
|
$this->session->set_flashdata('qty_over', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$datDpsv = $this->Persediaan->getData_DaftarPenarikanService_byPSV($datPsv[0]['ID_PSV']);
|
|
foreach ($datDpsv as $key) {
|
|
if ($key['TYPE_JENIS']==1) {
|
|
$datSns = $this->Persediaan->getData_SnService_byPSV_byBARANG($key['PSV_ID'], $key['BARANG_ID']);
|
|
foreach ($datSns as $dat) {
|
|
$update = [
|
|
'TGL_SNS' => $tgl,
|
|
];
|
|
$action = $this->Persediaan->update('sn_service', $update, 'ID_SNS', $dat['ID_SNS']);
|
|
|
|
$datSnStock = $this->Persediaan->getData_SnStock_byNAMA_7($dat['NAMA_SNS']);
|
|
$update = [
|
|
'STATUS_SNSTOCK' => '0'
|
|
];
|
|
$action = $this->Persediaan->update('sn_stock', $update, 'ID_SNSTOCK', $datSnStock[0]['ID_SNSTOCK']);
|
|
}
|
|
} else if ($key['TYPE_JENIS']==0) {
|
|
$input = [
|
|
'TGL_NONSNS' => $tgl,
|
|
'KODE_BUKTI' => $datPsv[0]['KODE_PSV'],
|
|
'BARANG_ID' => $key['BARANG_ID'],
|
|
'MASUK_NONSNS' => '0',
|
|
'KELUAR_NONSNS' => $key['QTY_DPSV'],
|
|
'PENERIMA_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Persediaan->create('nonsn_service', $input);
|
|
}
|
|
|
|
$datKuantiti = $this->Persediaan->getData_Kuantiti_byID($key['BARANG_ID']);
|
|
if ($level==0) {
|
|
$service_kuantiti = $datKuantiti[0]['SERVICE_KUANTITI'];
|
|
$pcm_kuantiti = $datKuantiti[0]['PCM_KUANTITI'];
|
|
$service = $service_kuantiti-$key['QTY_DPSV'];
|
|
$pcm = $pcm_kuantiti+$key['QTY_DPSV'];
|
|
$update = [
|
|
'SERVICE_KUANTITI' => $service,
|
|
'PCM_KUANTITI' => $pcm,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
} else if ($level==1) {
|
|
$service_kuantiti = $datKuantiti[0]['SERVICE_KUANTITI'];
|
|
$itp_kuantiti = $datKuantiti[0]['ITP_KUANTITI'];
|
|
$service = $service_kuantiti-$key['QTY_DPSV'];
|
|
$itp = $itp_kuantiti+$key['QTY_DPSV'];
|
|
$update = [
|
|
'SERVICE_KUANTITI' => $service,
|
|
'ITP_KUANTITI' => $itp,
|
|
];
|
|
$action = $this->Persediaan->update('kuantiti', $update, 'ID_KUANTITI', $key['BARANG_ID']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_PSV' => '1',
|
|
'TGL_PSV' => $tgl
|
|
];
|
|
$action = $this->Persediaan->update('penarikan_service', $update, 'ID_PSV', $datPsv[0]['ID_PSV']);
|
|
|
|
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 dataService_Gudang_B2() { // [134]
|
|
$datPersediaan1 = $this->Persediaan->getData_SnService_allStatus_InternalOnly();
|
|
$datPersediaan2 = $this->Persediaan->getData_NonSnService_groupBARANG();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan service terima",
|
|
'persediaan1' => $datPersediaan1,
|
|
'persediaan2' => $datPersediaan2,
|
|
'tgl' => $tgl,
|
|
];
|
|
$this->load->view('proses/PersediaanService_Gudang_B2', $data);
|
|
}
|
|
|
|
public function dataService_Gudang_B3($id) { // [135]
|
|
$datPersediaan = $this->Persediaan->getData_NonSnService_byBARANG($id);
|
|
$datBarang = $this->Persediaan->getData_Barang_byID($id);
|
|
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan service terima",
|
|
'persediaan' => $datPersediaan,
|
|
'kode_barang' => $datBarang[0]['KODE_BARANG'],
|
|
];
|
|
$this->load->view('proses/PersediaanService_Gudang_B3', $data);
|
|
}
|
|
|
|
public function dataStokOpname_Gudang_A1() { // [136]
|
|
$kondisi = $this->input->post('kondisi');
|
|
$jenis_gudang = $this->input->post('jenis_gudang');
|
|
$id_jenis = $this->input->post('id_jenis');
|
|
$datJenis = $this->Persediaan->getData_Jenis_Not2();
|
|
$tgl = date('d/m/Y');
|
|
|
|
$dataJenis = $this->Persediaan->getData_Jenis_Not2($id_jenis);
|
|
if ($id_jenis=="") {
|
|
$jen = "Semua Jenis";
|
|
} else {
|
|
$nama_jenis = $dataJenis[0]['NAMA_JENIS'];
|
|
$jen = "$nama_jenis";
|
|
}
|
|
|
|
if ($kondisi==null){
|
|
$jenis_gudang = 1;
|
|
$all = 2 ;
|
|
$title = "Gudang Global (Semua Jenis)";
|
|
} else if ($kondisi!=null AND $jenis_gudang=="") {
|
|
$jenis_gudang = NULL;
|
|
$title = "Semua Gudang ($jen)";
|
|
$all = 1;
|
|
} else {
|
|
$all = 2;
|
|
if ($jenis_gudang==NULL) {
|
|
$title = "";
|
|
} else if ($jenis_gudang=="1") {
|
|
$title = "Gudang Global ($jen)";
|
|
} else if ($jenis_gudang=="2") {
|
|
$title = "Gudang PCM ($jen)";
|
|
} else if ($jenis_gudang=="3") {
|
|
$title = "Gudang Konsinyasi ($jen)";
|
|
} else if ($jenis_gudang=="4") {
|
|
$title = "Gudang Peminjaman ($jen)";
|
|
} else if ($jenis_gudang=="5") {
|
|
$title = "Gudang Pending ($jen)";
|
|
} else if ($jenis_gudang=="6") {
|
|
$title = "Gudang Antik ($jen)";
|
|
} else if ($jenis_gudang=="7") {
|
|
$title = "Gudang Proyek ($jen)";
|
|
} else if ($jenis_gudang=="8") {
|
|
$title = "Gudang Service ($jen)";
|
|
} else if ($jenis_gudang=="9") {
|
|
$title = "Gudang ITP ($jen)";
|
|
}
|
|
}
|
|
|
|
$persediaan = $this->Persediaan->getData_StokKuantiti($all, $jenis_gudang, $id_jenis);
|
|
$data = [
|
|
'sidebar' => "menu persediaan",
|
|
'navChild' => "persediaan stokopname",
|
|
'persediaan' => $persediaan,
|
|
'jenis' => $datJenis,
|
|
'id_jenis' => $id_jenis,
|
|
'tgl' => $tgl,
|
|
'title' => $title,
|
|
'all' => $all,
|
|
'jenis_gudang' => $jenis_gudang
|
|
];
|
|
$this->load->view('proses/PersediaanStokOpname_Gudang_A1', $data);
|
|
}
|
|
|
|
public function simpan_excel_stokOpname() { // [137]
|
|
$jenis_gudang = $this->input->post('jenis_gudang');
|
|
$id_jenis = $this->input->post('id_jenis');
|
|
$all = $this->input->post('all');
|
|
$username = $this->input->post('username');
|
|
$tgl = date('d/m/Y');
|
|
$persediaan = $this->Persediaan->getData_StokKuantiti($all, $jenis_gudang, $id_jenis);
|
|
$pilih_tabel = array('No', 'Jenis', 'Kode Barang', 'Nama Barang', 'Kuantiti');
|
|
|
|
if ($jenis_gudang==NULL) {
|
|
$gudang = "";
|
|
} else if ($jenis_gudang=="1") {
|
|
$gudang = "Gudang Global";
|
|
} else if ($jenis_gudang=="2") {
|
|
$gudang = "Gudang PCM";
|
|
} else if ($jenis_gudang=="3") {
|
|
$gudang = "Gudang Konsinyasi";
|
|
} else if ($jenis_gudang=="4") {
|
|
$gudang = "Gudang Peminjaman";
|
|
} else if ($jenis_gudang=="5") {
|
|
$gudang = "Gudang Pending";
|
|
} else if ($jenis_gudang=="6") {
|
|
$gudang = "Gudang Antik";
|
|
} else if ($jenis_gudang=="7") {
|
|
$gudang = "Gudang Proyek";
|
|
} else if ($jenis_gudang=="8") {
|
|
$gudang = "Gudang Service";
|
|
} else if ($jenis_gudang=="9") {
|
|
$gudang = "Gudang ITP";
|
|
}
|
|
|
|
$data = [
|
|
'title' => '',
|
|
'jumlah_kolom' => count($pilih_tabel),
|
|
'nama_tabel' => $pilih_tabel,
|
|
'persediaan' => $persediaan,
|
|
'tgl' => $tgl,
|
|
'gudang' => $gudang,
|
|
];
|
|
$this->load->view('cetak/excel_stokOpname', $data);
|
|
}
|
|
}
|