Initial commit
This commit is contained in:
887
resources/views/menu_v1/configs/devices.blade.php
Executable file
887
resources/views/menu_v1/configs/devices.blade.php
Executable file
@ -0,0 +1,887 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Master Devices
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
<style>
|
||||
/* .select2-container {
|
||||
z-index: 99999;
|
||||
} */
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">Device (<span id="count_devices">0</span>)</p>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button id="btnMdlNewDevice" class="btn btn-sm btn-danger">Tambah Device Baru</button>
|
||||
</div>
|
||||
<div class="col-auto text-end ps-0">
|
||||
{{-- <button class="btn btn-sm btn-danger">Upload</button> --}}
|
||||
{{-- <button class="btn btn-sm btn-danger">Download</button> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="tDevices" class="table table-hover dataTable">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">#</th>
|
||||
<th class="text-center">Action</th>
|
||||
<th class="">Device ID</th>
|
||||
<th class="">Name</th>
|
||||
<th class="text-end">Simcard</th>
|
||||
<th class="text-end">Type</th>
|
||||
<th class="text-center">Status</th>
|
||||
<th class="text-center">Pemasangan</th>
|
||||
<th class="text-center">Ketersediaan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlNewDevice" aria-labelledby="mdlNewDeviceLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlNewDeviceLabel">Tambah Device Baru</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Primary --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Data Device</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<label for="add-device_id" class="col-form-label">Device ID<span class="text-danger">*</span></label>
|
||||
<input type="number" name="add-device_id" id="add-device_id" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-name" class="col-form-label">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" name="add-name" id="add-name" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-simcard" class="col-form-label">Simcard<span class="text-danger">*</span></label>
|
||||
<input type="number" name="add-simcard" id="add-simcard" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-type" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||
<select name="add-type" id="add-type" class="form-control" style="width:100%;">
|
||||
<option value="" selected disabled>Belum dipilih</option>
|
||||
<option value="{{ \App\Models\Devices::TYPE_BUILT_IN }}">Built-in</option>
|
||||
<option value="{{ \App\Models\Devices::TYPE_PORTABLE }}">Portable</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-status" class="form-label">Status<span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-status">
|
||||
<label class="form-check-label" for="add-status"><span class="text-dark" id="add-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="add-assigned" class="form-label">Terpasang ? <span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-assigned">
|
||||
<label class="form-check-label" for="add-assigned"><span class="text-dark" id="add-txtAssigned">Dilepas</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group vhcAssignGroup d-none">
|
||||
<label for="add-vhc_assigned" class="col-form-label">Kendaraan<span class="text-danger">*</span></label>
|
||||
<select name="add-vhc_assigned" id="add-vhc_assigned" class="form-control" style="width:100%;">
|
||||
<option value="" selected disabled>Belum dipilih</option>
|
||||
@foreach ($vhcs as $vhc)
|
||||
<option value="{{ $vhc->vid }}" data-vid="{{ $vhc->vid }}" data-nopol="{{ $vhc->nopol1 . ' ' . $vhc->nopol2 . ' ' . $vhc->nopol3 }}">{{ $vhc->nopol1 . ' ' . $vhc->nopol2 . ' ' . $vhc->nopol3 }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="add-available" class="form-label">Tersedia ? <span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-available">
|
||||
<label class="form-check-label" for="add-available"><span class="text-dark" id="add-txtAvailable">Tidak Tersedia</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button id="btnSubmitNewDevice" type="button" class="btn btn-sm btn-danger">Submit data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlUpdtDevice" aria-labelledby="mdlUpdtDeviceLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlUpdtDeviceLabel">Edit Device</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Primary --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Data Device</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-device_id" class="col-form-label">Device ID<span class="text-danger">*</span></label>
|
||||
<input type="number" name="updt-device_id" id="updt-device_id" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-name" class="col-form-label">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-name" id="updt-name" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-simcard" class="col-form-label">Simcard<span class="text-danger">*</span></label>
|
||||
<input type="number" name="updt-simcard" id="updt-simcard" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-type" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||
<select name="updt-type" id="updt-type" class="form-control" style="width:100%;">
|
||||
<option value="" selected disabled>Belum dipilih</option>
|
||||
<option value="{{ \App\Models\Devices::TYPE_BUILT_IN }}">Built-in</option>
|
||||
<option value="{{ \App\Models\Devices::TYPE_PORTABLE }}">Portable</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-status" class="form-label">Status<span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-status">
|
||||
<label class="form-check-label" for="updt-status"><span class="text-dark" id="updt-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="updt-assigned" class="form-label">Terpasang ? <span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-assigned">
|
||||
<label class="form-check-label" for="updt-assigned"><span class="text-dark" id="updt-txtAssigned">Dilepas</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group vhcAssignGroup d-none">
|
||||
<label for="updt-vhc_assigned" class="col-form-label">Kendaraan<span class="text-danger">*</span></label>
|
||||
<select name="updt-vhc_assigned" id="updt-vhc_assigned" class="form-control" style="width:100%;">
|
||||
<option value="" selected disabled>Belum dipilih</option>
|
||||
@foreach ($vhcs as $vhc)
|
||||
<option value="{{ $vhc->vid }}" data-vid="{{ $vhc->vid }}" data-nopol="{{ $vhc->nopol1 . ' ' . $vhc->nopol2 . ' ' . $vhc->nopol3 }}">{{ $vhc->nopol1 . ' ' . $vhc->nopol2 . ' ' . $vhc->nopol3 }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="updt-available" class="form-label">Tersedia ? <span class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-available">
|
||||
<label class="form-check-label" for="updt-available"><span class="text-dark" id="updt-txtAvailable">Tidak Tersedia</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="btnDelDevice_updt" class="btn btn-sm btn-warning">Hapus ?</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button id="btnSubmitUpdtDevices" type="button" class="btn btn-sm btn-danger">Ubah data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDelDevice" aria-labelledby="mdlDelDeviceLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlDelDeviceLabel">Delete Device</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex justify-content-center">
|
||||
<p class="mb-0">
|
||||
Kamu yakin ingin menghapus device
|
||||
<a href="#" class="text-danger">
|
||||
<span id="del-device_id"></span>
|
||||
</a>
|
||||
?
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-danger" data-bs-dismiss="modal">Tutup</button>
|
||||
<button id="btnSubmitDelDevice" type="button" class="btn btn-sm btn-secondary">Iya, hapus</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('customjs')
|
||||
<script src="{{ asset('assets/js/load-image.all.min.js') }}"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
const State = {
|
||||
file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}",
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
stts_isact: {
|
||||
active: "{{ App\Models\Devices::IS_ACTIVE }}",
|
||||
inactive: "{{ App\Models\Devices::IS_INACTIVE }}",
|
||||
},
|
||||
stts_assigned: {
|
||||
assigned: "{{ App\Models\Devices::IS_ASSIGNED }}",
|
||||
unassigned: "{{ App\Models\Devices::IS_UNASSIGNED }}",
|
||||
},
|
||||
stts_available: {
|
||||
available: "{{ App\Models\Devices::IS_AVAIL }}",
|
||||
unavailable: "{{ App\Models\Devices::IS_UNAVAIL }}",
|
||||
},
|
||||
type: {
|
||||
built_in: "{{ App\Models\Devices::TYPE_BUILT_IN }}",
|
||||
portable: "{{ App\Models\Devices::TYPE_PORTABLE }}",
|
||||
},
|
||||
delay_typing_front: 1000,
|
||||
};
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
ANew.activate();
|
||||
AUpdt.activate();
|
||||
ADel.activate();
|
||||
},
|
||||
event: function() {
|
||||
$('#add-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtStatus').html('Active')
|
||||
else
|
||||
$('#add-txtStatus').html('Inactive')
|
||||
});
|
||||
$('#updt-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtStatus').html('Active')
|
||||
else
|
||||
$('#updt-txtStatus').html('Inactive')
|
||||
});
|
||||
$('#add-assigned').bind('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#add-txtAssigned').html('Terpasang')
|
||||
$('.vhcAssignGroup').removeClass('d-none');
|
||||
} else {
|
||||
$('#add-txtAssigned').html('Dilepas')
|
||||
$('.vhcAssignGroup').addClass('d-none');
|
||||
}
|
||||
});
|
||||
$('#updt-assigned').bind('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#updt-txtAssigned').html('Terpasang')
|
||||
$('.vhcAssignGroup').removeClass('d-none');
|
||||
} else {
|
||||
$('#updt-txtAssigned').html('Dilepas')
|
||||
$('.vhcAssignGroup').addClass('d-none');
|
||||
}
|
||||
});
|
||||
$('#add-available').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtAvailable').html('Tersedia')
|
||||
else
|
||||
$('#add-txtAvailable').html('Tidak Tersedia')
|
||||
});
|
||||
$('#updt-available').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtAvailable').html('Tersedia')
|
||||
else
|
||||
$('#updt-txtAvailable').html('Tidak Tersedia')
|
||||
});
|
||||
// fix modal select2
|
||||
$('#add-type').select2({
|
||||
dropdownParent: $('#mdlNewDevice'),
|
||||
});
|
||||
$('#add-vhc_assigned').select2({
|
||||
dropdownParent: $('#mdlNewDevice'),
|
||||
});
|
||||
$('#updt-type').select2({
|
||||
dropdownParent: $('#mdlUpdtDevice'),
|
||||
});
|
||||
$('#updt-vhc_assigned').select2({
|
||||
dropdownParent: $('#mdlUpdtDevice'),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
// $('#tDevices').DataTable();
|
||||
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||
$('#tDevices').DataTable({
|
||||
processing: true,
|
||||
serverSide: false,
|
||||
bLengthChange: true,
|
||||
deferRender: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: "{{ route('api_list_devices') }}",
|
||||
type: 'GET',
|
||||
complete: function(jqXHR, textStatus, c) {
|
||||
let count = jqXHR.responseJSON.count;
|
||||
if (typeof count != 'undefined') {
|
||||
$('#count_devices').text(count);
|
||||
}
|
||||
// removeTableSkeletonLoading()
|
||||
},
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
className: 'text-end',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
let action = `
|
||||
<a href="#" class="text-decoration-none me-1 btnUpdtDevice">
|
||||
<span class="icon ion-edit fz-16"></span>
|
||||
</a>
|
||||
`;
|
||||
// <a href="#" class="text-decoration-none text-danger btnDelDevice">
|
||||
// <span class="icon ion-trash-b fz-16"></span>
|
||||
// </a>
|
||||
return action;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'device_id',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
createdCell: function(td, cellData, rowData, row, col) {
|
||||
$(td).attr('data-id', rowData.id);
|
||||
$(td).attr('data-device_id', rowData.device_id);
|
||||
$(td).attr('data-simcard', rowData.simcard);
|
||||
},
|
||||
render: function(data, type, row, meta) {
|
||||
return `<span class="d-none">${data}</span>` + Helper.splitEvery4Char(`${data}`);
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'name',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'simcard',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return `<span class="d-none">${data}</span>` + Helper.splitEvery4Char(`${data}`);
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'type',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.type.built_in) return 'Built-In';
|
||||
return 'Portable';
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'is_active',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_isact.active) return '<span class="badge rounded-pill bg-success">Active</span>';
|
||||
return '<span class="badge rounded-pill bg-danger">Inactive</span>';
|
||||
}
|
||||
},
|
||||
// {
|
||||
// data: 'is_idle',
|
||||
// className: 'text-center text-nowrap',
|
||||
// visible: true,
|
||||
// orderable: true,
|
||||
// searchable: true,
|
||||
// render: function(data, type, row, meta) {
|
||||
// if (data == 'yes') return '<span class="badge rounded-pill bg-danger">Dilepas</span>';
|
||||
// return '<span class="badge rounded-pill bg-success">Terpasang</span>';
|
||||
// }
|
||||
// },
|
||||
{
|
||||
data: 'is_assigned',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_assigned.assigned) {
|
||||
return '<span class="badge rounded-pill bg-success">Terpasang</span>'
|
||||
} else {
|
||||
return '<span class="badge rounded-pill bg-danger">Dilepas</span>'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'is_available',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_available.available) {
|
||||
return '<span class="badge rounded-pill bg-success">Tersedia</span>'
|
||||
} else {
|
||||
return '<span class="badge rounded-pill bg-danger">Tidak Tersedia</span>'
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const ANew = {
|
||||
activate: function() {
|
||||
ANew.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#btnMdlNewDevice').on('click', function() {
|
||||
$('#mdlNewDevice').modal('show');
|
||||
});
|
||||
$('#mdlNewDevice').on('shown.bs.modal', function() {
|
||||
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitNewDevice').on('click', function() {
|
||||
let data = ANew.getData();
|
||||
ANew.submitData(data);
|
||||
});
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
data.device_id = $('#add-device_id').val();
|
||||
data.name = $('#add-name').val();
|
||||
data.simcard = $('#add-simcard').val();
|
||||
data.type = $('#add-type').val();
|
||||
|
||||
if ($('#add-status').prop('checked')) {
|
||||
data.status = State.stts_isact.active;
|
||||
} else {
|
||||
data.status = State.stts_isact.inactive;
|
||||
}
|
||||
|
||||
if ($('#add-assigned').prop('checked')) {
|
||||
data.assigned = State.stts_assigned.assigned;
|
||||
} else {
|
||||
data.assigned = State.stts_assigned.unassigned;
|
||||
}
|
||||
data.vid = $('#add-vhc_assigned').val();
|
||||
|
||||
if ($('#add-available').prop('checked')) {
|
||||
data.available = State.stts_available.available;
|
||||
} else {
|
||||
data.available = State.stts_available.unavailable;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitNewDevice').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitNewDevice').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_add_device') }}",
|
||||
method: 'POST',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitNewDevice').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success add new device');
|
||||
$('#mdlNewDevice').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitNewDevice').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const AUpdt = {
|
||||
activate: function() {
|
||||
AUpdt.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#tDevices').on('click', '.btnUpdtDevice', async function(e) {
|
||||
let id = $(e.target).closest('tr').find('td[data-id]').data('id');
|
||||
let resp = await AUpdt.reqData({
|
||||
id
|
||||
});
|
||||
if (resp.type != 'success') {
|
||||
Helper.toast('Device Not Found', 'just now', 'please try again');
|
||||
return false;
|
||||
}
|
||||
AUpdt.passDataToView(resp.data);
|
||||
});
|
||||
$('#mdlUpdtDevice').on('shown.bs.modal', function() {
|
||||
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitUpdtDevices').on('click', function() {
|
||||
let data = AUpdt.getData();
|
||||
AUpdt.submitData(data);
|
||||
});
|
||||
},
|
||||
reqData: function(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: "{{ route('api_show_device', '') }}/" + params.id,
|
||||
method: 'GET',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
},
|
||||
data: params,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
resolve({
|
||||
type: 'success',
|
||||
data: data.data
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
passDataToView: async function(data) {
|
||||
$('#updt-device_id').val(data.device_id);
|
||||
$('#updt-name').val(data.name);
|
||||
$('#updt-simcard').val(data.simcard);
|
||||
$('#updt-type').val(data.type).trigger('change');
|
||||
|
||||
if (data.is_active == State.stts_isact.active) {
|
||||
$('#updt-status').prop('checked', true).trigger('change');
|
||||
} else {
|
||||
$('#updt-status').prop('checked', false).trigger('change');
|
||||
}
|
||||
|
||||
if (data.is_assigned == State.stts_assigned.assigned) {
|
||||
$('#updt-assigned').prop('checked', true).trigger('change');
|
||||
} else {
|
||||
$('#updt-assigned').prop('checked', false).trigger('change');
|
||||
}
|
||||
let vhc_id = (data?.vhc_id) ? data?.vhc_id : '';
|
||||
if (vhc_id == 0 || vhc_id == '') {} else {
|
||||
if ($(`#updt-vhc_assigned option[value='${vhc_id}']`).length < 1) {
|
||||
$('#updt-vhc_assigned').append(`<option value="${vhc_id }}" data-vid="${vhc_id }}" data-nopol="${data.vhc_nopol1} ${data.vhc_nopol2} ${data.vhc_nopol3}</option>`);
|
||||
$('#updt-vhc_assigned').select2({
|
||||
dropdownParent: $('#mdlUpdtDevice'),
|
||||
});
|
||||
}
|
||||
}
|
||||
$('#updt-vhc_assigned').val(vhc_id).trigger('change');
|
||||
|
||||
if (data.is_available == State.stts_available.available) {
|
||||
$('#updt-available').prop('checked', true).trigger('change');
|
||||
} else {
|
||||
$('#updt-available').prop('checked', false).trigger('change');
|
||||
}
|
||||
|
||||
$('#mdlUpdtDevice').data('id', data.id);
|
||||
$('#mdlUpdtDevice').modal('show');
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
data.id = $('#mdlUpdtDevice').data('id');
|
||||
|
||||
data.device_id = $('#updt-device_id').val();
|
||||
data.name = $('#updt-name').val();
|
||||
data.simcard = $('#updt-simcard').val();
|
||||
data.type = $('#updt-type').val();
|
||||
|
||||
if ($('#updt-status').prop('checked')) {
|
||||
data.status = State.stts_isact.active;
|
||||
} else {
|
||||
data.status = State.stts_isact.inactive;
|
||||
}
|
||||
|
||||
if ($('#updt-assigned').prop('checked')) {
|
||||
data.assigned = State.stts_assigned.assigned;
|
||||
} else {
|
||||
data.assigned = State.stts_assigned.unassigned;
|
||||
}
|
||||
data.vid = $('#updt-vhc_assigned').val();
|
||||
|
||||
if ($('#updt-available').prop('checked')) {
|
||||
data.available = State.stts_available.available;
|
||||
} else {
|
||||
data.available = State.stts_available.unavailable;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitUpdtDevices').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitUpdtDevices').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_updt_device', '') }}/" + data.id,
|
||||
method: 'PUT',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitUpdtDevices').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success update device');
|
||||
$('#mdlUpdtDevice').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitUpdtDevices').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const ADel = {
|
||||
activate: function() {
|
||||
ADel.event();
|
||||
},
|
||||
event: function() {
|
||||
// on table
|
||||
$('#tDevices').on('click', '.btnDelDevice', function(e) {
|
||||
let row = $(e.target).closest('tr');
|
||||
let id = row.find('td[data-id]').data('id');
|
||||
let device_id = row.find('td[data-device_id]').data('device_id');
|
||||
let simcard = row.find('td[data-simcard]').data('simcard');
|
||||
ADel.passDataToView({
|
||||
id,
|
||||
device_id,
|
||||
simcard,
|
||||
});
|
||||
$('#mdlDelDevice').data('id', id);
|
||||
$('#mdlDelDevice').modal('show');
|
||||
});
|
||||
$('#btnSubmitDelDevice').on('click', function() {
|
||||
let data = {
|
||||
id: $('#mdlDelDevice').data('id'),
|
||||
};
|
||||
ADel.submitData(data);
|
||||
});
|
||||
// on modal update
|
||||
$('#btnDelDevice_updt').on('click', function(e) {
|
||||
const {
|
||||
id,
|
||||
device_id,
|
||||
simcard
|
||||
} = AUpdt.getData();
|
||||
ADel.passDataToView({
|
||||
id,
|
||||
device_id,
|
||||
simcard,
|
||||
});
|
||||
$('#mdlDelDevice').data('id', id);
|
||||
$('#mdlDelDevice').modal('show');
|
||||
});
|
||||
},
|
||||
passDataToView: function(data) {
|
||||
$('#del-device_id').text(data.device_id);
|
||||
$('#del-simcard').text(data.simcard);
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitDelDevice').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitDelDevice').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_del_device', '') }}/" + data.id,
|
||||
method: 'DELETE',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitDelDevice').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success delete device');
|
||||
$('#mdlDelDevice').modal('hide');
|
||||
$('#mdlUpdtDevice').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitDelDevice').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Wrapper.activate();
|
||||
</script>
|
||||
@endsection
|
||||
123
resources/views/menu_v1/configs/index_logs_gps.blade.php
Executable file
123
resources/views/menu_v1/configs/index_logs_gps.blade.php
Executable file
@ -0,0 +1,123 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Logs Gps Trackers
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">Logs Gps Trackers
|
||||
(<span id="count_logs">0</span>)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="tLogs" class="table table-hover dataTable">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">#</th>
|
||||
<th class="text-end text-nowrap">Device ID / IMEI</th>
|
||||
<th class="text-center text-nowrap">At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('customjs')
|
||||
<script>
|
||||
'use strict';
|
||||
const State = {
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
};
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
},
|
||||
event: function() {
|
||||
setInterval(() => {
|
||||
DTable.reload();
|
||||
}, 10000);
|
||||
},
|
||||
};
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
// $('#tLogs').DataTable();
|
||||
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||
$('#tLogs').DataTable({
|
||||
processing: true,
|
||||
serverSide: false,
|
||||
bLengthChange: true,
|
||||
deferRender: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: "{{ route('api_conf_list_logs_gps') }}",
|
||||
type: 'GET',
|
||||
complete: function(jqXHR, textStatus, c) {
|
||||
let count = jqXHR.responseJSON.count;
|
||||
if (typeof count != 'undefined') {
|
||||
$('#count_logs').text(count);
|
||||
}
|
||||
// removeTableSkeletonLoading()
|
||||
},
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
className: 'text-end',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'device_id',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
// createdCell: function(td, cellData, rowData, row, col) {
|
||||
// $(td).attr('data-ttid', rowData.id);
|
||||
// $(td).attr('data-type_name', rowData.type_name);
|
||||
// },
|
||||
},
|
||||
{
|
||||
data: 'crt',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return moment.unix(data).format('DD MMM YYYY HH:mm:ss');
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Wrapper.activate();
|
||||
</script>
|
||||
@endsection
|
||||
771
resources/views/menu_v1/configs/insurances.blade.php
Executable file
771
resources/views/menu_v1/configs/insurances.blade.php
Executable file
@ -0,0 +1,771 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Assuransi
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
<style>
|
||||
/* .select2-container {
|
||||
z-index: 99999;
|
||||
} */
|
||||
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">Asuransi (<span id="count_insurances">0</span>)</p>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button id="btnMdlNewInsurance" class="btn btn-sm btn-danger">Buat Asuransi Baru</button>
|
||||
</div>
|
||||
<div class="col-auto text-end ps-0">
|
||||
{{-- <button class="btn btn-sm btn-danger">Upload</button> --}}
|
||||
{{-- <button class="btn btn-sm btn-danger">Download</button> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="tInsurances" class="table table-hover dataTable">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">#</th>
|
||||
<th class="text-center">Action</th>
|
||||
<th class="">Nama Premi</th>
|
||||
<th class="text-end">Range (Rp)</th>
|
||||
<th class="text-end">Harga Premi (Rp)</th>
|
||||
<th class="">Keterangan</th>
|
||||
<th class="text-center">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlNewInsurance"
|
||||
aria-labelledby="mdlNewInsuranceLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlNewInsuranceLabel">Buat Asuransi Baru</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Primary --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Data Premi</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<label for="add-name" class="col-form-label">Nama Premi<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="add-name" id="add-name" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-price" class="col-form-label">Harga Premi<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="add-price" id="add-price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-min_price" class="col-form-label">Jumlah Minimal Pertangguhan<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="add-min_price" id="add-min_price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="add-max_price" class="col-form-label">Jumlah Maksimal Pertangguhan<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="add-max_price" id="add-max_price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<label for="add-desc" class="col-form-label">Keterangan</label>
|
||||
<textarea name="add-desc" id="add-desc" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-status" class="form-label">Status<span
|
||||
class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-status">
|
||||
<label class="form-check-label" for="add-status"><span class="text-dark"
|
||||
id="add-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button id="btnSubmitNewInsurance" type="button" class="btn btn-sm btn-danger">Submit data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlEdtInsurances"
|
||||
aria-labelledby="mdlEdtInsurancesLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlEdtInsurancesLabel">Edit Asuransi</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Primary --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Data Premi</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-name" class="col-form-label">Nama Premi<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-name" id="updt-name" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-price" class="col-form-label">Harga Premi<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-price" id="updt-price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-min_price" class="col-form-label">Jumlah Minimal Pertangguhan<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-min_price" id="updt-min_price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="updt-max_price" class="col-form-label">Jumlah Maksimal Pertangguhan<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-max_price" id="updt-max_price" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<label for="updt-desc" class="col-form-label">Keterangan</label>
|
||||
<textarea name="updt-desc" id="updt-desc" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-status" class="form-label">Status<span
|
||||
class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-status">
|
||||
<label class="form-check-label" for="updt-status"><span class="text-dark"
|
||||
id="updt-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="btnDelInsurance_updt" class="btn btn-sm btn-warning">Hapus ?</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button id="btnSubmitEdtInsurances" type="button" class="btn btn-sm btn-danger">Ubah data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDelInsurance"
|
||||
aria-labelledby="mdlDelInsuranceLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlDelInsuranceLabel">Delete Asuransi</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex justify-content-center">
|
||||
<p class="mb-0">
|
||||
Kamu yakin ingin menghapus asuransi
|
||||
<a href="#" class="text-danger">
|
||||
<span id="del-name"></span>
|
||||
</a>
|
||||
?
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-danger" data-bs-dismiss="modal">Tutup</button>
|
||||
<button id="btnSubmitDelInsurance" type="button" class="btn btn-sm btn-secondary">Iya, hapus</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('customjs')
|
||||
<script src="{{ asset('assets/js/load-image.all.min.js') }}"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
const State = {
|
||||
file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}",
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
stts_isact: {
|
||||
active: "{{ App\Models\Insurances::IS_ACTIVE }}",
|
||||
inactive: "{{ App\Models\Insurances::IS_INACTIVE }}",
|
||||
},
|
||||
delay_typing_front: 1000,
|
||||
};
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
ANew.activate();
|
||||
AUpdt.activate();
|
||||
ADel.activate();
|
||||
},
|
||||
event: function() {
|
||||
$('#add-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtStatus').html('Active')
|
||||
else
|
||||
$('#add-txtStatus').html('Inactive')
|
||||
});
|
||||
$('#updt-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtStatus').html('Active')
|
||||
else
|
||||
$('#updt-txtStatus').html('Inactive')
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
// $('#tInsurances').DataTable();
|
||||
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||
$('#tInsurances').DataTable({
|
||||
processing: true,
|
||||
serverSide: false,
|
||||
bLengthChange: true,
|
||||
deferRender: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: "{{ route('api_list_insurances') }}",
|
||||
type: 'GET',
|
||||
complete: function(jqXHR, textStatus, c) {
|
||||
let count = jqXHR.responseJSON.count;
|
||||
if (typeof count != 'undefined') {
|
||||
$('#count_insurances').text(count);
|
||||
}
|
||||
// removeTableSkeletonLoading()
|
||||
},
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
className: 'text-end',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
let action = `
|
||||
<a href="#" class="text-decoration-none me-1 btnUpdtInsurance">
|
||||
<span class="icon ion-edit fz-16"></span>
|
||||
</a>
|
||||
`;
|
||||
// <a href="#" class="text-decoration-none text-danger btnDelInsurance">
|
||||
// <span class="icon ion-trash-b fz-16"></span>
|
||||
// </a>
|
||||
return action;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'premi_name',
|
||||
className: 'text-start text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
createdCell: function(td, cellData, rowData, row, col) {
|
||||
$(td).attr('data-iid', rowData.id);
|
||||
$(td).attr('data-premi_name', rowData.premi_name);
|
||||
$(td).attr('data-premi_price', rowData.premi_price);
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'premi_min_price',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return (new Intl.NumberFormat('id-ID')).format(data) + ' - ' + (
|
||||
new Intl.NumberFormat('id-ID')).format(row.premi_max_price);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'premi_price',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return (new Intl.NumberFormat('id-ID')).format(data);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'desc',
|
||||
className: 'text-start',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (!data) return '-';
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'is_active',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_isact.active)
|
||||
return '<span class="badge rounded-pill bg-success">Active</span>';
|
||||
return '<span class="badge rounded-pill bg-danger">Inactive</span>';
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const ANew = {
|
||||
activate: function() {
|
||||
ANew.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#btnMdlNewInsurance').on('click', function() {
|
||||
$('#mdlNewInsurance').modal('show');
|
||||
});
|
||||
$('#mdlNewInsurance').on('shown.bs.modal', function() {
|
||||
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitNewInsurance').on('click', function() {
|
||||
let data = ANew.getData();
|
||||
ANew.submitData(data);
|
||||
});
|
||||
// input
|
||||
$('#add-price').on('keyup', function(e) {
|
||||
let price = '';
|
||||
if ($('#add-price').val().length < 1) {
|
||||
price = '';
|
||||
} else {
|
||||
price = Number($('#add-price').val().split('.').join(''))
|
||||
price = (new Intl.NumberFormat('id-ID')).format(price);
|
||||
}
|
||||
$('#add-price').val(price);
|
||||
});
|
||||
$('#add-min_price').on('keyup', function(e) {
|
||||
let min_price = '';
|
||||
if ($('#add-min_price').val().length < 1) {
|
||||
min_price = '';
|
||||
} else {
|
||||
min_price = Number($('#add-min_price').val().split('.').join(''))
|
||||
min_price = (new Intl.NumberFormat('id-ID')).format(min_price);
|
||||
}
|
||||
$('#add-min_price').val(min_price);
|
||||
});
|
||||
$('#add-max_price').on('keyup', function(e) {
|
||||
let max_price = '';
|
||||
if ($('#add-max_price').val().length < 1) {
|
||||
max_price = '';
|
||||
} else {
|
||||
max_price = Number($('#add-max_price').val().split('.').join(''))
|
||||
max_price = (new Intl.NumberFormat('id-ID')).format(max_price);
|
||||
}
|
||||
$('#add-max_price').val(max_price);
|
||||
});
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
data.name = $('#add-name').val();
|
||||
data.desc = $('#add-desc').val();
|
||||
|
||||
data.price = $('#add-price').val().split('.').join('');
|
||||
data.min_price = $('#add-min_price').val().split('.').join('');
|
||||
data.max_price = $('#add-max_price').val().split('.').join('');
|
||||
|
||||
if ($('#add-status').prop('checked')) {
|
||||
data.status = State.stts_isact.active;
|
||||
} else {
|
||||
data.status = State.stts_isact.inactive;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitNewInsurance').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitNewInsurance').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_add_insurance') }}",
|
||||
method: 'POST',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitNewInsurance').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success add new insurance');
|
||||
$('#mdlNewInsurance').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitNewInsurance').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const AUpdt = {
|
||||
activate: function() {
|
||||
AUpdt.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#tInsurances').on('click', '.btnUpdtInsurance', async function(e) {
|
||||
let iid = $(e.target).closest('tr').find('td[data-iid]').data('iid');
|
||||
let resp = await AUpdt.reqData({
|
||||
iid
|
||||
});
|
||||
if (resp.type != 'success') {
|
||||
Helper.toast('Insurance Not Found', 'just now', 'please try again');
|
||||
return false;
|
||||
}
|
||||
AUpdt.passDataToView(resp.data);
|
||||
});
|
||||
$('#mdlEdtInsurances').on('shown.bs.modal', function() {
|
||||
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitEdtInsurances').on('click', function() {
|
||||
let data = AUpdt.getData();
|
||||
AUpdt.submitData(data);
|
||||
});
|
||||
// input
|
||||
$('#updt-price').on('keyup', function(e) {
|
||||
let price = '';
|
||||
if ($('#updt-price').val().length < 1) {
|
||||
price = '';
|
||||
} else {
|
||||
price = Number($('#updt-price').val().split('.').join(''))
|
||||
price = (new Intl.NumberFormat('id-ID')).format(price);
|
||||
}
|
||||
$('#updt-price').val(price);
|
||||
});
|
||||
$('#updt-min_price').on('keyup', function(e) {
|
||||
let min_price = '';
|
||||
if ($('#updt-min_price').val().length < 1) {
|
||||
min_price = '';
|
||||
} else {
|
||||
min_price = Number($('#updt-min_price').val().split('.').join(''))
|
||||
min_price = (new Intl.NumberFormat('id-ID')).format(min_price);
|
||||
}
|
||||
$('#updt-min_price').val(min_price);
|
||||
});
|
||||
$('#updt-max_price').on('keyup', function(e) {
|
||||
let max_price = '';
|
||||
if ($('#updt-max_price').val().length < 1) {
|
||||
max_price = '';
|
||||
} else {
|
||||
max_price = Number($('#updt-max_price').val().split('.').join(''))
|
||||
max_price = (new Intl.NumberFormat('id-ID')).format(max_price);
|
||||
}
|
||||
$('#updt-max_price').val(max_price);
|
||||
});
|
||||
},
|
||||
reqData: function(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: "{{ route('api_show_insurance', '') }}/" + params.iid,
|
||||
method: 'GET',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
},
|
||||
data: params,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
resolve({
|
||||
type: 'success',
|
||||
data: data.data
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
passDataToView: async function(data) {
|
||||
$('#updt-name').val(data.premi_name);
|
||||
$('#updt-desc').val(data.desc);
|
||||
|
||||
$('#updt-price').val((new Intl.NumberFormat('id-ID').format(data.premi_price)));
|
||||
$('#updt-min_price').val((new Intl.NumberFormat('id-ID').format(data.premi_min_price)));
|
||||
$('#updt-max_price').val((new Intl.NumberFormat('id-ID').format(data.premi_max_price)));
|
||||
|
||||
if (data.is_active == State.stts_isact.active) {
|
||||
$('#updt-status').prop('checked', true);
|
||||
} else {
|
||||
$('#updt-status').prop('checked', false);
|
||||
}
|
||||
|
||||
$('#mdlEdtInsurances').data('id', data.id);
|
||||
$('#mdlEdtInsurances').modal('show');
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
data.iid = $('#mdlEdtInsurances').data('id');
|
||||
|
||||
data.name = $('#updt-name').val();
|
||||
data.desc = $('#updt-desc').val();
|
||||
|
||||
data.price = $('#updt-price').val().split('.').join('');
|
||||
data.min_price = $('#updt-min_price').val().split('.').join('');
|
||||
data.max_price = $('#updt-max_price').val().split('.').join('');
|
||||
|
||||
if ($('#updt-status').prop('checked')) {
|
||||
data.status = State.stts_isact.active;
|
||||
} else {
|
||||
data.status = State.stts_isact.inactive;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitEdtInsurances').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitEdtInsurances').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_edit_insurance', '') }}/" + data.iid,
|
||||
method: 'PUT',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitEdtInsurances').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success update insurance');
|
||||
$('#mdlEdtInsurances').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitEdtInsurances').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const ADel = {
|
||||
activate: function() {
|
||||
ADel.event();
|
||||
},
|
||||
event: function() {
|
||||
// on table
|
||||
$('#tInsurances').on('click', '.btnDelInsurance', function(e) {
|
||||
let row = $(e.target).closest('tr');
|
||||
let iid = row.find('td[data-iid]').data('iid');
|
||||
let premi_name = row.find('td[data-premi_name]').data('premi_name');
|
||||
let premi_price = row.find('td[data-premi_price]').data('premi_price');
|
||||
ADel.passDataToView({
|
||||
iid,
|
||||
name: premi_name,
|
||||
price: premi_price,
|
||||
});
|
||||
$('#mdlDelInsurance').data('id', iid);
|
||||
$('#mdlDelInsurance').modal('show');
|
||||
});
|
||||
$('#btnSubmitDelInsurance').on('click', function() {
|
||||
let data = {
|
||||
iid: $('#mdlDelInsurance').data('id'),
|
||||
};
|
||||
ADel.submitData(data);
|
||||
});
|
||||
// on modal update
|
||||
$('#btnDelInsurance_updt').on('click', function(e) {
|
||||
let data = AUpdt.getData();
|
||||
ADel.passDataToView({
|
||||
iid: data.iid,
|
||||
name: data.name,
|
||||
price: data.price,
|
||||
});
|
||||
$('#mdlDelInsurance').data('id', data.iid);
|
||||
$('#mdlDelInsurance').modal('show');
|
||||
});
|
||||
},
|
||||
passDataToView: function(data) {
|
||||
$('#del-name').text(data.name);
|
||||
$('#del-price').text(data.price);
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitDelInsurance').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitDelInsurance').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_del_insurance', '') }}/" + data.iid,
|
||||
method: 'DELETE',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitDelInsurance').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success delete insurance');
|
||||
$('#mdlDelInsurance').modal('hide');
|
||||
$('#mdlEdtInsurances').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitDelInsurance').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Wrapper.activate();
|
||||
</script>
|
||||
@endsection
|
||||
1574
resources/views/menu_v1/configs/pocket_money.blade.php
Executable file
1574
resources/views/menu_v1/configs/pocket_money.blade.php
Executable file
File diff suppressed because it is too large
Load Diff
1706
resources/views/menu_v1/configs/pricing.blade.php
Executable file
1706
resources/views/menu_v1/configs/pricing.blade.php
Executable file
File diff suppressed because it is too large
Load Diff
404
resources/views/menu_v1/configs/static_insurances.blade.php
Executable file
404
resources/views/menu_v1/configs/static_insurances.blade.php
Executable file
@ -0,0 +1,404 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Assuransi
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="content">
|
||||
<div class="card">
|
||||
{{-- <div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">Asuransi (<span id="count_insurances">0</span>)</p>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button id="btnMdlNewInsurance" class="btn btn-sm btn-danger">Buat Asuransi Baru</button>
|
||||
</div>
|
||||
<div class="col-auto text-end ps-0">
|
||||
<button class="btn btn-sm btn-danger">Upload</button>
|
||||
<button class="btn btn-sm btn-danger">Download</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="tInsurances" class="table table-hover dataTable">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">#</th>
|
||||
<th class="text-center">Action</th>
|
||||
<th class="">Deskripsi</th>
|
||||
<th class="text-end">Percent</th>
|
||||
<th class="text-center">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlEdtInsurances"
|
||||
aria-labelledby="mdlEdtInsurancesLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlEdtInsurancesLabel">Edit Asuransi</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Primary --}}
|
||||
<div class="mb-3">
|
||||
{{-- <div class="border-bottom">
|
||||
<h6>Data Premi</h6>
|
||||
</div> --}}
|
||||
<div class="row">
|
||||
{{-- <div class="col-sm-12">
|
||||
<label for="updt-desc" class="col-form-label">Deskripsi</label>
|
||||
<textarea name="updt-desc" id="updt-desc" class="form-control"></textarea>
|
||||
</div> --}}
|
||||
<div class="col-sm-12">
|
||||
<label for="updt-amt_percent" class="col-form-label">Percent dari nilai pertangguhan<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-amt_percent" id="updt-amt_percent" class="form-control">
|
||||
</div>
|
||||
{{-- <div class="col-sm-12">
|
||||
<label for="updt-amt_flat" class="col-form-label">Percent<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" name="updt-amt_flat" id="updt-amt_flat" class="form-control">
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
{{-- <div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-status" class="form-label">Status<span
|
||||
class="text-danger">*</span></label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-status">
|
||||
<label class="form-check-label" for="updt-status"><span class="text-dark"
|
||||
id="updt-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{-- <button type="button" id="btnDelInsurance_updt" class="btn btn-sm btn-warning">Hapus ?</button> --}}
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button id="btnSubmitEdtInsurances" type="button" class="btn btn-sm btn-danger">Ubah data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('customjs')
|
||||
<script>
|
||||
'use strict';
|
||||
const State = {
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
stts_isact: {
|
||||
active: "{{ App\Models\StaticInsurances::IS_ACTIVE }}",
|
||||
inactive: "{{ App\Models\StaticInsurances::IS_INACTIVE }}",
|
||||
},
|
||||
delay_typing_front: 1000,
|
||||
};
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
AUpdt.activate();
|
||||
},
|
||||
event: function() {
|
||||
$('#add-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtStatus').html('Active')
|
||||
else
|
||||
$('#add-txtStatus').html('Inactive')
|
||||
});
|
||||
$('#updt-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtStatus').html('Active')
|
||||
else
|
||||
$('#updt-txtStatus').html('Inactive')
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
// $('#tInsurances').DataTable();
|
||||
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||
$('#tInsurances').DataTable({
|
||||
processing: true,
|
||||
serverSide: false,
|
||||
bLengthChange: true,
|
||||
deferRender: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: "{{ route('api_list_static_insurances') }}",
|
||||
type: 'GET',
|
||||
complete: function(jqXHR, textStatus, c) {
|
||||
let count = jqXHR.responseJSON.count;
|
||||
if (typeof count != 'undefined') {
|
||||
$('#count_insurances').text(count);
|
||||
}
|
||||
// removeTableSkeletonLoading()
|
||||
},
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
className: 'text-end',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
let action = `
|
||||
<a href="#" class="text-decoration-none me-1 btnUpdtInsurance">
|
||||
<span class="icon ion-edit fz-16"></span>
|
||||
</a>
|
||||
`;
|
||||
// <a href="#" class="text-decoration-none text-danger btnDelInsurance">
|
||||
// <span class="icon ion-trash-b fz-16"></span>
|
||||
// </a>
|
||||
return action;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'desc',
|
||||
className: 'text-start text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
createdCell: function(td, cellData, rowData, row, col) {
|
||||
$(td).attr('data-id', rowData.id);
|
||||
$(td).attr('data-desc', rowData.desc);
|
||||
$(td).attr('data-amt_percent', rowData.amt_percent);
|
||||
},
|
||||
render: function(data, type, row, meta) {
|
||||
if (!data) return '-';
|
||||
return data;
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'amt_percent',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return data + '%';
|
||||
},
|
||||
},
|
||||
// {
|
||||
// data: 'amt_flat',
|
||||
// className: 'text-end text-nowrap',
|
||||
// visible: true,
|
||||
// orderable: true,
|
||||
// searchable: true,
|
||||
// render: function(data, type, row, meta) {
|
||||
// return (new Intl.NumberFormat('id-ID')).format(data);
|
||||
// }
|
||||
// },
|
||||
{
|
||||
data: 'is_active',
|
||||
className: 'text-center text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_isact.active)
|
||||
return '<span class="badge rounded-pill bg-success">Active</span>';
|
||||
return '<span class="badge rounded-pill bg-danger">Inactive</span>';
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const AUpdt = {
|
||||
activate: function() {
|
||||
AUpdt.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#tInsurances').on('click', '.btnUpdtInsurance', async function(e) {
|
||||
let id = $(e.target).closest('tr').find('td[data-id]').data('id');
|
||||
let resp = await AUpdt.reqData({
|
||||
id
|
||||
});
|
||||
if (resp.type != 'success') {
|
||||
Helper.toast('Insurance Not Found', 'just now', 'please try again');
|
||||
return false;
|
||||
}
|
||||
AUpdt.passDataToView(resp.data);
|
||||
});
|
||||
$('#mdlEdtInsurances').on('shown.bs.modal', function() {
|
||||
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitEdtInsurances').on('click', function() {
|
||||
let data = AUpdt.getData();
|
||||
let isValid = AUpdt.checkData(data);
|
||||
if (!isValid) return false;
|
||||
AUpdt.submitData(data);
|
||||
});
|
||||
},
|
||||
reqData: function(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: "{{ route('api_show_static_insurance', '') }}/" + params.id,
|
||||
method: 'GET',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
},
|
||||
data: params,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
resolve({
|
||||
type: 'success',
|
||||
data: data.data
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
passDataToView: async function(data) {
|
||||
// $('#updt-desc').val(data.desc);
|
||||
|
||||
$('#updt-amt_percent').val(data.amt_percent);
|
||||
// $('#updt-amt_flat').val((new Intl.NumberFormat('id-ID').format(data.amt_flat)));
|
||||
|
||||
// if (data.is_active == State.stts_isact.active) {
|
||||
// $('#updt-status').prop('checked', true);
|
||||
// } else {
|
||||
// $('#updt-status').prop('checked', false);
|
||||
// }
|
||||
|
||||
$('#mdlEdtInsurances').data('id', data.id);
|
||||
$('#mdlEdtInsurances').modal('show');
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
data.id = $('#mdlEdtInsurances').data('id');
|
||||
|
||||
data.amt_percent = Number($('#updt-amt_percent').val());
|
||||
// data.desc = $('#updt-desc').val();
|
||||
data.desc = data.amt_percent + '% dari nilai pertangguhan';
|
||||
// data.amt_flat = $('#updt-amt_flat').val().split('.').join('');
|
||||
|
||||
// if ($('#updt-status').prop('checked')) {
|
||||
// data.status = State.stts_isact.active;
|
||||
// } else {
|
||||
// data.status = State.stts_isact.inactive;
|
||||
// }
|
||||
|
||||
return data;
|
||||
},
|
||||
checkData: function(data, isAlert = true) {
|
||||
if (data.amt_percent < 1 || isNaN(data.amt_percent)) {
|
||||
if (isAlert) Helper.toast('Warning', 'just now', 'Percent tidak valid');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitEdtInsurances').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitEdtInsurances').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_edit_static_insurance', '') }}/" + data.id,
|
||||
method: 'PUT',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitEdtInsurances').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success update insurance');
|
||||
$('#mdlEdtInsurances').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitEdtInsurances').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Wrapper.activate();
|
||||
</script>
|
||||
@endsection
|
||||
755
resources/views/menu_v1/configs/truck_types.blade.php
Executable file
755
resources/views/menu_v1/configs/truck_types.blade.php
Executable file
@ -0,0 +1,755 @@
|
||||
@extends('app.app')
|
||||
|
||||
@section('title')
|
||||
Conf Truck Types
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row d-flex align-items-center">
|
||||
<div class="col-3">
|
||||
<p class="card-title text-bold mb-0">Truck Types (<span id="count_trucktypes">0</span>)</p>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button id="btnMdlNewTruckType" class="btn btn-sm btn-danger">Add New Truck Types</button>
|
||||
</div>
|
||||
<div class="col-auto text-end ps-0">
|
||||
{{-- <button class="btn btn-sm btn-danger">Upload</button> --}}
|
||||
{{-- <button class="btn btn-sm btn-danger">Download</button> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="tTruckTypes" class="table table-hover dataTable">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th class="">#</th>
|
||||
<th class="text-center">Action</th>
|
||||
<th class="">Name</th>
|
||||
<th class="text-end text-nowrap">Max KG</th>
|
||||
<th class="text-end text-nowrap">Max CBM</th>
|
||||
<th class="text-end text-nowrap">Max Koli</th>
|
||||
<th class="text-center">Status</th>
|
||||
<th class="text-center">Publish</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlNewTruckType" aria-labelledby="mdlNewTruckTypeLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlNewTruckTypeLabel">Add New Truck Type</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Truck Type --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Truck Type</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<label for="add-type_name" class="col-form-label">Type Name:</label>
|
||||
<input type="text" name="add-type_name" id="add-type_name" class="form-control" placeholder="Please consider use english language">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Weight --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Weight</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-max_kg" class="col-form-label">Max (KG)</label>
|
||||
<input type="text" name="add-max_kg" id="add-max_kg" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-max_cbm" class="col-form-label">Max (CBM)</label>
|
||||
<input type="text" name="add-max_cbm" id="add-max_cbm" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-max_koli" class="col-form-label">Max (Koli):</label>
|
||||
<input type="text" name="add-max_koli" id="add-max_koli" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-status" class="form-label">Status</label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-status">
|
||||
<label class="form-check-label" for="add-status"><span class="text-dark" id="add-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="add-publish" class="form-label">Publish</label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="add-publish">
|
||||
<label class="form-check-label" for="add-publish"><span class="text-dark" id="add-txtPublish">Unpublish</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button id="btnSubmitNewTruckType" type="button" class="btn btn-sm btn-danger">Submit data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlEdtTruckType" aria-labelledby="mdlEdtTruckTypeLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlEdtTruckTypeLabel">Edit TruckType</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
{{-- Truck Type --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Truck Type</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<label for="updt-type_name" class="col-form-label">Type Name:</label>
|
||||
<input type="text" name="updt-type_name" id="updt-type_name" class="form-control" placeholder="Please consider use english language">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Weight --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Weight</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-max_kg" class="col-form-label">Max (KG)</label>
|
||||
<input type="text" name="updt-max_kg" id="updt-max_kg" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-max_cbm" class="col-form-label">Max (CBM)</label>
|
||||
<input type="text" name="updt-max_cbm" id="updt-max_cbm" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-max_koli" class="col-form-label">Max (Koli):</label>
|
||||
<input type="text" name="updt-max_koli" id="updt-max_koli" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Utilites --}}
|
||||
<div class="mb-3">
|
||||
<div class="border-bottom">
|
||||
<h6>Utilities</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-status" class="form-label">Status</label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-status">
|
||||
<label class="form-check-label" for="updt-status"><span class="text-dark" id="updt-txtStatus">Inactive</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<label for="updt-publish" class="form-label">Publish ?</label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="updt-publish">
|
||||
<label class="form-check-label" for="updt-publish"><span class="text-dark" id="updt-publishStatus">Unpublish</span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="btnDelTruckType_updt" class="btn btn-sm btn-warning">Delete ?</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button id="btnSubmitEdtTruckType" type="button" class="btn btn-sm btn-danger">Update data</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDelTruckType" aria-labelledby="mdlDelTruckTypeLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="mdlDelTruckTypeLabel">Delete TruckType</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex justify-content-center">
|
||||
<p class="mb-0">
|
||||
Are you sure want to delete this truck type
|
||||
<a href="#" class="text-danger">
|
||||
<span id="del-type_name"></span>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-danger" data-bs-dismiss="modal">Close</button>
|
||||
<button id="btnSubmitDelTruckType" type="button" class="btn btn-sm btn-secondary">Yes, delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('customjs')
|
||||
<script src="{{ asset('assets/js/load-image.all.min.js') }}"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
const State = {
|
||||
file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}",
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
stts_conf: {
|
||||
active: "{{ App\Models\ConfTruckTypes::IS_ACTIVE }}",
|
||||
inactive: "{{ App\Models\ConfTruckTypes::IS_INACTIVE }}",
|
||||
publish: "{{ App\Models\ConfTruckTypes::IS_PUBLISH }}",
|
||||
unpublish: "{{ App\Models\ConfTruckTypes::IS_UNPUBLISH }}",
|
||||
},
|
||||
delay_typing_front: 1000,
|
||||
};
|
||||
|
||||
const Wrapper = {
|
||||
activate: function() {
|
||||
Wrapper.event();
|
||||
DTable.activate();
|
||||
RNew.activate();
|
||||
RUpdt.activate();
|
||||
RDel.activate();
|
||||
},
|
||||
event: function() {
|
||||
$('#add-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtStatus').html('Active')
|
||||
else
|
||||
$('#add-txtStatus').html('Inactive')
|
||||
});
|
||||
$('#updt-status').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtStatus').html('Active')
|
||||
else
|
||||
$('#updt-txtStatus').html('Inactive')
|
||||
});
|
||||
|
||||
$('#add-publish').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#add-txtPublish').html('Publish')
|
||||
else
|
||||
$('#add-txtPublish').html('Unpublish')
|
||||
});
|
||||
$('#updt-publish').bind('change', function() {
|
||||
if ($(this).is(':checked'))
|
||||
$('#updt-txtPublish').html('Publish')
|
||||
else
|
||||
$('#updt-txtPublish').html('Unpublish')
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
DTable.reload();
|
||||
},
|
||||
reload: function() {
|
||||
// $('#tTruckTypes').DataTable();
|
||||
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||
$('#tTruckTypes').DataTable({
|
||||
processing: true,
|
||||
serverSide: false,
|
||||
bLengthChange: true,
|
||||
deferRender: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: "{{ route('api_conf_list_truck_types') }}",
|
||||
type: 'GET',
|
||||
complete: function(jqXHR, textStatus, c) {
|
||||
let count = jqXHR.responseJSON.count;
|
||||
if (typeof count != 'undefined') {
|
||||
$('#count_trucktypes').text(count);
|
||||
}
|
||||
// removeTableSkeletonLoading()
|
||||
},
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
className: 'text-end',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
let action = `
|
||||
<a href="#" class="text-decoration-none me-1 btnUpdtTruckType">
|
||||
<span class="icon ion-edit fz-16"></span>
|
||||
</a>
|
||||
`;
|
||||
// <a href="#" class="text-decoration-none text-danger btnDelTruckType">
|
||||
// <span class="icon ion-trash-b fz-16"></span>
|
||||
// </a>
|
||||
return action;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'type_name',
|
||||
className: 'text-left text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
createdCell: function(td, cellData, rowData, row, col) {
|
||||
$(td).attr('data-ttid', rowData.id);
|
||||
$(td).attr('data-type_name', rowData.type_name);
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'max_kg',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return data || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'max_cbm',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return data || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'max_koli',
|
||||
className: 'text-end text-nowrap',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return data || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'is_active',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_conf.active) {
|
||||
return '<span class="badge rounded-pill bg-success">Active</span>';
|
||||
} else {
|
||||
return '<span class="badge rounded-pill bg-danger">Inactive</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'is_publish',
|
||||
className: 'text-center',
|
||||
visible: true,
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
if (data == State.stts_conf.publish) {
|
||||
return '<span class="badge rounded-pill bg-success">Publish</span>';
|
||||
} else {
|
||||
return '<span class="badge rounded-pill bg-danger">Unpublish</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const RNew = {
|
||||
activate: function() {
|
||||
RNew.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#btnMdlNewTruckType').on('click', function() {
|
||||
$('#mdlNewTruckType').modal('show');
|
||||
});
|
||||
$('#mdlNewTruckType').on('shown.bs.modal', function() {
|
||||
// init select2
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitNewTruckType').on('click', function() {
|
||||
let data = RNew.getData();
|
||||
RNew.submitData(data);
|
||||
});
|
||||
// input
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
|
||||
data.type_name = $('#add-type_name').val();
|
||||
|
||||
data.max_kg = $('#add-max_kg').val();
|
||||
data.max_cbm = $('#add-max_cbm').val();
|
||||
data.max_koli = $('#add-max_koli').val();
|
||||
|
||||
if ($('#add-status').prop('checked')) {
|
||||
data.status = State.stts_conf.active;
|
||||
} else {
|
||||
data.status = State.stts_conf.inactive;
|
||||
}
|
||||
|
||||
if ($('#add-publish').prop('checked')) {
|
||||
data.publish = State.stts_conf.publish;
|
||||
} else {
|
||||
data.publish = State.stts_conf.unpublish;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitNewTruckType').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitNewTruckType').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_conf_add_truck_type') }}",
|
||||
method: 'POST',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitNewTruckType').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success add new truck type');
|
||||
$('#mdlNewTruckType').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitNewTruckType').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const RUpdt = {
|
||||
activate: function() {
|
||||
RUpdt.event();
|
||||
},
|
||||
event: function() {
|
||||
// modal
|
||||
$('#tTruckTypes').on('click', '.btnUpdtTruckType', async function(e) {
|
||||
let ttid = $(e.target).closest('tr').find('td[data-ttid]').data('ttid');
|
||||
let resp = await RUpdt.reqData({
|
||||
ttid
|
||||
});
|
||||
if (resp.type != 'success') {
|
||||
Helper.toast('Truck Type Not Found', 'just now', 'please try again');
|
||||
return false;
|
||||
}
|
||||
RUpdt.passDataToView(resp.data);
|
||||
});
|
||||
$('#mdlEdtTruckType').on('shown.bs.modal', function() {
|
||||
// init select2
|
||||
});
|
||||
// button
|
||||
$('#btnSubmitEdtTruckType').on('click', function() {
|
||||
let data = RUpdt.getData();
|
||||
RUpdt.submitData(data);
|
||||
});
|
||||
// input
|
||||
},
|
||||
reqData: function(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: "{{ route('api_conf_show_truck_type', '') }}/" + params.ttid,
|
||||
method: 'GET',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
},
|
||||
data: params,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
resolve({
|
||||
type: 'success',
|
||||
data: data.data
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
passDataToView: async function(data) {
|
||||
$('#updt-type_name').val(data.type_name);
|
||||
|
||||
$('#updt-max_kg').val(data.max_kg || '');
|
||||
$('#updt-max_cbm').val(data.max_cbm || '');
|
||||
$('#updt-max_koli').val(data.max_koli || '');
|
||||
|
||||
if (data.is_active == State.stts_conf.active) {
|
||||
$('#updt-status').prop('checked', true).trigger('change');
|
||||
} else {
|
||||
$('#updt-status').prop('checked', false).trigger('change');
|
||||
}
|
||||
|
||||
if (data.is_publish == State.stts_conf.publish) {
|
||||
$('#updt-publish').prop('checked', true).trigger('change');
|
||||
} else {
|
||||
$('#updt-publish').prop('checked', false).trigger('change');
|
||||
}
|
||||
|
||||
$('#mdlEdtTruckType').data('id', data.id);
|
||||
$('#mdlEdtTruckType').modal('show');
|
||||
},
|
||||
getData: function() {
|
||||
let data = {};
|
||||
|
||||
data.ttid = $('#mdlEdtTruckType').data('id');
|
||||
data.type_name = $('#updt-type_name').val();
|
||||
|
||||
data.max_kg = $('#updt-max_kg').val();
|
||||
data.max_cbm = $('#updt-max_cbm').val();
|
||||
data.max_koli = $('#updt-max_koli').val();
|
||||
|
||||
if ($('#updt-status').prop('checked')) {
|
||||
data.status = State.stts_conf.active;
|
||||
} else {
|
||||
data.status = State.stts_conf.inactive;
|
||||
}
|
||||
|
||||
if ($('#updt-publish').prop('checked')) {
|
||||
data.publish = State.stts_conf.publish;
|
||||
} else {
|
||||
data.publish = State.stts_conf.unpublish;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitEdtTruckType').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitEdtTruckType').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_conf_edit_truck_type', '') }}/" + data.ttid,
|
||||
method: 'PUT',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitEdtTruckType').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success update trucktype');
|
||||
$('#mdlEdtTruckType').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitEdtTruckType').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const RDel = {
|
||||
activate: function() {
|
||||
RDel.event();
|
||||
},
|
||||
event: function() {
|
||||
// on table
|
||||
$('#tTruckTypes').on('click', '.btnDelTruckType', function(e) {
|
||||
let row = $(e.target).closest('tr');
|
||||
let ttid = row.find('td[data-ttid]').data('ttid');
|
||||
let type_name = row.find('td[data-type_name]').data('type_name');
|
||||
RDel.passDataToView({
|
||||
ttid,
|
||||
type_name,
|
||||
});
|
||||
$('#mdlDelTruckType').data('id', ttid);
|
||||
$('#mdlDelTruckType').modal('show');
|
||||
});
|
||||
$('#btnSubmitDelTruckType').on('click', function() {
|
||||
let data = {
|
||||
ttid: $('#mdlDelTruckType').data('id'),
|
||||
};
|
||||
RDel.submitData(data);
|
||||
});
|
||||
// on modal update
|
||||
$('#btnDelTruckType_updt').on('click', function(e) {
|
||||
let data = RUpdt.getData();
|
||||
RDel.passDataToView({
|
||||
ttid: data.ttid,
|
||||
type_name: data.type_name,
|
||||
});
|
||||
$('#mdlDelTruckType').data('id', data.ttid);
|
||||
$('#mdlDelTruckType').modal('show');
|
||||
});
|
||||
},
|
||||
passDataToView: function(data) {
|
||||
$('#del-type_name').text(data.type_name);
|
||||
},
|
||||
submitData: async function(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof $('#btnSubmitDelTruckType').attr('disabed') != 'undefined') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$('#btnSubmitDelTruckType').attr('disabed', true);
|
||||
$.ajax({
|
||||
url: "{{ route('api_conf_del_truck_type', '') }}/" + data.ttid,
|
||||
method: 'DELETE',
|
||||
crossDomain: true,
|
||||
processData: true,
|
||||
headers: {
|
||||
'x-api-key': Helper.getCookie('_trtk'),
|
||||
'x-csrf-token': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
data: data,
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
$('#btnSubmitDelTruckType').removeAttr('disabed');
|
||||
if (data.meta.type != 'success') {
|
||||
resolve({
|
||||
type: 'fail'
|
||||
});
|
||||
Helper.toast('Warning', 'just now', data.meta.message);
|
||||
return false;
|
||||
}
|
||||
Helper.toast('Success', 'just now', 'success delete trucktype');
|
||||
$('#mdlDelTruckType').modal('hide');
|
||||
$('#mdlEdtTruckType').modal('hide');
|
||||
DTable.reload();
|
||||
resolve({
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
error: (jqXHR, textStatus, error) => {
|
||||
$('#btnSubmitDelTruckType').removeAttr('disabed');
|
||||
if (jqXHR.status >= 500) {
|
||||
Helper.toast('Error', 'just now', 'Please try again');
|
||||
} else {
|
||||
Helper.toast('Error', 'just now', jqXHR.responseJSON.meta
|
||||
.message);
|
||||
}
|
||||
resolve({
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Wrapper.activate();
|
||||
</script>
|
||||
@endsection
|
||||
1140
resources/views/menu_v1/configs/usersMenuPermissions.blade.php
Executable file
1140
resources/views/menu_v1/configs/usersMenuPermissions.blade.php
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user