Update Item & Station

This commit is contained in:
ArifHilmi 2025-03-14 11:03:12 +08:00
parent e5e1414826
commit 213fd2b460
7 changed files with 99 additions and 70 deletions

View File

@ -288,7 +288,7 @@
<div class="form-group row">
<label for="DONo" class="col-sm-4">Enter DO Number:</label>
<div class="col-sm-8">
<input type="text" id="DONo" name="DONo" class="form-control" v-model="DONo" placeholder="DO123456">
<input type="text" id="DONo" name="DONo" class="form-control" v-model="DONo" placeholder="DO123456" required>
</div>
</div>
@ -296,7 +296,7 @@
<div class="form-group row">
<label for="DODate" class="col-sm-4">Enter DO Date:</label>
<div class="col-sm-8">
<input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" v-model="DODate">
<input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" v-model="DODate" required>
</div>
</div>
@ -304,7 +304,7 @@
<div class="form-group row">
<label for="warranty" class="col-sm-4">Enter Warranty (Months):</label>
<div class="col-sm-8">
<input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" required v-model="warranty">
<input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" v-model="warranty" required>
</div>
</div>
@ -320,7 +320,7 @@
<div class="form-group row">
<label for="invoiceNo" class="col-sm-4">Invoice Number:</label>
<div class="col-sm-8">
<input type="text" id="invoiceNo" name="invoiceNo" class="form-control" v-model="invoiceNo" placeholder="Invoice123456">
<input type="text" id="invoiceNo" name="invoiceNo" class="form-control" v-model="invoiceNo" placeholder="Invoice123456" required>
</div>
</div>
@ -328,7 +328,7 @@
<div class="form-group row">
<label for="invoiceDate" class="col-sm-4">Invoice Date:</label>
<div class="col-sm-8">
<input type="date" id="invoiceDate" name="invoiceDate" class="form-control" v-model="invoiceDate">
<input type="date" id="invoiceDate" name="invoiceDate" class="form-control" v-model="invoiceDate" required>
</div>
</div>
@ -401,12 +401,12 @@
purchaseDate: null,
PO: null,
currency: "MYR",
DefaultPrice: 0.01,
DefaultPrice: null,
currencyRate: 1,
convertPrice: 0.01,
DONo: null,
DODate: null,
warranty: 0,
warranty: null,
EndWDate: null,
invoiceNo: null,
invoiceDate: null,
@ -473,6 +473,18 @@
},
methods: {
async addItem() {
// List of required fields
const requiredFields = ['DefaultPrice', 'DONo', 'DODate', 'warranty', 'invoiceNo', 'invoiceDate'];
// Loop through required fields and check if any are null or empty
for (let field of requiredFields) {
if (this[field] === null || this[field] === '') {
alert('Item Error', `Please fill in required fields: ${field}.`, 'warning');
return;
}
}
if (this.showProduct.category == "Disposable") {
this.serialNumber = "";
}
@ -489,9 +501,11 @@
DefaultPrice: this.DefaultPrice,
CurrencyRate: this.currencyRate,
ConvertPrice: this.convertPrice,
DONo: this.DONo,
DODate: this.DODate,
Warranty: this.warranty,
EndWDate: this.EndWDate,
InvoiceNo: this.invoiceNo,
InvoiceDate: this.invoiceDate,
CreatedByUserId: this.currentUser.id,
TeamType: this.selectedTeamType,
@ -811,17 +825,19 @@
this.purchaseDate = null;
this.PO = null;
this.currency = 'MYR';
this.DefaultPrice = 0.01;
this.DefaultPrice = null;
this.currencyRate = 1;
this.convertPrice = 0.01;
this.DODate = null;
this.warranty = 0;
this.warranty = null;
this.DONo = null;
this.invoiceNo = null;
this.EndWDate = null;
this.invoiceDate = null;
this.selectedProduct = '';
this.selectedSupplier = '';
this.selectedCompany = this.currentUserCompanyDept.companyId;
this.selectedDepartment = '';
// this.selectedCompany = this.currentUserCompanyDept.companyId;
// this.selectedDepartment = '';
this.selectedTeamType = '';
this.partNumber = null;
},

View File

@ -27,11 +27,11 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label">Station User PIC</label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUserName" :disabled="currentUser != null" required v-on:change="updateDepartment()">
<div class="">
<select class="btn btn-primary form-select" v-model="selectedUserName" :disabled="currentUser != null" required v-on:change="updateDepartment()">
<option class="btn-light" value="" disabled selected>Select User</option>
<option v-for="(technicianUser, index) in users" :key="index" :value="technicianUser.fullname">
{{ technicianUser.fullname }}
<option class="btn-light" v-for="(technicianUser, index) in users" :key="index" :value="technicianUser.fullName">
{{ technicianUser.fullName }}
</option>
</select>
@ -113,12 +113,11 @@
methods: {
async fetchUsers() {
try {
const response = await fetch(`/IdentityAPI/GetTechnicianUserInformation/`, {
const response = await fetch(`/InvMainAPI/UserList/`, {
method: 'POST',
});
if (response.ok) {
const data = await response.json();
this.users = data.technicianUsers;
this.users = await response.json();
}
else {
console.error(`Failed to fetch user: ${response.statusText}`);
@ -230,11 +229,11 @@
},
{
"title": "Station User PIC",
"data": "stationPicID",
"data": "fullName",
},
{
"title": "Department ID",
"data": "departmentId",
"title": "Department",
"data": "departmentName",
},
{
"title": "Delete",
@ -250,7 +249,7 @@
})
// Attach click event listener to the delete buttons
$('#stationDatatable tbody').on('click', '.delete-btn', function () {
$('#stationDatatable tbody').off('click', '.delete-btn').on('click', '.delete-btn', function () {
const stationId = $(this).data('id');
self.deleteStation(stationId);
});
@ -259,7 +258,8 @@
},
updateDepartment() {
// Find the selected user by their full name
const selectedUser = this.users.find(user => user.fullname === this.selectedUserName);
const selectedUser = this.users.find(user => user.fullName === this.selectedUserName);
console.log(selectedUser);
if (selectedUser) {
this.stationUserPIC = selectedUser.id;
this.departmentId = selectedUser.department.departmentId;

View File

@ -70,44 +70,44 @@ namespace PSTW_CentralSystem.Controllers.API
}
}
[HttpPost("GetTechnicianUserInformation")]
public async Task<IActionResult> GetTechnicianUserInformation()
{
try
{
var users = await _identityDbContext.Users
.Include(u => u.Department)
.ToListAsync(); // Retrieve all users with department info
//[HttpPost("GetTechnicianUserInformation")]
//public async Task<IActionResult> GetTechnicianUserInformation()
//{
// try
// {
// var users = await _identityDbContext.Users
// .Include(u => u.Department)
// .ToListAsync(); // Retrieve all users with department info
var technicianUsers = new List<object>();
// var technicianUsers = new List<object>();
foreach (var user in users)
{
var roles = await _userManager.GetRolesAsync(user);
if (roles.Contains("Technician"))
{
technicianUsers.Add(new
{
id = user.Id,
fullname = user.FullName,
department = user.Department
});
}
}
// foreach (var user in users)
// {
// var roles = await _userManager.GetRolesAsync(user);
// if (roles.Contains("Technician"))
// {
// technicianUsers.Add(new
// {
// id = user.Id,
// fullname = user.FullName,
// department = user.Department
// });
// }
// }
if (!technicianUsers.Any())
{
return NotFound(new { message = "No technicians found" });
}
// if (!technicianUsers.Any())
// {
// return NotFound(new { message = "No technicians found" });
// }
return Ok(new { technicianUsers = technicianUsers });
}
catch (Exception ex)
{
return StatusCode(500, new { message = $"An error occurred: {ex.Message}" });
}
// return Ok(new { technicianUsers = technicianUsers });
// }
// catch (Exception ex)
// {
// return StatusCode(500, new { message = $"An error occurred: {ex.Message}" });
// }
}
//}
#endregion User
#region LDAP Login

View File

@ -1231,8 +1231,17 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("StationList")]
public async Task<IActionResult> StationList()
{
var stationList = await _centralDbContext.Stations.Include(i => i.StationPic).ToListAsync();
return Json(stationList);
var stationList = await _centralDbContext.Stations.Include(i => i.StationPic).Include(i => i.Department).ToListAsync();
return Json(stationList.Select(i => new
{
i.StationId,
i.StationPicID,
i.StationName,
i.DepartmentId,
i.StationPic?.FullName,
i.Department?.DepartmentName,
}));
}
[HttpPost("AddStation")]
@ -1311,10 +1320,15 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("UserList")]
public async Task<IActionResult> UserList()
{
var userList = await _centralDbContext.Users.ToListAsync();
return Json(userList);
}
var userList = await _centralDbContext.Users.Include(i => i.Department).ToListAsync();
return Json(userList.Select(i => new
{
i.Id,
i.FullName,
i.Department,
}));
}
#endregion AllUser

View File

@ -1,6 +1,5 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>
<p>PSTW All right reserved 2025</p>

View File

@ -233,7 +233,7 @@
<!-- Comment -->
<!-- ============================================================== -->
<partial name="_LoginPartial" />
<li class="nav-item dropdown">
@* <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
@ -250,14 +250,14 @@
<a class="dropdown-item" href="#">Something else here</a>
</li>
</ul>
</li>
</li> *@
<!-- ============================================================== -->
<!-- End Comment -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Messages -->
<!-- ============================================================== -->
<li class="nav-item dropdown">
@* <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle waves-effect waves-dark"
href="#"
id="2"
@ -348,7 +348,7 @@
</li>
</ul>
</ul>
</li>
</li> *@
<!-- ============================================================== -->
<!-- End Messages -->
<!-- ============================================================== -->
@ -375,14 +375,14 @@
</a>
<ul class="dropdown-menu dropdown-menu-end user-dd animated"
aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="javascript:void(0)"><i class="mdi mdi-account me-1 ms-1"></i> My Profile</a>
@* <a class="dropdown-item" href="javascript:void(0)"><i class="mdi mdi-account me-1 ms-1"></i> My Profile</a>
<a class="dropdown-item" href="javascript:void(0)"><i class="mdi mdi-wallet me-1 ms-1"></i> My Balance</a>
<a class="dropdown-item" href="javascript:void(0)"><i class="mdi mdi-email me-1 ms-1"></i> Inbox</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:void(0)">
<i class="mdi mdi-settings me-1 ms-1"></i> Account
Setting
</a>
</a> *@
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:void(0)"><i class="fa fa-power-off me-1 ms-1"></i> Logout</a>
<div class="dropdown-divider"></div>

View File

@ -3,7 +3,7 @@
//"DefaultConnection": "Server=localhost;uid=root;Password='';Database=web_interface;"
//"DefaultConnection": "server=175.136.244.102;user id=root;password=tw_mysql_root;port=3306;database=web_interface"
//"CentralConnnection": "Server=192.168.12.12;Port=3306;uid=installer;password='pstw_mysql_installer';database=pstw_cs;", //DB_dev Local connection
"CentralConnnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs;" //DB_dev Public connection
"CentralConnnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs_prod;" //DB_dev Public connection
//"InventoryConnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs_inventory;" //DB_dev connection
//"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=intern;password='intern_mysql_acct';database=web_interface;"//DB_dev connection
},