update item request inv master
This commit is contained in:
parent
531106d90d
commit
1c4e1a32c6
@ -45,7 +45,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers.Admin
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult QrScanner()
|
||||
public IActionResult QrMaster()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult Qr()
|
||||
public ActionResult QrUser()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -18,7 +18,8 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
|
||||
[ForeignKey("UserId")]
|
||||
public virtual UserModel? User { get; set; }
|
||||
public string? ProductCategory { get; set; }
|
||||
public string? remark { get; set; }
|
||||
public string? remarkUser { get; set; }
|
||||
public string? remarkMasterInv { get; set; }
|
||||
public string? status { get; set; }
|
||||
public DateTime requestDate { get; set; }
|
||||
public DateTime? approvalDate { get; set; }
|
||||
|
||||
@ -1 +1,800 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Product Request";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
|
||||
<div id="requestProduct" class="row">
|
||||
<div class="row card">
|
||||
<div class="card-header">
|
||||
<h2>Pending Request</h2>
|
||||
@* <button id="addRequestBtn" class="btn btn-success col-md-3 col-lg-3 m-1 col-12"><i class="fa fa-plus"></i> Add Request</button> *@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@* <div v-if="loading">
|
||||
<div class="spinner-border text-info" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div> *@
|
||||
<table class="table table-bordered table-hover table-striped no-wrap" id="requestDatatable" style=" width:100%;border-style: solid; border-width: 1px"></table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row card">
|
||||
<div class="card-header">
|
||||
<h2>Item Request</h2>
|
||||
@* <button id="addRequestBtn" class="btn btn-success col-md-3 col-lg-3 m-1 col-12"><i class="fa fa-plus"></i> Add Request</button> *@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@* <div v-if="loading">
|
||||
<div class="spinner-border text-info" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div> *@
|
||||
<table class="table table-bordered table-hover table-striped no-wrap" id="settledrequestDatatable" style=" width:100%;border-style: solid; border-width: 1px"></table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectRequestModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="rejectRequestModalLabel">Reject Request</h5>
|
||||
<button type="button" class="closeModal" data-dismiss="modal" aria-label="Close" v-on:click="showRequestModal=false">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<form v-on:submit.prevent="rejectRequest" data-aos="fade-right">
|
||||
@* <div class=" register" data-aos="fade-right"> *@
|
||||
<div data-aos="fade-right">
|
||||
<div class="row" data-aos="fade-right">
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||
<h3 class="register-heading">REJECT REQUEST</h3>
|
||||
<div class="row register-form">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="form-group row">
|
||||
@* <label class="col-sm-4 col-form-label hidden-label">Request Id</label> *@
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<input type="text" id="currentRequestId" name="currentRequestId" v-model="currentRequestId" class="form-control" hidden />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Remark</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<input type="text" id="rejectremark" name="rejectremark" v-model="rejectremark" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Submit and Reset Buttons *@
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-3">
|
||||
<button type="button" v-on:click="resetForm" class="btn btn-secondary m-1">Reset</button>
|
||||
<button type="submit" class="btn btn-primary m-1 submit-button">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
<script>
|
||||
$(function () {
|
||||
app.mount('#requestProduct');
|
||||
|
||||
// Attach a click event listener to elements with the class 'btn-success'.
|
||||
$('#addRequestBtn').on('click', function () {
|
||||
// Show the modal
|
||||
$('#requestModal').modal('show');
|
||||
});
|
||||
$('.closeModal').on('click', function () {
|
||||
// Show the modal
|
||||
$('.modal').modal('hide');
|
||||
});
|
||||
$('.submit-button').on('click', function () {
|
||||
// Show the modal
|
||||
$('#rejectModal').modal('hide');
|
||||
});
|
||||
});
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
requestId : null,
|
||||
userId : null,
|
||||
stationId : null,
|
||||
productId : null,
|
||||
remark: "",
|
||||
document: null,
|
||||
quantity: 0,
|
||||
status: "",
|
||||
requestDate : null,
|
||||
approvalDate : null,
|
||||
productCategory: "",
|
||||
productName: null,
|
||||
productCategory: null,
|
||||
stations: [],
|
||||
selectedProduct: "",
|
||||
selectedStation: "",
|
||||
selectedCategory: "",
|
||||
showRequestModal: false,
|
||||
showRejectModal: false,
|
||||
loading: false,
|
||||
request: [],
|
||||
currentUser: null,
|
||||
currentRequestId: "",
|
||||
rejectremark: "",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchRequest();
|
||||
this.fetchUser();
|
||||
this.fetchProducts();
|
||||
this.fetchStation();
|
||||
},
|
||||
computed: {
|
||||
// filteredDepartments() {
|
||||
// if (!this.selectedCompany) {
|
||||
// return []; No company selected, return empty list
|
||||
// }
|
||||
// const company = this.companies.find(c => c.companyId === this.selectedCompany);
|
||||
// this.selectedDepartment = '';
|
||||
// return company ? company.departments : [];
|
||||
// },
|
||||
// showProduct() {
|
||||
// if (!this.selectedProduct) {
|
||||
// return []; No company selected, return empty list
|
||||
// }
|
||||
// const product = this.products.find(c => c.productId === this.selectedProduct);
|
||||
// return product ? product : {};
|
||||
// },
|
||||
},
|
||||
methods: {
|
||||
async addRequest() {
|
||||
try {
|
||||
const requiredFields = ['stationId', 'productId', 'quantity', 'productCategory'];
|
||||
|
||||
// Loop through required fields and check if any are null or empty
|
||||
for (let field of requiredFields) {
|
||||
if (this[field] === null || this[field] === '') {
|
||||
alert('Request Error', `Please fill in required fields: ${field}.`, 'warning');
|
||||
return; // Exit early if validation fails
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Proceed to send the data to the API
|
||||
const response = await fetch('/InvMainAPI/AddRequest', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// 'Authorization': `Bearer ${this.token}`
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
});
|
||||
if (response.ok) {
|
||||
// If the form submission was successful, display a success message
|
||||
alert('Success!', 'Request form has been successfully submitted.', 'success');
|
||||
const requestItem = await response.json();
|
||||
this.items.push(requestItem);
|
||||
|
||||
this.fetchRequest();
|
||||
|
||||
// Reset the form
|
||||
this.resetForm();
|
||||
} else {
|
||||
throw new Error('Failed to submit form.');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
|
||||
// Displaying error message
|
||||
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
initiateTable() {
|
||||
self = this;
|
||||
this.requestDatatable = $('#requestDatatable').DataTable({
|
||||
"data": this.items.filter(item => item.status == "Requested"),
|
||||
"columns": [
|
||||
{
|
||||
"title": "Request ID",
|
||||
"data": "requestId",
|
||||
},
|
||||
{
|
||||
"title": "Product ID",
|
||||
"data": "productId",
|
||||
},
|
||||
{
|
||||
"title": "Product Category",
|
||||
"data": "productCategory",
|
||||
},
|
||||
{
|
||||
"title": "Request Quantity",
|
||||
"data": "requestQuantity",
|
||||
},
|
||||
{
|
||||
"title": "Document/Picture",
|
||||
"data": "document",
|
||||
},
|
||||
{
|
||||
"title": "User Remark",
|
||||
"data": "remarkUser",
|
||||
},
|
||||
{
|
||||
"title": "InvMaster Remark",
|
||||
"data": "remarkMasterInv",
|
||||
},
|
||||
{
|
||||
"title": "Status",
|
||||
"data": "status",
|
||||
},
|
||||
{
|
||||
"title": "Request Date",
|
||||
"data": "requestDate",
|
||||
},
|
||||
{
|
||||
"title": "Approval Date",
|
||||
"data": "approvalDate",
|
||||
},
|
||||
{
|
||||
"title": "Reject",
|
||||
"data" :"requestId",
|
||||
"render": function (data, type, row) {
|
||||
var rejectButton = `<button type="button" class="btn btn-danger reject-btn" data-id="${data}">Reject</button>`;
|
||||
return rejectButton
|
||||
},
|
||||
"className": "align-middle",
|
||||
},
|
||||
{
|
||||
"title": "Approve",
|
||||
"data": "requestId",
|
||||
"render": function (data) {
|
||||
var approveButton = `<button type="button" class="btn btn-success approve-btn" data-id="${data}">Approve</button>`;
|
||||
return approveButton;
|
||||
},
|
||||
"className": "align-middle",
|
||||
}
|
||||
],
|
||||
responsive: true,
|
||||
drawCallback: function (settings) {
|
||||
// Generate QR codes after rows are rendered
|
||||
// const api = this.api();
|
||||
// api.rows().every(function () {
|
||||
// const data = this.data(); Row data
|
||||
// const containerId = `qr${data.requestId}`;
|
||||
// const container = $(`#${containerId}`);
|
||||
// container.empty();
|
||||
// container.append(`${data.requestId}`);
|
||||
// console.log(container[0]);
|
||||
// if (container) {
|
||||
// Generate QR code only if not already generated
|
||||
// new QRCode(container[0], {
|
||||
// text: data.qrString,
|
||||
// width: 100,
|
||||
// height: 100,
|
||||
// colorDark: "#000000",
|
||||
// colorLight: "#ffffff",
|
||||
// correctLevel: QRCode.CorrectLevel.M
|
||||
// });
|
||||
// }
|
||||
// container.on('click', function() {
|
||||
// window.open(data.qrString, '_blank');
|
||||
// });
|
||||
// });
|
||||
},
|
||||
});
|
||||
|
||||
this.settledrequestDatatable = $('#settledrequestDatatable').DataTable({
|
||||
"data": this.items.filter(item => item.status !== "Requested"),
|
||||
"columns": [
|
||||
{
|
||||
"title": "Request ID",
|
||||
"data": "requestId",
|
||||
},
|
||||
{
|
||||
"title": "Product ID",
|
||||
"data": "productId",
|
||||
},
|
||||
{
|
||||
"title": "Product Category",
|
||||
"data": "productCategory",
|
||||
},
|
||||
{
|
||||
"title": "Request Quantity",
|
||||
"data": "requestQuantity",
|
||||
},
|
||||
{
|
||||
"title": "Document/Picture",
|
||||
"data": "document",
|
||||
},
|
||||
{
|
||||
"title": "User Remark",
|
||||
"data": "remarkUser",
|
||||
},
|
||||
{
|
||||
"title": "InvMaster Remark",
|
||||
"data": "remarkMasterInv",
|
||||
},
|
||||
{
|
||||
"title": "Status",
|
||||
"data": "status",
|
||||
},
|
||||
{
|
||||
"title": "Request Date",
|
||||
"data": "requestDate",
|
||||
},
|
||||
{
|
||||
"title": "Approval Date",
|
||||
"data": "approvalDate",
|
||||
},
|
||||
// {
|
||||
// "title": "Reject",
|
||||
// "data" :null,
|
||||
// "render": function (data, type, row) {
|
||||
// return `<button type="button" class="btn btn-danger reject-btn"
|
||||
// data-id="${row.requestId}"
|
||||
// data-remark="${row.remark || ''}">
|
||||
// Reject
|
||||
// </button>`;
|
||||
|
||||
// },
|
||||
// "className": "align-middle",
|
||||
// },
|
||||
// {
|
||||
// "title": "Approve",
|
||||
// "data": "requestId",
|
||||
// "render": function (data) {
|
||||
// var approveButton = `<button type="button" class="btn btn-success approve-btn" data-id="${data}">Approve</button>`;
|
||||
// return approveButton;
|
||||
// },
|
||||
// "className": "align-middle",
|
||||
// }
|
||||
],
|
||||
responsive: true,
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Attach click event listener to the delete buttons
|
||||
$('#requestDatatable tbody').on('click', '.reject-btn', function () {
|
||||
const requestId = $(this).data('id');
|
||||
self.rejectRequestModal(requestId);
|
||||
});
|
||||
|
||||
$('#requestDatatable tbody').on('click', '.approve-btn', function () {
|
||||
const requestId = $(this).data('id');
|
||||
self.approveRequest(requestId);
|
||||
});
|
||||
|
||||
$('#requestDatatable tbody').on('click', '.print-btn', function () {
|
||||
const $button = $(this); // The clicked button
|
||||
const $row = $button.closest('tr'); // The parent row of the button
|
||||
const itemId = $button.data('id'); // Get the item ID from the button's data attribute
|
||||
|
||||
let imageSrc;
|
||||
|
||||
// Check if the table is collapsed
|
||||
if ($row.hasClass('child')) {
|
||||
// For collapsed view: Look for the closest `.dtr-data` that contains the img
|
||||
imageSrc = $row.prev('tr').find('td:nth-child(1) img').attr('src');
|
||||
} else {
|
||||
// For expanded view: Find the img in the first column of the current row
|
||||
imageSrc = $row.find('td:nth-child(1) img').attr('src');
|
||||
}
|
||||
|
||||
if (imageSrc) {
|
||||
self.printItem(itemId, imageSrc); // Call the print function with the itemId and imageSrc
|
||||
} else {
|
||||
console.error("Image source not found.");
|
||||
}
|
||||
});
|
||||
|
||||
$('#itemDatatable tbody').on('click', '.reject-btn', function () {
|
||||
const $button = $(this); // The clicked button
|
||||
const $row = $button.closest('tr'); // The parent row of the button
|
||||
const itemId = $button.data('id'); // Get the item ID from the button's data attribute
|
||||
|
||||
|
||||
self.printItem(itemId, imageSrc); // Call the print function with the itemId and imageSrc
|
||||
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
async fetchRequest() {
|
||||
try {
|
||||
// const token = localStorage.getItem('token'); // Get the token from localStorage
|
||||
const response = await fetch('/InvMainAPI/ItemRequestList', {
|
||||
method: 'GET', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set content type
|
||||
// 'Authorization': `Bearer ${token}` // Include the token in the headers
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch item');
|
||||
}
|
||||
this.items = await response.json();
|
||||
|
||||
if (this.requestDatatable) {
|
||||
this.requestDatatable.clear().destroy();
|
||||
}
|
||||
this.initiateTable();
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error fetching item:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async fetchProducts() {
|
||||
try {
|
||||
// const token = localStorage.getItem('token'); // Get the token from localStorage
|
||||
const response = await fetch('/InvMainAPI/ProductList', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set content type
|
||||
// 'Authorization': `Bearer ${token}` // Include the token in the headers
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch products');
|
||||
}
|
||||
|
||||
this.products = await response.json();
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error fetching products:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async fetchCompanies() {
|
||||
try {
|
||||
const response = await fetch('/AdminAPI/GetDepartmentWithCompanyList', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch companies');
|
||||
}
|
||||
|
||||
this.companies = await response.json();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching products:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async fetchSuppliers() {
|
||||
try {
|
||||
const response = await fetch('/InvMainAPI/SupplierList', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch suppliers');
|
||||
}
|
||||
this.suppliers = await response.json(); // Get the full response object
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching suppliers:', error);
|
||||
}
|
||||
},
|
||||
async fetchStation() {
|
||||
try {
|
||||
const response = await fetch('/InvMainAPI/StationList', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch suppliers');
|
||||
}
|
||||
this.stations = await response.json(); // Get the full response object
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching suppliers:', error);
|
||||
}
|
||||
},
|
||||
async fetchStore() {
|
||||
try {
|
||||
const response = await fetch('/InvMainAPI/StoreList/', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch suppliers');
|
||||
}
|
||||
this.stores = await response.json(); // Get the full response object
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching suppliers:', error);
|
||||
}
|
||||
},
|
||||
async fetchUsers() {
|
||||
try {
|
||||
const response = await fetch('/InvMainAPI/UserList', {
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch suppliers');
|
||||
}
|
||||
this.users = await response.json(); // Get the full response object
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching suppliers:', error);
|
||||
}
|
||||
},
|
||||
async fetchCurrencyData() {
|
||||
try {
|
||||
// Fetch currency data from the API
|
||||
const response = await fetch('https://openexchangerates.org/api/currencies.json'); // Example API
|
||||
this.currencies = await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching currency data:', error);
|
||||
}
|
||||
},
|
||||
convertCurrency() {
|
||||
// Your currency conversion logic here
|
||||
console.log('Selected currency:', this.currency);
|
||||
},
|
||||
resetForm() {
|
||||
// this.company = '';
|
||||
// this.Dept = null;
|
||||
// this.productName = null;
|
||||
// this.imageProduct = null;
|
||||
// this.serialNumber = '';
|
||||
// this.quantity = 1;
|
||||
// this.supplierName = null;
|
||||
// this.purchaseDate = null;
|
||||
// this.PO = null;
|
||||
// this.currency = 'MYR';
|
||||
// this.DefaultPrice = 0.01;
|
||||
// this.currencyRate = 1;
|
||||
// this.convertPrice = 0.01;
|
||||
// this.DODate = null;
|
||||
// this.warranty = 0;
|
||||
// this.EndWDate = null;
|
||||
// this.invoiceDate = null;
|
||||
// this.selectedProduct = '';
|
||||
// this.selectedSupplier = '';
|
||||
// this.selectedCompany = this.currentUserCompanyDept.companyId;
|
||||
// this.selectedDepartment = '';
|
||||
// this.selectedTeamType = '';
|
||||
// this.partNumber = null;
|
||||
},
|
||||
|
||||
// FRONT END FUNCTIONS
|
||||
//----------------------//
|
||||
//Calculate Total Price
|
||||
convertCurrency() {
|
||||
const total = this.DefaultPrice * this.currencyRate;
|
||||
this.convertPrice = total.toFixed(2);
|
||||
this.DefaultPrice = this.DefaultPrice
|
||||
// .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points
|
||||
// .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point
|
||||
// .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places
|
||||
|
||||
},
|
||||
calculateWarrantyEndDate() {
|
||||
// Check if DODate and warranty are valid
|
||||
if (!this.DODate || isNaN(Date.parse(this.DODate))) {
|
||||
this.EndWDate = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const DODates = new Date(this.DODate);
|
||||
const warrantyMonth = parseInt(this.warranty);
|
||||
|
||||
// Ensure warranty is a valid number
|
||||
if (!isNaN(warrantyMonth)) {
|
||||
DODates.setMonth(DODates.getMonth() + warrantyMonth);
|
||||
this.EndWDate = DODates.toISOString().split('T')[0];
|
||||
} else {
|
||||
this.EndWDate = null;
|
||||
}
|
||||
},
|
||||
async approveRequest(itemId) {
|
||||
// if (!confirm("Are you sure you want to approve this request?")) {
|
||||
// return;
|
||||
// }
|
||||
try {
|
||||
const response = await fetch(`/InvMainAPI/ApproveRequest/${itemId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alert(result.message);
|
||||
|
||||
//static update
|
||||
const row = $(`.approve-btn[data-id="${itemId}"]`).closest('tr');
|
||||
let rowData = this.requestDatatable.row(row).data();
|
||||
|
||||
// Update the status and remark
|
||||
rowData.status = "Approved";
|
||||
|
||||
// Remove row from requestDatatable
|
||||
this.requestDatatable.row(row).remove().draw();
|
||||
|
||||
// Add updated row to settledrequestDatatable
|
||||
this.settledrequestDatatable.row.add(rowData).draw();
|
||||
|
||||
|
||||
} else {
|
||||
alert(result.message);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Error approving request:", error);
|
||||
// alert("An error occurred while approving the request.");
|
||||
}
|
||||
finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async rejectRequest() {
|
||||
|
||||
const formData = {
|
||||
RemarkMasterInv: this.rejectremark,
|
||||
|
||||
};
|
||||
|
||||
let requestId = this.currentRequestId;
|
||||
|
||||
try {
|
||||
|
||||
const response = await fetch(`/InvMainAPI/RejectRequest/${requestId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// 'Authorization': `Bearer ${this.token}`
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
|
||||
});
|
||||
if (response.ok) {
|
||||
// If the form submission was successful, display a success message
|
||||
// alert('Success!', 'Request has been Rejected.', 'success');
|
||||
|
||||
const row = $(`.approve-btn[data-id="${requestId}"]`).closest('tr');
|
||||
let rowData = this.requestDatatable.row(row).data();
|
||||
|
||||
// Update the status and remark
|
||||
rowData.status = "Rejected";
|
||||
rowData.remarkMasterInv = this.rejectremark;
|
||||
|
||||
// Remove row from requestDatatable
|
||||
this.requestDatatable.row(row).remove().draw();
|
||||
|
||||
// Add updated row to settledrequestDatatable
|
||||
this.settledrequestDatatable.row.add(rowData).draw();
|
||||
|
||||
|
||||
} else {
|
||||
throw new Error('Failed to submit form.');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
|
||||
// Displaying error message
|
||||
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||
}
|
||||
finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async rejectRequestModal(requestId, remark) {
|
||||
|
||||
this.currentRequestId = requestId;
|
||||
this.rejectremark = remark;
|
||||
|
||||
|
||||
$(`#rejectModal`).modal('show');
|
||||
|
||||
|
||||
},
|
||||
async printItem(itemId, imgSrc) {
|
||||
try {
|
||||
this.thisQRInfo.uniqueID = itemId;
|
||||
const uniqueQR = itemId;
|
||||
const container = document.getElementById("QrContainer");
|
||||
|
||||
if (!container) {
|
||||
console.error("Container not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Safely set image content
|
||||
const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL
|
||||
container.innerHTML = `<img src="${sanitizedImgSrc}" alt="QR Code" class="text-center " />`;
|
||||
|
||||
// Fetch QR information
|
||||
const qrInfo = this.getPrintedQR(uniqueQR);
|
||||
if (!qrInfo) {
|
||||
console.error("QR Info not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.thisQRInfo = qrInfo;
|
||||
this.thisQRInfo.imgSrc = sanitizedImgSrc
|
||||
this.thisQRInfo.imgContainer = container.innerHTML
|
||||
$(`#QrItemModal`).modal('show'); // Show modal
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Error generating QR code:", error);
|
||||
alert("An error occurred while generating the QR code.");
|
||||
}
|
||||
},
|
||||
async fetchUser() {
|
||||
try {
|
||||
const response = await fetch(`/IdentityAPI/GetUserInformation/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
this.currentUser = data?.userInfo || null;
|
||||
const companyDeptData = await this.currentUser.department;
|
||||
this.currentUserCompanyDept = companyDeptData;
|
||||
this.selectedCompany = companyDeptData?.companyId || "";
|
||||
this.selectedDepartment = companyDeptData?.departmentId || "";
|
||||
}
|
||||
else {
|
||||
console.error(`Failed to fetch user: ${response.statusText}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@ -33,8 +33,8 @@
|
||||
<div id="app" data-aos="fade-right">
|
||||
<h1 data-aos="fade-right">QR & Barcode Scanner</h1>
|
||||
<div id="reader" data-aos="fade-right"></div>
|
||||
<h2>Scan Result:</h2>
|
||||
<div v-if="qrCodeResult" id="qrCodeResult">
|
||||
|
||||
<div v-if="thisItem" id="qrCodeResult" style="text-align: center; margin: 20px 0; padding: 20px;">
|
||||
<h2>Scan Result:</h2>
|
||||
</div>
|
||||
</div>
|
||||
@ -112,82 +112,198 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* <div> *@
|
||||
@* <p v-if="isAdmin">Welcome, Admin! You have full access.</p> *@
|
||||
@* <p v-else-if="userRole === 'user'">Welcome, User! You have limited access.</p> *@
|
||||
@* <p v-else>Guest View: Please log in.</p> *@
|
||||
@* </div> *@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
|
||||
<div class=" register" data-aos="fade-right">
|
||||
<div class="row" data-aos="fade-right">
|
||||
<div class=" register" data-aos="fade-right">
|
||||
<div class="row" data-aos="fade-right">
|
||||
|
||||
@*Right Side*@
|
||||
<div class="col-md-12">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||
<h3 class="register-heading">REGISTRATION ITEM</h3>
|
||||
<div class="row register-form">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
@*Right Side*@
|
||||
<div class="col-md-12">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||
<div style="text-align: center; margin: 20px 0; padding: 20px;">
|
||||
<h2 class="register-heading">Add Item Movement</h2>
|
||||
</div>
|
||||
|
||||
<!-- Company Dropdown -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To User:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required>
|
||||
<option class="btn-light" value="" disabled selected>Select User</option>
|
||||
<option class="btn-light" v-for="(user, index) in userlist" :key="index" :value="user.id">{{user.fullName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Department Dropdown -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To Store:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore" >
|
||||
<option class="btn-light" value="" disabled selected>Select Store</option>
|
||||
<option class="btn-light" v-for="(store, index) in storelist" :key="index" :value="store.id">{{ store.StoreName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Remark *@
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Remark:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" id="remark" name="remark" v-model="remark" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@* Submit and Reset Buttons *@
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-3">
|
||||
<button type="button" v-on:click="resetForm" class="btn btn-secondary m-1">Reset</button>
|
||||
<button type="submit" class="btn btn-primary m-1">Submit</button>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label"></label>
|
||||
<div class="col-sm-6">
|
||||
<div class="dropdown">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10 offset-sm-1" v-model="selectedAction" required>
|
||||
<option class="btn-light" value="" disabled selected>Select Action</option>
|
||||
<option class="btn-light" value="user">Assign to User</option>
|
||||
<option class="btn-light" value="supplier">Assign to Supplier</option>
|
||||
<option class="btn-light" value="faulty">Faulty</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedAction === 'user'">
|
||||
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
|
||||
<div class="row register-form">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To User:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required>
|
||||
<option class="btn-light" value="" disabled selected>Select User</option>
|
||||
<option class="btn-light" v-for="(user, index) in userlist" :key="index" :value="user.id">{{user.fullName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To Store:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore" >
|
||||
<option class="btn-light" value="" disabled selected>Select Store</option>
|
||||
<option class="btn-light" v-for="(store, index) in storelist" :key="index" :value="store.id">{{ store.StoreName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Remark:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" id="remark" name="remark" v-model="remark" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@* Submit and Reset Buttons *@
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-3">
|
||||
<button type="button" v-on:click="resetForm" class="btn btn-secondary m-1">Reset</button>
|
||||
<button type="submit" class="btn btn-primary m-1">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedAction === 'supplier'">
|
||||
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
|
||||
<div class="row register-form">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To supplier:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required>
|
||||
<option class="btn-light" value="" disabled selected>Select User</option>
|
||||
<option class="btn-light" v-for="(user, index) in userlist" :key="index" :value="user.id">{{user.fullName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To Store:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore">
|
||||
<option class="btn-light" value="" disabled selected>Select Store</option>
|
||||
<option class="btn-light" v-for="(store, index) in storelist" :key="index" :value="store.id">{{ store.StoreName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Remark:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" id="remark" name="remark" v-model="remark" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@* Submit and Reset Buttons *@
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-3">
|
||||
<button type="button" v-on:click="resetForm" class="btn btn-secondary m-1">Reset</button>
|
||||
<button type="submit" class="btn btn-primary m-1">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedAction === 'faulty'">
|
||||
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
|
||||
<div class="row register-form">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To User:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="dropdown">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required>
|
||||
<option class="btn-light" value="" disabled selected>Select User</option>
|
||||
<option class="btn-light" v-for="(user, index) in userlist" :key="index" :value="user.id">{{user.fullName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">To Store:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore">
|
||||
<option class="btn-light" value="" disabled selected>Select Store</option>
|
||||
<option class="btn-light" v-for="(store, index) in storelist" :key="index" :value="store.id">{{ store.StoreName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Faulty:</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" id="remark" name="remark" v-model="remark" class="form-control" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@* Submit and Reset Buttons *@
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-3">
|
||||
<button type="button" v-on:click="resetForm" class="btn btn-secondary m-1">Reset</button>
|
||||
<button type="submit" class="btn btn-primary m-1">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@ -227,6 +343,7 @@
|
||||
storelist: null,
|
||||
selectedUser: "",
|
||||
selectedStore: "",
|
||||
selectedAction: "",
|
||||
|
||||
companies: [
|
||||
{
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
|
||||
<div class="col-6 col-md-6 col-lg-3">
|
||||
<div class="card card-hover">
|
||||
<a asp-area="Inventory" asp-controller="ItemMovement" asp-action="Qr">
|
||||
<a asp-area="Inventory" asp-controller="InventoryMaster" asp-action="QrMaster">
|
||||
<div class="box bg-success text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-checkbox-multiple-blank-circle"></i>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
<div class="col-6 col-md-6 col-lg-3">
|
||||
<div class="card card-hover">
|
||||
<a asp-area="Inventory" asp-controller="ItemMovement" asp-action="Qr">
|
||||
<a asp-area="Inventory" asp-controller="ItemMovement" asp-action="QrUser">
|
||||
<div class="box bg-success text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-checkbox-multiple-blank-circle"></i>
|
||||
|
||||
@ -811,8 +811,10 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
}
|
||||
|
||||
[HttpPost("RejectRequest/{id}")]
|
||||
public async Task<IActionResult> RejectRequest(int id)
|
||||
public async Task<IActionResult> RejectRequest(int id, [FromBody] RequestModel request)
|
||||
{
|
||||
|
||||
|
||||
var Request = await _centralDbContext.Requests.FindAsync(id);
|
||||
if (Request == null)
|
||||
{
|
||||
@ -820,6 +822,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
}
|
||||
|
||||
Request.status = "Rejected";
|
||||
Request.remarkMasterInv = request.remarkMasterInv;
|
||||
Request.approvalDate = DateTime.UtcNow;
|
||||
_centralDbContext.SaveChanges();
|
||||
|
||||
|
||||
@ -6,10 +6,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Areas\Inventory\Views\InventoryMaster\ItemRequestMaster.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.11" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user