499 lines
21 KiB
HTML
499 lines
21 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
<meta name="description" content="">
|
|
<meta name="author" content="">
|
|
|
|
<title>Shenior Kurir | List Kurir</title>
|
|
|
|
<!-- Main Styles -->
|
|
<link rel="stylesheet" href="/styles/style.min.css">
|
|
|
|
<!-- mCustomScrollbar -->
|
|
<link rel="stylesheet" href="/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
|
|
|
<!-- Waves Effect -->
|
|
<link rel="stylesheet" href="/plugin/waves/waves.min.css">
|
|
|
|
<!-- Sweet Alert -->
|
|
<link rel="stylesheet" href="/plugin/sweet-alert/sweetalert.css">
|
|
|
|
<link rel="stylesheet" href="/fonts/fontello/fontello.css">
|
|
|
|
<link rel="stylesheet" href="/fonts/material-design-iconic-font/css/material-design-iconic-font.min.css">
|
|
<link rel="stylesheet" href="/fonts/material-design/css/materialdesignicons.css">
|
|
|
|
<link rel="stylesheet" href="/plugin/datatables/media/css/dataTables.bootstrap.min.css">
|
|
|
|
<!-- Toastr -->
|
|
<link rel="stylesheet" href="/plugin/toastr/toastr.css">
|
|
</head>
|
|
|
|
<body>
|
|
<div class="main-menu">
|
|
<header class="header">
|
|
<a href="/admin" class="logo">Shenior Kurir</a>
|
|
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
|
<div class="user">
|
|
<a href="#" class="avatar"><img src="/images/admin.png" alt=""><span class="status online"></span></a>
|
|
<h5 class="name"><a href="#">Admin</a></h5>
|
|
<h5 class="position">Admin</h5>
|
|
|
|
</div>
|
|
<!-- /.user -->
|
|
</header>
|
|
<!-- /.header -->
|
|
<div class="content">
|
|
|
|
<div class="navigation">
|
|
<h5 class="title">Navigasi</h5>
|
|
<!-- /.title -->
|
|
<ul class="menu js__accordion">
|
|
<li>
|
|
<a class="waves-effect" href="/admin"><i class="menu-icon fa fa-home"></i><span>Halaman
|
|
Utama</span></a>
|
|
</li>
|
|
|
|
<li class="current active">
|
|
<a class="waves-effect" href="/admin/kurir"><i
|
|
class="menu-icon ico mdi mdi-motorbike"></i><span>List Kurir</span></a>
|
|
</li>
|
|
|
|
<li>
|
|
<a class="waves-effect" href="/admin/user"><i class="menu-icon fa fa-users"></i><span>List
|
|
User</span></a>
|
|
</li>
|
|
|
|
<li>
|
|
<a class="waves-effect" href="/admin/list"><i class="menu-icon ico icon-table"></i><span>List
|
|
Penghantaran</span></a>
|
|
</li>
|
|
|
|
|
|
<li>
|
|
<a class="waves-effect" href="#" onclick="logout()"><i
|
|
class="menu-icon ico icon-logout"></i><span>Logout</span></a>
|
|
</li>
|
|
</ul>
|
|
|
|
</div>
|
|
<!-- /.navigation -->
|
|
</div>
|
|
<!-- /.content -->
|
|
</div>
|
|
<!-- /.main-menu -->
|
|
|
|
<div class="fixed-navbar">
|
|
<div class="pull-left">
|
|
<button type="button"
|
|
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
|
|
<h1 class="page-title">List Kurir</h1>
|
|
<!-- /.page-title -->
|
|
</div>
|
|
<!-- /.pull-left -->
|
|
<div class="pull-right">
|
|
|
|
|
|
<a href="#" class="ico-item ico icon-logout" onclick="logout()"></a>
|
|
</div>
|
|
<!-- /.pull-right -->
|
|
</div>
|
|
<!-- /.fixed-navbar -->
|
|
|
|
<div id="wrapper">
|
|
<div class="main-content">
|
|
<div class="row small-spacing">
|
|
<div class="col-xs-12">
|
|
<div class="box-content card">
|
|
<h4 class="box-title">Form Kurir</h4>
|
|
<!-- /.box-title -->
|
|
<div class="card-content">
|
|
<div class="form-group">
|
|
<button type="button" class="btn btn-sm btn-info btn-rounded waves-effect waves-light"
|
|
onclick="addKurirOpenModal()">Pendaftaran Kurir Baru</button>
|
|
</div>
|
|
<div class="form-group" style="overflow-x: auto;">
|
|
<table id="tb-kurir" class="table table-striped table-bordered display"
|
|
style="width:100%">
|
|
|
|
</table>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<!-- /.box-content -->
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<footer class="footer">
|
|
<ul class="list-inline">
|
|
<li>Arifuddin Naawi Amanah © 2025.</li>
|
|
<!-- <li><a href="#">Privacy</a></li>
|
|
<li><a href="#">Terms</a></li>
|
|
<li><a href="#">Help</a></li> -->
|
|
</ul>
|
|
</footer>
|
|
</div>
|
|
<!-- /.main-content -->
|
|
</div><!--/#wrapper -->
|
|
|
|
<div class="modal fade" id="modal-kurir" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
|
aria-hidden="true">×</span></button>
|
|
<h4 class="modal-title" id="modal-kurir-title">Modal title</h4>
|
|
</div>
|
|
<form class="modal-body" id="form-modal">
|
|
<div class="form-group">
|
|
<!-- show the upload -->
|
|
<div id="show-upload-gambar-kurir" style="display: none">
|
|
<center>
|
|
<div id="preview-gambar-kurir" style="height: 200px; width: 150px"></div>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
<div class="form-group" id="form-gambar-kurir">
|
|
<!-- create upload -->
|
|
<label for="modal-kurir-nama">Photo Kurir</label>
|
|
<input type="file" class="form-control" id="gambar-kurir" accept="image/*"
|
|
onchange="showUpload(this, 'gambar-kurir')">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-kurir-nama">Nama</label>
|
|
<input type="text" class="form-control" id="nama" placeholder="Masukkan Nama">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="modal-kurir-nama">No Telpon/HP</label>
|
|
<input type="text" class="form-control" id="no_telpon" oninput="numberOnly(this)" maxlength="13"
|
|
placeholder="Masukkan No Telpon/HP">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-kurir-nama">Jenis Kelamin</label>
|
|
<select class="form-control" id="jenis-kelamin">
|
|
<option value="" disabled selected>-Pilih Jenis Kelamin</option>
|
|
<option value="Laki-laki">Laki-laki</option>
|
|
<option value="Perempuan">Perempuan</option>
|
|
</select>
|
|
</div>
|
|
<hr>
|
|
<div class="form-group">
|
|
<!-- show the upload -->
|
|
<div id="show-upload-gambar-motor" style="display: none">
|
|
<center>
|
|
<div id="preview-gambar-motor" style="height: 200px; width: 150px"></div>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
<div class="form-group" id="form-gambar-motor">
|
|
<!-- create upload -->
|
|
<label for="modal-kurir-nama">Photo Motor</label>
|
|
<input type="file" class="form-control" id="gambar-motor" accept="image/*"
|
|
onchange="showUpload(this, 'gambar-motor')">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="modal-kurir-dd-motor">DD Motor</label>
|
|
<input type="text" class="form-control" id="dd-motor" placeholder="Masukkan DD Motor">
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-default btn-sm waves-effect waves-light"
|
|
data-dismiss="modal">Close</button>
|
|
<button type="button" class="btn btn-primary btn-sm waves-effect waves-light" id="btn-tambah-kurir"
|
|
onclick="tambahkurir()">Daftar Kurir</button>
|
|
<button type="button" class="btn btn-info btn-sm waves-effect waves-light" id="btn-edit-kurir"
|
|
onclick="editkurir()">Edit Kurir ?</button>
|
|
<button type="button" class="btn btn-primary btn-sm waves-effect waves-light" id="btn-update-kurir"
|
|
onclick="updatekurir()">Update kurir</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
|
<!--[if lt IE 9]>
|
|
<script src="/script/html5shiv.min.js"></script>
|
|
<script src="/script/respond.min.js"></script>
|
|
<![endif]-->
|
|
<!--
|
|
================================================== -->
|
|
<!-- Placed at the end of the document so the pages load faster -->
|
|
<script src="/scripts/jquery.min.js"></script>
|
|
<script src="/scripts/modernizr.min.js"></script>
|
|
<script src="/plugin/bootstrap/js/bootstrap.min.js"></script>
|
|
<script src="/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
|
|
<script src="/plugin/nprogress/nprogress.js"></script>
|
|
<script src="/plugin/sweet-alert/sweetalert.min.js"></script>
|
|
<script src="/plugin/waves/waves.min.js"></script>
|
|
<!-- Full Screen Plugin -->
|
|
<script src="/plugin/fullscreen/jquery.fullscreen-min.js"></script>
|
|
|
|
<script src="/plugin/datatables/media/js/jquery.dataTables.min.js"></script>
|
|
<script src="/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>
|
|
<script src="/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
|
|
|
|
<!-- Toastr -->
|
|
<script src="/plugin/toastr/toastr.min.js"></script>
|
|
|
|
<script src="/block/jquery.blockUI.js"></script>
|
|
|
|
<script src="/scripts/main.min.js"></script>
|
|
<script src="/my-js.js"></script>
|
|
<script>
|
|
function reloadTable() {
|
|
// destroy table
|
|
// $('#tb-kurir').DataTable().destroy();
|
|
$('#tb-kurir').DataTable({
|
|
// responsive: true,
|
|
scrollX: true,
|
|
// order: [
|
|
// [0, 'asc']
|
|
// ],
|
|
ajax: {
|
|
url: '/admin/kurir/data',
|
|
type: 'GET',
|
|
timeout: 120000,
|
|
dataSrc: function (data) {
|
|
// console.log(data.data)
|
|
return data
|
|
}
|
|
},
|
|
"sAjaxDataProp": "",
|
|
"aoColumns": [
|
|
{
|
|
"mData": "no_telpon",
|
|
"title": "No Telpon",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": "nama",
|
|
"title": "Nama",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": "status",
|
|
"title": "Status",
|
|
"render": function (data, type, row) {
|
|
return data == null || data == "" || data == undefined ? "Tersedia" : data
|
|
}
|
|
},
|
|
{
|
|
"mData": null,
|
|
"title": "Aksi",
|
|
"render": function (data, type, row) {
|
|
return `<button type='button' onclick='open_modal_edit("${data.no_telpon}")' title='Detail Kurir' class='btn btn-info btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-info'></i></button> <button type='button' onclick='deletekurir(${data.telpon})' title='Hapus Kurir' class='btn btn-danger btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-delete'></i></button>`
|
|
}
|
|
}
|
|
]
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
reloadTable()
|
|
|
|
function addKurirOpenModal() {
|
|
selectClicked = false
|
|
$('#show-upload-gambar-kurir').hide();
|
|
$('#show-upload-gambar-motor').hide();
|
|
$('#modal-kurir-title').text('Form Pendaftaran Kurir Baru');
|
|
$('#modal-kurir-nis').val('');
|
|
$("#show-upload").hide();
|
|
$('#gambar-kurir').val('');
|
|
$('#modal-kurir').modal('show');
|
|
$("#form-gambar-kurir").attr("hidden", false);
|
|
enableInput(false)
|
|
$("#btn-edit-kurir").hide();
|
|
$("#btn-tambah-kurir").show();
|
|
$("#btn-update-kurir").hide();
|
|
$("#form-modal").trigger("reset");
|
|
}
|
|
|
|
function showUpload(element, stat) {
|
|
var file = element.files[0];
|
|
|
|
if (file) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (event) {
|
|
var imageUrl = event.target.result;
|
|
|
|
// Create an image element
|
|
var img = document.createElement('img');
|
|
img.src = imageUrl;
|
|
img.style.maxWidth = '100%'; // Make the image fit the width of the div
|
|
img.style.maxHeight = '100%'; // Make the image fit the height of the div
|
|
|
|
const id = stat == 'gambar-kurir' ? 'show-upload-gambar-kurir' : 'show-upload-gambar-motor'
|
|
|
|
const id_preview = stat == 'gambar-kurir' ? 'preview-gambar-kurir' : 'preview-gambar-motor'
|
|
// Get the preview div
|
|
var previewDiv = document.getElementById(`${id_preview}`);
|
|
$('#' + id).show();
|
|
|
|
// Clear any existing content in the preview div
|
|
previewDiv.innerHTML = '';
|
|
|
|
// Append the image to the preview div
|
|
previewDiv.appendChild(img);
|
|
}
|
|
reader.readAsDataURL(file);
|
|
}
|
|
}
|
|
|
|
function tambahkurir() {
|
|
var form = new FormData();
|
|
form.append('gambar_kurir', $('#gambar-kurir')[0].files[0]);
|
|
form.append('gambar_motor', $('#gambar-motor')[0].files[0]);
|
|
form.append('dd_motor', $('#dd-motor').val());
|
|
form.append('nama', $('#nama').val());
|
|
form.append('no_telpon', $('#no_telpon').val());
|
|
form.append('jenis_kelamin', $('#jenis-kelamin').val());
|
|
|
|
if ($('#gambar-kurir')[0].files[0] == '' || $('#gambar-motor')[0].files[0] == '' || $('#dd-motor').val() == '' || $('#nama').val() == '' || $('#no_telpon').val() == '' || $('#jenis-kelamin').val() == '') return toastr.error('Lengkapi Data Kurir');
|
|
|
|
console.log("jalankan");
|
|
|
|
swal({
|
|
title: "Yakin?",
|
|
text: "Anda yakin ingin menambahkan kurir baru?",
|
|
icon: "info",
|
|
showCancelButton: !0,
|
|
// confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "Ya",
|
|
cancelButtonText: "Tidak",
|
|
}, function (y) {
|
|
if (y) {
|
|
$.ajax({
|
|
url: '/admin/kurir/',
|
|
type: 'POST',
|
|
data: form,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function () {
|
|
$('#modal-kurir').modal('hide');
|
|
blockUI('Pendaftaran Kurir Sedang Diproses...');
|
|
},
|
|
success: function (response) {
|
|
console.log(response);
|
|
$("#tb-kurir").DataTable().destroy();
|
|
reloadTable();
|
|
$.unblockUI();
|
|
// create swal with timer 3000 and no buttons
|
|
swal({
|
|
title: 'Success',
|
|
text: 'Pendaftaran Kurir Berhasil',
|
|
type: 'success',
|
|
timer: 3000,
|
|
showConfirmButton: false
|
|
})
|
|
|
|
},
|
|
|
|
error: function (xhr, status, error) {
|
|
$.unblockUI();
|
|
// console.log(xhr.responseJSON);
|
|
// console.log(status);
|
|
// console.log(error);
|
|
toastr.error(xhr.responseJSON.error);
|
|
setTimeout(() => {
|
|
$('#modal-kurir').modal('show');
|
|
}, 500);
|
|
}
|
|
});
|
|
} else {
|
|
// close swal
|
|
swal.close()
|
|
}
|
|
})
|
|
|
|
|
|
}
|
|
|
|
function open_modal_edit(no_telpon) {
|
|
// console.log(no_telpon)
|
|
selectClicked = false
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/admin/kurir/' + no_telpon,
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
blockUI('Loading')
|
|
},
|
|
success: function (data) {
|
|
// console.log(json)
|
|
$('#modal-kurir-title').html('Detail Kurir')
|
|
// hide form-gambar div
|
|
$("#form-gambar-kurir").attr("hidden", true);
|
|
$("#form-gambar-motor").attr("hidden", true);
|
|
$("#no_telpon").val(data.no_telpon)
|
|
$("#nama").val(data.nama)
|
|
$("#jenis-kelamin").val(data.jenis_kelamin)
|
|
$("#dd-motor").val(data.dd_motor)
|
|
// disable all input in #form-modal
|
|
|
|
enableInput(true)
|
|
$("#btn-tambah-kurir").hide()
|
|
$("#btn-edit-kurir").show()
|
|
$("#btn-update-kurir").hide()
|
|
$('#modal-kurir').modal('show')
|
|
var img = document.createElement('img');
|
|
img.src = 'kurir/gambar/' + data.no_telpon + '/' + data.gambar_kurir;
|
|
img.style.maxWidth = '100%'; // Make the image fit the width of the div
|
|
img.style.maxHeight = '100%'; // Make the image fit the height of the div
|
|
|
|
// Get the preview div
|
|
var previewDiv = document.getElementById('preview-gambar-kurir');
|
|
$('#show-upload-gambar-kurir').show();
|
|
// Clear any existing content in the preview div
|
|
previewDiv.innerHTML = '';
|
|
|
|
// Append the image to the preview div
|
|
previewDiv.appendChild(img);
|
|
|
|
var img = document.createElement('img');
|
|
img.src = 'kurir/gambar/' + data.no_telpon + '/' + data.gambar_motor;
|
|
img.style.maxWidth = '100%'; // Make the image fit the width of the div
|
|
img.style.maxHeight = '100%'; // Make the image fit the height of the div
|
|
|
|
// Get the preview div
|
|
var previewDiv = document.getElementById('preview-gambar-motor');
|
|
$('#show-upload-gambar-motor').show();
|
|
// Clear any existing content in the preview div
|
|
previewDiv.innerHTML = '';
|
|
|
|
// Append the image to the preview div
|
|
previewDiv.appendChild(img)
|
|
|
|
|
|
$.unblockUI();
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
$.unblockUI();
|
|
swal("Ups!", jqXHR.responseJSON.message ?? 'Something went wrong', "error");
|
|
}
|
|
})
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |