Files
shopee-apps/application/views/proses/MD_MasterBarang.php
T
2026-06-13 16:02:07 +10:00

892 lines
36 KiB
PHP

<!doctype html>
<html class="fixed sidebar-left-collapsed">
<head>
<!-- Basic -->
<meta charset="UTF-8">
<title>MASTER DATA</title>
<meta name="keywords" content="HTML5 Admin Template" />
<meta name="description" content="Porto Admin - Responsive HTML5 Template">
<meta name="author" content="okler.net">
<!-- Mobile Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Vendor CSS -->
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/magnific-popup/magnific-popup.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap-datepicker/css/datepicker3.css" />
<!-- Specific Page Vendor CSS -->
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/select2/select2.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/pnotify/pnotify.custom.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css" />
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/vendor/base/jquery-ui.css" />
<!-- Theme CSS -->
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/theme.css" />
<!-- Skin CSS -->
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/skins/default.css" />
<!-- Theme Custom CSS -->
<link rel="stylesheet" href="<?php echo base_url('') ?>assets/stylesheets/theme-custom.css">
<!-- Head Libs -->
<script src="<?php echo base_url('') ?>assets/vendor/modernizr/modernizr.js"></script>
</head>
<script src="<?= base_url() ?>assets/bower_components/jquery/jquery-3.3.1.min.js"></script>
<script src="<?= base_url() ?>assets/bower_components/sweetalert2/sweetalert2.all.min.js"></script>
<style>
.ui-front {
z-index: 9999;
}
.bordergoldall {
border-left-style: solid;
border-right-style: solid;
border-top-style: solid;
border-bottom-style: solid;
border-width: 5px;
border-color: gold;
}
.borderorangeall {
border-left-style: solid;
border-right-style: solid;
border-top-style: solid;
border-bottom-style: solid;
border-width: 5px;
border-color: orange;
}
.f18 {
font-size: 18px;
}
</style>
<script type="text/javascript">
let base_url = '<?= base_url() ?>';
</script>
<body>
<section class="body">
<!-- start: header -->
<?php $this->load->view('template/header'); ?>
<!-- end: header -->
<div class="inner-wrapper">
<!-- start: sidebar -->
<?php $this->load->view('template/sidebar'); ?>
<!-- end: sidebar -->
<section role="main" class="content-body">
<?php
$id_karyawan = $this->session->userdata('id_karyawan');
$nama_panggilan = $this->session->userdata('nama_panggilan');
$username = $this->session->userdata('username');
$tgl_now = date('d/m/Y');
?>
<header class="page-header">
<h2><b>Data Master Barang | </b><b style="color:LightGreen">[<?=$tampil?>]</b></h2>
</header>
<!-- start: page -->
<section class="panel panel-featured panel-featured-dark">
<header class="panel-heading">
<div class="panel-actions">
<a data-toggle="modal" data-target="#modalFitur" style="color:Coral"><b>Fitur </b><i class="fa fa-question-circle"></i></a>&nbsp&nbsp
<a onclick="tutupTab()"><b style="color:Black">Tutup <i class="fa fa-times"></i></b></a>
</div>
<h2 class="panel-title"><b style="color:Olive">DATA BARANG</b></h2>
</header>
<div class="panel-body">
<div class="panel-group" id="accordion">
<div class="panel panel-accordion">
<header class="panel-heading">
<h2 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" <?php if ($hak>=2) { ?>href="#collapseOne" onclick="setBersih()"<?php } ?>>
<b class="f18" style="color:DarkGreen"><b style="color:Black">[1]</b> DATA BARU <?php if ($hak<=1) { ?><i class="fa fa-ban text-danger"></i><?php } ?></b>
</a>
</h2>
</header>
<div id="collapseOne" class="accordion-body collapse">
<div class="panel-body">
<div class="form-group bordergoldall">
<h4><div class="col-md-12">
<b style="color:DarkCyan"><i>Note : [Warna Merah harus diisi.]</i></b>
</div></h4>
<br><br>
<h4><div class="col-md-2"><b style="color:Red">Kode</b></div></h4>
<div class="col-md-4">
<textarea type="text" id="kode_barangnew" rows="3" cols="3" class="form-control" autocomplete="off" style="text-transform:uppercase" data-plugin-maxlength maxlength="30" placeholder="Kode Barang"></textarea>
<small class="help-block"></small>
</div>
<h4><div class="col-md-2"><b style="color:Red">Nama</b></div></h4>
<div class="col-md-4">
<textarea type="text" id="nama_barangnew" rows="3" cols="3" class="form-control" autocomplete="off" data-plugin-maxlength maxlength="80" placeholder="Nama Barang"></textarea>
<small class="help-block"></small>
</div>
<h4><div class="col-md-2"><b style="color:Red">Jenis</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_jenisnew" class="form-control populate">
<option value="" selected>Pilih Jenis</option>
<?php if (is_array($jenis) || is_object($jenis)) {
foreach ($jenis as $key) { ?>
<?php if ($key['TYPE_JENIS']==0) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-SN)</option>
<?php } else if ($key['TYPE_JENIS']==1) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (SN)</option>
<?php } else if ($key['TYPE_JENIS']==2) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-QTY)</option>
<?php } ?>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Merk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_merknew" class="form-control populate">
<?php if (is_array($merk) || is_object($merk)) {
foreach ($merk as $key) { ?>
<option value="<?= $key['ID_MERK'] ?>" ><?= $key['NAMA_MERK'] ?></option>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Model</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_modelnew" class="form-control populate">
<?php if (is_array($model) || is_object($model)) {
foreach ($model as $key) { ?>
<option value="<?= $key['ID_MODEL'] ?>" ><?= $key['NAMA_MODEL'] ?></option>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Produk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_produknew" class="form-control populate">
<?php if (is_array($produk) || is_object($produk)) {
foreach ($produk as $key) { ?>
<?php if ($key['ID_PRODUK']==0) { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?> [Dikosongi]</option>
<?php } else { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?></option>
<?php } ?>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Garansi</b></div></h4>
<div class="col-md-4">
<input type="number" id="garansi_barangnew" onchange="cekNilai(1)" class="form-control" autocomplete="off" placeholder="Garansi Barang" required>
<small class="help-block"></small>
</div>
<div class="col-md-12 text-right">
<button type="button" class="btn btn-success" onclick="tambahData()"><b>Tambah Data</b> <i class="fa fa-plus"></i></button>
<small class="help-block"></small>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-accordion">
<header class="panel-heading">
<h2 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" <?php if ($hak>0) { ?>href="#collapseTwo" onclick="setBersih()"<?php } ?>>
<b class="f18" style="color:DarkGreen"><b style="color:Black">[2]</b> CARI DATA <i style="color:Brown">(Ubah/Hapus)</i> <?php if ($hak==0) { ?><i class="fa fa-ban text-danger"></i><?php } ?></b>
</a>
</h2>
</header>
<div id="collapseTwo" class="accordion-body collapse">
<div class="panel-body">
<div class="form-group">
<h4><div class="col-md-2"><b style="color:SlateBlue">Pilih Data</b></div></h4>
<input type="hidden" id="id_barangLihat" class="form-control">
<div class="col-md-6">
<div class="input-group">
<input autocomplete="off" style="background:lightgrey;" type="text" id="kode_barangTemp" class="form-control" placeholder="Klik pada Icon" required>
<span class="input-group-addon" data-toggle="modal" data-target="#modalAmbilBarang" onclick="isiMasterBarang()"><i class="fa fa-cube text-danger"></i></span>
</div>
<small class="help-block"></small>
</div>
</div>
<div class="form-group borderorangeall" id="detailData" hidden="hidden">
<h4><div class="col-md-12">
<b style="color:DarkOrchid"><i>Note : [Semua Perubahan akan Otomatis tersimpan.]</i></b><br>
<b style="color:DarkCyan"><i>Note : [Warna Merah harus diisi.]</i></b>
</div></h4>
<br><br>
<input type="hidden" id="kode_barangTemp" class="form-control">
<input type="hidden" id="nama_barangTemp" class="form-control">
<input type="hidden" id="garansi_barangTemp" class="form-control">
<input type="hidden" id="id_jenisTemp" class="form-control">
<h4><div class="col-md-2"><b style="color:Red">Kode</b></div></h4>
<div class="col-md-4">
<textarea type="text" id="kode_baranged" rows="3" cols="3" <?php if ($hak>=1) { ?>onchange="ubahData(1)"<?php } ?> class="form-control" autocomplete="off" style="text-transform:uppercase" data-plugin-maxlength maxlength="30" placeholder="Kode Barang"></textarea>
<small class="help-block"></small>
</div>
<h4><div class="col-md-2"><b style="color:Red">Nama</b></div></h4>
<div class="col-md-4">
<textarea type="text" id="nama_baranged" rows="3" cols="3" <?php if ($hak>=1) { ?>onchange="ubahData(2)"<?php } ?> class="form-control" autocomplete="off" data-plugin-maxlength maxlength="80" placeholder="Nama Barang"></textarea>
<small class="help-block"></small>
</div>
<h4><div class="col-md-2"><b style="color:Red">Jenis</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_jenised" <?php if ($hak>=1) { ?>onchange="ubahData(3)"<?php } ?> class="form-control populate">
<?php if (is_array($jenis) || is_object($jenis)) {
foreach ($jenis as $key) { ?>
<?php if ($key['TYPE_JENIS']==0) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-SN)</option>
<?php } else if ($key['TYPE_JENIS']==1) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (SN)</option>
<?php } else if ($key['TYPE_JENIS']==2) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-QTY)</option>
<?php } ?>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Merk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_merked" <?php if ($hak>=1) { ?>onchange="ubahData(4)"<?php } ?> class="form-control populate">
<?php if (is_array($merk) || is_object($merk)) {
foreach ($merk as $key) { ?>
<option value="<?= $key['ID_MERK'] ?>" ><?= $key['NAMA_MERK'] ?></option>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Model</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_modeled" <?php if ($hak>=1) { ?>onchange="ubahData(5)"<?php } ?> class="form-control populate">
<?php if (is_array($model) || is_object($model)) {
foreach ($model as $key) { ?>
<option value="<?= $key['ID_MODEL'] ?>" ><?= $key['NAMA_MODEL'] ?></option>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Produk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_produked" <?php if ($hak>=1) { ?>onchange="ubahData(6)"<?php } ?> class="form-control populate">
<?php if (is_array($produk) || is_object($produk)) {
foreach ($produk as $key) { ?>
<?php if ($key['ID_PRODUK']==0) { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?> [Dikosongi]</option>
<?php } else { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?></option>
<?php } ?>
<?php }
} ?>
</select>
<small class="help-block"></small>
</div>
</div>
<h4><div class="col-md-2"><b style="color:Red">Garansi</b></div></h4>
<div class="col-md-4">
<input type="number" id="garansi_baranged" class="form-control" <?php if ($hak>=1) { ?>onchange="ubahData(7)"<?php } ?> autocomplete="off" placeholder="Garansi Barang" required>
<small class="help-block"></small>
</div>
<div class="col-md-12 text-right" id="buttonDelete" hidden="hidden">
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#modalHapus" onclick="hapusData()"><b>Hapus Data</b> <i class="fa fa-minus"></i></button>
<small class="help-block"></small>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-accordion">
<header class="panel-heading">
<h2 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" <?php if ($hak>0) { ?>href="#collapseThree" onclick="setBersih()"<?php } ?>>
<b class="f18" style="color:DarkGreen"><b style="color:Black">[3]</b> CETAK DATA <?php if ($hak==0) { ?><i class="fa fa-ban text-danger"></i><?php } ?></b>
</a>
</h2>
</header>
<div id="collapseThree" class="accordion-body collapse">
<div class="panel-body">
<div class="form-group">
<h4><div class="col-md-2"><b style="color:SlateBlue">Jenis</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_jenislap" class="form-control populate">
<option value="" selected>Semua Jenis</option>
<?php if (is_array($jenis) || is_object($jenis)) {
foreach ($jenis as $key) { ?>
<?php if ($key['TYPE_JENIS']==0) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-SN)</option>
<?php } else if ($key['TYPE_JENIS']==1) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (SN)</option>
<?php } else if ($key['TYPE_JENIS']==2) { ?>
<option value="<?= $key['ID_JENIS'] ?>" ><?= $key['NAMA_JENIS'] ?> (NON-QTY)</option>
<?php } ?>
<?php }
} ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<h4><div class="col-md-2"><b style="color:SlateBlue">Merk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_merklap" class="form-control populate">
<option value="" selected>Semua Merk</option>
<option value="0">Tanpa Merk [Dikosongi]</option>
<?php if (is_array($merk) || is_object($merk)) {
foreach ($merk as $key) { ?>
<option value="<?= $key['ID_MERK'] ?>" ><?= $key['NAMA_MERK'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<h4><div class="col-md-2"><b style="color:SlateBlue">Model</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_modellap" class="form-control populate">
<option value="" selected>Semua Model</option>
<option value="0">Tanpa Model [Dikosongi]</option>
<?php if (is_array($model) || is_object($model)) {
foreach ($model as $key) { ?>
<option value="<?= $key['ID_MODEL'] ?>" ><?= $key['NAMA_MODEL'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<h4><div class="col-md-2"><b style="color:SlateBlue">Produk</b></div></h4>
<div class="col-md-4">
<div class="form-group">
<select data-plugin-selectTwo id="id_produklap" class="form-control populate">
<option value="" selected>Semua Produk</option>
<?php if (is_array($produk) || is_object($produk)) {
foreach ($produk as $key) { ?>
<?php if ($key['ID_PRODUK']==0) { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?> [Dikosongi]</option>
<?php } else { ?>
<option value="<?= $key['ID_PRODUK'] ?>" ><?= $key['NAMA_PRODUK'] ?></option>
<?php } ?>
<?php }
} ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<?= form_open('Menu/MD_Excel_DataBarang', array('id' => 'formmaster'), array('method' => 'MD_Excel_DataBarang')); ?>
<h4><div class="col-md-2"><b style="color:SlateBlue">Menu</b></div></h4>
<div class="col-md-10 btn-group">
<input type="hidden" id="id_jenisfill" name="id_jenisfill" class="form-control">
<input type="hidden" id="id_merkfill" name="id_merkfill" class="form-control">
<input type="hidden" id="id_modelfill" name="id_modelfill" class="form-control">
<input type="hidden" id="id_produkfill" name="id_produkfill" class="form-control">
<button type="submit" class="btn btn-default" onclick="isiData()" target="_blank"><b style="color:DarkGreen">Excel <i class="fa fa-file-excel-o"></i></b></button>
</div>
<?= form_close(); ?>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</section>
</section>
</div>
</section>
<div id="modalFitur" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" style="width:50%">
<div class="modal-content">
<header class="panel-heading">
<h4 class="panel-title"><b>Fitur Teknis</b></h4>
</header>
<div class="panel-body">
<div class="modal-wrapper">
<div class="modal-text">
<div class="form-group">
<h5>
<b style="color:DarkRed">Berikut ini adalah Daftar Menu yang dapat diakses sesuai dengan Hak Akses Anda.</b><br>
<br><b style="color:DarkGreen">AKSES PENUH/OPERATOR</b><br><b> Semua Fungsi (Tambah, Ubah, Hapus)</b><br>
<br><b style="color:DarkGreen">TERBATAS</b><br><b>Hanya dapat Membaca Data</b><br>
</h5>
</div>
</div>
</div>
</div>
<footer class="panel-footer">
<div class="row">
<div class="col-md-12">
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Close</button>
</div>
</div>
</footer>
</div>
</div>
</div>
<div id="modalAmbilBarang" class="modal fade ui-front" tabindex="-1" role="dialog" data-keyboard="false">
<div class="modal-dialog modal-lg" style="width:60%">
<header class="panel-heading">
<h2 class="panel-title"><b>Isi Data | <b style="color:Red">[Barang]</b></b></h2>
<div class="panel-actions">
<a class="text-dark" data-dismiss="modal"><b>Tutup </b><i class="fa fa-times"></i></a>
</div>
</header>
<div class="panel-body">
<div class="modal-wrapper">
<div class="modal-text">
<div class="row form-bordered">
<div class="form-group">
<div class="form-group">
<div class="col-md-6"></div>
<div class="col-md-6">
<input type="text" id="barangSearch" oninput="cariDataBarang()" autocomplete="off" class="form-control populate" placeholder="Cari Barang..."></input>
</div>
</div>
<div class="col-md-12">
<table class="table table-bordered table-striped mb-none">
<thead>
<?php if ($hak>1) { ?>
<th class="center default">Pilih</th>
<?php } ?>
<th class="default">Barang</th>
<th class="default">Jenis</th>
<th class="default">Merk</th>
</thead>
<tbody id="isiTabelBarang"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="modalHapus" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<?= form_open('Menu/MD_Hapus_DataBarang', array('id' => 'formmaster'), array('method' => 'MD_Hapus_DataBarang')); ?>
<div class="modal-content">
<header class="panel-heading">
<h2 class="panel-title"><b>Hapus Data</b></h2>
</header>
<div class="panel-body">
<div class="modal-wrapper">
<div class="modal-text">
<input type="hidden" name="id_barangdel" id="id_barangdel" class="form-control">
<h4>Apakah ingin menghapus Data?</h4>
</div>
</div>
</div>
<footer class="panel-footer">
<div class="row">
<div class="col-md-12 text-right">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
<button type="submit" name="SubmitButton" id="SubmitButton" class="btn btn-danger"><b>Hapus</b> <i class="fa fa-minus"></i></button>
</div>
</div>
</footer>
</div>
<?= form_close(); ?>
</div>
</div>
<?php
$this->load->view('template/sidebar_right');
$this->load->view('template/script_vendor');
$this->load->view('template/script_flashdata');
$this->load->view('template/notification');
?>
<script>
$(document).ready(function() {
document.getElementById("id_merknew").value = 0;
document.getElementById("id_modelnew").value = 0;
document.getElementById("id_produknew").value = 0;
$('#id_merknew').select2().select2('val', 0);
$('#id_modelnew').select2().select2('val', 0);
$('#id_produknew').select2().select2('val', 0);
});
function tutupTab() {
window.close();
}
function cekNilai(id) {
PNotify.removeAll();
if (id==1) {
var nilai = document.getElementById("garansi_barangnew").value;
} else if (id==2) {
var nilai = document.getElementById("garansi_baranged").value;
}
var nilai = nilai.replace(/,/g,'.');
var cekNumber = isNaN(nilai);
if (cekNumber==true) {
notify("not_number");
if (id==1) {
document.getElementById("garansi_barangnew").value = 0;
} else if (id==2) {
document.getElementById("garansi_baranged").value = document.getElementById("garansi_barangTemp").value;
}
}
if (nilai<0 || nilai=="") {
notify("less_zero");
if (id==1) {
document.getElementById("garansi_barangnew").value = 0;
} else if (id==2) {
document.getElementById("garansi_baranged").value = document.getElementById("garansi_barangTemp").value;
}
}
}
function setBersih() {
document.getElementById('detailData').style.display = 'none';
document.getElementById("id_jenisnew").value = null;
document.getElementById("id_jenised").value = null;
document.getElementById("id_jenislap").value = null;
document.getElementById("id_merknew").value = 0;
document.getElementById("id_merked").value = null;
document.getElementById("id_merklap").value = null;
document.getElementById("id_modelnew").value = 0;
document.getElementById("id_modeled").value = null;
document.getElementById("id_modellap").value = null;
document.getElementById("id_produknew").value = 0;
document.getElementById("id_produked").value = null;
document.getElementById("id_produklap").value = null;
document.getElementById("kode_barangnew").value = null;
document.getElementById("kode_baranged").value = null;
document.getElementById("kode_barangTemp").value = null;
document.getElementById("nama_barangnew").value = null;
document.getElementById("nama_baranged").value = null;
document.getElementById("garansi_barangnew").value = 0;
document.getElementById("garansi_baranged").value = 0;
$('#id_jenisnew').select2().select2('val', null);
$('#id_jenised').select2().select2('val', null);
$('#id_jenislap').select2().select2('val', null);
$('#id_merknew').select2().select2('val', 0);
$('#id_merked').select2().select2('val', null);
$('#id_merklap').select2().select2('val', null);
$('#id_modelnew').select2().select2('val', 0);
$('#id_modeled').select2().select2('val', null);
$('#id_modellap').select2().select2('val', null);
$('#id_produknew').select2().select2('val', 0);
$('#id_produked').select2().select2('val', null);
$('#id_produklap').select2().select2('val', null);
}
function lihatData(id) {
document.getElementById('detailData').style.display = 'block';
var hak = <?=$hak?>;
if (id!="" && hak>0) {
$.ajax({
url: "<?= base_url() ?>index.php/Menu/MD_Ambil_DataBarang",
type: "POST",
dataType: "json",
data: {
id_barang : id,
},
success: function(response) {
document.getElementById("id_jenised").value = response.id_jenis;
document.getElementById("id_jenisTemp").value = response.id_jenis;
document.getElementById("id_merked").value = response.id_merk;
document.getElementById("id_modeled").value = response.id_model;
document.getElementById("id_produked").value = response.id_produk;
document.getElementById("kode_baranged").value = response.kode_barang;
document.getElementById("kode_barangTemp").value = response.kode_barang;
document.getElementById("nama_baranged").value = response.nama_barang;
document.getElementById("nama_barangTemp").value = response.nama_barang;
document.getElementById("garansi_baranged").value = response.garansi_barang;
document.getElementById("garansi_barangTemp").value = response.garansi_barang;
$('#id_jenised').select2().select2('val', response.id_jenis);
$('#id_merked').select2().select2('val', response.id_merk);
$('#id_modeled').select2().select2('val', response.id_model);
$('#id_produked').select2().select2('val', response.id_produk);
if (hak==1) {
document.getElementById("kode_baranged").disabled = true;
document.getElementById("nama_baranged").disabled = true;
document.getElementById("garansi_baranged").disabled = true;
document.getElementById("id_jenised").disabled = true;
document.getElementById("id_merked").disabled = true;
document.getElementById("id_modeled").disabled = true;
document.getElementById("id_produked").disabled = true;
} else {
document.getElementById('buttonDelete').style.display = 'block';
}
}
});
} else {
document.getElementById('detailData').style.display = 'none';
document.getElementById('buttonDelete').style.display = 'none';
}
}
function tambahData() {
var status = 0;
var kode_barang = document.getElementById("kode_barangnew").value;
var nama_barang = document.getElementById("nama_barangnew").value;
var garansi_barang = document.getElementById("garansi_barangnew").value;
var id_jenis = document.getElementById("id_jenisnew").value;
var id_merk = document.getElementById("id_merknew").value;
var id_model = document.getElementById("id_modelnew").value;
var id_produk = document.getElementById("id_produknew").value;
PNotify.removeAll();
if (kode_barang=="") {
notify("kode_null");
status++;
}
if (nama_barang=="") {
notify("nama_null");
status++;
}
if (id_jenis=="") {
notify("jenisid_null");
status++;
}
if (status==0) {
$.ajax({
url: "<?= base_url() ?>index.php/Menu/MD_Tambah_DataBarang",
type: "POST",
dataType: "json",
data: {
kode_barang : kode_barang,
nama_barang : nama_barang,
garansi_barang : garansi_barang,
id_jenis : id_jenis,
id_merk : id_merk,
id_model : id_model,
id_produk : id_produk,
},
success: function(response) {
if (response.value==1) {
notify("success_add");
delayReload(1000,"<?= base_url() ?>index.php/Menu/MD_MasterBarang/");
} else if (response.value==2) {
notify("name_same");
} else if (response.value==3) {
notify("kode_same");
} else if (response.value==0) {
notify("failed");
}
}
});
}
setBersih();
}
function ubahData(menu) {
//1. Ganti Kode Barang
//2. Ganti Nama Barang
//3. Ganti Jenis
//4. Ganti Merk
//5. Ganti Model
//6. Ganti Produk
//7. Ganti Garansi Barang
var id_barang = document.getElementById("id_barangLihat").value;
var id_jenis = document.getElementById("id_jenised").value;
var id_jenisTemp = document.getElementById("id_jenisTemp").value;
var id_merk = document.getElementById("id_merked").value;
var id_model = document.getElementById("id_modeled").value;
var id_produk = document.getElementById("id_produked").value;
var kode_barang = document.getElementById("kode_baranged").value;
var kode_barangTemp = document.getElementById("kode_barangTemp").value;
var nama_barang = document.getElementById("nama_baranged").value;
var nama_barangTemp = document.getElementById("nama_barangTemp").value;
var garansi_barang = document.getElementById("garansi_baranged").value;
var garansi_barangTemp = document.getElementById("garansi_barangTemp").value;
var status = 0;
PNotify.removeAll();
if (id_barang!="") {
if (kode_barang.length==0 || nama_barang.length==0) {
notify("datainput_null");
document.getElementById("kode_baranged").value = kode_barangTemp;
document.getElementById("nama_baranged").value = nama_barangTemp;
document.getElementById("garansi_baranged").value = garansi_barangTemp;
status++;
}
}
if (id_jenis=="") {
status++;
}
if (id_merk=="") {
status++;
}
if (id_model=="") {
status++;
}
if (id_produk=="") {
status++;
}
if (menu==7) {
cekNilai(2);
}
if (status==0) {
$.ajax({
url: "<?= base_url() ?>index.php/Menu/MD_Ubah_DataBarang",
type: "POST",
dataType: "json",
data: {
id_barang : id_barang,
id_jenis : id_jenis,
id_merk : id_merk,
id_model : id_model,
id_produk : id_produk,
kode_barang : kode_barang,
nama_barang : nama_barang,
garansi_barang : garansi_barang,
menu : menu,
},
success: function(response) {
if (response.value==1) {
notify("success_ed");
} else if (response.value==2) {
notify("name_same");
document.getElementById("nama_baranged").value = nama_barangTemp;
} else if (response.value==3) {
notify("kode_same");
document.getElementById("kode_baranged").value = kode_barangTemp;
} else if (response.value==4) {
notify("jenisNotSame");
document.getElementById("id_jenised").value = id_jenisTemp;
} else if (response.value==5) {
notify("latest");
delayReload(1000,"<?= base_url() ?>index.php/Menu/MD_MasterBarang/");
} else if (response.value==0) {
notify("failed");
}
}
});
}
}
function hapusData() {
PNotify.removeAll();
document.getElementById("id_barangdel").value = document.getElementById("id_barangLihat").value;
}
function isiData() {
document.getElementById("id_jenisfill").value = document.getElementById("id_jenislap").value;
document.getElementById("id_merkfill").value = document.getElementById("id_merklap").value;
document.getElementById("id_modelfill").value = document.getElementById("id_modellap").value;
document.getElementById("id_produkfill").value = document.getElementById("id_produklap").value;
}
function isiMasterBarang() {
PNotify.removeAll();
document.getElementById("barangSearch").value = null;
document.getElementById("barangSearch").innerHTML = "";
tampilkanDataMasterBarang(null);
}
function cariDataBarang() {
var search = document.getElementById("barangSearch").value;
tampilkanDataMasterBarang(search);
}
function tampilkanDataMasterBarang(textSearch) {
var hak = <?=$hak?>;
$.ajax({
type: 'POST',
data: {
search : textSearch,
mode : 2
},
url: '<?= base_url('') ?>index.php/Menu/GE_AmbilData_MasterBarang',
dataType: 'json',
success: function(response) {
JUMLAH = response.data.length;
var baris = '';
for (var i = 1; i <= JUMLAH; i++) {
var id = response.data[i - 1]['ID_BARANG'];
var nama = response.data[i - 1]['NAMA_BARANG'];
var kode = response.data[i - 1]['KODE_BARANG'];
var jenis = response.data[i - 1]['NAMA_JENIS'];
var merk = response.data[i - 1]['NAMA_MERK'];
baris += '<tr>';
if (hak>1) {
baris += '<td class="center" style="vertical-align: middle;" ><button onclick="pilihBarang(' + id + ')"><i class="fa fa-circle text-primary"></i></button></td>';
}
baris += '<td class="text-left" style="vertical-align: middle;"><b style="color:Black">' + kode + '</b><br>' + nama + '</td>';
baris += '<td class="text-left" style="vertical-align: middle;"><b style="color:DarkGreen">' + jenis + '</b></td>';
baris += '<td class="text-left" style="vertical-align: middle;"><b style="color:Chocolate">' + merk + '</b></td>';
baris += '</tr>';
}
$('#isiTabelBarang').html(baris);
}
});
}
function pilihBarang(id) {
PNotify.removeAll();
document.getElementById("id_barangLihat").value = id;
$('#modalAmbilBarang').modal('hide');
lihatData(id);
}
</script>
</body>
</html>