distribution category
This commit is contained in:
210
app/Http/Controllers/ConfDistributionController.php
Normal file
210
app/Http/Controllers/ConfDistributionController.php
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Validator;
|
||||||
|
use Hidehalo\Nanoid\Client as Nanoid;
|
||||||
|
use Hidehalo\Nanoid\GeneratorInterface as NanoidInterface;
|
||||||
|
use App\Responses;
|
||||||
|
use App\Helper;
|
||||||
|
use App\Models\ConfRates;
|
||||||
|
use App\Models\ConfTruckTypes;
|
||||||
|
use App\Models\Vehicles;
|
||||||
|
|
||||||
|
class ConfDistributionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function view_distribution_category(Request $req)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
return view("menu_v1.configs.distribution_category", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function api_add_distribution_category(Request $req)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$now = time();
|
||||||
|
// new or edit
|
||||||
|
$tipe = $req->tipe ?? "new";
|
||||||
|
|
||||||
|
$input = [
|
||||||
|
"dc_code" => $req->dc_code,
|
||||||
|
"dc_name" => $req->dc_name,
|
||||||
|
];
|
||||||
|
$rulesInput = [
|
||||||
|
"dc_code" => "required|string|max:10",
|
||||||
|
"dc_name" => "required|string|max:100",
|
||||||
|
];
|
||||||
|
|
||||||
|
// validasi input
|
||||||
|
$isValidInput = Validator::make($input, $rulesInput);
|
||||||
|
if (!$isValidInput->passes()) {
|
||||||
|
$apiResp = Responses::bad_input($isValidInput->messages()->first());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($tipe == "new"){
|
||||||
|
$uniqCode = DB::select("SELECT * FROM t_conf_distribution_category WHERE dc_code = ?", [$req->dc_code]);
|
||||||
|
}
|
||||||
|
if($tipe == "edit"){
|
||||||
|
$uniqCode = DB::select("SELECT * FROM t_conf_distribution_category WHERE dc_code = ? AND id != ?", [$req->dc_code, $req->id]);
|
||||||
|
}
|
||||||
|
if (count($uniqCode) > 0) {
|
||||||
|
$apiResp = Responses::bad_request("type code has been used");
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$insD = [
|
||||||
|
"dc_code" => $req->dc_code,
|
||||||
|
"dc_name" => $req->dc_name,
|
||||||
|
"crt" => $now,
|
||||||
|
"crt_by" => $req->auth->uid,
|
||||||
|
"updt" => $now,
|
||||||
|
"updt_by" => $req->auth->uid,
|
||||||
|
];
|
||||||
|
// $insQ = DB::insert("INSERT
|
||||||
|
// INTO t_conf_distribution_category (dc_code, dc_name, crt, crt_by, updt, updt_by)
|
||||||
|
// VALUES (?, ?, ?, ?, ?, ?)
|
||||||
|
// ", array_values($insD));
|
||||||
|
$insQ = DB::insert("INSERT into t_conf_distribution_category set
|
||||||
|
dc_code = ?,
|
||||||
|
dc_name = ?,
|
||||||
|
crt = ?,
|
||||||
|
crt_by = ?,
|
||||||
|
updt = ?,
|
||||||
|
updt_by = ?
|
||||||
|
on duplicate key update
|
||||||
|
dc_code = values(dc_code),
|
||||||
|
dc_name = values(dc_name),
|
||||||
|
updt = values(updt),
|
||||||
|
updt_by = values(updt_by)
|
||||||
|
", array_values($insD));
|
||||||
|
|
||||||
|
|
||||||
|
$apiResp = Responses::created("success " . ($tipe == "new" ? "add new" : "edit") . " distribution category");
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$apiResp = Responses::error($e->getMessage());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function api_list_distribution_category(Request $req)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
$list = DB::select("SELECT * FROM t_conf_distribution_category WHERE dlt IS NULL ORDER BY dc_code ASC");
|
||||||
|
foreach ($list as $key => $row) {
|
||||||
|
$list[$key]->DT_RowIndex = $key + 1;
|
||||||
|
$list[$key]->action = "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
$apiResp = Responses::success("success list distribution category");
|
||||||
|
$apiResp["count"] = count($list);
|
||||||
|
$apiResp["data"] = $list;
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$apiResp = Responses::error($e->getMessage());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function api_show_distribution_category(Request $req, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$input = [
|
||||||
|
"id" => $id,
|
||||||
|
];
|
||||||
|
$rulesInput = [
|
||||||
|
"id" => "required|integer|not_in:0",
|
||||||
|
];
|
||||||
|
|
||||||
|
// validasi input
|
||||||
|
$isValidInput = Validator::make($input, $rulesInput);
|
||||||
|
if (!$isValidInput->passes()) {
|
||||||
|
$apiResp = Responses::bad_input($isValidInput->messages()->first());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtl = DB::select("SELECT * FROM t_conf_distribution_category WHERE id = ? AND dlt IS NULL limit 1", [$id]);
|
||||||
|
if (count($dtl) < 1) {
|
||||||
|
$apiResp = Responses::not_found("truck type not found");
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$apiResp = Responses::success("success get detail vehicle type");
|
||||||
|
$apiResp["data"] = $dtl[0];
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$apiResp = Responses::error($e->getMessage());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function api_del_distribution_category(Request $req, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
$input = [
|
||||||
|
"id" => $id,
|
||||||
|
];
|
||||||
|
$rulesInput = [
|
||||||
|
"id" => "required|integer|not_in:0",
|
||||||
|
];
|
||||||
|
|
||||||
|
// validasi input
|
||||||
|
$isValidInput = Validator::make($input, $rulesInput);
|
||||||
|
if (!$isValidInput->passes()) {
|
||||||
|
$apiResp = Responses::bad_input($isValidInput->messages()->first());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtl = DB::select("SELECT * FROM t_conf_distribution_category WHERE id = ? AND dlt IS NULL limit 1", [$id]);
|
||||||
|
if (count($dtl) < 1) {
|
||||||
|
$apiResp = Responses::not_found("vehicle type not found");
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$updtQ = DB::update("UPDATE t_conf_distribution_category
|
||||||
|
SET
|
||||||
|
dlt = ?,
|
||||||
|
dlt_by = ?,
|
||||||
|
updt = ?,
|
||||||
|
updt_by = ?
|
||||||
|
WHERE id = ? AND dlt IS NULL
|
||||||
|
", [1, $req->user()->id, $now, $req->user()->id, $id]);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
$apiResp = Responses::success("success delete vehicle type");
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$apiResp = Responses::error($e->getMessage());
|
||||||
|
return new Response($apiResp, $apiResp["meta"]["code"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
390
resources/views/menu_v1/configs/distribution_category.blade.php
Normal file
390
resources/views/menu_v1/configs/distribution_category.blade.php
Normal file
@ -0,0 +1,390 @@
|
|||||||
|
@extends('app.app')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
Conf Distribution Categorys
|
||||||
|
@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">Distribution Category</p>
|
||||||
|
</div>
|
||||||
|
@can('config_distribution_category.create')
|
||||||
|
<div class="col text-end">
|
||||||
|
<button id="btnMdlNew" class="btn btn-sm btn-danger">Add New Distribution Category</button>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
<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="tList" class="table table-hover dataTable w-100">
|
||||||
|
<thead>
|
||||||
|
<tr class="">
|
||||||
|
<th class="">#</th>
|
||||||
|
<th class="text-center">Action</th>
|
||||||
|
<th class="">Code</th>
|
||||||
|
<th class="">Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlNew" aria-labelledby="mdlLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="mdlLabel">Add New Category</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form id="fNew">
|
||||||
|
<!--input hidden -->
|
||||||
|
<input type="hidden" name="tipe" id="tipe" value="new">
|
||||||
|
<input type="hidden" name="id" id="id">
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="dc_code" class="col-form-label">Code:</label>
|
||||||
|
<input type="text" name="dc_code" id="dc_code" class="form-control" placeholder="Category code, example: VF, VO, etc">
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="dc_name" class="col-form-label">Name:</label>
|
||||||
|
<input type="text" name="dc_name" id="dc_name" class="form-control" placeholder="Category name">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
@can('config_distribution_category.delete')
|
||||||
|
<button type="button" id="btnDel" class="btn btn-sm btn-warning">Delete ?</button>
|
||||||
|
@endcan
|
||||||
|
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<button id="btnSubmit" type="button" class="btn btn-sm btn-danger">Submit data</button>
|
||||||
|
@can('config_distribution_category.edit')
|
||||||
|
<button id="btnEdit" type="button" class="btn btn-sm btn-danger">Update data</button>
|
||||||
|
@endcan
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDel" aria-labelledby="mdlDelLabel" 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="mdlDelLabel">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 Distribution Category
|
||||||
|
<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="btnSubmitDel" 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') }}/",
|
||||||
|
delay_typing_front: 1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
const Wrapper = {
|
||||||
|
activate: function() {
|
||||||
|
Wrapper.event();
|
||||||
|
DTable.activate();
|
||||||
|
},
|
||||||
|
event: function() {
|
||||||
|
$('#btnMdlNew').on('click', function() {
|
||||||
|
$('#fNew')[0].reset();
|
||||||
|
$('#btnDel').hide();
|
||||||
|
$('#btnEdit').hide();
|
||||||
|
$('#btnSubmit').show();
|
||||||
|
$('#mdlLabel').text('New Distribution Category');
|
||||||
|
$('#dc_code').focus();
|
||||||
|
|
||||||
|
$('#mdlNew').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnSubmit, #btnEdit').on('click', function() {
|
||||||
|
let data=$("#fNew").serialize()
|
||||||
|
Wrapper.submitData(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#tList').on('click', '.btnUpdt', function(e) {
|
||||||
|
// console.log("updt klik");
|
||||||
|
const id = $(this).data('id');
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('api_conf_show_distribution_category', '') }}/" + id,
|
||||||
|
method: 'GET',
|
||||||
|
crossDomain: true,
|
||||||
|
processData: true,
|
||||||
|
headers: {
|
||||||
|
'x-api-key': Helper.getCookie('_trtk'),
|
||||||
|
},
|
||||||
|
// data: params,
|
||||||
|
success: (data, textStatus, jqXHR) => {
|
||||||
|
console.log("res data", data);
|
||||||
|
|
||||||
|
if (data.meta.type != 'success') {
|
||||||
|
resolve({
|
||||||
|
type: 'fail'
|
||||||
|
});
|
||||||
|
Helper.toast('Warning', 'just now', data.meta.message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert value
|
||||||
|
$('#mdlLabel').text('Edit Distribution Category');
|
||||||
|
$('#btnDel').show();
|
||||||
|
$('#btnEdit').show();
|
||||||
|
$('#btnSubmit').hide();
|
||||||
|
|
||||||
|
$('#tipe').val("edit");
|
||||||
|
$('#id').val(id);
|
||||||
|
$('#dc_code').val(data.data.dc_code);
|
||||||
|
$('#dc_name').val(data.data.dc_name);
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#mdlNew').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnDel').on('click', function(e) {
|
||||||
|
$('#mdlDel').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnSubmitDel').on('click', function(e) {
|
||||||
|
const id = $('#id').val()
|
||||||
|
const data = {
|
||||||
|
id: $('#mdlDel').data('id'),
|
||||||
|
};
|
||||||
|
$('#btnSubmitDel').attr('disabed', true);
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('api_conf_del_distribution_category', '') }}/" + 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) => {
|
||||||
|
$('#btnSubmitDel').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 Distribution Category');
|
||||||
|
$('#mdlDel').modal('hide');
|
||||||
|
$('#mdlNew').modal('hide');
|
||||||
|
$('#tList').DataTable().ajax.reload();
|
||||||
|
resolve({
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: (jqXHR, textStatus, error) => {
|
||||||
|
$('#btnSubmitDel').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'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#mdlDel').on('show.bs.modal', function () {
|
||||||
|
$('#mdlNew').css('opacity', '0.5'); // fade background modal
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#mdlDel').on('hidden.bs.modal', function () {
|
||||||
|
$('#mdlNew').css('opacity', '1');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
submitData: async function(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (typeof $('#btnSubmit').attr('disabed') != 'undefined') {
|
||||||
|
resolve({
|
||||||
|
type: 'fail'
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$('#btnSubmit').attr('disabed', true);
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('api_conf_add_distribution_category') }}",
|
||||||
|
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) => {
|
||||||
|
$('#btnSubmit').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 Distribution Category');
|
||||||
|
$('#mdlNew').modal('hide');
|
||||||
|
$('#tList').DataTable().ajax.reload();
|
||||||
|
resolve({
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: (jqXHR, textStatus, error) => {
|
||||||
|
$('#btnSubmit').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 DTable = {
|
||||||
|
activate: function() {
|
||||||
|
DTable.reload();
|
||||||
|
},
|
||||||
|
reload: function() {
|
||||||
|
// $('#tList').DataTable();
|
||||||
|
// if (Driver.Table.firstInitDataTable == 1) { loadTableSkeletonLoading() } else { Driver.Table.firstInitDataTable = 1; }
|
||||||
|
$('#tList').DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: false,
|
||||||
|
bLengthChange: true,
|
||||||
|
deferRender: true,
|
||||||
|
destroy: true,
|
||||||
|
ajax: {
|
||||||
|
url: "{{ route('api_conf_list_distribution_category') }}",
|
||||||
|
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,
|
||||||
|
width: "30px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'action',
|
||||||
|
className: 'text-center',
|
||||||
|
visible: true,
|
||||||
|
orderable: true,
|
||||||
|
searchable: true,
|
||||||
|
width: "100px",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
let action = `
|
||||||
|
<a href="#" class="text-decoration-none me-1 btnUpdt" data-id="${row.id}" title="Update" data-bs-toggle="tooltip" data-bs-placement="top">
|
||||||
|
<span class="icon ion-eye fz-16"></span>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'dc_code',
|
||||||
|
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: 'dc_name',
|
||||||
|
className: 'text-left',
|
||||||
|
visible: true,
|
||||||
|
orderable: true,
|
||||||
|
searchable: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Wrapper.activate();
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@ -42,18 +42,22 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
@if (auth()->user()->can('config_truck_type.view') || auth()->user()->can('config_master_device.view') || auth()->user()->can('config_logs_gps.view'))
|
@if (auth()->user()->can('report_vehicle_trip.view') || auth()->user()->can('report_abnormality.view'))
|
||||||
<li class="nav-item dropdown {{ Request::segment(1) == 'reports' ? 'active' : '' }}">
|
<li class="nav-item dropdown {{ Request::segment(1) == 'reports' ? 'active' : '' }}">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="dropdownConfig" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="dropdownConfig" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
Reports
|
Reports
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" style="right: 0; left: auto;" aria-labelledby="dropdownConfig">
|
<ul class="dropdown-menu" style="right: 0; left: auto;" aria-labelledby="dropdownConfig">
|
||||||
<li>
|
@can('report_vehicle_trip.view')
|
||||||
<a class="dropdown-item {{ Request::segment(2) == 'vehicle-trips' ? 'active' : '' }}" href="{{ route('view_report_vehicle_trips') }}" title="">Vehicle Trips</a>
|
<li>
|
||||||
</li>
|
<a class="dropdown-item {{ Request::segment(2) == 'vehicle-trips' ? 'active' : '' }}" href="{{ route('view_report_vehicle_trips') }}" title="">Vehicle Trips</a>
|
||||||
<li>
|
</li>
|
||||||
<a class="dropdown-item {{ Request::segment(2) == 'abnormalities' ? 'active' : '' }}" href="{{ route('view_report_abnormalities') }}" title="">Abnormalities</a>
|
@endcan
|
||||||
</li>
|
@can('report_abnormality.view')
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item {{ Request::segment(2) == 'abnormalities' ? 'active' : '' }}" href="{{ route('view_report_abnormalities') }}" title="">Abnormalities</a>
|
||||||
|
</li>
|
||||||
|
@endcan
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
@ -73,11 +77,21 @@
|
|||||||
<a class="dropdown-item {{ Request::segment(2) == 'devices' ? 'active' : '' }}" href="{{ route('view_config_devices') }}" title="">Master Devices</a>
|
<a class="dropdown-item {{ Request::segment(2) == 'devices' ? 'active' : '' }}" href="{{ route('view_config_devices') }}" title="">Master Devices</a>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
@can('config_logs_gps.view')
|
@can('config_logs_gps.view')
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item {{ Request::segment(2) == 'logs_gps' ? 'active' : '' }}" href="{{ route('view_config_logs_gps') }}" title="">Logs Gps</a>
|
<a class="dropdown-item {{ Request::segment(2) == 'logs_gps' ? 'active' : '' }}" href="{{ route('view_config_logs_gps') }}" title="">Logs Gps</a>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
|
@can('config_distribution_category.view')
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item {{ Request::segment(2) == 'distribution_category' ? 'active' : '' }}" href="{{ route('view_config_distribution_category') }}" title="">Distribution Category</a>
|
||||||
|
</li>
|
||||||
|
@endcan
|
||||||
|
@can('config_pool.view')
|
||||||
|
<!-- <li>
|
||||||
|
<a href="">Pool</a>
|
||||||
|
</li> -->
|
||||||
|
@endcan
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@ -153,9 +153,23 @@ Route::middleware(["auth", "auth.user"])->group(function () {
|
|||||||
);
|
);
|
||||||
Route::get("/config/logbook_keys", "LogbookKeysController@view_lgb_keys")->name("view_config_lgb_keys");
|
Route::get("/config/logbook_keys", "LogbookKeysController@view_lgb_keys")->name("view_config_lgb_keys");
|
||||||
|
|
||||||
|
// distribution category
|
||||||
|
Route::get("/config/distribution_category", "ConfDistributionController@view_distribution_category")
|
||||||
|
->name("view_config_distribution_category")
|
||||||
|
->middleware("permission:config_distribution_category.view");
|
||||||
|
Route::post("/api/conf/distribution_category", "ConfDistributionController@api_add_distribution_category")->name("api_conf_add_distribution_category");
|
||||||
|
Route::get("/api/conf/distribution_category", "ConfDistributionController@api_list_distribution_category")->name("api_conf_list_distribution_category");
|
||||||
|
Route::get("/api/conf/distribution_category/{id}", "ConfDistributionController@api_show_distribution_category")->name("api_conf_show_distribution_category");
|
||||||
|
Route::delete("/api/conf/distribution_category/{id}", "ConfDistributionController@api_del_distribution_category")->name("api_conf_del_distribution_category");
|
||||||
|
|
||||||
|
// Route::get("/config/pool", "ConfTruckTypeController@view_pool")
|
||||||
|
// ->name("view_config_pool")
|
||||||
|
// ->middleware("permission:config_pool.view");
|
||||||
|
|
||||||
// reports
|
// reports
|
||||||
Route::get("/reports/vehicle-trips", "ReportsController@view_report_vehicle_trips")->name("view_report_vehicle_trips");
|
Route::get("/reports/vehicle-trips", "ReportsController@view_report_vehicle_trips")->name("view_report_vehicle_trips");
|
||||||
Route::get("/reports/vehicle-trips-list", "ReportsController@api_report_vehicle_trips_list")->name("api_report_vehicle_trips_list");
|
Route::get("/reports/vehicle-trips-list", "ReportsController@api_report_vehicle_trips_list")->name("api_report_vehicle_trips_list");
|
||||||
|
Route::get("/reports/vehicle-trip-detail", "ReportsController@view_report_trip_detail")->name("view_report_trip_detail");
|
||||||
Route::get("/reports/abnormalities", "ReportsController@view_report_abnormalities")->name("view_report_abnormalities");
|
Route::get("/reports/abnormalities", "ReportsController@view_report_abnormalities")->name("view_report_abnormalities");
|
||||||
Route::get("/reports/abnormalities-list", "ReportsController@api_report_abnormalities_list")->name("api_report_abnormalities_list");
|
Route::get("/reports/abnormalities-list", "ReportsController@api_report_abnormalities_list")->name("api_report_abnormalities_list");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user