134 lines
3.1 KiB
PHP
134 lines
3.1 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageSn extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelSn', 'MS');
|
|
$this->load->model('ModelBeli', 'MBeli');
|
|
$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()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
$jabatan = $this->session->userdata('jabatan');
|
|
if ($username == null) {
|
|
redirect("Action");
|
|
} elseif ($jabatan != "ADMIN") {
|
|
redirect("Action");
|
|
}
|
|
|
|
$datSn = $this->MS->getDataSn();
|
|
|
|
$data = [
|
|
'sidebar' => "data proses sn",
|
|
'navChild' => "data proses barangsn",
|
|
'sn' => $datSn
|
|
];
|
|
|
|
$this->load->view('master/Sn', $data);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
if ($username == null) {
|
|
redirect("Login");
|
|
}
|
|
$datSn = $this->MS->getDataSn();
|
|
$datBeli = $this->MBeli->getDataBeliSn();
|
|
$data = [
|
|
'sidebar' => "data proses sn",
|
|
'navChild' => "data proses barangsn",
|
|
'sn' => $datSn,
|
|
'beli' => $datBeli
|
|
];
|
|
$this->load->view('proses/TambahSn', $data);
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
$action1 = $this->MS->delete('sn', $id, 'ID_SN');
|
|
$action2 = $this->MS->delete('inventorysn', $id, 'ID_INVENTORYSN');
|
|
|
|
if ($action1) {
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageSn');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dihapus');
|
|
redirect('ManageSn');
|
|
}
|
|
|
|
}
|
|
|
|
public function sn()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
$jabatan = $this->session->userdata('jabatan');
|
|
if ($username == null) {
|
|
redirect("Login");
|
|
} elseif ($jabatan != "ADMIN") {
|
|
redirect("Login");
|
|
}
|
|
|
|
$beli = $this->MS->getBeli();
|
|
|
|
$data = [
|
|
'sidebar' => "data proses sn",
|
|
'navChild' => "data proses barangsn",
|
|
'sn' => $beli
|
|
];
|
|
|
|
$this->load->view('master/Sn', $data);
|
|
}
|
|
|
|
public function getsn($id)
|
|
{
|
|
$sn = $this->MS->getSnn($id);
|
|
$this->output_json(['sn' => $sn]);
|
|
}
|
|
|
|
public function ambildatasn($id = null)
|
|
{
|
|
if ($id != null) {
|
|
$sn = $this->MS->getSnn($id);
|
|
$data = ['beli' => $id, 'sn' => $sn];
|
|
$this->load->view('proses/ambildatasn', $data);
|
|
} else {
|
|
$data = ['beli' => null, 'sn' => []];
|
|
$this->load->view('proses/ambildatasn', $data);
|
|
}
|
|
}
|
|
|
|
public function tambahsn($beli, $sn)
|
|
{
|
|
|
|
$datID = $this->MS->getIDBarang($beli);
|
|
if (is_array($datID)||is_object($$datID)) {
|
|
$input = [
|
|
'NAMA_SN' => $sn,
|
|
'BELI_ID' => $beli,
|
|
'BARANG_ID' => $datID[0]['BARANG_ID']
|
|
];
|
|
$input2 = [
|
|
'NAMA_INVENTORYSN' => $sn,
|
|
'BARANG_ID' => $datID[0]['BARANG_ID'],
|
|
'GUDANG_ID' => '1'
|
|
];
|
|
$action = $this->MS->create('sn', $input);
|
|
$action2 = $this->MS->create('inventorysn', $input2);
|
|
$this->output_json(['value' => "berhasil"]);
|
|
}
|
|
}
|
|
|
|
}
|