1437 lines
42 KiB
PHP
1437 lines
42 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 ManagePenjualanST extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelPenjualan', 'Penjualan');
|
|
$this->load->model('ModelBarang', 'Barang');
|
|
$this->load->model('ModelNeraca', 'Neraca');
|
|
$this->load->model('ModelProcessor', 'Processor');
|
|
$this->load->model('ModelRam', 'Ram');
|
|
$this->load->model('ModelSsd', 'Ssd');
|
|
$this->load->model('ModelHdd', 'Hdd');
|
|
$this->load->model('ModelLain', 'Lain');
|
|
$this->load->library(['datatables', 'form_validation']);
|
|
$this->form_validation->set_error_delimiters('', '');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
|
|
public function index() {
|
|
$datPenjualan = $this->Penjualan->getDataPenjualanST();
|
|
|
|
$data = [
|
|
'sidebar' => "menu penjualan",
|
|
'navChild' => "",
|
|
'penjualan' => $datPenjualan,
|
|
];
|
|
|
|
$this->load->view('proses/PenjualanST', $data);
|
|
}
|
|
|
|
public function dataPesanan($id) {
|
|
$pesanan = $this->Penjualan->getData_DaftarJual_byPENJUALAN($id);
|
|
$title = $this->Penjualan->getTitlePesanan($id);
|
|
$data = [
|
|
'sidebar' => "menu penjualan",
|
|
'navChild' => "",
|
|
'pesanan' => $pesanan,
|
|
'id_penjualan' => $id,
|
|
'title' => $title[0]['KODE_PENJUALAN'],
|
|
];
|
|
|
|
$this->load->view('proses/PenjualanBarang', $data);
|
|
}
|
|
|
|
public function dataStockSn($id) {
|
|
$pesanan = $this->Penjualan->getDataPotongSn($id);
|
|
$qty = $this->Penjualan->getMaxQtyPotong($id);
|
|
$qty_real = $this->Penjualan->getMaxQtyBarang();
|
|
|
|
$id_barang = $pesanan[0]['ID_BARANG'];
|
|
$dataSnBelum = $this->Penjualan->getDataSnBelum($id_barang);
|
|
$dataSnSudah = $this->Penjualan->getDataSnSudah($id);
|
|
|
|
$data = [
|
|
'sidebar' => "menu penjualan",
|
|
'navChild' => "",
|
|
'pesanan' => $pesanan,
|
|
'id_dj' => $id,
|
|
'id_barang' => $id_barang,
|
|
'qty' => $qty,
|
|
'qty_real' => $qty_real,
|
|
'title1' => $pesanan[0]['KODE_PENJUALAN'],
|
|
'title2' => $pesanan[0]['NAMA_BARANG'],
|
|
'qty_dj' => $pesanan[0]['QTY_DJ'],
|
|
'id_penjualan' => $pesanan[0]['ID_PENJUALAN'],
|
|
'dataSn1' => $dataSnSudah,
|
|
'dataSn2' => $dataSnBelum,
|
|
];
|
|
|
|
$this->load->view('proses/PenjualanSN', $data);
|
|
}
|
|
|
|
public function datasn() {
|
|
$id = $this->input->post('id');
|
|
$data = $this->Penjualan->getDataSn($id);
|
|
$this->output_json(['value' => 1, 'total' => sizeof($data), 'data' => $data]);
|
|
}
|
|
|
|
public function jumlahdatasn() {
|
|
$id = $this->input->post('id');
|
|
$data = $this->Penjualan->getDataSn($id);
|
|
$this->output_json(['value' => 1, 'jumlah_data' => sizeof($data)]);
|
|
}
|
|
|
|
public function potongsn() {
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$nama_sn = $this->input->post('nama_sn');
|
|
$nama_sn = strtoupper($nama_sn);
|
|
|
|
$dataSn = $this->Penjualan->getDataSnBarang($id_barang);
|
|
foreach ($dataSn as $key) {
|
|
if ($nama_sn==$key['NAMA_SN']) {
|
|
$id_sn = $key['ID_SN'];
|
|
$data = [
|
|
'STATUS_SN' => '0',
|
|
'DJ_ID' => $id_dj
|
|
];
|
|
$action = $this->Penjualan->update('sn', $data, 'ID_SN', $id_sn);
|
|
}
|
|
}
|
|
|
|
$daftar_jual = $this->Penjualan->getDataPotongSn($id_dj);
|
|
$qtyDj = $daftar_jual[0]['QTY_DJ'];
|
|
|
|
$qtyReal = $this->Penjualan->getMaxQtyPotong($id_dj);
|
|
if ($qtyReal==$qtyDj){
|
|
$this->output_json(['value' => 2, 'nama_sn' => $nama_sn]);
|
|
$this->session->set_flashdata('flashkunci', 'dikunci');
|
|
} else if ($action){
|
|
$this->output_json(['value' => 1, 'nama_sn' => $nama_sn]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'nama_sn' => $nama_sn]);
|
|
$this->session->set_flashdata('flashgagal', 'dikunci');
|
|
}
|
|
}
|
|
|
|
public function resetsn() {
|
|
$id = $this->input->post('id_sn');
|
|
$dataDj = $this->Penjualan->getDataSnDj($id);
|
|
$id_dj = $dataDj[0]['DJ_ID'];
|
|
$qty_dj = $dataDj[0]['QTY_DJ'];
|
|
|
|
$data = [
|
|
'STATUS_SN' => NULL,
|
|
'DJ_ID' => NULL
|
|
];
|
|
$action = $this->Penjualan->update('sn', $data, 'ID_SN', $id);
|
|
|
|
$qtyReal = $this->Penjualan->getMaxQtyPotong($id_dj);
|
|
if ($qtyReal+1==$qty_dj){
|
|
$this->output_json(['value' => 2, 'message' => 'Berhasil', 'dt' => $action]);
|
|
$this->session->set_flashdata('flashkurang', 'dikunci');
|
|
} else if ($action) {
|
|
$this->output_json(['value' => 1, 'message' => 'Berhasil', 'dt' => $action]);
|
|
} else {
|
|
$this->output_json(['value' => 0, 'message' => "gagal", 'dt' => $action]);
|
|
}
|
|
}
|
|
|
|
public function kodeDetailKm() {
|
|
$kk = $this->Penjualan->getKodeDetailKm();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KM/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 3, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 9 - strlen($str);
|
|
$data = "KM/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataStockKeluar($id) {
|
|
$pesanan = $this->Penjualan->getPenjualanStockKeluar($id);
|
|
$title = $this->Penjualan->getTitleKeluarMasuk($id);
|
|
$barang = $this->Barang->getBarangKeluarMasuk();
|
|
$cabutan = $this->Barang->getBarangCabutan();
|
|
|
|
$data = [
|
|
'sidebar' => "menu penjualan",
|
|
'navChild' => "",
|
|
'pesanan' => $pesanan,
|
|
'id_dj' => $id,
|
|
'barang' => $barang,
|
|
'cabutan' => $cabutan,
|
|
'id_penjualan' => $title[0]['PENJUALAN_ID'],
|
|
'ket_dj' => $title[0]['KET_DJ'],
|
|
];
|
|
|
|
$this->load->view('proses/PenjualanGudangKeluar', $data);
|
|
}
|
|
|
|
public function savekeluar() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_barang = $this->input->post('id_barang');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$kode_km = $this->kodeDetailKm();
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
$kuantiti = $this->Penjualan->getKuantitiBarang($id_barang);
|
|
$id_kuantiti = $kuantiti[0]['ID_KUANTITI'];
|
|
$pcm_kuantiti = $kuantiti[0]['PCM_KUANTITI'];
|
|
$proses_kuantiti = $kuantiti[0]['PROSES_KUANTITI'];
|
|
|
|
if ($qty_km>$pcm_kuantiti) {
|
|
$this->session->set_flashdata('flashkuantiti', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$temp = $proses_kuantiti+$qty_km;
|
|
$pcm = $pcm_kuantiti-$qty_km;
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '0',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
];
|
|
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
$update = [
|
|
'PROSES_KUANTITI' => $temp,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
|
|
$action = $this->Penjualan->update('kuantiti', $update, 'ID_KUANTITI', $id_kuantiti);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapuskeluar() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
|
|
$detail_km = $this->Penjualan->getDataDetailKm($id_km);
|
|
$id_barang = $detail_km[0]['BARANG_ID'];
|
|
$qty_km = $detail_km[0]['QTY_KM'];
|
|
|
|
$kuantiti = $this->Penjualan->getKuantitiBarang($id_barang);
|
|
$id_kuantiti = $kuantiti[0]['ID_KUANTITI'];
|
|
$pcm_kuantiti = $kuantiti[0]['PCM_KUANTITI'];
|
|
$proses_kuantiti = $kuantiti[0]['PROSES_KUANTITI'];
|
|
|
|
$temp = $proses_kuantiti-$qty_km;
|
|
$pcm = $pcm_kuantiti+$qty_km;
|
|
|
|
$update = [
|
|
'PROSES_KUANTITI' => $temp,
|
|
'PCM_KUANTITI' => $pcm
|
|
];
|
|
|
|
$action = $this->Penjualan->update('kuantiti', $update, 'ID_KUANTITI', $id_kuantiti);
|
|
|
|
$action = $this->Penjualan->delete('detail_km', $id_km ,'ID_KM');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function kodeStockKuantiti() {
|
|
$kk = $this->Penjualan->getKodeStockKuantiti();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "STQ/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 = "STQ/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function kodeStockSn() {
|
|
$kk = $this->Penjualan->getKodeStockSn();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "STSN/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 5, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 11 - strlen($str);
|
|
$data = "STSN/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function dataStockMasuk($id) {
|
|
$pesanan = $this->Penjualan->getPenjualanStockMasuk($id);
|
|
$title = $this->Penjualan->getTitleKeluarMasuk($id);
|
|
$sn = $this->Penjualan->getDataSnCabut($id);
|
|
$processor = $this->Processor->getDataProcessor();
|
|
$ram = $this->Ram->getDataRam();
|
|
$ssd = $this->Ssd->getDataSsd();
|
|
$hdd = $this->Hdd->getDataHdd();
|
|
$lain = $this->Lain->getDataLain();
|
|
|
|
$data = [
|
|
'sidebar' => "menu penjualan",
|
|
'navChild' => "",
|
|
'pesanan' => $pesanan,
|
|
'id_dj' => $id,
|
|
'sn' => $sn,
|
|
'id_penjualan' => $title[0]['PENJUALAN_ID'],
|
|
'ket_dj' => $title[0]['KET_DJ'],
|
|
'idkm' => $title[0]['ID_KM'],
|
|
'processor' => $processor,
|
|
'ram' => $ram,
|
|
'ssd' => $ssd,
|
|
'hdd' => $hdd,
|
|
'lain' => $lain,
|
|
];
|
|
|
|
$this->load->view('proses/PenjualanGudangMasuk', $data);
|
|
}
|
|
|
|
public function savemasuk() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_processor = $this->input->post('id_processor');
|
|
$id_ram = $this->input->post('id_ram');
|
|
$id_ssd = $this->input->post('id_ssd');
|
|
$id_hdd = $this->input->post('id_hdd');
|
|
$id_lain = $this->input->post('id_lain');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km1 = $this->input->post('qty_km1');
|
|
$qty_km2 = $this->input->post('qty_km2');
|
|
$qty_km3 = $this->input->post('qty_km3');
|
|
$qty_km4 = $this->input->post('qty_km4');
|
|
$qty_km5 = $this->input->post('qty_km5');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($id_processor!=NULL) {
|
|
if ($qty_km1=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($id_ram!=NULL) {
|
|
if ($qty_km2=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($id_ssd!=NULL) {
|
|
if ($qty_km3=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($id_hdd!=NULL) {
|
|
if ($qty_km4=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($id_lain!=NULL) {
|
|
if ($qty_km5=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
if ($qty_km1>4 OR $qty_km2>24 OR $qty_km3>12 OR $qty_km4>12 OR $qty_km5>4) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($id_processor==0 AND $id_ram==0 AND $id_ssd==0 AND $id_hdd==0 AND $id_lain==0) {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($qty_km1==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km2==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km3==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km4==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km5==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_processor!=0 OR $id_processor!="") {
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/PROC";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataProcessor = $this->Processor->getDataProcessor($id_processor);
|
|
$nama_barang = $dataProcessor[0]['NAMA_PROCESSOR'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km1,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km1,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km1,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
}
|
|
|
|
if ($id_ram!=0 OR $id_ram!="") {
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/RAM";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataRam = $this->Ram->getDataRam($id_ram);
|
|
$nama_barang = $dataRam[0]['NAMA_RAM'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km2,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km2,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km2,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
}
|
|
|
|
if ($id_ssd!=0 OR $id_ssd!="") {
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/SSD";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataSsd = $this->Ssd->getDataSsd($id_ssd);
|
|
$nama_barang = $dataSsd[0]['NAMA_SSD'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km3,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km3,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km3,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
}
|
|
|
|
if ($id_hdd!=0 OR $id_hdd!="") {
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/HDD";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataHdd = $this->Hdd->getDataHdd($id_hhd);
|
|
$nama_barang = $dataHdd[0]['NAMA_HDD'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km4,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km4,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km4,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
}
|
|
|
|
if ($id_lain!=0 OR $id_lain!="") {
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/LAIN$id_lain";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataLain = $this->Lain->getDataLain($id_lain);
|
|
$nama_barang = $dataLain[0]['NAMA_LAIN'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km5,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km5,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km5,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function savemasukp() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_processor = $this->input->post('id_processor');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($qty_km>4) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_processor==0 OR $id_processor=="") {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/PROC";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataProcessor = $this->Processor->getDataProcessor($id_processor);
|
|
$nama_barang = $dataProcessor[0]['NAMA_PROCESSOR'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function savemasukr() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_ram = $this->input->post('id_ram');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($qty_km>24) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_ram==0 OR $id_ram=="") {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/RAM";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataRam = $this->Ram->getDataRam($id_ram);
|
|
$nama_barang = $dataRam[0]['NAMA_RAM'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function savemasuks() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_ssd = $this->input->post('id_ssd');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($qty_km>12) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_ssd==0 OR $id_ssd=="") {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/SSD";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataSsd = $this->Ssd->getDataSsd($id_ssd);
|
|
$nama_barang = $dataSsd[0]['NAMA_SSD'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function savemasukh() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_hdd = $this->input->post('id_hdd');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($qty_km>12) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_hdd==0 OR $id_hdd=="") {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/HDD";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataHdd = $this->Hdd->getDataHdd($id_hdd);
|
|
$nama_barang = $dataHdd[0]['NAMA_HDD'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function savemasukl() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id');
|
|
$id_dj = $this->input->post('id_dj');
|
|
$id_lain = $this->input->post('id_lain');
|
|
$id_sn = $this->input->post('id_sn');
|
|
$qty_km = $this->input->post('qty_km');
|
|
$tgl_km = date('m/d/Y');
|
|
|
|
if ($qty_km>4) {
|
|
$this->session->set_flashdata('flashlimit', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km=="") {
|
|
$this->session->set_flashdata('flashkosong', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else if ($qty_km==0) {
|
|
$this->session->set_flashdata('flashzero', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
if ($id_lain==0 OR $id_lain=="") {
|
|
$this->session->set_flashdata('flashnone', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$dataSn = $this->Penjualan->getNama_Sn($id_sn);
|
|
$nama_sn = $dataSn[0]['NAMA_SN'];
|
|
$kode_barang = "CAB/$nama_sn/LAIN$id_lain";
|
|
|
|
$stockMasuk = $this->Penjualan->getPenjualanStockMasuk($id_dj);
|
|
foreach ($stockMasuk as $key) {
|
|
$dataKm = $this->Penjualan->getDataDetailKm($key['ID_KM']);
|
|
$barangID = $dataKm[0]['BARANG_ID'];
|
|
$dataBarang = $this->Penjualan->getDataBarang($barangID);
|
|
$kodeBarang = $dataBarang[0]['KODE_BARANG'];
|
|
if ($kodeBarang==$kode_barang) {
|
|
$this->session->set_flashdata('flashkembar', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
$dataLain = $this->Lain->getDataLain($id_lain);
|
|
$nama_barang = $dataLain[0]['NAMA_LAIN'];
|
|
|
|
$input = [
|
|
'KODE_BARANG' => $kode_barang,
|
|
'NAMA_BARANG' => $nama_barang,
|
|
'JENIS_ID' => '6'
|
|
];
|
|
$action = $this->Penjualan->create('barang', $input);
|
|
|
|
$kode_km = $this->kodeDetailKm();
|
|
$id_barang = $this->Penjualan->getID_Barang();
|
|
$id_barang = $id_barang[0]['ID_BARANG'];
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'GLOBAL_KUANTITI' => $qty_km,
|
|
'PROSES_KUANTITI' => '0',
|
|
'PCM_KUANTITI' => $qty_km,
|
|
'CABUTAN_KUANTITI' => '0',
|
|
'PEMINJAMAN_KUANTITI' => '0',
|
|
'PENDING_KUANTITI' => '0',
|
|
'KONSINYASI_KUANTITI' => '0',
|
|
'SEWA_KUANTITI' => '0',
|
|
'SERVICE_KUANTITI' => '0',
|
|
'THR_KUANTITI' => '0',
|
|
'ITC_KUANTITI' => '0'
|
|
];
|
|
$action = $this->Penjualan->create('kuantiti', $input);
|
|
|
|
$input = [
|
|
'BARANG_ID' => $id_barang,
|
|
'AVG_DH' => '0',
|
|
'DEALER_DH' => '0',
|
|
'USER_DH' => '0'
|
|
];
|
|
|
|
$action = $this->Penjualan->create('daftar_harga', $input);
|
|
|
|
$input = [
|
|
'DJ_ID' => $id_dj,
|
|
'JENIS_KM' => '1',
|
|
'BARANG_ID' => $id_barang,
|
|
'KODE_KM' => $kode_km,
|
|
'QTY_KM' => $qty_km,
|
|
'TGL_KM' => $tgl_km,
|
|
'SN_ID' => $id_sn
|
|
];
|
|
$action = $this->Penjualan->create('detail_km', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapusmasuk() {
|
|
$method = $this->input->post('method');
|
|
$id_km = $this->input->post('id_km');
|
|
|
|
$detail_km = $this->Penjualan->getDataDetailKm($id_km);
|
|
$id_barang = $detail_km[0]['BARANG_ID'];
|
|
|
|
$action = $this->Penjualan->delete('barang', $id_barang ,'ID_BARANG');
|
|
$action = $this->Penjualan->delete('kuantiti', $id_barang ,'BARANG_ID');
|
|
$action = $this->Penjualan->delete('daftar_harga', $id_barang ,'BARANG_ID');
|
|
$action = $this->Penjualan->delete('detail_km', $id_km ,'ID_KM');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function konfirmasi() {
|
|
$method = $this->input->post('method');
|
|
$id_penjualan = $this->input->post('id_penjualan');
|
|
|
|
$dataDj = $this->Penjualan->getPenjualanPesanan($id_penjualan);
|
|
foreach ($dataDj as $key) {
|
|
$type_jenis = $key['TYPE_JENIS'];
|
|
if ($type_jenis=="1") {
|
|
$qtyReal = $this->Penjualan->getQtyReal($key['ID_DJ']);
|
|
$qtyDj = $key['QTY_DJ'];
|
|
if ($qtyReal<$qtyDj) {
|
|
$this->session->set_flashdata('flashsn', 'diproses');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($dataDj as $key) {
|
|
$type_jenis = $key['TYPE_JENIS'];
|
|
if ($type_jenis=="1") {
|
|
$sn = $this->Penjualan->getDataSn($key['ID_DJ']);
|
|
foreach ($sn as $dat) {
|
|
$kode_stsn = $this->kodeStockSn();
|
|
$input = [
|
|
'KODE_STSN' => $kode_stsn,
|
|
'KODE_BUKTI' => $key['KODE_PENJUALAN'],
|
|
'TGL_STSN' => $key['TGL_PENJUALAN'],
|
|
'BARANG_ID' => $key['BID'],
|
|
'PELANGGAN_ID' => $key['PELANGGAN_ID'],
|
|
'SN_ID' => $dat['ID_SN']
|
|
];
|
|
$action = $this->Penjualan->create('stock_sn', $input);
|
|
$update = [
|
|
'STATUS_SN' => '1'
|
|
];
|
|
$action = $this->Penjualan->update('sn', $update, 'ID_SN', $dat['ID_SN']);
|
|
}
|
|
}
|
|
$dataKuantiti = $this->Penjualan->getKuantitiBarang($key['BID']);
|
|
$id_kuantiti = $dataKuantiti[0]['ID_KUANTITI'];
|
|
$global_kuantiti = $dataKuantiti[0]['GLOBAL_KUANTITI'];
|
|
$proses_kuantiti = $dataKuantiti[0]['PROSES_KUANTITI'];
|
|
$global = $global_kuantiti-$key['QTY_DJ'];
|
|
$proses = $proses_kuantiti-$key['QTY_DJ'];
|
|
$kode_stq = $this->kodeStockKuantiti();
|
|
$input = [
|
|
'KODE_STQ' => $kode_stq,
|
|
'KODE_BUKTI' => $key['KODE_PENJUALAN'],
|
|
'TGL_STQ' => $key['TGL_PENJUALAN'],
|
|
'BARANG_ID' => $key['BID'],
|
|
'QTY_BEFORE' => $global_kuantiti,
|
|
'QTY_IN' => '0',
|
|
'QTY_OUT' => $key['QTY_DJ'],
|
|
'QTY_AFTER' => $global
|
|
];
|
|
$action = $this->Penjualan->create('stock_kuantiti', $input);
|
|
$update = [
|
|
'GLOBAL_KUANTITI' => $global,
|
|
'PROSES_KUANTITI' => $proses,
|
|
];
|
|
$action = $this->Penjualan->update('kuantiti', $update, 'ID_KUANTITI', $id_kuantiti);
|
|
}
|
|
|
|
$penjualan = $this->Penjualan->getPenjualanStock($id_penjualan);
|
|
foreach ($penjualan as $key) {
|
|
if ($key['JENIS_KM']=="1") {
|
|
$kode_stq = $this->kodeStockKuantiti();
|
|
$input = [
|
|
'KODE_STQ' => $kode_stq,
|
|
'KODE_BUKTI' => $key['KODE_KM'],
|
|
'TGL_STQ' => $key['TGL_KM'],
|
|
'BARANG_ID' => $key['BKM'],
|
|
'QTY_BEFORE' => '0',
|
|
'QTY_IN' => $key['QTY_KM'],
|
|
'QTY_OUT' => '0',
|
|
'QTY_AFTER' => $key['QTY_KM']
|
|
];
|
|
$action = $this->Penjualan->create('stock_kuantiti', $input);
|
|
} else if ($key['JENIS_KM']=="0") {
|
|
$kuantiti = $this->Penjualan->getKuantitiBarang($key['BKM']);
|
|
$id_kuantiti = $kuantiti[0]['ID_KUANTITI'];
|
|
$global_kuantiti = $kuantiti[0]['GLOBAL_KUANTITI'];
|
|
$qty = $global_kuantiti-$key['QTY_KM'];
|
|
$kode_stq = $this->kodeStockKuantiti();
|
|
$input = [
|
|
'KODE_STQ' => $kode_stq,
|
|
'KODE_BUKTI' => $key['KODE_KM'],
|
|
'TGL_STQ' => $key['TGL_KM'],
|
|
'BARANG_ID' => $key['BKM'],
|
|
'QTY_BEFORE' => $global_kuantiti,
|
|
'QTY_IN' => '0',
|
|
'QTY_OUT' => $key['QTY_KM'],
|
|
'QTY_AFTER' => $qty
|
|
];
|
|
$action = $this->Penjualan->create('stock_kuantiti', $input);
|
|
}
|
|
}
|
|
|
|
$totalSn = $this->Penjualan->getPenjualanKeluarMasuk($id_penjualan);
|
|
foreach ($totalSn as $key) {
|
|
$datSn = $this->Penjualan->getDataSnDj($key['ID_SN']);
|
|
$status_sn = $datSn[0]['STATUS_SN'];
|
|
if ($status_sn!="1") {
|
|
$update = [
|
|
'STATUS_SN' => '2'
|
|
];
|
|
$action = $this->Penjualan->update('sn', $update, 'ID_SN', $key['ID_SN']);
|
|
}
|
|
}
|
|
|
|
$update = [
|
|
'STATUS_PENJUALAN' => '1'
|
|
];
|
|
|
|
$action = $this->Penjualan->update('penjualan', $update, 'ID_PENJUALAN', $id_penjualan);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diproses');
|
|
redirect('ManagePenjualanST');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diproses');
|
|
redirect('ManagePenjualanST');
|
|
}
|
|
|
|
}
|
|
|
|
}
|