localize library cdn, remove approve button from transaction page, fix all fitur running datatable as well, fixing sortable datatable using new cdn, fix modal approve, add note to receiver mutations
This commit is contained in:
@@ -1,74 +1,96 @@
|
||||
$(document).ready(function () {
|
||||
console.log("Mutations index.js loaded");
|
||||
|
||||
// Check if DataTables is available
|
||||
if (typeof $.fn.DataTable === "undefined") {
|
||||
console.error("DataTables not available!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy existing table if any
|
||||
if ($.fn.DataTable.isDataTable("#mutations-table")) {
|
||||
$("#mutations-table").DataTable().destroy();
|
||||
}
|
||||
|
||||
// Initialize DataTable
|
||||
var table = $("#mutations-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: $("#mutations-table").data("url"),
|
||||
type: "GET",
|
||||
error: function (xhr, error, code) {
|
||||
console.error("DataTables AJAX error:", error, code);
|
||||
},
|
||||
},
|
||||
columns: [
|
||||
columnDefs: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
targets: 0, // No. column
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: "5%",
|
||||
},
|
||||
{
|
||||
data: "mutation_number",
|
||||
name: "mutation_number",
|
||||
width: "12%",
|
||||
targets: [1, 2, 3, 4, 5, 6, 7], // All sortable columns
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "created_at",
|
||||
name: "created_at",
|
||||
width: "12%",
|
||||
},
|
||||
{
|
||||
data: "from_dealer",
|
||||
name: "fromDealer.name",
|
||||
width: "13%",
|
||||
},
|
||||
{
|
||||
data: "to_dealer",
|
||||
name: "toDealer.name",
|
||||
width: "13%",
|
||||
},
|
||||
{
|
||||
data: "requested_by",
|
||||
name: "requestedBy.name",
|
||||
width: "12%",
|
||||
},
|
||||
{
|
||||
data: "total_items",
|
||||
name: "total_items",
|
||||
width: "8%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
data: "status",
|
||||
name: "status",
|
||||
width: "12%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
data: "action",
|
||||
name: "action",
|
||||
targets: 8, // Action column
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: "20%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
targets: [6, 7], // Total Items and Status columns
|
||||
className: "text-center",
|
||||
},
|
||||
],
|
||||
order: [[2, "desc"]], // Order by created_at desc
|
||||
columns: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
},
|
||||
{
|
||||
data: "mutation_number",
|
||||
name: "mutation_number",
|
||||
},
|
||||
{
|
||||
data: "created_at",
|
||||
name: "created_at",
|
||||
},
|
||||
{
|
||||
data: "from_dealer",
|
||||
name: "fromDealer.name",
|
||||
},
|
||||
{
|
||||
data: "to_dealer",
|
||||
name: "toDealer.name",
|
||||
},
|
||||
{
|
||||
data: "requested_by",
|
||||
name: "requestedBy.name",
|
||||
},
|
||||
{
|
||||
data: "total_items",
|
||||
name: "total_items",
|
||||
},
|
||||
{
|
||||
data: "status",
|
||||
name: "status",
|
||||
},
|
||||
{
|
||||
data: "action",
|
||||
name: "action",
|
||||
},
|
||||
],
|
||||
order: [[1, "desc"]], // Order by mutation_number desc (which follows ID order)
|
||||
pageLength: 10,
|
||||
responsive: true,
|
||||
});
|
||||
|
||||
// Modal event handlers are now handled by Bootstrap 5 data attributes
|
||||
// No need for manual modal show/hide handlers
|
||||
|
||||
// Handle Cancel Button Click with SweetAlert
|
||||
$(document).on("click", ".btn-cancel", function () {
|
||||
var mutationId = $(this).data("id");
|
||||
|
||||
Reference in New Issue
Block a user