493 lines
21 KiB
PHP
493 lines
21 KiB
PHP
<!doctype html>
|
|
<html class="fixed sidebar-left-collapsed">
|
|
|
|
<head>
|
|
|
|
<!-- Basic -->
|
|
<meta charset="UTF-8">
|
|
|
|
<title>PROSES | POTONG SN</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" />
|
|
|
|
<!-- Web Fonts -->
|
|
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
|
|
|
|
<!-- 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" />
|
|
|
|
<!-- 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>
|
|
|
|
<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">
|
|
<header class="page-header">
|
|
<h2><strong>(Step 3)</strong> | Potong SN</h2>
|
|
|
|
<div class="right-wrapper pull-right">
|
|
<ol class="breadcrumbs">
|
|
<li>
|
|
<a href="<?php echo base_url() ?>index.php">
|
|
<i class="fa fa-home"></i>
|
|
</a>
|
|
</li>
|
|
<li><span>Serial Number</span></li>
|
|
</ol>
|
|
|
|
<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- start: page -->
|
|
<?php if (is_array($pesanan) || is_object($pesanan)) {
|
|
foreach ($pesanan as $key) { ?>
|
|
<section class="panel">
|
|
<header class="panel-heading">
|
|
<div class="panel-actions">
|
|
<a href="javascript:window.history.go(-1);"><strong>Kembali</strong><i class="fa fa-backward"></i></a>
|
|
</div>
|
|
|
|
<?php if ($qty_dj>$qty) { ?>
|
|
<h2 class="panel-title">DATA SN</h2>
|
|
<?php } else { ?>
|
|
<h2 class="panel-title">DATA SN <strong>(DATA TERKUNCI)</strong></h2>
|
|
<?php } ?>
|
|
|
|
</header>
|
|
<div class="panel-body">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="col-md-3 control-label">Kode Barang</label>
|
|
<div class="col-md-9">
|
|
<input class="form-control" name="kode_barang" id="kode_barang" value="<?= $key['KODE_BARANG'] ?> | Max Potong <?= $key['QTY_DJ'] ?> Unit" type="text" placeholder="na" readonly>
|
|
|
|
<small class="help-block"></small>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($qty_dj>$qty) { ?>
|
|
<div class="form-group">
|
|
<label class="col-md-3 control-label">Potong SN</label>
|
|
<div class="col-md-9">
|
|
<input class="form-control" name="nama_sn_e" id="nama_sn_e" type="text" placeholder="Serial Number">
|
|
</div>
|
|
</div>
|
|
<?php } else { ?>
|
|
<div class="form-group">
|
|
<label class="col-md-3 control-label">Potong SN</label>
|
|
<div class="col-md-9">
|
|
<input class="form-control" name="nama_sn_e" id="nama_sn_e" type="text" placeholder="SN terpenuhi, Hapus untuk Revisi" readonly>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="form-group">
|
|
<div class="col-md-12 table-responsive">
|
|
<table class="table table-bordered table-striped mb-none dataTable" id="tsn" role="grid" aria-describedby="datatable-editable_info">
|
|
<thead>
|
|
<tr>
|
|
<th class="dark center">No</th>
|
|
<th class="dark center">Serial Number</th>
|
|
<th class="dark center">PILIHAN</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody id="isitabel">
|
|
</tbody>
|
|
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<?php }
|
|
} ?>
|
|
<!-- end: page -->
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<div id="modalsave" class="modal fade" tabindex="-1" role="dialog">
|
|
<div class="modal-dialog">
|
|
<header class="panel-heading">
|
|
<h2 class="panel-title">Ubah Data</h2>
|
|
</header>
|
|
<div class="panel-body">
|
|
<div class="modal-wrapper">
|
|
<div class="modal-text">
|
|
<input type="hidden" name="id_sn" id="id_sn" class="form-control" value="">
|
|
<input type="hidden" name="nama_sn" id="nama_sn" class="form-control" value="">
|
|
<p id="textP">Are you sure that you want to delete this image?</p>
|
|
</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 class="btn btn-warning " id="cfm" data-dismiss="modal" onclick="confirm()">Edit Data</button>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="modalhapus" class="modal fade modal-block-danger" tabindex="-1" role="dialog">
|
|
<div class="modal-dialog">
|
|
<header class="panel-heading">
|
|
<h2 class="panel-title">Batal Potong</h2>
|
|
</header>
|
|
<div class="panel-body">
|
|
<div class="modal-wrapper">
|
|
<div class="modal-text">
|
|
<input type="hidden" name="id_snhapus" id="id_snhapus" class="form-control" value="">
|
|
<p id="texthapus">Are you sure that you want to delete this image?</p>
|
|
</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 class="btn btn-danger " id="cfmhapus" data-dismiss="modal" onclick="confirmHapus()">Hapus Data</button>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery/jquery.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/bootstrap/js/bootstrap.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/nanoscroller/nanoscroller.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/magnific-popup/magnific-popup.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>
|
|
|
|
<!-- Specific Page Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/select2/select2.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
|
|
<!-- Specific Page Vendor -->
|
|
<script src="<?php echo base_url('') ?>assets/vendor/pnotify/pnotify.custom.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-autosize/jquery.autosize.js"></script>
|
|
|
|
<!-- Theme Base, Components and Settings -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.js"></script>
|
|
|
|
<!-- Theme Custom -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.custom.js"></script>
|
|
|
|
<!-- Theme Initialization Files -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/theme.init.js"></script>
|
|
|
|
|
|
<!-- Examples -->
|
|
<!-- Examples -->
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.default.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.tabletools.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/tables/examples.datatables.editable.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/ui-elements/examples.notifications.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/vendor/jquery-validation/jquery.validate.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/forms/examples.validation.js"></script>
|
|
<script src="<?php echo base_url('') ?>assets/javascripts/ui-elements/examples.modals.js"></script>
|
|
|
|
<!-- notif -->
|
|
<script>
|
|
$(document).ready(function() {
|
|
var NOBARIS = '';
|
|
var IDDETAIL = '<?= $id_dj ?>';
|
|
var JUMLAH = '';
|
|
|
|
LoadData();
|
|
|
|
$(document).on('click', '#hapusbaris', function(e) {
|
|
e.preventDefault();
|
|
var d = namabarang.value;
|
|
alert(d);
|
|
var no = 1;
|
|
$(this).parent().parent().remove();
|
|
$('#tsn tbody tr').each(function() {
|
|
$(this).find('td:nth-child(1)').html(no);
|
|
no++;
|
|
});
|
|
})
|
|
otm();
|
|
});
|
|
|
|
function resetbaris(id) {
|
|
document.getElementById("idsn" + id).value = document.getElementById("idsn" + id).defaultValue;
|
|
document.getElementById("sn" + id).value = document.getElementById("sn" + id).defaultValue;
|
|
}
|
|
|
|
function hapus(id) {
|
|
NOBARIS = id;
|
|
var mIdSn = document.getElementById("idsn" + id).value;
|
|
var mSn = document.getElementById("sn" + id).value;
|
|
$("#id_snhapus").val(mIdSn);
|
|
$("#texthapus").html("Apakah ingin membatalkan potong SN <b>" + mSn + "</b>?");
|
|
}
|
|
|
|
function confirmHapus() {
|
|
var is = document.getElementById("id_snhapus").value;
|
|
$("#id_sn").val('');
|
|
if (is == '') {
|
|
resetbaris(NOBARIS);
|
|
} else {
|
|
$.ajax({
|
|
type: "POST",
|
|
data: 'id_sn=' + is,
|
|
url: '<?= base_url() ?>index.php/ManagePenjualanST/resetsn',
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
|
|
if (response.value == 1) {
|
|
LoadData();
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN berhasil dinormalkan.',
|
|
type: 'success',
|
|
shadow: true
|
|
});
|
|
} else if (response.value == 2){
|
|
location.reload();
|
|
} else {
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN gagal dinormalkan.',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
function LoadData() {
|
|
$.ajax({
|
|
type: 'POST',
|
|
data: 'id=' + <?= $id_dj ?> + 'id_barang=' + <?= $id_barang ?>,
|
|
url: '<?= base_url('') ?>index.php/ManagePenjualanST/datasn',
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
var baris = '';
|
|
var total = <?= $qty_dj ?>;
|
|
JUMLAH = response.total;
|
|
|
|
for (var i = 1; i <= total; i++) {
|
|
|
|
if (i <= response.data.length) {
|
|
|
|
var sn = response.data[i - 1]['NAMA_SN'];
|
|
var id = response.data[i - 1]['ID_SN'];
|
|
|
|
baris += '<tr>';
|
|
baris += '<td class="center " style="vertical-align: middle;" ><b>' + i + '</b></td>';
|
|
baris += '<td class="center" style="vertical-align: middle;">';
|
|
baris += '<input class="form-control input-sm " name="idsn' + i + '" id="idsn' + i + '" type="hidden" value="' + id + '" placeholder="-" >';
|
|
baris += '<input class="form-control input-sm " name="namasn' + i + '" id="sn' + i + '" type="text" value="' + sn + '" placeholder="-" >';
|
|
baris += '</td>';
|
|
baris += '<td class="center " style="vertical-align: middle;">';
|
|
baris += `<button type="button" id="hapusbaris` + i + `" onclick="hapus('` + i + `')" class="btn btn-xs btn-danger " data-toggle="modal" data-target="#modalhapus" ><i class="fa fa-trash-o"></i></button>`;
|
|
baris += ' ';
|
|
baris += '</td>';
|
|
baris += '</tr>';
|
|
} else {
|
|
baris += '<tr>';
|
|
baris += '<td class="center " style="vertical-align: middle;" ><b>' + i + '</b></td>';
|
|
baris += '<td class="center" style="vertical-align: middle;">';
|
|
baris += '<input class="form-control input-sm " name="idsn' + i + '" id="idsn' + i + '" type="hidden" placeholder="-" >';
|
|
baris += '<input class="form-control input-sm " name="namasn' + i + '" id="sn' + i + '" type="text" placeholder="-" >';
|
|
baris += '</td>';
|
|
baris += '<td class="center" style="vertical-align: middle;">';
|
|
baris += `<button type="button" id="hapusbaris` + i + `" onclick="hapus('` + i + `')" class="btn btn-xs btn-danger " data-toggle="modal" data-target="#modalhapus" ><i class="fa fa-trash-o"></i></button>`;
|
|
baris += ' ';
|
|
baris += '</td>';
|
|
baris += '</tr>';
|
|
}
|
|
|
|
}
|
|
|
|
$('#isitabel').html(baris);
|
|
// console.log(response);
|
|
// alert(response.data.length)
|
|
}
|
|
});
|
|
}
|
|
|
|
function otm() {
|
|
setInterval(function() {
|
|
$.ajax({
|
|
url: "<?= base_url() ?>index.php/ManagePenjualanST/jumlahdatasn",
|
|
type: "POST",
|
|
dataType: "json",
|
|
data: 'id=' + <?= $id_dj ?> + 'id_barang=' + <?= $id_barang ?>,
|
|
success: function(response) {
|
|
if (response.jumlah_data != JUMLAH) {
|
|
LoadData();
|
|
}
|
|
}
|
|
});
|
|
}, 1000);
|
|
}
|
|
|
|
nama_sn_e.addEventListener("keyup", function(event) {
|
|
var dat = nama_sn_e.value;
|
|
if (event.keyCode === 13) {
|
|
var pnj = nama_sn_e.value.length;
|
|
if (dat == "") {
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'Tidak boleh Kosong',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
$('[name="nama_sn_e"]').closest('.form-group').addClass('has-error');
|
|
} else if (pnj > 40) {
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'Karakter melebihi batas',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
$('[name="nama_sn_e"]').closest('.form-group').addClass('has-error');
|
|
|
|
} else {
|
|
var is = '';
|
|
$.ajax({
|
|
type: "POST",
|
|
data: 'id_sn=' + is + '&nama_sn=' + dat + '&id_dj=<?= $id_dj ?>' + '&id_barang=<?= $id_barang ?>',
|
|
url: '<?= base_url() ?>index.php/ManagePenjualanST/potongsn',
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
|
|
if (response.value == 1) {
|
|
LoadData();
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN berhasil dipotong.',
|
|
type: 'success',
|
|
shadow: true
|
|
});
|
|
} else if (response.value == 2){
|
|
location.reload();
|
|
} else if (response.value == 0){
|
|
location.reload();
|
|
} else {
|
|
LoadData();
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN gagal menyimpan.',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
}
|
|
$("#nama_sn_e").val("");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
nama_sn_e.oninput = function() {
|
|
$('[name="nama_sn_e"]').closest('.form-group').removeClass('has-error').addClass('');
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
<?php if ($this->session->flashdata('flash')) { ?>
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN berhasil <?= $this->session->flashdata('flash'); ?>.',
|
|
type: 'success',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
<?php if ($this->session->flashdata('flashgagal')) { ?>
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'SN gagal <?= $this->session->flashdata('flashgagal'); ?>.',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
<?php if ($this->session->flashdata('flashlebih')) { ?>
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'Nominal melebihi kuantiti.',
|
|
type: 'error',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
<?php if ($this->session->flashdata('flashkurang')) { ?>
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'Data bisa Input kembali.',
|
|
type: 'warning',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
<?php if ($this->session->flashdata('flashkunci')) { ?>
|
|
new PNotify({
|
|
title: 'Pemberitahuan',
|
|
text: 'Kuantiti terpenuhi, Masuk Mode Kunci.',
|
|
type: 'warning',
|
|
shadow: true
|
|
});
|
|
<?php } ?>
|
|
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|