partial update detail opnames page

This commit is contained in:
2025-06-05 15:18:20 +07:00
parent ce0a4718e0
commit d294bb7876
15 changed files with 217 additions and 72 deletions

View File

@@ -0,0 +1,20 @@
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
});
let tableContainer = $("#opname-detail-table");
let url = tableContainer.data("url");
let table = $("#opname-detail-table").DataTable({
processing: true,
serverSide: true,
ajax: url,
columns: [
{ data: "opname_date", name: "opname_date" },
{ data: "user_name", name: "user.name" },
{ data: "product_name", name: "product.name" },
{ data: "system_stock", name: "system_stock" },
{ data: "physical_stock", name: "physical_stock" },
{ data: "difference", name: "difference" },
],
});

View File

@@ -16,34 +16,3 @@ let table = $("#opnames-table").DataTable({
{ data: "action", name: "action", orderable: false, searchable: false },
],
});
$(document).on("click", ".btn-product-stock-dealers", function () {
const productId = $(this).data("id");
const productName = $(this).data("name");
const ajaxUrl = $(this).data("url");
// Set product name in modal title
$("#product-name-title").text(productName);
// Initialize or reload DataTable inside modal
$("#dealer-stock-table").DataTable({
destroy: true, // reinit if exists
processing: true,
serverSide: true,
ajax: {
url: ajaxUrl,
data: {
product_id: productId,
},
},
columns: [
{ data: "dealer_name", name: "dealer_name" },
{ data: "system_stock", name: "system_stock" },
{ data: "physical_stock", name: "physical_stock" },
{ data: "difference", name: "difference" },
{ data: "opname_date", name: "opname_date" },
],
});
// Show the modal
$("#dealerStockModal").modal("show");
});

View File

@@ -14,7 +14,12 @@ let table = $("#products-table").DataTable({
{ data: "name", name: "name" },
{ data: "category_name", name: "category.name" },
{ data: "unit", name: "unit" },
{ data: "total_stock", name: "total_stock" },
{
data: "total_stock",
name: "total_stock",
orderable: false,
searchable: false,
},
{ data: "action", name: "action", orderable: false, searchable: false },
],
});
@@ -83,3 +88,37 @@ $(document).on("click", ".btn-toggle-active", function () {
}
});
});
$(document).on("click", ".btn-product-stock-dealers", function () {
const productId = $(this).data("id");
const productName = $(this).data("name");
const ajaxUrl = $(this).data("url");
// Set product name in modal title
$("#product-name-title").text(productName);
// Initialize or reload DataTable inside modal
$("#dealer-stock-table").DataTable({
destroy: true, // reinit if exists
processing: true,
serverSide: true,
ajax: {
url: ajaxUrl,
data: {
product_id: productId,
},
},
columns: [
{ data: "dealer_name", name: "dealer_name" },
{ data: "system_stock", name: "system_stock" },
{ data: "physical_stock", name: "physical_stock" },
{ data: "difference", name: "difference" },
{ data: "opname_date", name: "opname_date" },
],
initComplete: function () {
$("#dealerStockModal").modal("show");
},
});
});
$(document).on("click", "#dealerStockModal .close", function () {
$("#dealerStockModal").modal("hide");
});

View File

@@ -16,7 +16,7 @@
@csrf
<div class="form-group">
<label for="dealer">Dealer</label>
<select name="dealer" id="dealer" class="form-control">
<select name="dealer" id="dealer" class="form-control" required >
<option value="">Pilih Dealer</option>
@foreach($dealers as $dealer)
<option value="{{ $dealer->id }}">{{ $dealer->name }}</option>
@@ -28,17 +28,17 @@
<div class="form-row align-items-end product-row">
<div class="form-group col-md-4">
<label for="product[]">Produk</label>
<select name="product[]" class="form-control product-select" >
<select name="product[]" class="form-control product-select" required >
<option value="">Pilih Produk</option>
</select>
</div>
<div class="form-group col-md-3">
<label>Stok Sistem</label>
<input type="text" name="system_quantity[]" class="form-control" placeholder="Stok sistem">
<input type="text" name="system_quantity[]" class="form-control" placeholder="Stok sistem" required >
</div>
<div class="form-group col-md-3">
<label>Stok Fisik</label>
<input type="text" name="physical_quantity[]" class="form-control" placeholder="Stok fisik">
<input type="text" name="physical_quantity[]" class="form-control" placeholder="Stok fisik" required >
</div>
<div class="form-group col-md-2">
<button type="button" class="btn btn-success btn-add-row"><i class="flaticon2-plus"></i></button>

View File

@@ -0,0 +1,39 @@
@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-list-1"></i>
</span>
<h3 class="kt-portlet__head-title">
Detail Opname
</h3>
</div>
</div>
<div class="kt-portlet__body">
<div class="table-responsive">
<!--begin: Datatable -->
<table class="table table-striped table-bordered table-hover" id="opname-detail-table" data-url="{{ route("opnames.show", $opname->id) }}">
<thead>
<tr>
<th>Tanggal</th>
<th>Pengguna</th>
<th>Produk</th>
<th>Sistem</th>
<th>Fisik</th>
<th>Selisih</th>
</tr>
</thead>
</table>
<!--end: Datatable -->
</div>
</div>
</div>
@endsection
@section('javascripts')
<script src="{{ mix('js/warehouse_management/opnames/detail.js') }}"></script>
@endsection

View File

@@ -11,7 +11,7 @@
Tabel Opnames
</h3>
</div>
@can('create', $menus['product_categories.index'])
@can('create', $menus['opnames.index'])
<div class="kt-portlet__head-toolbar">
<div class="kt-portlet__head-wrapper">
<div class="kt-portlet__head-actions">
@@ -38,35 +38,7 @@
<!--end: Datatable -->
</div>
</div>
</div>
<div class="modal fade" id="dealerStockModal" tabindex="-1" role="dialog" aria-labelledby="dealerStockModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Dealer Stock for <span id="product-name-title"></span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<table id="dealer-stock-table" class="table table-bordered">
<thead>
<tr>
<th>Dealer</th>
<th>System Stock</th>
<th>Physical Stock</th>
<th>Difference</th>
<th>Opname Date</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('javascripts')

View File

@@ -11,7 +11,7 @@
Tabel Produk
</h3>
</div>
@can('create', $menus['product_categories.index'])
@can('create', $menus['products.index'])
<div class="kt-portlet__head-toolbar">
<div class="kt-portlet__head-wrapper">
<div class="kt-portlet__head-actions">
@@ -41,6 +41,34 @@
</div>
</div>
</div>
{{-- modal dealer stock --}}
<div class="modal fade" id="dealerStockModal" tabindex="-1" role="dialog" aria-labelledby="dealerStockModalLabel" aria-hidden="true">
<div class="modal-dialog pl-5 modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Dealer Stock for <span id="product-name-title"></span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<table id="dealer-stock-table" class="table table-bordered">
<thead>
<tr>
<th>Dealer</th>
<th>System Stock</th>
<th>Physical Stock</th>
<th>Difference</th>
<th>Opname Date</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('javascripts')