994 lines
31 KiB
HTML
994 lines
31 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 paket | Pengiriman Paket</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">
|
|
<script src="/auth.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="main-menu">
|
|
<header class="header">
|
|
<a href="/admin" class="logo">Shenior paket</a>
|
|
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
|
<div class="user">
|
|
<a href="#" class="avatar"><img src="/images/person.png" id="img-avatar" alt=""
|
|
style="width: 65px; height: 65px;"><span class="status online"></span></a>
|
|
<h5 class="name"><a href="#" id="h5-title">...</a></h5>
|
|
<h5 class="position">Pengguna</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="/user"><i class="menu-icon fa fa-home"></i><span>Halaman
|
|
Utama</span></a>
|
|
</li>
|
|
|
|
<li class="current active">
|
|
<a class="waves-effect" href="/user/kirim-paket"><i
|
|
class="menu-icon ico mdi mdi-motorbike"></i><span>Pengiriman Paket</span></a>
|
|
</li>
|
|
|
|
<li>
|
|
<a class="waves-effect" href="/user/history" ><i
|
|
class="menu-icon ico icon-table"></i><span>History Pengiriman</span></a>
|
|
</li>
|
|
|
|
<li>
|
|
<a class="waves-effect" href="/user/profil"><i class="menu-icon ico icon-user"></i><span>Profil
|
|
Pengunna</span></a>
|
|
</li>
|
|
|
|
<li>
|
|
<a class="waves-effect" onclick="logout()" href="#"><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">Pengiriman Paket</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 Pengiriman Paket</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="addpaketOpenModal()">Pendaftaran Pengiriman Baru</button>
|
|
</div>
|
|
|
|
<div class="form-group text-center" id="text-tiada-pengiriman">
|
|
<p>Tidak ada pengiriman dilakukan</p>
|
|
</div>
|
|
<div class="form-group" id="form-tb-paket">
|
|
<table id="tb-paket" 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-paket" 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-paket-title">Modal title</h4>
|
|
</div>
|
|
<form class="modal-body" id="form-modal">
|
|
<div class="form-group">
|
|
<!-- show the upload -->
|
|
<div id="show-upload-gambar-paket" style="display: none">
|
|
<center>
|
|
<div id="preview-gambar-paket" style="height: 200px; width: 150px"></div>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
<div class="form-group" id="form-gambar-paket">
|
|
<!-- create upload -->
|
|
<label for="modal-paket-nama">Photo Paket</label>
|
|
<input type="file" class="form-control" id="gambar-paket" accept="image/*"
|
|
onchange="showUpload(this, 'gambar-paket')">
|
|
</div>
|
|
|
|
<div class="form-group" id="div-nomor-resi" style="display: none">
|
|
<label for="modal-paket-nomor-resi">Nomor Resi</label>
|
|
<input type="text" class="form-control" id="nomor_resi">
|
|
</div>
|
|
|
|
<div class="form-group" id="div-waktu-dibuat" style="display: none">
|
|
<label for="modal-paket-waktu-dibuat">Waktu Dibuat</label>
|
|
<input type="text" class="form-control" id="waktu_dibuat">
|
|
</div>
|
|
|
|
<div class="form-group" id="div-status" style="display: none">
|
|
<label for="modal-paket-div-status">Status</label>
|
|
<input type="text" class="form-control" id="status">
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-nama-pengirim">Nama Pengirim</label>
|
|
<input type="text" class="form-control" id="nama_pengirim" placeholder="Masukkan Nama Pengirim">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-no-telpon-pengirim">No Telpon/HP Pengirim</label>
|
|
<input type="text" class="form-control" id="no_telpon_pengirim" oninput="numberOnly(this)"
|
|
maxlength="13" placeholder="Masukkan No Telpon/HP Pengirim">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-alamat-pengirim">Alamat Pengirim</label>
|
|
<textarea name="alamat_pengirim" class="form-control" id="alamat_pengirim"
|
|
placeholder="Masukkan Alamat Pengirim" style="resize: none;"></textarea>
|
|
</div>
|
|
|
|
<hr>
|
|
<hr>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-nama-penerima">Nama Penerima</label>
|
|
<input type="text" class="form-control" id="nama_penerima" placeholder="Masukkan Nama Penerima">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-no-telpon-penerima">No Telpon/HP Penerima</label>
|
|
<input type="text" class="form-control" id="no_telpon_penerima" oninput="numberOnly(this)"
|
|
maxlength="13" placeholder="Masukkan No Telpon/HP Penerima">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-alamat-penerima">Alamat Penerima</label>
|
|
<textarea name="alamat_penerima" class="form-control" id="alamat_penerima"
|
|
placeholder="Masukkan Alamat Penerima" style="resize: none;"></textarea>
|
|
</div>
|
|
|
|
<!-- ini dibawah untuk div tamnpilkan progress -->
|
|
<div id="div-form-progress">
|
|
<hr>
|
|
|
|
<div class="form-group" id="div-data-kurir">
|
|
<!-- create underline on <i> -->
|
|
<label for="modal-paket-berat">Kurir Yang Ditugaskan <i
|
|
style="text-decoration: underline;color: blue">(Klik Untuk Melihat Info
|
|
Kurir)</i></label>
|
|
<input type="text" class="form-control" id="input_kurir">
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
|
|
<div class="form-group">
|
|
<label for="modal-paket-berat">Progress</label>
|
|
<div class="activity-list">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- akhir div tampilan progress -->
|
|
|
|
|
|
</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-pengiriman"
|
|
onclick="tambahpengiriman()">Lakukan Pengiriman</button>
|
|
<button type="button" class="btn btn-xs btn-danger btn-sm waves-effect waves-light"
|
|
id="btn-batalkan-paket">Batalkan Pengiriman</button>
|
|
<button type="button" class="btn btn-xs btn-success btn-sm waves-effect waves-light"
|
|
id="btn-terima-paket">Paket Diterima</button>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<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-kurir" 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-kurir" 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-kurir">
|
|
<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-kurir" placeholder="Masukkan DD Motor">
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-default btn-sm waves-effect waves-light"
|
|
id="button-close-modal-kurir">Close</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="/socket-io/client-dist/socket.io.js"></script>
|
|
|
|
<script src="/scripts/main.min.js"></script>
|
|
|
|
<script src="/my-js.js"></script>
|
|
|
|
|
|
<script>
|
|
function showUpload(element) {
|
|
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;
|
|
// make the width 150px and height 150px
|
|
img.style.width = '150px';
|
|
img.style.height = '150px';
|
|
const id = 'show-upload-gambar-paket'
|
|
|
|
const id_preview = 'preview-gambar-paket'
|
|
// 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);
|
|
}
|
|
}
|
|
|
|
|
|
</script>
|
|
<script>
|
|
const global_data = JSON.parse(localStorage.getItem('user'));
|
|
document.getElementById('h5-title').innerHTML = global_data.nama;
|
|
$("#no_telpon_pengirim").val(global_data.no_telpon);
|
|
$("#nama_pengirim").val(global_data.nama);
|
|
$("#alamat_pengirim").val(global_data.alamat);
|
|
$("#img-avatar").attr("src", global_data.gambar == null || global_data.gambar == "" ? "/images/person.png" : "/user/gambar/" + global_data._id + "/" + global_data.gambar);
|
|
|
|
function reloadTable() {
|
|
// destroy table
|
|
// $('#tb-kurir').DataTable().destroy();
|
|
$('#tb-paket').DataTable({
|
|
// responsive: true,
|
|
scrollX: true,
|
|
// order: [
|
|
// [0, 'asc']
|
|
// ],
|
|
ajax: {
|
|
url: '/user/paket/' + global_data._id + '/paket',
|
|
type: 'GET',
|
|
timeout: 120000,
|
|
dataSrc: function (data) {
|
|
// console.log(data)
|
|
if (data.length == 0) {
|
|
$("#form-tb-paket").hide();
|
|
$("#text-tiada-pengiriman").show();
|
|
} else {
|
|
$("#form-tb-paket").show();
|
|
$("#text-tiada-pengiriman").hide();
|
|
}
|
|
return data.reverse();
|
|
}
|
|
},
|
|
"sAjaxDataProp": "",
|
|
"aoColumns": [
|
|
// {
|
|
// "mData": "_id",
|
|
// "title": "No Resi",
|
|
// "render": function (data, type, row) {
|
|
// return data
|
|
// }
|
|
// },
|
|
{
|
|
"mData": "nama_pengirim",
|
|
"title": "Nama Pengirim",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": "nama_penerima",
|
|
"title": "Nama Penerima",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": "alamat_penerima",
|
|
"title": "Alamat Penerima",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": "status",
|
|
"title": "Status",
|
|
"render": function (data, type, row) {
|
|
return data
|
|
}
|
|
},
|
|
{
|
|
"mData": null,
|
|
"title": "Aksi",
|
|
"render": function (data, type, row) {
|
|
let html = '';
|
|
if (data.status == "Menunggu Admin Memproses") {
|
|
html = `<button type='button' onclick='deletepaket("${data._id}")' title='Batalkan Pengiriman' class='btn btn-danger btn-circle btn-sm waves-effect waves-light'><i class='ico icon-cancel-circled'></i></button>`;
|
|
}
|
|
return `<button type='button' onclick='open_modal_paket("${data._id}")' title='Detail Pengiriman' class='btn btn-info btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-info'></i></button> ${html}`
|
|
}
|
|
}
|
|
]
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
reloadTable()
|
|
|
|
</script>
|
|
<script src="/user.js"></script>
|
|
|
|
<script>
|
|
function addpaketOpenModal() {
|
|
$("#btn-pengiriman").show();
|
|
$("#btn-batalkan-paket").hide();
|
|
$("#div-form-progress").hide();
|
|
$("#btn-terima-paket").hide();
|
|
$('#modal-paket-title').html('Form Pengiriman Paket Baru');
|
|
$("#div-nomor-resi").hide();
|
|
$("#div-waktu-dibuat").hide();
|
|
$("#div-status").hide();
|
|
$("#nama_pengirim").val(global_data.nama);
|
|
$("#no_telpon_pengirim").val(global_data.no_telpon);
|
|
$("#alamat_pengirim").val(global_data.alamat);
|
|
$("#nama_penerima").val("");
|
|
$("#no_telpon_penerima").val("");
|
|
$("#alamat_penerima").val("");
|
|
$("#show-upload-gambar-paket").hide();
|
|
$("#gambar-paket").val('');
|
|
$('#form-modal :input').prop('disabled', false);
|
|
$('#modal-paket').modal({
|
|
backdrop: 'static',
|
|
keyboard: false // Optional: prevents closing via Esc key
|
|
});
|
|
}
|
|
function tambahpengiriman() {
|
|
if ($("#gambar-paket")[0].files.length == 0) {
|
|
toastr.error("Foto Pengiriman Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#gambar-paket").focus();
|
|
return;
|
|
}
|
|
if ($("#nama_pengirim").val() == "") {
|
|
toastr.error("Nama Pengirim Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#nama_pengirim").focus();
|
|
return;
|
|
}
|
|
|
|
if ($("#no_telpon_pengirim").val() == "") {
|
|
toastr.error("No Telpon Pengirim Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#no_telpon_pengirim").focus();
|
|
return;
|
|
}
|
|
|
|
if ($("#alamat_pengirim").val() == "") {
|
|
toastr.error("Alamat Pengirim Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#alamat_pengirim").focus();
|
|
return;
|
|
}
|
|
|
|
if ($("#nama_penerima").val() == "") {
|
|
toastr.error("Nama Penerima Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#nama_penerima").focus();
|
|
return;
|
|
}
|
|
|
|
if ($("#no_telpon_penerima").val() == "") {
|
|
toastr.error("No Telpon Penerima Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#no_telpon_penerima").focus();
|
|
return;
|
|
}
|
|
|
|
if ($("#alamat_penerima").val() == "") {
|
|
toastr.error("Alamat Penerima Tidak Boleh Kosong");
|
|
// focus to input
|
|
$("#alamat_penerima").focus();
|
|
return;
|
|
}
|
|
|
|
|
|
swal({
|
|
title: "Yakin?",
|
|
text: "Anda yakin ingin mengirim paket?",
|
|
icon: "info",
|
|
showCancelButton: !0,
|
|
// confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "Ya",
|
|
cancelButtonText: "Tidak",
|
|
}, function (y) {
|
|
if (y) {
|
|
let form_data = new FormData();
|
|
form_data.append('_id', global_data._id);
|
|
form_data.append('no_telpon_pengirim', $("#no_telpon_pengirim").val());
|
|
form_data.append('nama_pengirim', $("#nama_pengirim").val());
|
|
form_data.append('alamat_pengirim', $("#alamat_pengirim").val());
|
|
form_data.append('nama_penerima', $("#nama_penerima").val());
|
|
form_data.append('no_telpon_penerima', $("#no_telpon_penerima").val());
|
|
form_data.append('alamat_penerima', $("#alamat_penerima").val());
|
|
form_data.append('gambar_paket', $("#gambar-paket")[0].files[0]);
|
|
|
|
$.ajax({
|
|
url: '/user/kirim-paket/',
|
|
type: 'POST',
|
|
data: form_data,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function () {
|
|
$('#modal-paket').modal('hide');
|
|
blockUI('Melakukan Permintaan Pengiriman Paket...');
|
|
},
|
|
|
|
complete: () => {
|
|
// console.log(data);
|
|
|
|
$.unblockUI();
|
|
},
|
|
success: (data) => {
|
|
console.log(data);
|
|
toastr.options.timeOut = 2500; // 2.5 seconds
|
|
toastr.success('Permintaan Pengiriman Paket Berhasil<br>Menunggu Admin Menyetujui');
|
|
$('#modal-paket').modal('hide');
|
|
// destroy table
|
|
$('#tb-paket').DataTable().destroy();
|
|
reloadTable();
|
|
// $.unblockUI();
|
|
},
|
|
// location.reload();
|
|
error: (xhr, status, error) => {
|
|
$('#modal-paket').modal('show');
|
|
console.log(xhr.responseJSON);
|
|
toastr.error(xhr.responseJSON !== undefined ? xhr.responseJSON : "Terjadi Kesalahan Server");
|
|
// $.unblockUI();
|
|
}
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
async function open_modal_paket(id) {
|
|
$("#btn-terima-paket").hide();
|
|
$("#div-form-progress").show();
|
|
$.ajax({
|
|
url: '/user/paket-detail/' + id,
|
|
type: 'GET',
|
|
timeout: 20000,
|
|
beforeSend: function () {
|
|
blockUI('Loading Data...');
|
|
},
|
|
complete: function () {
|
|
$.unblockUI();
|
|
},
|
|
success: function (data) {
|
|
// Handle the response here
|
|
|
|
// let waktu_dibuat = new Date(data.createdAt);
|
|
|
|
$('#modal-paket-title').html('Form Detail Pengiriman Paket');
|
|
|
|
$("#btn-pengiriman").hide();
|
|
$("#btn-batalkan-paket").hide();
|
|
if (data.status == "Menunggu Admin Memproses") {
|
|
$("#btn-batalkan-paket").show();
|
|
// add onclick deletepaket(data._id);
|
|
$("#btn-batalkan-paket").attr('onclick', 'deletepaket("' + data._id + '")');
|
|
}
|
|
|
|
// $("#id").val(data._id);
|
|
$("#div-nomor-resi").show();
|
|
$("#nomor_resi").val(data._id);
|
|
$("#div-waktu-dibuat").show();
|
|
$("#waktu_dibuat").val(formatToMakassar(data.createdAt));
|
|
$("#div-status").show();
|
|
$("#status").val(data.status);
|
|
$("#no_telpon_pengirim").val(data.no_telpon_pengirim);
|
|
$("#nama_pengirim").val(data.nama_pengirim);
|
|
$("#alamat_pengirim").val(data.alamat_pengirim);
|
|
$("#no_telpon_penerima").val(data.no_telpon_penerima);
|
|
$("#nama_penerima").val(data.nama_penerima);
|
|
$("#alamat_penerima").val(data.alamat_penerima);
|
|
// $("#gambar-paket").attr("src", data.gambar_paket);
|
|
|
|
var img = document.createElement('img');
|
|
img.src = "/user/paket-detail/" + data._id + "/" + data.gambar_paket;
|
|
// make the width 150px and height 150px
|
|
img.style.width = '150px';
|
|
img.style.height = '150px';
|
|
const id = 'show-upload-gambar-paket'
|
|
|
|
const id_preview = 'preview-gambar-paket'
|
|
// 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);
|
|
|
|
// disable all input in #form-modal
|
|
$("#form-gambar-paket").hide();
|
|
|
|
$('#form-modal :input').prop('disabled', true);
|
|
|
|
// tampilkan data kurir
|
|
if (data.nama_kurir) {
|
|
$("#input_kurir").val(data.nama_kurir);
|
|
$("#div-data-kurir").attr("onclick", `liat_info_kurir('${data.id_kurir}', '${data._id}')`);
|
|
$("#div-data-kurir").show();
|
|
} else {
|
|
$("#div-data-kurir").hide();
|
|
}
|
|
|
|
let activity_html = '';
|
|
for (let i = data.timeline.length - 1; i >= 0; i--) {
|
|
let colornya = 'bg-info';
|
|
|
|
if (data.timeline[i].status == 'Paket Telah Diterima Penerima') {
|
|
colornya = 'bg-success';
|
|
}
|
|
|
|
if (data.timeline[i].status.includes('Dibatalkan')) {
|
|
colornya = 'bg-danger';
|
|
}
|
|
|
|
activity_html += `<div class="activity-item">
|
|
<div class="bar ${colornya}">
|
|
<div class="dot ${colornya}"></div>
|
|
</div>
|
|
<div class="content">
|
|
<div class="date">${formatToMakassar(data.timeline[i].waktu)}</div>
|
|
<div class="text">
|
|
${data.timeline[i].status}
|
|
${!data.timeline[i].gambar ? "" : `<br><img src="/kurir/gambar-paket/${data._id}/${data.timeline[i].gambar}" width="100px" height="100px">`}
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
$('.activity-list').html(activity_html);
|
|
|
|
if (data.status == "Paket Telah Diterima Penerima") {
|
|
$("#btn-terima-paket").show();
|
|
$("#btn-terima-paket").attr("onclick", `terima_paket('${data._id}')`);
|
|
}
|
|
|
|
$('#modal-paket').modal({
|
|
backdrop: 'static',
|
|
keyboard: false // Optional: prevents closing via Esc key
|
|
});
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error('AJAX error:', error);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
// console.log(id);
|
|
|
|
}
|
|
|
|
|
|
function liat_info_kurir(id_kurir, id) {
|
|
// close modal-paket
|
|
$('#modal-paket').modal('hide');
|
|
console.log(id_kurir, id)
|
|
selectClicked = false
|
|
|
|
$("#button-close-modal-kurir").attr("onclick", `close_modal_kurir('${id}')`);
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/user/cek-kurir/' + id_kurir,
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
blockUI('Loading')
|
|
},
|
|
complete: function () {
|
|
$.unblockUI();
|
|
},
|
|
|
|
success: function (data) {
|
|
console.log(data)
|
|
$('#modal-kurir-title').html('Detail Kurir')
|
|
// hide form-gambar div
|
|
$("#form-gambar-kurir").attr("hidden", true);
|
|
$("#form-gambar-motor").attr("hidden", true);
|
|
$("#no_telpon-kurir").val(data.no_telpon)
|
|
$("#nama-kurir").val(data.nama)
|
|
$("#jenis-kelamin-kurir").val(data.jenis_kelamin)
|
|
$("#dd-motor-kurir").val(data.dd_motor)
|
|
// disable all input in #form-modal
|
|
|
|
enableInput(true)
|
|
|
|
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)
|
|
|
|
$('#modal-kurir').modal({
|
|
backdrop: 'static',
|
|
keyboard: false // Optional: prevents closing via Esc key
|
|
});
|
|
|
|
},
|
|
error: function (xhr, status, error) {
|
|
// console.error('AJAX error:', error);
|
|
// $('#modal-paket').modal('show');
|
|
console.log(xhr.responseJSON);
|
|
toastr.error(xhr.responseJSON !== undefined ? xhr.responseJSON : "Terjadi Kesalahan Server");
|
|
}
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
function close_modal_kurir(id) {
|
|
$('#modal-kurir').modal('hide');
|
|
|
|
// 1.5 sec then open modal
|
|
setTimeout(function () {
|
|
$('#modal-paket').modal('show');
|
|
}, 500);
|
|
// reloadTable(id);
|
|
}
|
|
|
|
|
|
function terima_paket(id) {
|
|
// close modal-paket
|
|
$('#modal-paket').modal('hide');
|
|
|
|
swal({
|
|
title: "Apakah Anda Yakin?",
|
|
text: "Paket Telah Diterima",
|
|
type: "success",
|
|
showCancelButton: !0,
|
|
confirmButtonColor: "green",
|
|
confirmButtonText: "Ya",
|
|
cancelButtonText: "Tidak",
|
|
}, function (willAccept) {
|
|
if (!willAccept) {
|
|
// show modal
|
|
$('#modal-paket').modal('show');
|
|
return;
|
|
}
|
|
|
|
swal.close();
|
|
// console.log(id)
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/user/terima-paket/' + id,
|
|
data: {
|
|
id_pengirim: global_data._id,
|
|
},
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
blockUI('Loading')
|
|
},
|
|
complete: function () {
|
|
$.unblockUI();
|
|
},
|
|
success: function (data) {
|
|
console.log(data)
|
|
setTimeout(function () {
|
|
swal({
|
|
title: "Sukses",
|
|
text: "Anda Dapat Melihat Detail Pengiriman Pada Menu <br><b>History Pengiriman</b>",
|
|
html: true,
|
|
type: "success",
|
|
timer: 3500, // time in milliseconds (2000ms = 2 seconds)
|
|
showConfirmButton: false
|
|
});
|
|
}, 250);
|
|
// destroy modal
|
|
$('#tb-paket').DataTable().destroy();
|
|
reloadTable();
|
|
|
|
},
|
|
error: function (xhr, status, error) {
|
|
// console.error('AJAX error:', error);
|
|
$('#modal-paket').modal('show');
|
|
console.log(xhr.responseJSON);
|
|
toastr.error(xhr.responseJSON !== undefined ? xhr.responseJSON : "Terjadi Kesalahan Server");
|
|
}
|
|
})
|
|
|
|
// setTimeout(function () {
|
|
|
|
// }, 250);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function deletepaket(id) {
|
|
// console.log(id)
|
|
|
|
const isOpen = $('#modal-paket').is(':visible');
|
|
if (isOpen) {
|
|
$('#modal-paket').modal('hide');
|
|
}
|
|
console.log(isOpen);
|
|
swal({
|
|
title: "Apakah Anda Yakin?",
|
|
text: "Anda Akan Membatal Pengiriman dengan No Resi <br><b>" + id + "</b>",
|
|
html: true,
|
|
type: "warning",
|
|
showCancelButton: !0,
|
|
confirmButtonColor: "red",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Ya",
|
|
cancelButtonText: "Tidak",
|
|
closeOnConfirm: !1,
|
|
closeOnCancel: !1
|
|
}, function (willDelete) {
|
|
if (!willDelete) {
|
|
swal.close();
|
|
// show modal
|
|
if (isOpen) {
|
|
$('#modal-paket').modal('show');
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
swal.close();
|
|
// console.log(id)
|
|
$.ajax({
|
|
type: 'DELETE',
|
|
url: '/user/delete-paket/' + id,
|
|
data: {
|
|
id_pengirim: global_data._id,
|
|
},
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
blockUI('Loading')
|
|
},
|
|
complete: function () {
|
|
$.unblockUI();
|
|
},
|
|
success: function (data) {
|
|
console.log(data)
|
|
// destroy modal
|
|
$('#tb-paket').DataTable().destroy();
|
|
reloadTable();
|
|
swal({
|
|
title: "Sukses",
|
|
text: "Pengiriman Berhasil Dibatalkan, Anda Dapat Melihat Detail Pengiriman Pada Menu <br><b>History Pengiriman</b>",
|
|
html: true,
|
|
type: "success",
|
|
timer: 2500, // time in milliseconds (2000ms = 2 seconds)
|
|
showConfirmButton: false
|
|
});
|
|
},
|
|
error: function (xhr, status, error) {
|
|
// console.error('AJAX error:', error);
|
|
if (isOpen) {
|
|
$('#modal-paket').modal('show');
|
|
}
|
|
console.log(xhr.responseJSON);
|
|
toastr.error(xhr.responseJSON !== undefined ? xhr.responseJSON : "Terjadi Kesalahan Server");
|
|
}
|
|
})
|
|
});
|
|
}
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
</html> |