create crud product categories and partial update crud products with dealers stock
This commit is contained in:
109
resources/js/warehouse_management/product_categories/index.js
Normal file
109
resources/js/warehouse_management/product_categories/index.js
Normal file
@@ -0,0 +1,109 @@
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
let tableContainer = $("#product-categories-table");
|
||||
let url = tableContainer.data("url");
|
||||
let table = $("#product-categories-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: url,
|
||||
columns: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
},
|
||||
{ data: "name", name: "name" },
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#addProductCategory").click(function () {
|
||||
$("#productCategoryForm")[0].reset();
|
||||
$("#category_id").val("");
|
||||
$("#modalTitle").text("Tambah Kategori");
|
||||
$("#productCategoryModal").modal("show");
|
||||
});
|
||||
|
||||
// Submit form (baik tambah maupun edit)
|
||||
$("#productCategoryForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let id = $("#category_id").val();
|
||||
let url = id
|
||||
? `/warehouse/product_categories/${id}`
|
||||
: `/warehouse/product_categories`;
|
||||
let method = id ? "PUT" : "POST";
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: method,
|
||||
data: {
|
||||
name: $("#name").val(),
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
...(id && { _method: "PUT" }),
|
||||
},
|
||||
success: function () {
|
||||
$("#productCategoryModal").modal("hide");
|
||||
$("#product-categories-table").DataTable().ajax.reload();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal menyimpan data");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
$(document).on("click", ".btn-edit-product-category", function () {
|
||||
const id = $(this).data("id");
|
||||
const url = $(this).data("url");
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "GET",
|
||||
success: function (response) {
|
||||
$("#category_id").val(response.id);
|
||||
$("#name").val(response.name);
|
||||
$("#modalTitle").text("Edit Kategori");
|
||||
$("#productCategoryModal").modal("show");
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal mengambil data");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-destroy-product-category", function () {
|
||||
Swal.fire({
|
||||
title: "Hapus nama kategori?",
|
||||
text: "Anda tidak akan bisa mengembalikannya!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#dedede",
|
||||
confirmButtonText: "Hapus",
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
const url = $(this).data("action");
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "POST",
|
||||
data: {
|
||||
_method: "DELETE",
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
success: function () {
|
||||
alert("Kategori berhasil dihapus.");
|
||||
$("#product-categories-table").DataTable().ajax.reload();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal menghapus kategori.");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
112
resources/js/warehouse_management/products/index.js
Normal file
112
resources/js/warehouse_management/products/index.js
Normal file
@@ -0,0 +1,112 @@
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
let tableContainer = $("#products-table");
|
||||
let url = tableContainer.data("url");
|
||||
let table = $("#products-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: url,
|
||||
columns: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
},
|
||||
{ data: "code", name: "code" },
|
||||
{ data: "name", name: "name" },
|
||||
{ data: "category_name", name: "category.name" },
|
||||
{ data: "total_stock", name: "total_stock" },
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#addProductCategory").click(function () {
|
||||
$("#productCategoryForm")[0].reset();
|
||||
$("#category_id").val("");
|
||||
$("#modalTitle").text("Tambah Kategori");
|
||||
$("#productCategoryModal").modal("show");
|
||||
});
|
||||
|
||||
// Submit form (baik tambah maupun edit)
|
||||
$("#productCategoryForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let id = $("#category_id").val();
|
||||
let url = id
|
||||
? `/warehouse/product_categories/${id}`
|
||||
: `/warehouse/product_categories`;
|
||||
let method = id ? "PUT" : "POST";
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: method,
|
||||
data: {
|
||||
name: $("#name").val(),
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
...(id && { _method: "PUT" }),
|
||||
},
|
||||
success: function () {
|
||||
$("#productCategoryModal").modal("hide");
|
||||
$("#product-categories-table").DataTable().ajax.reload();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal menyimpan data");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
$(document).on("click", ".btn-edit-product-category", function () {
|
||||
const id = $(this).data("id");
|
||||
const url = $(this).data("url");
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "GET",
|
||||
success: function (response) {
|
||||
$("#category_id").val(response.id);
|
||||
$("#name").val(response.name);
|
||||
$("#modalTitle").text("Edit Kategori");
|
||||
$("#productCategoryModal").modal("show");
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal mengambil data");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-destroy-product-category", function () {
|
||||
Swal.fire({
|
||||
title: "Hapus nama kategori?",
|
||||
text: "Anda tidak akan bisa mengembalikannya!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#dedede",
|
||||
confirmButtonText: "Hapus",
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
const url = $(this).data("action");
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "POST",
|
||||
data: {
|
||||
_method: "DELETE",
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
success: function () {
|
||||
alert("Kategori berhasil dihapus.");
|
||||
$("#product-categories-table").DataTable().ajax.reload();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal menghapus kategori.");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -114,7 +114,7 @@ License: You must have a valid license purchased only from themeforest(the above
|
||||
</div>
|
||||
<!-- end::Scrolltop -->
|
||||
|
||||
|
||||
<script src="{{ mix('js/app.js') }}"></script>
|
||||
@yield('javascripts')
|
||||
</body>
|
||||
<!-- end::Body -->
|
||||
|
||||
@@ -130,6 +130,160 @@
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
{{-- Section Header --}}
|
||||
<div class="kt-menu__section" style="padding: 10px 20px; font-weight: bold;">
|
||||
<i class="kt-menu__section-icon fa fa-box"></i>
|
||||
<span class="kt-menu__section-text">Manajemen Pengguna</span>
|
||||
</div>
|
||||
|
||||
{{-- Submenu Items --}}
|
||||
@can('view', $menus['dealer.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('dealer.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-car" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Pengguna</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['category.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('category.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-users" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Role & Privileges</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
{{-- Section Header --}}
|
||||
<div class="kt-menu__section" style="padding: 10px 20px; font-weight: bold;">
|
||||
<i class="kt-menu__section-icon fa fa-box"></i>
|
||||
<span class="kt-menu__section-text">Manajemen Transaksi</span>
|
||||
</div>
|
||||
|
||||
{{-- Submenu Items --}}
|
||||
@can('view', $menus['dealer.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('dealer.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-car" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Pekerjaan</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['category.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('category.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-users" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Kategori Pekerjaan</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Dealer</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
{{-- Section Header --}}
|
||||
<div class="kt-menu__section" style="padding: 10px 20px; font-weight: bold;">
|
||||
<i class="kt-menu__section-icon fa fa-box"></i>
|
||||
<span class="kt-menu__section-text">Manajemen Gudang</span>
|
||||
</div>
|
||||
|
||||
{{-- Submenu Items --}}
|
||||
@can('view', $menus['products.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('products.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-car" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Produk</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['product_categories.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('product_categories.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-users" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Kategori Produk</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Mutasi Produk</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Stock Opname</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
{{-- Section Header --}}
|
||||
<div class="kt-menu__section" style="padding: 10px 20px; font-weight: bold;">
|
||||
<i class="kt-menu__section-icon fa fa-box"></i>
|
||||
<span class="kt-menu__section-text">Laporan</span>
|
||||
</div>
|
||||
|
||||
{{-- Submenu Items --}}
|
||||
@can('view', $menus['dealer.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('dealer.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-car" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">SA</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['category.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('category.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-users" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Pekerjaan</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Dealer</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Stok Produk</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('view', $menus['work.index'])
|
||||
<li class="kt-menu__item" aria-haspopup="true">
|
||||
<a href="{{ route('work.index') }}" class="kt-menu__link">
|
||||
<i class="fa fa-list" style="display: flex; align-items: center; margin-right: 10px;"></i>
|
||||
<span class="kt-menu__link-text">Teknisi</span>
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-portlet kt-portlet--mobile" id="kt_blockui_datatable">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Kategori Produk
|
||||
</h3>
|
||||
</div>
|
||||
@can('create', $menus['product_categories.index'])
|
||||
<div class="kt-portlet__head-toolbar">
|
||||
<div class="kt-portlet__head-wrapper">
|
||||
<div class="kt-portlet__head-actions">
|
||||
<button type="button" class="btn btn-bold btn-label-brand btn-sm" id="addProductCategory"> Tambah </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<div class="table-responsive">
|
||||
<!--begin: Datatable -->
|
||||
<table class="table table-striped table-bordered table-hover" id="product-categories-table" data-url="{{ route("product_categories.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Nama Kategori</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<!--end: Datatable -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- begin modal --}}
|
||||
<div class="modal fade" id="productCategoryModal" tabindex="-1" aria-labelledby="modalTitle" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form id="productCategoryForm">
|
||||
@csrf
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalTitle">Tambah Kategori</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="category_id">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Nama Kategori</label>
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary" id="saveBtn">Simpan</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- end modal --}}
|
||||
@endsection
|
||||
|
||||
@section('javascripts')
|
||||
<script src="{{mix('js/warehouse_management/product_categories/index.js')}}"></script>
|
||||
@endsection
|
||||
@@ -0,0 +1,37 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-portlet kt-portlet--mobile" id="kt_blockui_datatable">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Tambah Produk
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<div class="">
|
||||
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<!--begin: Datatable -->
|
||||
<table class="table table-striped table-bordered table-hover" id="stock-dealers-table" data-url="{{ route("products.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Kode</th>
|
||||
<th>Nama</th>
|
||||
<th>Address</th>
|
||||
<th>Stok</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<!--end: Datatable -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,48 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-portlet kt-portlet--mobile" id="kt_blockui_datatable">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Produk
|
||||
</h3>
|
||||
</div>
|
||||
@can('create', $menus['product_categories.index'])
|
||||
<div class="kt-portlet__head-toolbar">
|
||||
<div class="kt-portlet__head-wrapper">
|
||||
<div class="kt-portlet__head-actions">
|
||||
<button type="button" class="btn btn-bold btn-label-brand btn-sm" id="addProductCategory"> Tambah </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<div class="table-responsive">
|
||||
<!--begin: Datatable -->
|
||||
<table class="table table-striped table-bordered table-hover" id="products-table" data-url="{{ route("products.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Kode</th>
|
||||
<th>Nama</th>
|
||||
<th>Kategori</th>
|
||||
<th>Stok</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<!--end: Datatable -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('javascripts')
|
||||
<script src="{{mix('js/warehouse_management/products/index.js')}}"></script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user