You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
819 lines
26 KiB
819 lines
26 KiB
<!DOCTYPE html>
|
|
<html lang="en" dir="ltr">
|
|
<html xmlns:th="http://www.thymeleaf.org">
|
|
|
|
<head th:replace="~{fragments/modules/base/head :: head}"></head>
|
|
<style>
|
|
|
|
.custom-card-wrapper {
|
|
padding: 0;
|
|
margin-top: -58px;
|
|
margin-left: -233px;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.custom-card-wrapper {
|
|
margin-left: 0;
|
|
margin-top: 0;
|
|
padding: 10px;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
<div class="wrapper">
|
|
<header th:replace="~{fragments/modules/base/header :: header}"></header>
|
|
<div class="page-wrap">
|
|
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
|
|
<div class="card">
|
|
<div class="main-content" style="background-color: white;">
|
|
<div class="container">
|
|
<!-- Card 2: Other Details -->
|
|
<div class="col-md-12">
|
|
<div class="custom-card-wrapper">
|
|
<!-- <div style="padding: 0px;margin-top:-58px;margin-left: -233px;"> -->
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<b>List of IT Assets</b>
|
|
<button type="button" class="btn btn-primary add-btn"> <i class="ik ik-plus"></i>Add Assets</button>
|
|
</div>
|
|
<div class="card-body" style="padding: 5px;">
|
|
<table id="AssetManageDatatable"
|
|
class="table table-striped table-bordered table-hover dataTable" role="grid"
|
|
style="width: 100%">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>S.NO</th>
|
|
<th>ASSET CODE</th>
|
|
<th>NAME</th>
|
|
<th>SOURCE</th>
|
|
<th>SERIAL NUMBER</th>
|
|
<th>RECEIVED DATE</th>
|
|
<th>RECEIVED BY</th>
|
|
<th>VENDOR DETAILS</th>
|
|
<th>INVOICE NUMBER</th>
|
|
<th>ACTION</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="pageLoader"
|
|
style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
|
|
<div style="position: relative; top: 50%; transform: translateY(-50%);">
|
|
<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
|
|
<span class="sr-only">Loading...</span>
|
|
</div>
|
|
<!-- Add the 'Please wait' text below the spinner -->
|
|
<p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="modal fade" id="AddAssetModal2" tabindex="-1" role="dialog" aria-labelledby="AddAssetModal2Label" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
Add Assets
|
|
</h5>
|
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<span id="school_udise" style="display: none;"></span>
|
|
<div class="row">
|
|
<!-- <div class="form-group col-6">
|
|
<label for="assetCode">Asset Code<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="assetCode" name="assetCode">
|
|
|
|
</div>-->
|
|
|
|
<div class="form-group col-6">
|
|
<label for="assetName">Name <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="assetName" name="assetName" required>
|
|
<option value="">-- Select Sub Asset Type --</option>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
<div class="form-group col-6">
|
|
<label for="assetSource">Source<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="assetSource" name="assetSource">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="serialNumber">Serial Number<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="serialNumber" name="serialNumber">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="vendorDetail">Vendor Detail<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="vendorDetail" name="vendorDetail">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="invoiceNumber">Invoice Number</label>
|
|
<input type="text" class="form-control" id="invoiceNumber" name="invoiceNumber">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row pb-2 mt-4">
|
|
<div class="col-12 d-flex justify-content-center">
|
|
<button type="button" class="btn btn-primary" id="savingAsset">Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="modal fade" id="EditAssetModal2" tabindex="-1" role="dialog" aria-labelledby="EditAssetModal2Label" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
Edit Assets
|
|
</h5>
|
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<span id="editid" style="display: none;"></span>
|
|
<div class="row">
|
|
<div class="form-group col-6">
|
|
<label for="editassetCode">Asset Code<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="editassetCode" name="editassetCode">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="editassetName">Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="editassetName" name="editassetName">
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="editassetSource">Source<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="editassetSource" name="editassetSource">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="editserialNumber">Serial Number<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="editserialNumber" name="editserialNumber">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="editvendorDetail">Vendor Detail<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="editvendorDetail" name="vendorDetail">
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-6">
|
|
<label for="editinvoiceNumber">Invoice Number</label>
|
|
<input type="text" class="form-control" id="editinvoiceNumber" name="editinvoiceNumber">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row pb-2 mt-4">
|
|
<div class="col-12 d-flex justify-content-center">
|
|
<button type="button" class="btn btn-primary" id="UpdatingAsset">Update</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script th:replace="~{fragments/modules/base/script :: script}"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
console.log("hi..asset Management");
|
|
|
|
$(document).ready(function () {
|
|
|
|
let AssetManageurlParams = new URLSearchParams(window.location.search);
|
|
let AssetManageschoolId = AssetManageurlParams.get("schoolId");
|
|
|
|
loadSavedBuildingAm(AssetManageschoolId);
|
|
|
|
if (!window.assetManagementEventsBound) {
|
|
|
|
$(document).on('click', '.edit-btn1', handleManageEdit);
|
|
// $(document).on('click', '.add-btn', handleAddAsset);
|
|
$(document).on('click', '.add-btn', function () {
|
|
handleAddAsset(AssetManageschoolId);
|
|
});
|
|
|
|
//$(document).on('click', '#savingAsset', handleSavingAsset);
|
|
|
|
// Pass school ID to the handler
|
|
$(document).on('click', '#savingAsset', function () {
|
|
handleSavingAsset(AssetManageschoolId);
|
|
});
|
|
|
|
$(document).on('click', '#UpdatingAsset', handelEditAsset);
|
|
|
|
window.assetManagementEventsBound = true;
|
|
}
|
|
|
|
});
|
|
$(document).on('input', '#assetSource, #vendorDetail', function () {
|
|
this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, ''); // Allow only alphanumeric + space
|
|
});
|
|
|
|
$(document).on('input', '#serialNumber, #invoiceNumber', function () {
|
|
this.value = this.value.replace(/[^a-zA-Z0-9/]/g, ''); // Allow only alphanumeric + "/"
|
|
});
|
|
|
|
|
|
function loadSavedBuildingAm(AssetManageschoolId) {
|
|
//console.log("hi");
|
|
var buttons = [
|
|
{
|
|
extend: 'pageLength',
|
|
className: 'btn btn-warning'
|
|
},
|
|
{
|
|
title: 'Data export',
|
|
extend: 'copyHtml5',
|
|
text: 'Copy',
|
|
className: 'btn btn-secondary',
|
|
id: 'copyBtn'
|
|
},
|
|
{
|
|
extend: 'excelHtml5',
|
|
text: 'Excel',
|
|
className: 'btn btn-secondary',
|
|
id: 'excelBtn',
|
|
title: 'Asset List'
|
|
},
|
|
{
|
|
extend: 'csvHtml5',
|
|
text: 'CSV',
|
|
className: 'btn btn-secondary',
|
|
id: 'csvBtn',
|
|
title: 'Asset List'
|
|
},
|
|
{
|
|
extend: 'pdfHtml5',
|
|
text: 'PDF',
|
|
className: 'btn btn-secondary',
|
|
id: 'pdfBtn',
|
|
title: 'Asset List'
|
|
},
|
|
{
|
|
extend: 'print',
|
|
text: 'Print',
|
|
className: 'btn btn-secondary',
|
|
id: 'printBtn',
|
|
title: 'Asset List',
|
|
exportOptions: {
|
|
columns: ':visible:not(.no-print)' // Exclude columns with class 'no-print' from print view
|
|
}
|
|
}
|
|
];
|
|
|
|
$.get('/gcc/api/gccschool/buildingasset/getAssetManagement', {school_id: AssetManageschoolId}, res => {
|
|
if ($.fn.DataTable.isDataTable('#AssetManageDatatable')) {
|
|
$('#AssetManageDatatable').DataTable().clear().destroy(true);
|
|
}
|
|
|
|
//console.log("hello");
|
|
let tableData = [];
|
|
if (res.status === "Sucess" && Array.isArray(res.data)) {
|
|
//console.log("res.data="+res.data);
|
|
tableData = res.data;
|
|
}
|
|
|
|
$('#AssetManageDatatable').DataTable({
|
|
data: tableData,
|
|
columns: [
|
|
{data: null, render: (d, t, r, m) => m.row + 1, className: 'text-center'},
|
|
{data: 'asset_name'},
|
|
{data: 'hardware_type'},
|
|
{data: 'source_of_asset'},
|
|
{data: 'serial_no'},
|
|
{data: 'date_received'},
|
|
{data: 'asset_category'},
|
|
{data: 'vendor_name'},
|
|
{data: 'invoice_num'},
|
|
{
|
|
data: 'it_details_id',
|
|
render: (data, t, row) => `
|
|
<div class="text-center">
|
|
<button class="btn btn-sm btn-success edit-btn1" data-id="${row.it_details_id}" ><i class="ik ik-edit-2" style="font-size:medium;margin-left:5px;"></i></button>
|
|
</div>`, className: 'text-center'
|
|
}
|
|
],
|
|
lengthMenu: [
|
|
[50, 100, 200, 500, -1],
|
|
['50 rows', '100 rows', '200 rows', '500 rows', 'Show all']
|
|
],
|
|
dom: 'Bftip',
|
|
//fixedColumns: {left: 0, right: 0},
|
|
scrollY: '70vh',
|
|
scrollX: true,
|
|
autoWidth: true,
|
|
paging: true,
|
|
info: true,
|
|
buttons: buttons,
|
|
responsive: false,
|
|
searching: true,
|
|
select: false,
|
|
processing: false,
|
|
language: {
|
|
emptyTable: '<span class="text-danger">No Details found</span>'
|
|
}
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
// Load sub asset types on modal open or page load
|
|
// Load sub asset types on modal open or page load
|
|
$.ajax({
|
|
url: '/gcc/api/gccschool/dropdown/getSubAssetType',
|
|
type: 'GET',
|
|
data: { assetid: 1 }, // or dynamic ID later
|
|
success: function (res) {
|
|
console.log("Sub Asset API Response:", res);
|
|
|
|
if (res.status === "OK" && Array.isArray(res.data)) {
|
|
$('#assetName').empty().append('<option value="">-- Select Sub Asset Type --</option>');
|
|
|
|
res.data.forEach(function (item) {
|
|
$('#assetName').append(
|
|
$('<option>', {
|
|
value: item.code,
|
|
text: item.asset_name
|
|
})
|
|
);
|
|
});
|
|
} else {
|
|
$('#assetName').empty().append('<option value="">No Sub Asset Types Found</option>');
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error("Failed to load sub asset types:", error);
|
|
$('#assetName').empty().append('<option value="">Error Loading</option>');
|
|
}
|
|
});
|
|
|
|
|
|
function handleAddAsset(schid) {
|
|
|
|
$('#AddAssetModal2').modal('show');
|
|
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/gcc/api/gccschool/schoolproperty/getSchoolDetails',
|
|
data: {schoolId: schid},
|
|
success: function (data) {
|
|
console.log(data);
|
|
$('#school_udise').text(data.udise);
|
|
},
|
|
error: function (xhr) {
|
|
console.log("Failed to get udise for school: " + xhr.responseJSON?.message);
|
|
}
|
|
});
|
|
|
|
|
|
$('#assetCode').val('');
|
|
$('#assetName').val('');
|
|
$('#assetSource').val('');
|
|
$('#serialNumber').val('');
|
|
$('#vendorDetail').val('');
|
|
$('#invoiceNumber').val('');
|
|
|
|
|
|
}
|
|
function handleSavingAsset(assetManageschoolId){
|
|
|
|
let school_udise = $('#school_udise').text().trim();
|
|
|
|
// let assetCode = $('#assetCode').val().trim();
|
|
//let subAssetId = $('#assetName').val();
|
|
//let subAssetId = $('#assetName').val(); // This gives selected value = sub_asset_id
|
|
|
|
let assetSource = $('#assetSource').val().trim();
|
|
let serialNumber = $('#serialNumber').val().trim();
|
|
let vendorDetail = $('#vendorDetail').val().trim();
|
|
let invoiceNumber = $('#invoiceNumber').val().trim();
|
|
//let assetCode = $('#assetName option:selected').text().trim();
|
|
|
|
let assetCode = $('#assetName').val(); // Get selected value
|
|
let assetName = $('#assetName option:selected').text().trim(); // Get selected text
|
|
|
|
|
|
// Console log to verify
|
|
console.log("UDISE:", school_udise);
|
|
console.log("Asset Code:", assetCode);
|
|
console.log("Asset Name:", assetName);
|
|
//console.log("Asset Name:", assetName);
|
|
console.log("Source:", assetSource);
|
|
console.log("Serial Number:", serialNumber);
|
|
console.log("Vendor Detail:", vendorDetail);
|
|
console.log("Invoice Number:", invoiceNumber);
|
|
console.log("assetManageschoolId="+assetManageschoolId);
|
|
//console.log("Asset Name:", assetName);
|
|
//console.log("Code:", code);
|
|
|
|
// Validation
|
|
/* if (assetCode === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Asset Code',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}*/
|
|
|
|
if (assetCode === '' || assetName === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please Select Name',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (assetSource === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Source',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (serialNumber === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Serial Number',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (vendorDetail === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Vendor Detail',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
console.log(assetManageschoolId);
|
|
|
|
/*if (invoiceNumber === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Invoice Number',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}*/
|
|
|
|
/* if (assetCode === '') {
|
|
Swal.fire('Missing Field', 'Please enter Asset Code', 'warning');
|
|
return;
|
|
}
|
|
if (assetName === '') {
|
|
Swal.fire('Missing Field', 'Please enter Name', 'warning');
|
|
return;
|
|
}
|
|
if (assetSource === '') {
|
|
Swal.fire('Missing Field', 'Please enter Source', 'warning');
|
|
return;
|
|
}
|
|
if (serialNumber === '') {
|
|
Swal.fire('Missing Field', 'Please enter Serial Number', 'warning');
|
|
return;
|
|
}
|
|
if (vendorDetail === '') {
|
|
Swal.fire('Missing Field', 'Please enter Vendor Detail', 'warning');
|
|
return;
|
|
}
|
|
if (invoiceNumber === '') {
|
|
Swal.fire('Missing Field', 'Please enter Invoice Number', 'warning');
|
|
return;
|
|
}*/
|
|
|
|
// AJAX POST
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/gcc/api/gccschool/buildingasset/addAsset", // your endpoint
|
|
data: {
|
|
// assetCode: code,
|
|
// sub_asset_id: subAssetId,
|
|
name:assetName,
|
|
code:assetCode,
|
|
source: assetSource,
|
|
serialNum: serialNumber,
|
|
vendorDetail: vendorDetail,
|
|
invoice_num: invoiceNumber,
|
|
udise: school_udise,
|
|
is_online: 0,
|
|
school_id: assetManageschoolId
|
|
},
|
|
success: function (response) {
|
|
if (response === "Sucess") {
|
|
Swal.fire({
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
icon: 'success',
|
|
title: 'Asset Added',
|
|
text: 'Asset added successfully!'
|
|
}).then(() => {
|
|
|
|
/* loadSavedBuildingAm(assetManageschoolId);
|
|
|
|
$('#AddAssetModal2').modal('hide'); */
|
|
|
|
location.reload();
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Something went wrong while saving asset.'
|
|
});
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error('Error saving assets:', error);
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Request Failed',
|
|
text: 'Unable to send request to the server.'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function handleManageEdit(){
|
|
|
|
console.log("Button clicked");
|
|
let id = $(this).data('id');
|
|
console.log("id=" + id);
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/gcc/api/gccschool/buildingasset/getAssets",
|
|
data: { it_details_id: id },
|
|
success: function (response) {
|
|
if (response.status === "Success" && response.data) {
|
|
let data = response.data;
|
|
|
|
// Populate modal fields
|
|
$('#editassetCode').val(data.asset_name || '');
|
|
$('#editassetName').val(data.hardware_type || '');
|
|
$('#editassetSource').val(data.source_of_asset || '');
|
|
$('#editserialNumber').val(data.serial_no || '');
|
|
$('#editvendorDetail').val(data.vendor_name || '');
|
|
$('#editinvoiceNumber').val(data.invoice_num || '');
|
|
|
|
$('#editid').val(data.it_details_id);
|
|
|
|
// Show the modal
|
|
$('#EditAssetModal2').modal('show');
|
|
} else {
|
|
Swal.fire('Error', 'Unable to fetch asset details.', 'error');
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error('Error fetching asset:', error);
|
|
Swal.fire('Error', 'Server error while fetching asset.', 'error');
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function handelEditAsset(){
|
|
|
|
let editassetCode = $('#editassetCode').val().trim();
|
|
let editassetName = $('#editassetName').val().trim();
|
|
let editassetSource = $('#editassetSource').val().trim();
|
|
let editserialNumber = $('#editserialNumber').val().trim();
|
|
let editvendorDetail = $('#editvendorDetail').val().trim();
|
|
let editinvoiceNumber = $('#editinvoiceNumber').val().trim();
|
|
let editid= $('#editid').val().trim();
|
|
|
|
// Validation
|
|
/* if (editassetCode === '') {
|
|
Swal.fire('Missing Field', 'Please enter Asset Code', 'warning');
|
|
return;
|
|
}
|
|
if (editassetName === '') {
|
|
Swal.fire('Missing Field', 'Please enter Name', 'warning');
|
|
return;
|
|
}
|
|
if (editassetSource === '') {
|
|
Swal.fire('Missing Field', 'Please enter Source', 'warning');
|
|
return;
|
|
}
|
|
if (editserialNumber === '') {
|
|
Swal.fire('Missing Field', 'Please enter Serial Number', 'warning');
|
|
return;
|
|
}
|
|
if (editvendorDetail === '') {
|
|
Swal.fire('Missing Field', 'Please enter Vendor Detail', 'warning');
|
|
return;
|
|
}
|
|
if (editinvoiceNumber === '') {
|
|
Swal.fire('Missing Field', 'Please enter Invoice Number', 'warning');
|
|
return;
|
|
}*/
|
|
if (editassetCode === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Asset Code',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (editassetName === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Name',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (editassetSource === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Source',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (editserialNumber === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Serial Number',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (editvendorDetail === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Vendor Detail',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
/* if (editinvoiceNumber === '') {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Missing Field',
|
|
text: 'Please enter Invoice Number',
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
showConfirmButton: true
|
|
});
|
|
return;
|
|
}*/
|
|
|
|
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/gcc/api/gccschool/buildingasset/editAsset", // your endpoint
|
|
data: {
|
|
assetCode: editassetCode,
|
|
name: editassetName,
|
|
source: editassetSource,
|
|
serialNum: editserialNumber,
|
|
vendorDetail: editvendorDetail,
|
|
invoice_num: editinvoiceNumber,
|
|
it_details_id: editid
|
|
|
|
},
|
|
success: function (response) {
|
|
if (response === "Success") {
|
|
Swal.fire({
|
|
allowOutsideClick: false,
|
|
allowEscapeKey: false,
|
|
allowEnterKey: false,
|
|
icon: 'success',
|
|
title: 'Asset Updated',
|
|
text: 'Asset Updated successfully!'
|
|
|
|
}).then(() => {
|
|
|
|
location.reload();
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Something went wrong while updating asset.'
|
|
});
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error('Error updating assets:', error);
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Request Failed',
|
|
text: 'Unable to send request to the server.'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|