Compare commits
26 Commits
main
...
dev_mohaim
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef18abce5 | ||
|
|
92d4225a82 | ||
|
|
66a1a36698 | ||
|
|
47657f6f75 | ||
|
|
46ad335dbe | ||
|
|
182effa8b5 | ||
|
|
1853718cbd | ||
|
|
e3fd97be95 | ||
|
|
17ffe30ae8 | ||
|
|
8b452c2bbd | ||
|
|
83b5935846 | ||
|
|
77321b60ff | ||
|
|
18510679bb | ||
|
|
ab7fc93b14 | ||
|
|
5498b79851 | ||
|
|
ad8031c3a4 | ||
|
|
75e94ddc94 | ||
|
|
7f1dcadd0c | ||
|
|
df0680fecf | ||
|
|
4eb1990286 | ||
|
|
e6931518df | ||
|
|
aa35c40142 | ||
|
|
a458cdba4c | ||
|
|
9944262dd1 | ||
|
|
73523abd37 | ||
|
|
072b0a63c4 |
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -749,11 +749,6 @@ FodyWeavers.xsd
|
||||||
# Additional files built by Visual Studio
|
# Additional files built by Visual Studio
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/csharp,angular,aspnetcore,visualstudio,visualstudiocode
|
# End of https://www.toptal.com/developers/gitignore/api/csharp,angular,aspnetcore,visualstudio,visualstudiocode
|
||||||
/HRM.UI/appsettings.json
|
|
||||||
/HRM.UI/appsettings.json
|
|
||||||
/HRM.UI/appsettings.json
|
|
||||||
/HRM.UI/appsettings.json
|
|
||||||
/HRM.UI/appsettings.json
|
|
||||||
|
|
||||||
# Employee photos written at runtime (approved thumbnails + photos awaiting approval).
|
# Employee photos written at runtime (approved thumbnails + photos awaiting approval).
|
||||||
# Not source; regenerated/repopulated by the app.
|
# Not source; regenerated/repopulated by the app.
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,9 @@ npm test # ng test (Karma, entry src/test.ts)
|
||||||
Both SPAs `ng serve` on 4200, so only one of the two can run at a time.
|
Both SPAs `ng serve` on 4200, so only one of the two can run at a time.
|
||||||
|
|
||||||
- `npm run lint` is **broken**: `angular.json` still points at the `@angular-devkit/build-angular:tslint`
|
- `npm run lint` is **broken**: `angular.json` still points at the `@angular-devkit/build-angular:tslint`
|
||||||
builder (with a `tslint.json`), which no longer exists in Angular 19. There is no ESLint config.
|
builder (with a `tslint.json`), which no longer exists in Angular 19. The `@angular-eslint/*` and `eslint` 9 devDependencies are
|
||||||
|
installed, but there is no ESLint config file and no `@angular-eslint/builder:lint` target yet, so
|
||||||
|
wiring ESLint up means adding both.
|
||||||
- `npm test` works, but coverage is nominal — 18 `.spec.ts` files across the whole app. Single spec:
|
- `npm test` works, but coverage is nominal — 18 `.spec.ts` files across the whole app. Single spec:
|
||||||
`ng test --include='**/some.component.spec.ts'`.
|
`ng test --include='**/some.component.spec.ts'`.
|
||||||
- There are no `*.Tests.csproj` anywhere in the solution.
|
- There are no `*.Tests.csproj` anywhere in the solution.
|
||||||
|
|
@ -474,7 +476,9 @@ When behavior differs between clients, look for or add a Logic key rather than b
|
||||||
## Branches: one product, many client deployments
|
## Branches: one product, many client deployments
|
||||||
|
|
||||||
**This checkout is not that repo.** It is `HRM-10` (`origin` = `103.197.204.162:3025/CelHRTeam/HRM-10`),
|
**This checkout is not that repo.** It is `HRM-10` (`origin` = `103.197.204.162:3025/CelHRTeam/HRM-10`),
|
||||||
a fresh import with a single branch `main` and a single squashed commit (`838b8d4` "first commit").
|
a fresh import whose history starts at one squashed commit (`838b8d4` "first commit"). Since then it
|
||||||
|
uses ordinary short-lived branches: `main` is the integration branch (PR target), with per-developer
|
||||||
|
branches (`dev_<name>`, `dev_<name>_<feature>`, `shamim`) merged back into it.
|
||||||
None of the older history exists here: every commit hash quoted elsewhere in this file (`c8588ce67`,
|
None of the older history exists here: every commit hash quoted elsewhere in this file (`c8588ce67`,
|
||||||
`91369150c`, `ac179c03e`, `73f466cd0`, `bfd085e0e`) is from the original `CelHRTeam/cel.hrm` repo, and
|
`91369150c`, `ac179c03e`, `73f466cd0`, `bfd085e0e`) is from the original `CelHRTeam/cel.hrm` repo, and
|
||||||
`git show`/`git log` recovery commands only work in a clone of that repo, not here.
|
`git show`/`git log` recovery commands only work in a clone of that repo, not here.
|
||||||
|
|
|
||||||
|
|
@ -949,6 +949,13 @@ namespace HRM.BO
|
||||||
DataSet GetBonusBankAdvice(int BonusID, DateTime dBonusMonth, string sEmpID);
|
DataSet GetBonusBankAdvice(int BonusID, DateTime dBonusMonth, string sEmpID);
|
||||||
DataSet GetBonusPaySlip(int BonusID, DateTime dBonusMonth, string sEmpID);
|
DataSet GetBonusPaySlip(int BonusID, DateTime dBonusMonth, string sEmpID);
|
||||||
int Save(BonusProcess item);
|
int Save(BonusProcess item);
|
||||||
|
BonusProcessAndSaveResult ProcessAndSave(BonusProcessAndSaveRequest request, int payrolltypeid, int userID);
|
||||||
|
BonusProcessAndSaveResult UploadAndSave(List<BonusProcess.BonusProcessDetail> uploadedRows,
|
||||||
|
BonusProcessAndSaveRequest request, int payrolltypeid, int userID);
|
||||||
|
BonusProcessRowTaxResult CalculateRowTax(BonusProcessRowTaxRequest request, int payrolltypeid);
|
||||||
|
BonusProcessGridRow SaveRow(BonusProcessRowSaveRequest request, int payrolltypeid, int userID);
|
||||||
|
List<BonusProcessGridRow> ClearTaxAndSave(int bonusProcessID, int payrolltypeid, int userID);
|
||||||
|
BonusProcessRowRemoveResult RemoveRow(int bonusProcessDetailID, int payrolltypeid);
|
||||||
void Delete(BonusProcess oBonusProcess);
|
void Delete(BonusProcess oBonusProcess);
|
||||||
List<BonusProcess> GetProcess(int bonusID, DateTime bonusMonth);
|
List<BonusProcess> GetProcess(int bonusID, DateTime bonusMonth);
|
||||||
List<BonusProcess> GetProcess(DateTime bonusMonth);
|
List<BonusProcess> GetProcess(DateTime bonusMonth);
|
||||||
|
|
|
||||||
96
HRM.BO/Bonus/BonusProcessAndSave.cs
Normal file
96
HRM.BO/Bonus/BonusProcessAndSave.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace HRM.BO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Process" button: calculate the bonus (and tax) of these employees and save it
|
||||||
|
/// in the same request (api/Bonus/processAndSave). Only the header and the employee IDs travel — the
|
||||||
|
/// browser no longer sends the whole calculated BonusProcess back for a separate Save.
|
||||||
|
/// </summary>
|
||||||
|
public class BonusProcessAndSaveRequest
|
||||||
|
{
|
||||||
|
public int BonusID { get; set; }
|
||||||
|
public DateTime BasicMonth { get; set; }
|
||||||
|
public DateTime PayDate { get; set; }
|
||||||
|
public DateTime CuttOfDate { get; set; }
|
||||||
|
public double CurrProcess { get; set; }
|
||||||
|
public bool IsDisburseWithSalary { get; set; }
|
||||||
|
public bool IsTaxProcess { get; set; }
|
||||||
|
public List<int> EmployeeIDs { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>One saved row of the Bonus Process grid, read back from the database.</summary>
|
||||||
|
public class BonusProcessGridRow
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID { get; set; }
|
||||||
|
public int BonusProcessID { get; set; }
|
||||||
|
public int BonusID { get; set; }
|
||||||
|
public int EmployeeID { get; set; }
|
||||||
|
public string EmployeeNo { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DateTime? JoiningDate { get; set; }
|
||||||
|
public bool IsConfirmed { get; set; }
|
||||||
|
public double GrossSalary { get; set; }
|
||||||
|
public double BasicSalary { get; set; }
|
||||||
|
public double BonusAmount { get; set; }
|
||||||
|
public double ChangeBonusAmount { get; set; }
|
||||||
|
public double TaxAmount { get; set; }
|
||||||
|
public double ChangeTaxAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>What processAndSave returns: the saved process and its rows.</summary>
|
||||||
|
public class BonusProcessAndSaveResult
|
||||||
|
{
|
||||||
|
public int BonusProcessID { get; set; }
|
||||||
|
public List<BonusProcessGridRow> Rows { get; set; } = new List<BonusProcessGridRow>();
|
||||||
|
/// <summary>Employees left out because this bonus was already processed for them this month.</summary>
|
||||||
|
public List<int> AlreadyProcessedEmployeeIDs { get; set; } = new List<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Modify dialog, "Calculate": the tax of one saved row for this bonus amount
|
||||||
|
/// (api/Bonus/calculateRowTax). Nothing is saved.
|
||||||
|
/// </summary>
|
||||||
|
public class BonusProcessRowTaxRequest
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID { get; set; }
|
||||||
|
public double BonusAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BonusProcessRowTaxResult
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID { get; set; }
|
||||||
|
public double BonusAmount { get; set; }
|
||||||
|
public double TaxAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Modify dialog, "Save": saves one row (api/Bonus/saveRow). With CalculateTax the server works the tax
|
||||||
|
/// out again from BonusAmount (TaxAmount is ignored); without it TaxAmount is the amount typed in.
|
||||||
|
/// </summary>
|
||||||
|
public class BonusProcessRowSaveRequest
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID { get; set; }
|
||||||
|
public double BonusAmount { get; set; }
|
||||||
|
public double TaxAmount { get; set; }
|
||||||
|
public bool CalculateTax { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// "Edited Tax Amount" (with CalculateTax): the tax the user settled on after seeing the calculated one.
|
||||||
|
/// Saved as CHANGETAXAMOUNT and on the Tax Deducted line; TAXAMOUNT keeps the calculated tax.
|
||||||
|
/// Null = use the calculated tax.
|
||||||
|
/// </summary>
|
||||||
|
public double? EditedTaxAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove button on a saved row (api/Bonus/removeRow/{id}): what was deleted. ProcessDeleted is true when
|
||||||
|
/// that was the process's last employee, so the (now empty) BONUSPROCESS header was deleted too.
|
||||||
|
/// </summary>
|
||||||
|
public class BonusProcessRowRemoveResult
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID { get; set; }
|
||||||
|
public int BonusProcessID { get; set; }
|
||||||
|
public bool ProcessDeleted { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -563,6 +563,7 @@ namespace HRM.BO
|
||||||
//void SaveBasicInfo(Employee item);
|
//void SaveBasicInfo(Employee item);
|
||||||
List<Employee> GetByEmpIDs(string empIDs, int payrollTypeID);
|
List<Employee> GetByEmpIDs(string empIDs, int payrollTypeID);
|
||||||
List<Employee> GetByEmpIDs(string empIDs);
|
List<Employee> GetByEmpIDs(string empIDs);
|
||||||
|
List<EmployeeLite> GetLiteByEmpIDs(List<int> empIDs);
|
||||||
List<Employee> GetFssEmp(string empIDs, int payrollTypeID);
|
List<Employee> GetFssEmp(string empIDs, int payrollTypeID);
|
||||||
List<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID);
|
List<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID);
|
||||||
DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID);
|
DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID);
|
||||||
|
|
|
||||||
17
HRM.BO/Employee/EmployeeLite.cs
Normal file
17
HRM.BO/Employee/EmployeeLite.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace HRM.BO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A light Employee: only the few columns that screens working on thousands of employees at once need
|
||||||
|
/// (Bonus Process today). Loading the whole Employee row for 10k+ employees never reached the browser.
|
||||||
|
/// To add a field: add the property here, the column in EmployeeDA.GetLiteByEmpIDs, and the read in
|
||||||
|
/// EmployeeService.GetLiteByEmpIDs (and in ClientApp _models/Employee/employeeLite.ts).
|
||||||
|
/// </summary>
|
||||||
|
public class EmployeeLite
|
||||||
|
{
|
||||||
|
public int EmployeeID { get; set; }
|
||||||
|
public bool IsConfirmed { get; set; }
|
||||||
|
public DateTime? JoiningDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -401,6 +401,13 @@ namespace HRM.BO
|
||||||
routerLink = "/authentication/system-auditlog",
|
routerLink = "/authentication/system-auditlog",
|
||||||
icon = "pi pi-fw pi-database",
|
icon = "pi pi-fw pi-database",
|
||||||
},
|
},
|
||||||
|
new WebMenuItem()
|
||||||
|
{
|
||||||
|
uniqueName = "WEB.01.09",
|
||||||
|
label = "Cipher Engine",
|
||||||
|
routerLink = "/authentication/cipher-engine",
|
||||||
|
icon = "pi pi-fw pi-code",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
67
HRM.BO/User/SystemAuditHistory.cs
Normal file
67
HRM.BO/User/SystemAuditHistory.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Ease.Core.Model;
|
||||||
|
|
||||||
|
namespace HRM.BO
|
||||||
|
{
|
||||||
|
#region SystemAuditHistory
|
||||||
|
|
||||||
|
/// <summary>Which change history the System Audit Log page asks for (one tab each).</summary>
|
||||||
|
public enum EnumSystemAuditHistory
|
||||||
|
{
|
||||||
|
Role = 1,
|
||||||
|
RolePermission = 2,
|
||||||
|
User = 3,
|
||||||
|
UserRole = 4,
|
||||||
|
UserAccessType = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One row of a change history, read from the Z_ table of that page
|
||||||
|
/// (Z_ROLE, Z_ROLEPERMISSION, Z_USERS, Z_USERROLE, Z_USERACCESSTYPE - see
|
||||||
|
/// SystemAuditHistory_DB_Changes.sql). Fields a history does not have stay null.
|
||||||
|
/// </summary>
|
||||||
|
public class SystemAuditHistory : ObjectTemplate
|
||||||
|
{
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
public SystemAuditHistory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
/// <summary>What happened, e.g. "User created", "Role modified", "Access type removed".</summary>
|
||||||
|
public string AuditType { get; set; }
|
||||||
|
public DateTime? AuditDate { get; set; }
|
||||||
|
public string LoginID { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Code { get; set; }
|
||||||
|
public string UserType { get; set; }
|
||||||
|
public string RoleName { get; set; }
|
||||||
|
public string RoleType { get; set; }
|
||||||
|
public string MenuKey { get; set; }
|
||||||
|
public string MenuName { get; set; }
|
||||||
|
public string AccessType { get; set; }
|
||||||
|
public string Activities { get; set; }
|
||||||
|
public int? ActionBy { get; set; }
|
||||||
|
public string ActionByLoginID { get; set; }
|
||||||
|
public string ActionByName { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISystemAuditHistory Service
|
||||||
|
|
||||||
|
public interface ISystemAuditHistoryService
|
||||||
|
{
|
||||||
|
/// <summary>The change history of one page in a date range (both days inclusive), newest first.</summary>
|
||||||
|
List<SystemAuditHistory> Get(EnumSystemAuditHistory type, DateTime dtFrom, DateTime dtTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,8 @@ namespace HRM.BO
|
||||||
PayrollTypeID = 0;
|
PayrollTypeID = 0;
|
||||||
UserID = 0;
|
UserID = 0;
|
||||||
UserObj = null;
|
UserObj = null;
|
||||||
|
// A row nobody approved yet is never live access (see UserAccessTypeMakerChecker_DB_Changes.sql).
|
||||||
|
AccessTypeStatus = EnumAuthStatus.NewNotYetApprove;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -23,9 +25,22 @@ namespace HRM.BO
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public int UserID { get; set; }
|
public int UserID { get; set; }
|
||||||
public User UserObj { get; set; }
|
public User UserObj { get; set; }
|
||||||
public EnumAuthStatus accessTypeStatus;
|
/// <summary>
|
||||||
public int? ApprovedBy;
|
/// UserAccessType.Status: Approved (5) = live; NewNotYetApprove (2) = requested, not live yet;
|
||||||
public DateTime? ApprovedDate;
|
/// DeletedNotYetApprove (3) = removal requested, still live until approved.
|
||||||
|
/// </summary>
|
||||||
|
public EnumAuthStatus AccessTypeStatus { get; set; }
|
||||||
|
public int? ApprovedBy { get; set; }
|
||||||
|
public DateTime? ApprovedDate { get; set; }
|
||||||
|
|
||||||
|
// Filled only by GetPending (the Pending approvals list), for display.
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public string LoginID { get; set; }
|
||||||
|
/// <summary>Who requested this pending row: CreatedBy for a new access, ModifiedBy for a removal.</summary>
|
||||||
|
public int MakerID { get; set; }
|
||||||
|
public string MakerLoginID { get; set; }
|
||||||
|
/// <summary>When it was requested: CreatedDate for a new access, ModifiedDate for a removal.</summary>
|
||||||
|
public DateTime? RequestDate { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
@ -41,6 +56,16 @@ namespace HRM.BO
|
||||||
int Save(UserAccessType item);
|
int Save(UserAccessType item);
|
||||||
void Save(List<UserAccessType> userAccessTypes);
|
void Save(List<UserAccessType> userAccessTypes);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
|
|
||||||
|
// Maker-checker (Authentication > User Access Type)
|
||||||
|
/// <summary>Maker: records the wanted payroll types of a user as pending changes. Returns how many rows changed.</summary>
|
||||||
|
int RequestChange(int userID, List<int> payrollTypeIDs, int makerID);
|
||||||
|
/// <summary>Checker: makes every pending change of the user live.</summary>
|
||||||
|
void Approve(int userID, int approverID);
|
||||||
|
/// <summary>Checker: drops every pending change of the user; access stays as it was.</summary>
|
||||||
|
void Reject(int userID, int rejecterID);
|
||||||
|
/// <summary>Every row waiting for approval, of every user, with user, payroll type and maker for display.</summary>
|
||||||
|
List<UserAccessType> GetPending();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,109 @@ namespace HRM.BO
|
||||||
|
|
||||||
void Save(List<UserRole> userRoles, int payrolltypeid);
|
void Save(List<UserRole> userRoles, int payrolltypeid);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
|
|
||||||
|
// Maker-checker (Authentication > User Role Permission). See UserRoleMakerChecker_DB_Changes.sql.
|
||||||
|
/// <summary>The person's live roles of the subject's role type, and any change waiting for approval.</summary>
|
||||||
|
UserRoleState GetRoleState(UserRoleSubject subject);
|
||||||
|
/// <summary>Maker: records the wanted roles as pending requests. Returns how many requests were made.</summary>
|
||||||
|
int RequestChange(UserRoleChangeRequest request, int makerID);
|
||||||
|
/// <summary>Checker: makes the subject's pending requests live (creates the login first if needed).</summary>
|
||||||
|
void Approve(UserRoleSubject subject, int approverID);
|
||||||
|
/// <summary>Checker: drops the subject's pending requests; live roles stay as they were.</summary>
|
||||||
|
void Reject(UserRoleSubject subject, int approverID);
|
||||||
|
/// <summary>Every request waiting for approval, of everyone, with names for display.</summary>
|
||||||
|
List<UserRoleRequest> GetPending();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region User role maker-checker
|
||||||
|
|
||||||
|
/// <summary>What a UserRoleRequest asks for.</summary>
|
||||||
|
public enum EnumUserRoleRequestType
|
||||||
|
{
|
||||||
|
Add = 1,
|
||||||
|
Remove = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whose roles: an Admin user (RoleType Admin, UserID) or a Self Service employee
|
||||||
|
/// (RoleType Self_Service, EmployeeID + PayrollTypeID; UserID only once the employee has a login).
|
||||||
|
/// </summary>
|
||||||
|
public class UserRoleSubject
|
||||||
|
{
|
||||||
|
public EnumRoleType RoleType { get; set; }
|
||||||
|
public int? UserID { get; set; }
|
||||||
|
public int? EmployeeID { get; set; }
|
||||||
|
public int? PayrollTypeID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Maker's request: the roles (of the subject's role type) the person should have.</summary>
|
||||||
|
public class UserRoleChangeRequest : UserRoleSubject
|
||||||
|
{
|
||||||
|
public UserRoleChangeRequest()
|
||||||
|
{
|
||||||
|
RoleIDs = new List<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> RoleIDs { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One UserRole row as the maker-checker screens show it (not a table of its own). A row waiting for
|
||||||
|
/// approval is a request: UserRole.Status 2 = give the role (RequestType Add, maker = CreatedBy),
|
||||||
|
/// Status 3 = take it away (RequestType Remove, maker = ModifiedBy). ID is the UserRoleID.
|
||||||
|
/// </summary>
|
||||||
|
public class UserRoleRequest : BasicBaseObject
|
||||||
|
{
|
||||||
|
public UserRoleRequest()
|
||||||
|
{
|
||||||
|
Status = EnumAuthStatus.NewNotYetApprove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumUserRoleRequestType RequestType { get; set; }
|
||||||
|
public int RoleID { get; set; }
|
||||||
|
public EnumRoleType RoleType { get; set; }
|
||||||
|
public int? UserID { get; set; }
|
||||||
|
public int? EmployeeID { get; set; }
|
||||||
|
public int? PayrollTypeID { get; set; }
|
||||||
|
/// <summary>NewNotYetApprove (2) = waiting, Approved (5), Rejected (10).</summary>
|
||||||
|
public EnumAuthStatus Status { get; set; }
|
||||||
|
public int? ApprovedBy { get; set; }
|
||||||
|
public DateTime? ApprovedDate { get; set; }
|
||||||
|
|
||||||
|
// Not database properties: filled for display.
|
||||||
|
public string RoleName { get; set; }
|
||||||
|
public string LoginID { get; set; }
|
||||||
|
public string PersonName { get; set; }
|
||||||
|
public string EmployeeNo { get; set; }
|
||||||
|
public string MakerLoginID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A person's roles of one role type, as the User Role Permission page shows them.</summary>
|
||||||
|
public class UserRoleState
|
||||||
|
{
|
||||||
|
public UserRoleState()
|
||||||
|
{
|
||||||
|
LiveRoleIDs = new List<int>();
|
||||||
|
Pending = new List<UserRoleRequest>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumRoleType RoleType { get; set; }
|
||||||
|
public int? UserID { get; set; }
|
||||||
|
public int? EmployeeID { get; set; }
|
||||||
|
/// <summary>Self Service: the employee's payroll type.</summary>
|
||||||
|
public int? PayrollTypeID { get; set; }
|
||||||
|
public string LoginID { get; set; }
|
||||||
|
public string PersonName { get; set; }
|
||||||
|
/// <summary>False for a Self Service employee who has no login yet (one is made when a change is sent).</summary>
|
||||||
|
public bool HasLogin { get; set; }
|
||||||
|
/// <summary>The login was made for a change still waiting for approval (Users.Status 2): it cannot sign in yet.</summary>
|
||||||
|
public bool LoginWaiting { get; set; }
|
||||||
|
/// <summary>Roles of this role type the person has now (live).</summary>
|
||||||
|
public List<int> LiveRoleIDs { get; set; }
|
||||||
|
/// <summary>Requests waiting for approval.</summary>
|
||||||
|
public List<UserRoleRequest> Pending { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,11 @@ namespace HRM.DA
|
||||||
|
|
||||||
internal static IDataReader GetUserPayrollType(TransactionContext tc, string loginID)
|
internal static IDataReader GetUserPayrollType(TransactionContext tc, string loginID)
|
||||||
{
|
{
|
||||||
|
// Live access only: a requested access (Status 2) is not live until approved; a requested
|
||||||
|
// removal (Status 3) stays live until approved.
|
||||||
string sql = SQLParser.MakeSQL(@"SELECT p.* FROM PayrollType p, UserAccessType ua,Users u
|
string sql = SQLParser.MakeSQL(@"SELECT p.* FROM PayrollType p, UserAccessType ua,Users u
|
||||||
where p.PayrollTypeID==ua.PayrollTypeID and u.UserID =ua.UserID and u.LoginID=%s", loginID);
|
where p.PayrollTypeID==ua.PayrollTypeID and u.UserID =ua.UserID and u.LoginID=%s and ua.Status<>%n",
|
||||||
|
loginID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
return tc.ExecuteReader(sql);
|
return tc.ExecuteReader(sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +71,8 @@ namespace HRM.DA
|
||||||
string sql = SQLParser.MakeSQL(@"SELECT * FROM PAYROLLTYPE WHERE PAYROLLTYPEID IN
|
string sql = SQLParser.MakeSQL(@"SELECT * FROM PAYROLLTYPE WHERE PAYROLLTYPEID IN
|
||||||
(SELECT DISTINCT ua.PAYROLLTYPEID FROM USERS u
|
(SELECT DISTINCT ua.PAYROLLTYPEID FROM USERS u
|
||||||
JOIN USERACCESSTYPE ua ON u.USERID = ua.UserId
|
JOIN USERACCESSTYPE ua ON u.USERID = ua.UserId
|
||||||
WHERE u.EMPLOYEEID=%n AND u.USERTYPE=%n)", employeeId, userType);
|
WHERE u.EMPLOYEEID=%n AND u.USERTYPE=%n AND ua.Status<>%n)",
|
||||||
|
employeeId, userType, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
return tc.ExecuteReader(sql);
|
return tc.ExecuteReader(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Ease.Core.DataAccess;
|
using Ease.Core.DataAccess;
|
||||||
using Ease.Core.Utility;
|
using Ease.Core.Utility;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -32,6 +33,176 @@ namespace HRM.DA
|
||||||
item.UsedProcess, item.PayrollTypeID, item.IsApprove, item.wfstatus);
|
item.UsedProcess, item.PayrollTypeID, item.IsApprove, item.wfstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts every detail row in one SqlBulkCopy (10k+ rows), instead of one INSERT per row.
|
||||||
|
/// Same columns and values as Insert(tc, BonusProcessDetail) below; IDs must already be set.
|
||||||
|
/// Runs inside the caller's transaction.
|
||||||
|
/// </summary>
|
||||||
|
internal static void InsertBulk(TransactionContext tc, List<BonusProcess.BonusProcessDetail> items)
|
||||||
|
{
|
||||||
|
if (items == null || items.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// money columns: round like SQL Server does when it converts a number literal to money (4 places)
|
||||||
|
Func<double, decimal> money = v => Math.Round((decimal)v, 4, MidpointRounding.AwayFromZero);
|
||||||
|
|
||||||
|
// column names exactly as in the BONUSPROCESSDETAIL table (bulk copy mapping is case-sensitive)
|
||||||
|
DataTable table = new DataTable("BONUSPROCESSDETAIL");
|
||||||
|
table.Columns.Add("BONUSPROCESSDETAILID", typeof(int));
|
||||||
|
table.Columns.Add("BONUSPROCESSID", typeof(int));
|
||||||
|
table.Columns.Add("BONUSID", typeof(int));
|
||||||
|
table.Columns.Add("EMPLOYEEID", typeof(int));
|
||||||
|
table.Columns.Add("DISBURSEDATE", typeof(DateTime));
|
||||||
|
table.Columns.Add("BONUSAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("GROSSSALARY", typeof(decimal));
|
||||||
|
table.Columns.Add("BASICSALARY", typeof(decimal));
|
||||||
|
table.Columns.Add("CHANGEBONUSAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("CHANGETAXAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("CHANGEADJUSTAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("CHANGESALARYITEMAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("CALCULATEDADJUSTAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("CALCULATEDSALARYITEMAMOUNT", typeof(decimal));
|
||||||
|
table.Columns.Add("TAXAMOUNT", typeof(decimal));
|
||||||
|
|
||||||
|
foreach (BonusProcess.BonusProcessDetail item in items)
|
||||||
|
{
|
||||||
|
table.Rows.Add(item.ID, item.BonusProcessID, item.BonusID, item.EmployeeID,
|
||||||
|
item.BonusMonth.Date, // Insert writes it with %d (date only)
|
||||||
|
money(item.BonusAmount), money(item.GrossSalary), money(item.BasicSalary),
|
||||||
|
money(item.ChangeBonusAmount), money(item.ChangeTaxAmount), money(item.ChangeAdjustAmount),
|
||||||
|
money(item.ChangeSalaryItemAmount), money(item.CalculatedAdjustAmount),
|
||||||
|
money(item.CalculatedSalaryItemAmount), money(item.TaxAmount));
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Microsoft.Data.SqlClient.SqlBulkCopy bulkCopy = new Microsoft.Data.SqlClient.SqlBulkCopy(
|
||||||
|
(Microsoft.Data.SqlClient.SqlConnection)tc.Connection, Microsoft.Data.SqlClient.SqlBulkCopyOptions.Default,
|
||||||
|
(Microsoft.Data.SqlClient.SqlTransaction)tc.Transaction))
|
||||||
|
{
|
||||||
|
bulkCopy.BulkCopyTimeout = 6000; // in seconds, as SaveBonusEmpCostCenter
|
||||||
|
bulkCopy.DestinationTableName = "BONUSPROCESSDETAIL";
|
||||||
|
foreach (DataColumn column in table.Columns)
|
||||||
|
bulkCopy.ColumnMappings.Add(column.ColumnName, column.ColumnName);
|
||||||
|
bulkCopy.WriteToServer(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The saved rows of one bonus process, with the employee columns the Bonus Process grid shows.</summary>
|
||||||
|
internal static IDataReader GetGridRows(TransactionContext tc, int bonusProcessID)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT bd.BONUSPROCESSDETAILID, bd.BONUSPROCESSID, bd.BONUSID, bd.EMPLOYEEID,
|
||||||
|
e.EMPLOYEENO, e.NAME, e.JOININGDATE, e.ISCONFIRMED,
|
||||||
|
bd.GROSSSALARY, bd.BASICSALARY, bd.BONUSAMOUNT, bd.CHANGEBONUSAMOUNT, bd.TAXAMOUNT, bd.CHANGETAXAMOUNT
|
||||||
|
FROM BONUSPROCESSDETAIL bd
|
||||||
|
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = bd.EMPLOYEEID
|
||||||
|
WHERE bd.BONUSPROCESSID = %n
|
||||||
|
ORDER BY e.EMPLOYEENO", bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>One saved row (Modify dialog), with the employee columns the grid shows.</summary>
|
||||||
|
internal static IDataReader GetGridRow(TransactionContext tc, int bonusProcessDetailID)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT bd.BONUSPROCESSDETAILID, bd.BONUSPROCESSID, bd.BONUSID, bd.EMPLOYEEID,
|
||||||
|
e.EMPLOYEENO, e.NAME, e.JOININGDATE, e.ISCONFIRMED,
|
||||||
|
bd.GROSSSALARY, bd.BASICSALARY, bd.BONUSAMOUNT, bd.CHANGEBONUSAMOUNT, bd.TAXAMOUNT, bd.CHANGETAXAMOUNT
|
||||||
|
FROM BONUSPROCESSDETAIL bd
|
||||||
|
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = bd.EMPLOYEEID
|
||||||
|
WHERE bd.BONUSPROCESSDETAILID = %n", bonusProcessDetailID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>One saved row and the header fields the Modify dialog needs (bonus, month, payroll type).</summary>
|
||||||
|
internal static IDataReader GetRowWithHeader(TransactionContext tc, int bonusProcessDetailID)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT bd.BONUSPROCESSDETAILID, bd.BONUSPROCESSID, bd.BONUSID, bd.EMPLOYEEID,
|
||||||
|
bd.CHANGEBONUSAMOUNT, bd.CHANGETAXAMOUNT, bd.TAXAMOUNT,
|
||||||
|
b.BONUSMONTH, b.PAYROLLTYPEID, b.ISTAXPROCESS
|
||||||
|
FROM BONUSPROCESSDETAIL bd
|
||||||
|
INNER JOIN BONUSPROCESS b ON b.BONUSPROCESSID = bd.BONUSPROCESSID
|
||||||
|
WHERE bd.BONUSPROCESSDETAILID = %n", bonusProcessDetailID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Modify dialog, Save: the amounts of one row.</summary>
|
||||||
|
internal static void UpdateRowAmounts(TransactionContext tc, int bonusProcessDetailID, double changeBonusAmount,
|
||||||
|
double changeTaxAmount, double taxAmount, int modifiedBy, DateTime modifiedDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(@"UPDATE BONUSPROCESSDETAIL SET CHANGEBONUSAMOUNT = %n, CHANGETAXAMOUNT = %n, TAXAMOUNT = %n,
|
||||||
|
MODIFIEDBY = %n, MODIFIEDDATE = %D
|
||||||
|
WHERE BONUSPROCESSDETAILID = %n",
|
||||||
|
changeBonusAmount, changeTaxAmount, taxAmount, modifiedBy, modifiedDate, bonusProcessDetailID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Clear Tax: the header fields of one bonus process (bonus, month, payroll type, options).</summary>
|
||||||
|
internal static IDataReader GetProcessHeaderForClearTax(TransactionContext tc, int bonusProcessID)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT BONUSPROCESSID, BONUSID, BONUSMONTH, PAYROLLTYPEID, ISTAXPROCESS, ISDISBURSEWITHSALARY
|
||||||
|
FROM BONUSPROCESS
|
||||||
|
WHERE BONUSPROCESSID = %n", bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clear Tax: the tax of every row of one bonus process becomes 0 — what the old Clear Tax + Save wrote
|
||||||
|
/// to BONUSPROCESSDETAIL (only CHANGETAXAMOUNT; TAXAMOUNT, the calculated tax, is kept).
|
||||||
|
/// </summary>
|
||||||
|
internal static void ClearTaxOfProcess(TransactionContext tc, int bonusProcessID, int modifiedBy, DateTime modifiedDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(@"UPDATE BONUSPROCESSDETAIL SET CHANGETAXAMOUNT = 0, MODIFIEDBY = %n, MODIFIEDDATE = %D
|
||||||
|
WHERE BONUSPROCESSID = %n",
|
||||||
|
modifiedBy, modifiedDate, bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clear Tax: the Tax Deducted line (ITEMCODE = Tax_Deducted, -212) of the bonus tax data (BONUSTEMPIT) of
|
||||||
|
/// every employee of one bonus process gets THISMONTHAMOUNT = 0 — the old save() merge with a cleared tax.
|
||||||
|
/// The other lines and columns are not touched.
|
||||||
|
/// </summary>
|
||||||
|
internal static void ClearBonusTempTaxOfProcess(TransactionContext tc, int bonusProcessID, int taxDeductedItemCode)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(@"UPDATE BONUSTEMPIT SET THISMONTHAMOUNT = 0
|
||||||
|
WHERE ITEMCODE = %n
|
||||||
|
AND EMPLOYEEID IN (SELECT EMPLOYEEID FROM BONUSPROCESSDETAIL WHERE BONUSPROCESSID = %n)",
|
||||||
|
taxDeductedItemCode, bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove (saved row): this employee's bonus tax data (BONUSTEMPIT), only when the process was saved
|
||||||
|
/// with Calculate Tax — a process without tax wrote no BONUSTEMPIT rows for it.
|
||||||
|
/// </summary>
|
||||||
|
internal static void DeleteRowBonusTempTax(TransactionContext tc, int bonusProcessID, int employeeID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(@"DELETE FROM BONUSTEMPIT
|
||||||
|
WHERE EMPLOYEEID = %n
|
||||||
|
AND EXISTS (SELECT 1 FROM BONUSPROCESS WHERE BONUSPROCESSID = %n AND ISTAXPROCESS = 1)",
|
||||||
|
employeeID, bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Remove (saved row): this employee's cost-center split in this process.</summary>
|
||||||
|
internal static void DeleteRowCostCenter(TransactionContext tc, int bonusProcessID, int employeeID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM BonusEmpCostCenter WHERE BonusProcessID = %n AND EmployeeID = %n",
|
||||||
|
bonusProcessID, employeeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Remove (saved row): the row itself.</summary>
|
||||||
|
internal static void DeleteRow(TransactionContext tc, int bonusProcessDetailID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM BONUSPROCESSDETAIL WHERE BONUSPROCESSDETAILID = %n", bonusProcessDetailID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Remove (saved row): how many rows the process still has.</summary>
|
||||||
|
internal static int CountRows(TransactionContext tc, int bonusProcessID)
|
||||||
|
{
|
||||||
|
object count = tc.ExecuteScalar("SELECT COUNT(*) FROM BONUSPROCESSDETAIL WHERE BONUSPROCESSID = %n", bonusProcessID);
|
||||||
|
return count == null || count == DBNull.Value ? 0 : Convert.ToInt32(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Remove (saved row): the header of a process that has no rows left, and anything still hanging on it.</summary>
|
||||||
|
internal static void DeleteEmptyProcess(TransactionContext tc, int bonusProcessID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM BonusEmpCostCenter WHERE BonusProcessID = %n", bonusProcessID);
|
||||||
|
tc.ExecuteNonQuery(@"DELETE FROM BONUSPROCESS WHERE BONUSPROCESSID = %n
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM BONUSPROCESSDETAIL WHERE BONUSPROCESSID = %n)",
|
||||||
|
bonusProcessID, bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void Insert(TransactionContext tc, BonusProcess.BonusProcessDetail item)
|
internal static void Insert(TransactionContext tc, BonusProcess.BonusProcessDetail item)
|
||||||
{
|
{
|
||||||
string sql = SQLParser.MakeSQL(
|
string sql = SQLParser.MakeSQL(
|
||||||
|
|
@ -487,6 +658,19 @@ AND BP.PayrollTypeID=%n", emps, FromDate, ToDate, payrollTypeID);
|
||||||
|
|
||||||
return approved;
|
return approved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen: how many BONUSPROCESS headers this bonus already has in this month (whole month)
|
||||||
|
/// for this payroll type. Used to stop the same bonus type being processed twice in one month.
|
||||||
|
/// </summary>
|
||||||
|
internal static int CountProcessInMonth(TransactionContext tc, int payrolltypeid, int bonusid, DateTime bonusMonth)
|
||||||
|
{
|
||||||
|
object count = tc.ExecuteScalar(
|
||||||
|
"SELECT COUNT(*) FROM BONUSPROCESS WHERE PAYROLLTYPEID = %n AND BONUSID = %n AND BONUSMONTH BETWEEN %d AND %d",
|
||||||
|
payrolltypeid, bonusid, PayrollGlobalFunctions.PayrollFirstDateOfMonth(bonusMonth),
|
||||||
|
PayrollGlobalFunctions.PayrollLastDateOfMonth(bonusMonth));
|
||||||
|
return (count == null || count == DBNull.Value) ? 0 : Convert.ToInt32(count);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal static DataSet GetMontlyProdBonus(TransactionContext tc, DateTime dBonusMonth)
|
internal static DataSet GetMontlyProdBonus(TransactionContext tc, DateTime dBonusMonth)
|
||||||
|
|
|
||||||
|
|
@ -785,6 +785,32 @@ namespace HRM.DA
|
||||||
tc.ExecuteNonQuery("UPDATE EMPCONTACT SET presentPOInBangla = %s, presentAddressInBangla = %s, parmanentPOInBangla = %s, permanentAddressInBangla =%s WHERE EMPLOYEEID = %s", employeBanglaInfo[1], employeBanglaInfo[2], employeBanglaInfo[3], employeBanglaInfo[4], employeBanglaInfo[0]);
|
tc.ExecuteNonQuery("UPDATE EMPCONTACT SET presentPOInBangla = %s, presentAddressInBangla = %s, parmanentPOInBangla = %s, permanentAddressInBangla =%s WHERE EMPLOYEEID = %s", employeBanglaInfo[1], employeBanglaInfo[2], employeBanglaInfo[3], employeBanglaInfo[4], employeBanglaInfo[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The full Employee rows of the given employees of one payroll type, for any number of employees
|
||||||
|
/// (10k+). Same result as GetByEmpIDs(tc, empIDs, payrollTypeID), but the IDs go in as ONE
|
||||||
|
/// varchar(max) parameter and a temp table with a primary key instead of an "IN (1,2,3,...)" list in
|
||||||
|
/// the SQL text. Needs SQL Server 2016+ (STRING_SPLIT).
|
||||||
|
/// </summary>
|
||||||
|
internal static IDataReader GetByEmpIDList(TransactionContext tc, List<int> empIDs, int payrollTypeID)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(@"SET NOCOUNT ON;
|
||||||
|
IF OBJECT_ID('tempdb..#empListIds') IS NOT NULL DROP TABLE #empListIds;
|
||||||
|
CREATE TABLE #empListIds (ID int NOT NULL PRIMARY KEY);
|
||||||
|
INSERT INTO #empListIds (ID) SELECT DISTINCT CONVERT(int, value) FROM STRING_SPLIT(@empIds, ',') WHERE value <> '';
|
||||||
|
SELECT e.* FROM Employee e
|
||||||
|
INNER JOIN #empListIds t ON t.ID = e.EMPLOYEEID
|
||||||
|
WHERE e.PAYROLLTYPEID = %n
|
||||||
|
ORDER BY e.EmployeeNo;
|
||||||
|
DROP TABLE #empListIds;", payrollTypeID);
|
||||||
|
|
||||||
|
// must be a SqlParameter[]: Ease.Core casts the array to SqlParameter[]
|
||||||
|
SqlParameter[] parameters =
|
||||||
|
{
|
||||||
|
SqlHelperExtension.CreateInParam("@empIds", SqlDbType.VarChar, string.Join(",", empIDs), -1) // varchar(max)
|
||||||
|
};
|
||||||
|
return tc.ExecuteReader(CommandType.Text, sql, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
internal static IDataReader GetByEmpIDs(TransactionContext tc, string empIDs)
|
internal static IDataReader GetByEmpIDs(TransactionContext tc, string empIDs)
|
||||||
{
|
{
|
||||||
string sTableName;
|
string sTableName;
|
||||||
|
|
@ -798,6 +824,34 @@ namespace HRM.DA
|
||||||
return dr;
|
return dr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The EmployeeLite columns only, for any number of employees (10k+ at a time).
|
||||||
|
/// The IDs go in as ONE varchar(max) parameter and land in a temp table with a primary key, so the
|
||||||
|
/// SQL text stays small and SQL Server knows how many rows to expect (an inline IN list or
|
||||||
|
/// STRING_SPLIT in the join is much slower at this size). Needs SQL Server 2016+ (STRING_SPLIT).
|
||||||
|
/// </summary>
|
||||||
|
internal static IDataReader GetLiteByEmpIDs(TransactionContext tc, List<int> empIDs)
|
||||||
|
{
|
||||||
|
const string sql = @"SET NOCOUNT ON;
|
||||||
|
IF OBJECT_ID('tempdb..#elEmpIds') IS NOT NULL DROP TABLE #elEmpIds;
|
||||||
|
CREATE TABLE #elEmpIds (ID int NOT NULL PRIMARY KEY);
|
||||||
|
INSERT INTO #elEmpIds (ID) SELECT DISTINCT CONVERT(int, value) FROM STRING_SPLIT(@empIds, ',') WHERE value <> '';
|
||||||
|
SELECT e.EMPLOYEEID AS EmployeeID, e.ISCONFIRMED AS IsConfirmed, e.JOININGDATE AS JoiningDate
|
||||||
|
FROM Employee e
|
||||||
|
INNER JOIN #elEmpIds t ON t.ID = e.EMPLOYEEID;
|
||||||
|
DROP TABLE #elEmpIds;";
|
||||||
|
|
||||||
|
// ints only (the caller passes List<int>), so the parameter can never carry anything but digits and commas
|
||||||
|
string ids = string.Join(",", empIDs);
|
||||||
|
// must be a SqlParameter[]: Ease.Core casts the array to SqlParameter[], and a lone parameter
|
||||||
|
// passed to "params IDataParameter[]" would arrive as an IDataParameter[] and fail that cast
|
||||||
|
SqlParameter[] parameters =
|
||||||
|
{
|
||||||
|
SqlHelperExtension.CreateInParam("@empIds", SqlDbType.VarChar, ids, -1) // varchar(max)
|
||||||
|
};
|
||||||
|
return tc.ExecuteReader(CommandType.Text, sql, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
internal static IDataReader GetFssEmp(TransactionContext tc, string empIDs, int payrollTypeID)
|
internal static IDataReader GetFssEmp(TransactionContext tc, string empIDs, int payrollTypeID)
|
||||||
{
|
{
|
||||||
string sTableName;
|
string sTableName;
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,19 @@ namespace HRM.DA
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Like hasTaxDataInSalaryTemp(tc, employeeId), but only SALARYTEMPIT (a salary processed and not yet
|
||||||
|
/// finalized) — BONUSTEMPIT is not looked at. Used by the Bonus Process Modify dialog: there the
|
||||||
|
/// employee's BONUSTEMPIT rows are that same bonus's own tax data, saved by Process.
|
||||||
|
/// </summary>
|
||||||
|
internal static bool hasTaxDataInSalaryTempOnly(TransactionContext tc, int employeeId)
|
||||||
|
{
|
||||||
|
object isprocessed = tc.ExecuteScalar(@"select count(*) cnt from SALARYTEMPIT WHERE EmployeeID =%n", employeeId);
|
||||||
|
if (isprocessed == null || isprocessed == DBNull.Value)
|
||||||
|
return false;
|
||||||
|
return Convert.ToInt32(isprocessed) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
internal static EnumIncomeTaxDataFrom TaxDataFrom(TransactionContext tc, int employeeId)
|
internal static EnumIncomeTaxDataFrom TaxDataFrom(TransactionContext tc, int employeeId)
|
||||||
{
|
{
|
||||||
object isprocessed = tc.ExecuteScalar(@"if exists(select * from SALARYTEMPIT where EmployeeID =%n ) select 3
|
object isprocessed = tc.ExecuteScalar(@"if exists(select * from SALARYTEMPIT where EmployeeID =%n ) select 3
|
||||||
|
|
@ -212,17 +225,54 @@ namespace HRM.DA
|
||||||
DataSet oIncomeTaxs = new DataSet();
|
DataSet oIncomeTaxs = new DataSet();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sql = SQLParser.MakeSQL(@"select salarytax.EMPLOYEENO,salarytax.Name,salarytax.EMPLOYEEID, salarytax.TaxAmount SalaryData, st.thisyeartotal TaxData from
|
// The employee IDs used to be spliced in twice as "in(1,2,3,...)". With 10k+ employees
|
||||||
|
// SQL Server cannot build a plan for that ("The query processor ran out of internal
|
||||||
|
// resources", error 8623). Now they go in as ONE varchar(max) parameter, land in a temp
|
||||||
|
// table with a primary key, and both parts of the UNION read "in (SELECT ID FROM #tdrEmpIds)".
|
||||||
|
// The query itself (columns, conditions, result) is unchanged. Needs SQL Server 2016+ (STRING_SPLIT).
|
||||||
|
List<string> ids = new List<string>();
|
||||||
|
foreach (string part in (empids ?? string.Empty).Split(','))
|
||||||
|
{
|
||||||
|
string id = part.Trim();
|
||||||
|
if (id.Length == 0) continue;
|
||||||
|
if (!int.TryParse(id, out int empId))
|
||||||
|
throw new ArgumentException("Invalid employee id: " + id);
|
||||||
|
ids.Add(empId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//string sql = SQLParser.MakeSQL(@"select salarytax.EMPLOYEENO,salarytax.Name,salarytax.EMPLOYEEID, salarytax.TaxAmount SalaryData, st.thisyeartotal TaxData from
|
||||||
|
// (Select tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID,sum(tab.TaxAmount) TaxAmount from
|
||||||
|
// (Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,sd.CHANGEDAMOUNT TaxAmount,s.salarymonth from SALARYMONTHLYDETAIL sd, SALARYMONTHLY s,Employee e where s.EMPLOYEEID=e.EMPLOYEEID and sd.SALARYMONTHLYID=s.SALARYMONTHLYID and s.SALARYMONTH
|
||||||
|
// between %d and %d and ITEMCODE=-129 and ITEMID=-129 and s.EMPLOYEEID in(%q)
|
||||||
|
// union
|
||||||
|
// Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,s.CHANGETAXAMOUNT TaxAmount,s.DISBURSEDATE salarymonth from BONUSPROCESSDETAIL s,Employee e where e.EMPLOYEEID=s.EMPLOYEEID and s.DISBURSEDATE between %d and %d and s.EMPLOYEEID in (%q)
|
||||||
|
// ) tab group by tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID) salarytax
|
||||||
|
// left join
|
||||||
|
// %q st on salarytax.Employeeid=st.employeeid and st.itemcode=-212 and st.itemid=-212",
|
||||||
|
//fromdate, toDate, empids, fromdate, toDate, empids, GetTableName(dataFrom));
|
||||||
|
|
||||||
|
string sql = SQLParser.MakeSQL(@"SET NOCOUNT ON;
|
||||||
|
IF OBJECT_ID('tempdb..#tdrEmpIds') IS NOT NULL DROP TABLE #tdrEmpIds;
|
||||||
|
CREATE TABLE #tdrEmpIds (ID int NOT NULL PRIMARY KEY);
|
||||||
|
INSERT INTO #tdrEmpIds (ID) SELECT DISTINCT CONVERT(int, value) FROM STRING_SPLIT(@empIds, ',') WHERE value <> '';
|
||||||
|
select salarytax.EMPLOYEENO,salarytax.Name,salarytax.EMPLOYEEID, salarytax.TaxAmount SalaryData, st.thisyeartotal TaxData from
|
||||||
(Select tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID,sum(tab.TaxAmount) TaxAmount from
|
(Select tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID,sum(tab.TaxAmount) TaxAmount from
|
||||||
(Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,sd.CHANGEDAMOUNT TaxAmount,s.salarymonth from SALARYMONTHLYDETAIL sd, SALARYMONTHLY s,Employee e where s.EMPLOYEEID=e.EMPLOYEEID and sd.SALARYMONTHLYID=s.SALARYMONTHLYID and s.SALARYMONTH
|
(Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,sd.CHANGEDAMOUNT TaxAmount,s.salarymonth from SALARYMONTHLYDETAIL sd, SALARYMONTHLY s,Employee e where s.EMPLOYEEID=e.EMPLOYEEID and sd.SALARYMONTHLYID=s.SALARYMONTHLYID and s.SALARYMONTH
|
||||||
between %d and %d and ITEMCODE=-129 and ITEMID=-129 and s.EMPLOYEEID in(%q)
|
between %d and %d and ITEMCODE=-129 and ITEMID=-129 and s.EMPLOYEEID in (SELECT ID FROM #tdrEmpIds)
|
||||||
union
|
union
|
||||||
Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,s.CHANGETAXAMOUNT TaxAmount,s.DISBURSEDATE salarymonth from BONUSPROCESSDETAIL s,Employee e where e.EMPLOYEEID=s.EMPLOYEEID and s.DISBURSEDATE between %d and %d and s.EMPLOYEEID in (%q)
|
Select e.EMPLOYEENO,e.Name,e.EMPLOYEEID,s.CHANGETAXAMOUNT TaxAmount,s.DISBURSEDATE salarymonth from BONUSPROCESSDETAIL s,Employee e where e.EMPLOYEEID=s.EMPLOYEEID and s.DISBURSEDATE between %d and %d and s.EMPLOYEEID in (SELECT ID FROM #tdrEmpIds)
|
||||||
) tab group by tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID) salarytax
|
) tab group by tab.EMPLOYEENO,tab.Name,tab.EMPLOYEEID) salarytax
|
||||||
left join
|
left join
|
||||||
%q st on salarytax.Employeeid=st.employeeid and st.itemcode=-212 and st.itemid=-212",
|
%q st on salarytax.Employeeid=st.employeeid and st.itemcode=-212 and st.itemid=-212;
|
||||||
fromdate, toDate, empids, fromdate, toDate, empids, GetTableName(dataFrom));
|
DROP TABLE #tdrEmpIds;",
|
||||||
oIncomeTaxs = tc.ExecuteDataSet(sql);
|
fromdate, toDate, fromdate, toDate, GetTableName(dataFrom));
|
||||||
|
|
||||||
|
// must be a Microsoft.Data.SqlClient.SqlParameter[]: Ease.Core casts the array to that type
|
||||||
|
Microsoft.Data.SqlClient.SqlParameter[] parameters =
|
||||||
|
{
|
||||||
|
Ease.Core.DataAccess.SQL.SqlHelperExtension.CreateInParam("@empIds", SqlDbType.VarChar, string.Join(",", ids), -1) // varchar(max)
|
||||||
|
};
|
||||||
|
oIncomeTaxs = tc.ExecuteDataSet(CommandType.Text, sql, parameters);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ namespace HRM.DA
|
||||||
//" WHERE RoleID = %n", item.Code, item.Name, item.ModifiedBy, item.ModifiedDate, item.Sequence, (int)item.RoleStatus, item.ApproveBy, item.ApproveDate, (int)item.RoleStatus, item.Description, item.ID);
|
//" WHERE RoleID = %n", item.Code, item.Name, item.ModifiedBy, item.ModifiedDate, item.Sequence, (int)item.RoleStatus, item.ApproveBy, item.ApproveDate, (int)item.RoleStatus, item.Description, item.ID);
|
||||||
|
|
||||||
tc.ExecuteNonQuery(
|
tc.ExecuteNonQuery(
|
||||||
"UPDATE Role SET Code=%s, name = %s, Sequence = %n, ApproveBy = %n,ApproveDate=%D,Status=%n , AUTHORIZEDBY=%n, AUTHORIZEDDATE=%D" +
|
"UPDATE Role SET Code=%s, name = %s, Description = %s, ROLETYPE = %n, Sequence = %n, ApproveBy = %n,ApproveDate=%D,Status=%n , AUTHORIZEDBY=%n, AUTHORIZEDDATE=%D" +
|
||||||
" WHERE RoleID = %n", item.Code, item.Name, item.Sequence, item.ApproveBy, item.ApproveDate,
|
" WHERE RoleID = %n", item.Code, item.Name, item.Description, (int)item.RoleType, item.Sequence, item.ApproveBy, item.ApproveDate,
|
||||||
(int)item.RoleStatus, item.ModifiedBy, item.ModifiedDate, item.ID);
|
(int)item.RoleStatus, item.ModifiedBy, item.ModifiedDate, item.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,8 +137,10 @@ namespace HRM.DA
|
||||||
//" WHERE r.RoleID= u.roleid and u.userid=%n order by PermissionCode",
|
//" WHERE r.RoleID= u.roleid and u.userid=%n order by PermissionCode",
|
||||||
//useridID);
|
//useridID);
|
||||||
|
|
||||||
|
// u.Status<>2: a role given but not approved yet is not live (UserRoleMakerChecker_DB_Changes.sql).
|
||||||
return tc.ExecuteReader(@"SELECT distinct r.*, CAST(REPLACE(r.PermissionCode, '.', '') AS int) pcode FROM RolePermission r, UserRole u
|
return tc.ExecuteReader(@"SELECT distinct r.*, CAST(REPLACE(r.PermissionCode, '.', '') AS int) pcode FROM RolePermission r, UserRole u
|
||||||
WHERE r.RoleID = u.roleid and u.userid = %n order by pcode",useridID);
|
WHERE r.RoleID = u.roleid and u.userid = %n and u.Status <> %n order by pcode",
|
||||||
|
useridID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IDataReader GetRolePermissionByUserID(TransactionContext tc, int userID, int employeeID)
|
internal static IDataReader GetRolePermissionByUserID(TransactionContext tc, int userID, int employeeID)
|
||||||
|
|
@ -157,7 +159,8 @@ namespace HRM.DA
|
||||||
//useridID);
|
//useridID);
|
||||||
|
|
||||||
return tc.ExecuteReader(@"SELECT distinct r.*, CAST(REPLACE(r.PermissionCode, '.', '') AS int) pcode FROM RolePermission r, UserRole u
|
return tc.ExecuteReader(@"SELECT distinct r.*, CAST(REPLACE(r.PermissionCode, '.', '') AS int) pcode FROM RolePermission r, UserRole u
|
||||||
WHERE (r.RoleID = u.roleid or r.ROLEID = 12) and u.userid = %n order by pcode", useridID);
|
WHERE (r.RoleID = u.roleid or r.ROLEID = 12) and u.userid = %n and u.Status <> %n order by pcode",
|
||||||
|
useridID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IDataReader GetRoleActionPermissionByRoleID(TransactionContext tc, int roleID)
|
internal static IDataReader GetRoleActionPermissionByRoleID(TransactionContext tc, int roleID)
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,9 @@ namespace HRM.DA
|
||||||
return tc.ExecuteDataSet(
|
return tc.ExecuteDataSet(
|
||||||
@"select distinct rp.PERMISSIONCODE MenuKey, rp.roleid RoleID from RolePermission rp
|
@"select distinct rp.PERMISSIONCODE MenuKey, rp.roleid RoleID from RolePermission rp
|
||||||
inner join UserRole ur on rp.roleID = ur.RoleID
|
inner join UserRole ur on rp.roleID = ur.RoleID
|
||||||
where ur.UserID=%n and rp.STATUS=%n",
|
where ur.UserID=%n and rp.STATUS=%n and ur.Status<>%n",
|
||||||
userID, (int)EnumAuthStatus.Approved);
|
userID, (int)EnumAuthStatus.Approved, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
|
// ur.Status<>2: a role given but not approved yet is not live (UserRoleMakerChecker_DB_Changes.sql).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
121
HRM.DA/DA/Users/SystemAuditHistoryDA.cs
Normal file
121
HRM.DA/DA/Users/SystemAuditHistoryDA.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using Ease.Core.DataAccess;
|
||||||
|
using HRM.BO;
|
||||||
|
|
||||||
|
namespace HRM.DA
|
||||||
|
{
|
||||||
|
// Change history of the Authentication pages, read from their Z_ tables
|
||||||
|
// (SystemAuditHistory_DB_Changes.sql). Every query returns the same columns, so one
|
||||||
|
// MapObject reads them all: AuditType, AuditDate, LoginID, Name, Code, UserType, RoleName,
|
||||||
|
// RoleType, MenuKey, MenuName, AccessType, Status, Activities, ActionBy, ActionByLoginID,
|
||||||
|
// ActionByName. Date range: both days inclusive, newest first.
|
||||||
|
internal class SystemAuditHistoryDA
|
||||||
|
{
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
private SystemAuditHistoryDA()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Get Function
|
||||||
|
|
||||||
|
// Z_ROLE keeps a copy of the row. "Update (before)" rows are left out (the "after" row
|
||||||
|
// shows the change). Who did it: the approver on an approval, else the editor, else the creator.
|
||||||
|
internal static IDataReader GetRole(TransactionContext tc, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(
|
||||||
|
@"SELECT CASE z.AUDITTYPE WHEN 'Inserted' THEN 'Role created'
|
||||||
|
WHEN 'Deleted' THEN 'Role deleted'
|
||||||
|
ELSE 'Role modified' END AuditType,
|
||||||
|
z.AUDITDATE AuditDate, NULL LoginID, z.NAME Name, z.CODE Code, NULL UserType,
|
||||||
|
NULL RoleName, z.ROLETYPE RoleType, NULL MenuKey, NULL MenuName, NULL AccessType,
|
||||||
|
z.STATUS Status, NULL Activities, a.ActionBy, u.LoginID ActionByLoginID, u.UserName ActionByName
|
||||||
|
FROM Z_ROLE z
|
||||||
|
CROSS APPLY (SELECT CASE WHEN z.AUDITTYPE = 'Deleted' THEN NULL
|
||||||
|
WHEN z.AUDITTYPE = 'Inserted' THEN z.CREATEDBY
|
||||||
|
WHEN z.STATUS = %n AND z.APPROVEBY IS NOT NULL THEN z.APPROVEBY
|
||||||
|
ELSE COALESCE(z.AUTHORIZEDBY, z.CREATEDBY) END ActionBy) a
|
||||||
|
LEFT JOIN Users u ON u.UserID = a.ActionBy
|
||||||
|
WHERE z.AUDITTYPE <> 'Update (before)'
|
||||||
|
AND z.AUDITDATE >= %d AND z.AUDITDATE < %d
|
||||||
|
ORDER BY z.AUDITDATE DESC",
|
||||||
|
(int)EnumAuthStatus.Approved, dtFrom.Date, dtTo.Date.AddDays(1));
|
||||||
|
return tc.ExecuteReader(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Z_ROLEPERMISSION (trigger trRolePermission). Menu name from the uploaded menu
|
||||||
|
// (ConfigurationAttribute), the same lookup RolePermissionDA.GetRolePerAudit uses.
|
||||||
|
internal static IDataReader GetRolePermission(TransactionContext tc, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(
|
||||||
|
@"SELECT z.audittype AuditType, z.auditdate AuditDate, NULL LoginID, NULL Name, r.Code Code, NULL UserType,
|
||||||
|
r.Name RoleName, r.RoleType RoleType, z.menukey MenuKey,
|
||||||
|
(SELECT TOP 1 ca.Value FROM ConfigurationAttribute ca
|
||||||
|
WHERE ca.AttributeName = 'name'
|
||||||
|
AND ca.ParentID = (SELECT MAX(ck.ParentID) FROM ConfigurationAttribute ck
|
||||||
|
WHERE ck.Value = z.menukey AND ck.AttributeName = 'key')) MenuName,
|
||||||
|
NULL AccessType, z.status Status, z.activities Activities,
|
||||||
|
z.actionby ActionBy, u.LoginID ActionByLoginID, u.UserName ActionByName
|
||||||
|
FROM Z_ROLEPERMISSION z
|
||||||
|
LEFT JOIN Role r ON r.RoleID = z.roleid
|
||||||
|
LEFT JOIN Users u ON u.UserID = z.actionby
|
||||||
|
WHERE z.auditdate >= %d AND z.auditdate < %d
|
||||||
|
ORDER BY z.auditdate DESC",
|
||||||
|
dtFrom.Date, dtTo.Date.AddDays(1));
|
||||||
|
return tc.ExecuteReader(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Z_USERS (trigger trUsers).
|
||||||
|
internal static IDataReader GetUser(TransactionContext tc, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(
|
||||||
|
@"SELECT z.audittype AuditType, z.auditdate AuditDate, z.loginid LoginID, z.name Name, NULL Code,
|
||||||
|
z.usertype UserType, NULL RoleName, NULL RoleType, NULL MenuKey, NULL MenuName, NULL AccessType,
|
||||||
|
NULL Status, z.activities Activities,
|
||||||
|
z.actionby ActionBy, u.LoginID ActionByLoginID, u.UserName ActionByName
|
||||||
|
FROM Z_USERS z
|
||||||
|
LEFT JOIN Users u ON u.UserID = z.actionby
|
||||||
|
WHERE z.auditdate >= %d AND z.auditdate < %d
|
||||||
|
ORDER BY z.auditdate DESC",
|
||||||
|
dtFrom.Date, dtTo.Date.AddDays(1));
|
||||||
|
return tc.ExecuteReader(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Z_USERROLE (trigger truserrole): Code / name are the role's.
|
||||||
|
internal static IDataReader GetUserRole(TransactionContext tc, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(
|
||||||
|
@"SELECT z.audittype AuditType, z.auditdate AuditDate, NULL LoginID, NULL Name, z.Code Code, NULL UserType,
|
||||||
|
z.name RoleName, NULL RoleType, NULL MenuKey, NULL MenuName, NULL AccessType,
|
||||||
|
NULL Status, z.activities Activities,
|
||||||
|
z.actionby ActionBy, u.LoginID ActionByLoginID, u.UserName ActionByName
|
||||||
|
FROM Z_USERROLE z
|
||||||
|
LEFT JOIN Users u ON u.UserID = z.actionby
|
||||||
|
WHERE z.auditdate >= %d AND z.auditdate < %d
|
||||||
|
ORDER BY z.auditdate DESC",
|
||||||
|
dtFrom.Date, dtTo.Date.AddDays(1));
|
||||||
|
return tc.ExecuteReader(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Z_USERACCESSTYPE (trigger trUserAccessType).
|
||||||
|
internal static IDataReader GetUserAccessType(TransactionContext tc, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
string sql = SQLParser.MakeSQL(
|
||||||
|
@"SELECT z.audittype AuditType, z.auditdate AuditDate, z.loginid LoginID, z.name Name, NULL Code,
|
||||||
|
NULL UserType, NULL RoleName, NULL RoleType, NULL MenuKey, NULL MenuName, z.payrolltype AccessType,
|
||||||
|
NULL Status, z.activities Activities,
|
||||||
|
z.actionby ActionBy, u.LoginID ActionByLoginID, u.UserName ActionByName
|
||||||
|
FROM Z_USERACCESSTYPE z
|
||||||
|
LEFT JOIN Users u ON u.UserID = z.actionby
|
||||||
|
WHERE z.auditdate >= %d AND z.auditdate < %d
|
||||||
|
ORDER BY z.auditdate DESC",
|
||||||
|
dtFrom.Date, dtTo.Date.AddDays(1));
|
||||||
|
return tc.ExecuteReader(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,8 +18,14 @@ namespace HRM.DA
|
||||||
|
|
||||||
internal static void Insert(TransactionContext tc, UserAccessType item)
|
internal static void Insert(TransactionContext tc, UserAccessType item)
|
||||||
{
|
{
|
||||||
tc.ExecuteNonQuery("INSERT INTO UserAccessType(UserAccessTypeID, PayrollTypeID, UserID)" +
|
tc.ExecuteNonQuery("INSERT INTO UserAccessType(UserAccessTypeID, PayrollTypeID, UserID, Status," +
|
||||||
" VALUES(%n, %n, %n)", item.ID, item.PayrollTypeID, item.UserID);
|
" CreatedBy, CreatedDate, ApprovedBy, ApprovedDate)" +
|
||||||
|
" VALUES(%n, %n, %n, %n, %n, %D, %n, %D)",
|
||||||
|
item.ID, item.PayrollTypeID, item.UserID, (int)item.AccessTypeStatus,
|
||||||
|
item.CreatedBy == 0 ? null : item.CreatedBy,
|
||||||
|
item.CreatedDate == System.DateTime.MinValue ? null : item.CreatedDate,
|
||||||
|
item.ApprovedBy == 0 ? null : item.ApprovedBy,
|
||||||
|
item.ApprovedDate == System.DateTime.MinValue ? null : item.ApprovedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -32,6 +38,43 @@ namespace HRM.DA
|
||||||
" WHERE UserAccessTypeID=%n", item.PayrollTypeID, item.UserID, item.ID);
|
" WHERE UserAccessTypeID=%n", item.PayrollTypeID, item.UserID, item.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maker asks to take a live access away: it stays live (Status 3) until approved.
|
||||||
|
internal static void RequestRemoval(TransactionContext tc, int userAccessTypeID, int makerID, System.DateTime requestDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("UPDATE UserAccessType SET Status=%n, ModifiedBy=%n, ModifiedDate=%D" +
|
||||||
|
" WHERE UserAccessTypeID=%n",
|
||||||
|
(int)EnumAuthStatus.DeletedNotYetApprove, makerID, requestDate, userAccessTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker approves: requested removals go, requested accesses become live.
|
||||||
|
internal static void Approve(TransactionContext tc, int userID, int approverID, System.DateTime approveDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM UserAccessType WHERE UserID=%n AND Status=%n",
|
||||||
|
userID, (int)EnumAuthStatus.DeletedNotYetApprove);
|
||||||
|
tc.ExecuteNonQuery("UPDATE UserAccessType SET Status=%n, ApprovedBy=%n, ApprovedDate=%D" +
|
||||||
|
" WHERE UserID=%n AND Status=%n",
|
||||||
|
(int)EnumAuthStatus.Approved, approverID, approveDate, userID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tells trigger trUserAccessType who is making the change (SystemAuditHistory_DB_Changes.sql),
|
||||||
|
// for the rows it cannot tell from the row itself (a reject, a deleted row). Lasts for this
|
||||||
|
// connection only; a pooled connection is reset before it is used again. Skipped on a
|
||||||
|
// SQL Server older than 2016, which has no session context.
|
||||||
|
internal static void SetAuditUser(TransactionContext tc, int userID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("IF OBJECT_ID('sys.sp_set_session_context') IS NOT NULL" +
|
||||||
|
" EXEC sp_set_session_context @key = N'AuditUserID', @value = %n", userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker rejects: requested accesses go, requested removals stay live as before.
|
||||||
|
internal static void Reject(TransactionContext tc, int userID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM UserAccessType WHERE UserID=%n AND Status=%n",
|
||||||
|
userID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
|
tc.ExecuteNonQuery("UPDATE UserAccessType SET Status=%n WHERE UserID=%n AND Status=%n",
|
||||||
|
(int)EnumAuthStatus.Approved, userID, (int)EnumAuthStatus.DeletedNotYetApprove);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Get Function
|
#region Get Function
|
||||||
|
|
@ -53,7 +96,29 @@ namespace HRM.DA
|
||||||
return tc.ExecuteReader("SELECT * FROM UserAccessType WHERE UserID=%n", UserID);
|
return tc.ExecuteReader("SELECT * FROM UserAccessType WHERE UserID=%n", UserID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Every row waiting for approval, of every user (Pending approvals list).
|
||||||
|
internal static IDataReader GetPending(TransactionContext tc)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT ua.*, p.Description PayrollTypeName, u.LoginID UserLoginID, u.UserName UserFullName,
|
||||||
|
mk.LoginID MakerLoginID
|
||||||
|
FROM UserAccessType ua
|
||||||
|
JOIN PayrollType p ON p.PayrollTypeID = ua.PayrollTypeID
|
||||||
|
JOIN Users u ON u.UserID = ua.UserID
|
||||||
|
LEFT JOIN Users mk ON mk.UserID = CASE WHEN ua.Status=%n THEN ua.ModifiedBy ELSE ua.CreatedBy END
|
||||||
|
WHERE ua.Status IN (%n, %n)
|
||||||
|
ORDER BY u.UserName, p.Description",
|
||||||
|
(int)EnumAuthStatus.DeletedNotYetApprove,
|
||||||
|
(int)EnumAuthStatus.NewNotYetApprove, (int)EnumAuthStatus.DeletedNotYetApprove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Names of the payroll types a pending approval of this user will newly give access to.
|
||||||
|
internal static IDataReader GetPendingNewDescriptions(TransactionContext tc, int userID)
|
||||||
|
{
|
||||||
|
return tc.ExecuteReader(@"SELECT p.Description FROM UserAccessType ua
|
||||||
|
JOIN PayrollType p ON p.PayrollTypeID = ua.PayrollTypeID
|
||||||
|
WHERE ua.UserID=%n AND ua.Status=%n",
|
||||||
|
userID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,13 @@ namespace HRM.DA
|
||||||
item.ParentID, item.UserStatus, item.ApprovedBy, item.ApprovedDate, item.ComputerName,
|
item.ParentID, item.UserStatus, item.ApprovedBy, item.ApprovedDate, item.ComputerName,
|
||||||
item.ApprovedComputerName, DataReader.GetNullValue(item.ExpireDate),item.UserStatus, item.ID);
|
item.ApprovedComputerName, DataReader.GetNullValue(item.ExpireDate),item.UserStatus, item.ID);
|
||||||
}
|
}
|
||||||
|
// User Role Permission maker-checker: switches a waiting employee login on (or records its status).
|
||||||
|
internal static void UpdateStatus(TransactionContext tc, int userID, EnumAuthStatus status, int approvedBy, DateTime approvedDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("UPDATE Users SET Status = %n, ApprovedBy=%n, ApprovedDate=%D WHERE UserID = %n",
|
||||||
|
(int)status, approvedBy, approvedDate, userID);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void Approve(TransactionContext tc, User item)
|
internal static void Approve(TransactionContext tc, User item)
|
||||||
{
|
{
|
||||||
tc.ExecuteNonQuery("UPDATE Users SET Status = %n, ApprovedBy=%n, ApprovedDate=%D,ComputerName=%s,ApprovedComputerName=%s," +
|
tc.ExecuteNonQuery("UPDATE Users SET Status = %n, ApprovedBy=%n, ApprovedDate=%D,ComputerName=%s,ApprovedComputerName=%s," +
|
||||||
|
|
@ -243,8 +250,8 @@ namespace HRM.DA
|
||||||
{
|
{
|
||||||
return tc.ExecuteReader(@"SELECT u.* FROM Users u
|
return tc.ExecuteReader(@"SELECT u.* FROM Users u
|
||||||
WHERE u.UserType=%n AND u.UserID IN
|
WHERE u.UserType=%n AND u.UserID IN
|
||||||
(SELECT ua.UserID FROM UserAccessType ua WHERE ua.PayrollTypeID=%n)",
|
(SELECT ua.UserID FROM UserAccessType ua WHERE ua.PayrollTypeID=%n AND ua.Status<>%n)",
|
||||||
type, payrollTypeID);
|
type, payrollTypeID, (int)EnumAuthStatus.NewNotYetApprove);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IDataReader GetAll(TransactionContext tc)
|
internal static IDataReader GetAll(TransactionContext tc)
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,9 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
|
|
||||||
return tc.ExecuteReader(
|
return tc.ExecuteReader(
|
||||||
@"SELECT ur.*, u.LOGINID LoginID, u.USERNAME UserName,R.Name RoleName FROM UserRole ur,[Users] u, Role R
|
@"SELECT ur.*, u.LOGINID LoginID, u.USERNAME UserName,R.Name RoleName, u.EmployeeID employeeID,
|
||||||
|
(SELECT e.PayrollTypeID FROM Employee e WHERE e.EmployeeID = u.EmployeeID) EmpPayrollTypeID
|
||||||
|
FROM UserRole ur,[Users] u, Role R
|
||||||
WHERE ur.RoleID=r.RoleID and u.UserID =ur.UserID %q order by u.LoginID,R.Name", sqlClause);
|
WHERE ur.RoleID=r.RoleID and u.UserID =ur.UserID %q order by u.LoginID,R.Name", sqlClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +146,111 @@ namespace HRM.DA
|
||||||
tc.ExecuteNonQuery("DELETE FROM UserRole WHERE UserID=%n", nUserID);
|
tc.ExecuteNonQuery("DELETE FROM UserRole WHERE UserID=%n", nUserID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Maker-checker (Authentication > User Role Permission, UserRoleMakerChecker_DB_Changes.sql)
|
||||||
|
|
||||||
|
// UserRole.Status: Approved (5) = live; NewNotYetApprove (2) = given, not live until approved;
|
||||||
|
// DeletedNotYetApprove (3) = being taken away, still live until approved.
|
||||||
|
|
||||||
|
// Maker gives a role: it waits for approval (Status 2). CreatedBy is the maker.
|
||||||
|
internal static void InsertPending(TransactionContext tc, int userRoleID, int roleID, int userID,
|
||||||
|
int makerID, DateTime requestDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(
|
||||||
|
"INSERT INTO UserRole(UserRoleID, RoleID, UserID, EventDate, CreatedBy, Status, ComputerName, ApprovedComputerName)" +
|
||||||
|
" VALUES(%n, %n, %n, %D, %n, %n, %s, %s)",
|
||||||
|
userRoleID, roleID, userID, requestDate, makerID, (int)EnumAuthStatus.NewNotYetApprove, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every change below touches ONE UserRole row (by UserRoleID): the audit trigger dbo.truserrole
|
||||||
|
// handles a single row only, and a multi-row UPDATE fails inside it (Msg 512).
|
||||||
|
|
||||||
|
// Maker takes a live role away: it stays live (Status 3) until approved. ModifiedBy is the maker.
|
||||||
|
internal static void RequestRemoval(TransactionContext tc, int userRoleID, int makerID, DateTime requestDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(
|
||||||
|
"UPDATE UserRole SET Status=%n, ModifiedBy=%n, ModifiedDate=%D WHERE UserRoleID=%n",
|
||||||
|
(int)EnumAuthStatus.DeletedNotYetApprove, makerID, requestDate, userRoleID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker approves a given role: it becomes live. AuthorizedBy / AuthorizedDate are the checker.
|
||||||
|
internal static void ApproveRow(TransactionContext tc, int userRoleID, int approverID, DateTime approveDate)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery(
|
||||||
|
"UPDATE UserRole SET Status=%n, AuthorizedBy=%n, AuthorizedDate=%D WHERE UserRoleID=%n",
|
||||||
|
(int)EnumAuthStatus.Approved, approverID, approveDate, userRoleID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker rejects a removal: the role stays live as before.
|
||||||
|
internal static void RestoreRow(TransactionContext tc, int userRoleID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("UPDATE UserRole SET Status=%n WHERE UserRoleID=%n",
|
||||||
|
(int)EnumAuthStatus.Approved, userRoleID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker approves a removal, or rejects a given role: the row goes.
|
||||||
|
internal static void DeleteRow(TransactionContext tc, int userRoleID)
|
||||||
|
{
|
||||||
|
tc.ExecuteNonQuery("DELETE FROM UserRole WHERE UserRoleID=%n", userRoleID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inside the maker's write transaction: counts the user's changes of one role type waiting for approval
|
||||||
|
// and keeps that range locked until commit, so a second maker sending at the same moment waits here
|
||||||
|
// and then sees the first change (instead of making a second pending change).
|
||||||
|
internal static int CountPendingLocked(TransactionContext tc, int userID, EnumRoleType roleType)
|
||||||
|
{
|
||||||
|
object o = tc.ExecuteScalar(
|
||||||
|
"SELECT COUNT(*) FROM UserRole WITH (UPDLOCK, HOLDLOCK)" +
|
||||||
|
" WHERE UserID=%n AND Status IN (%n, %n) AND RoleID IN (SELECT RoleID FROM Role WHERE RoleType=%n)",
|
||||||
|
userID, (int)EnumAuthStatus.NewNotYetApprove, (int)EnumAuthStatus.DeletedNotYetApprove, (int)roleType);
|
||||||
|
return o == null || o == DBNull.Value ? 0 : Convert.ToInt32(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same idea for a Self Service employee with no login yet: counts the employee's logins and keeps them
|
||||||
|
// locked, so two makers cannot both create a login for the same employee.
|
||||||
|
internal static int CountEmployeeLoginsLocked(TransactionContext tc, int employeeID)
|
||||||
|
{
|
||||||
|
object o = tc.ExecuteScalar(
|
||||||
|
"SELECT COUNT(*) FROM Users WITH (UPDLOCK, HOLDLOCK) WHERE EmployeeID=%n AND UserType=%n",
|
||||||
|
employeeID, (int)EnumUserType.Employee);
|
||||||
|
return o == null || o == DBNull.Value ? 0 : Convert.ToInt32(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static int CountByUser(TransactionContext tc, int userID)
|
||||||
|
{
|
||||||
|
object o = tc.ExecuteScalar("SELECT COUNT(*) FROM UserRole WHERE UserID=%n", userID);
|
||||||
|
return o == null || o == DBNull.Value ? 0 : Convert.ToInt32(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserRole rows with role, person and maker for the maker-checker screens. pendingOnly: only rows
|
||||||
|
// waiting for approval (Status 2 / 3). userID / roleType narrow it to one person's roles of one type.
|
||||||
|
internal static IDataReader GetForMakerChecker(TransactionContext tc, bool pendingOnly, int? userID, EnumRoleType? roleType)
|
||||||
|
{
|
||||||
|
string clause = "";
|
||||||
|
if (pendingOnly)
|
||||||
|
clause += SQLParser.MakeSQL(" AND ur.Status IN (%n, %n)",
|
||||||
|
(int)EnumAuthStatus.NewNotYetApprove, (int)EnumAuthStatus.DeletedNotYetApprove);
|
||||||
|
if (userID.HasValue)
|
||||||
|
clause += SQLParser.MakeSQL(" AND ur.UserID=%n", userID.Value);
|
||||||
|
if (roleType.HasValue)
|
||||||
|
clause += SQLParser.MakeSQL(" AND r.RoleType=%n", (int)roleType.Value);
|
||||||
|
|
||||||
|
return tc.ExecuteReader(
|
||||||
|
@"SELECT ur.UserRoleID, ur.RoleID, ur.UserID, ur.Status, ur.CreatedBy, ur.EventDate,
|
||||||
|
ur.ModifiedBy, ur.ModifiedDate, r.Name RoleName, r.RoleType,
|
||||||
|
u.LoginID, COALESCE(e.Name, u.UserName) PersonName, u.EmployeeID,
|
||||||
|
e.EmployeeNo, e.PayrollTypeID, mk.LoginID MakerLoginID
|
||||||
|
FROM UserRole ur
|
||||||
|
JOIN Role r ON r.RoleID = ur.RoleID
|
||||||
|
JOIN Users u ON u.UserID = ur.UserID
|
||||||
|
LEFT JOIN Employee e ON e.EmployeeID = u.EmployeeID
|
||||||
|
LEFT JOIN Users mk ON mk.UserID = CASE WHEN ur.Status = %n THEN ur.ModifiedBy ELSE ur.CreatedBy END
|
||||||
|
WHERE 1 = 1 %q
|
||||||
|
ORDER BY PersonName, r.Name",
|
||||||
|
(int)EnumAuthStatus.DeletedNotYetApprove, clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
internal static void Update(TransactionContext tc, int id, EnumStatus status)
|
internal static void Update(TransactionContext tc, int id, EnumStatus status)
|
||||||
{
|
{
|
||||||
tc.ExecuteNonQuery("UPDATE UserRole SET Status = %n,AuthorizedBy=%n,AuthorizedDate=%D WHERE UserID = %n",
|
tc.ExecuteNonQuery("UPDATE UserRole SET Status = %n,AuthorizedBy=%n,AuthorizedDate=%D WHERE UserID = %n",
|
||||||
|
|
|
||||||
|
|
@ -495,6 +495,60 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A copy of CalculateTax for the Bonus Process Modify dialog (one employee, after Process has already
|
||||||
|
/// saved). The only difference: the "salary processed and not yet finalized" check looks at SALARYTEMPIT
|
||||||
|
/// only, not at BONUSTEMPIT — after Process the employee's BONUSTEMPIT rows are this same bonus's own
|
||||||
|
/// tax data, so CalculateTax would always refuse. A salary in the middle of its process still stops it.
|
||||||
|
/// CalculateTax itself is unchanged and still used by Process, Upload and CalculateBonusTax.
|
||||||
|
/// </summary>
|
||||||
|
public void CalculateTaxForModify(List<BonusProcess.BonusProcessDetail> bprocesdetails, List<Employee> oEmployees, Bonus oBonus, int payrolltypeid)
|
||||||
|
{
|
||||||
|
if (_payrolltype == null)
|
||||||
|
_payrolltype = new PayrollTypeService().Get(payrolltypeid);
|
||||||
|
|
||||||
|
if (_parameters == null)
|
||||||
|
_parameters = new BonusParameterService().Get(EnumStatus.Regardless, payrolltypeid);
|
||||||
|
|
||||||
|
if (_payrolltype.TaxParamID == null) throw new ServiceException("Current year Tax paramter setup not found.");
|
||||||
|
TaxParameter oparamter = new TaxParameterService().Get((int)_payrolltype.TaxParamID);
|
||||||
|
|
||||||
|
List<ADParameter> oParams = new ADParameterService().Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance, _payrolltype.ID);
|
||||||
|
List<IncomeTax> oTaxes = new IncomeTaxService().Get(EnumIncomeTaxDataFrom.ProcessTempData, _payrolltype.ID);
|
||||||
|
double nTaxAmount = 0;
|
||||||
|
int nCount = 0;
|
||||||
|
// salary only (SALARYTEMPIT); the employee's own bonus tax rows (BONUSTEMPIT) do not stop a Modify
|
||||||
|
IncomeTaxService taxService = new IncomeTaxService();
|
||||||
|
bool salaryProcessed = oEmployees.Any(e => e != null && taxService.hasTaxDataInSalaryTempOnly(e.ID));
|
||||||
|
if (salaryProcessed == true)
|
||||||
|
{
|
||||||
|
throw new ServiceException("Current month salary is processed and not yet finalized. Tax calculation "
|
||||||
|
+ " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax.");
|
||||||
|
}
|
||||||
|
TaxCalculator oCalculator = new TaxCalculator((int)_payrolltype.TaxParamID, _payrolltype.ID);
|
||||||
|
oCalculator.TaxParameter = oparamter;
|
||||||
|
oCalculator.payrolltype = _payrolltype;
|
||||||
|
foreach (BonusProcess.BonusProcessDetail item in bprocesdetails)
|
||||||
|
{
|
||||||
|
nCount++;
|
||||||
|
oCalculator.Employee = oEmployees.FirstOrDefault(x => x.ID == item.EmployeeID);
|
||||||
|
if (item.BonusParam == null)
|
||||||
|
{
|
||||||
|
item.BonusParam = new BonusParameterService().GetApplicableParameter(item.Employee, (int)item.Employee.GradeID, _parameters, oBonus.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.ChangeBonusAmount > 0)
|
||||||
|
{
|
||||||
|
List<TaxRawItem> oTaxRowItems = new List<TaxRawItem>();
|
||||||
|
oTaxRowItems.Add(TaxRawItem.Create(oBonus.Name, item.ChangeBonusAmount, enumIncomeTaxItemType.Bonus, item.BonusID));
|
||||||
|
nTaxAmount = 0;
|
||||||
|
item.IncomeTaxcoll = oCalculator.CalculateBonus(oTaxRowItems, item.BonusParam, ref nTaxAmount, oParams, oTaxes);
|
||||||
|
item.TaxAmount = nTaxAmount;
|
||||||
|
item.ChangeTaxAmount = nTaxAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UndoTax(BonusProcess oProcessedItems, List<Employee> oEmployees, Bonus oBonus)
|
public void UndoTax(BonusProcess oProcessedItems, List<Employee> oEmployees, Bonus oBonus)
|
||||||
{
|
{
|
||||||
if (_payrolltype.TaxParamID == null) throw new ServiceException("Current year Tax paramter setup not found.");
|
if (_payrolltype.TaxParamID == null) throw new ServiceException("Current year Tax paramter setup not found.");
|
||||||
|
|
|
||||||
|
|
@ -860,8 +860,7 @@ namespace HRM.DA
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BonusProcessDA.Update(tc, oBonusProcess);
|
BonusProcessDA.Update(tc, oBonusProcess);
|
||||||
BonusProcessDA.DeleteProcessDetailByProcessID(tc, oBonusProcess.BonusID, oBonusProcess.ID,
|
BonusProcessDA.DeleteProcessDetailByProcessID(tc, oBonusProcess.BonusID, oBonusProcess.ID, oBonusProcess.PayrollTypeID);
|
||||||
oBonusProcess.PayrollTypeID);
|
|
||||||
BonusProcessDA.DeleteEmpCostCenter(tc, oBonusProcess.ID);
|
BonusProcessDA.DeleteEmpCostCenter(tc, oBonusProcess.ID);
|
||||||
}
|
}
|
||||||
List<IncomeTax> incometaxes = new List<IncomeTax>();
|
List<IncomeTax> incometaxes = new List<IncomeTax>();
|
||||||
|
|
@ -904,6 +903,694 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Process" button: calculate the bonus (and tax) of the given employees and
|
||||||
|
/// save it in the same call — there is no separate Save step any more. Does on the server what the
|
||||||
|
/// screen used to do in three requests (BonusProcess, the tax-merge step of save(), saveBonusProcess):
|
||||||
|
/// 1. checks: bonus not approved, inputs present; employees this bonus was already processed for this
|
||||||
|
/// month are left out (the screen already leaves them out and lists them);
|
||||||
|
/// 2. CalculateBonus — the same BonusCalculator.CalCulate the old Process button called;
|
||||||
|
/// 3. tax merge — the same rule save() applied in the browser, now for every row;
|
||||||
|
/// 4. save — the same rows Save(BonusProcess) writes, in ONE transaction (all or nothing), with the
|
||||||
|
/// detail rows inserted by one bulk copy instead of one INSERT each;
|
||||||
|
/// 5. returns the saved rows, read back from the database.
|
||||||
|
/// </summary>
|
||||||
|
public BonusProcessAndSaveResult ProcessAndSave(BonusProcessAndSaveRequest request, int payrolltypeid, int userID)
|
||||||
|
{
|
||||||
|
if (request == null)
|
||||||
|
throw new ServiceException("Nothing to process.");
|
||||||
|
if (request.BonusID <= 0)
|
||||||
|
throw new ServiceException("Please select a bonus.");
|
||||||
|
if (request.EmployeeIDs == null || request.EmployeeIDs.Count == 0)
|
||||||
|
throw new ServiceException("Please select employee for the proces");
|
||||||
|
if (request.CurrProcess <= 0)
|
||||||
|
throw new ServiceException("Currently Process For Basic must be greater than zero.");
|
||||||
|
|
||||||
|
PayrollType payrollType = new PayrollTypeService().Get(payrolltypeid);
|
||||||
|
if (payrollType == null)
|
||||||
|
throw new ServiceException("Payroll type not found.");
|
||||||
|
DateTime bonusMonth = payrollType.NextPayProcessDate;
|
||||||
|
|
||||||
|
// 1. checks
|
||||||
|
if (this.IsApproved(request.BonusID, bonusMonth, payrolltypeid))
|
||||||
|
throw new ServiceException("selected Bonus is already process and Approved");
|
||||||
|
this.CheckAlreadyProcessedInMonth(request.BonusID, bonusMonth, payrolltypeid);
|
||||||
|
|
||||||
|
BonusProcessAndSaveResult result = new BonusProcessAndSaveResult();
|
||||||
|
HashSet<int> alreadyProcessed = new HashSet<int>(
|
||||||
|
(this.GetBonusDetails(payrolltypeid, request.BonusID, bonusMonth) ?? new List<BonusProcess.BonusProcessDetail>())
|
||||||
|
.Select(x => x.EmployeeID));
|
||||||
|
List<int> empIDs = new List<int>();
|
||||||
|
foreach (int id in request.EmployeeIDs.Distinct())
|
||||||
|
{
|
||||||
|
if (alreadyProcessed.Contains(id)) result.AlreadyProcessedEmployeeIDs.Add(id);
|
||||||
|
else empIDs.Add(id);
|
||||||
|
}
|
||||||
|
if (empIDs.Count == 0)
|
||||||
|
throw new ServiceException("The selected bonus is already processed for all the selected employees.");
|
||||||
|
|
||||||
|
List<Employee> employees = new EmployeeService().GetByEmpIDList(empIDs, payrolltypeid);
|
||||||
|
if (employees.Count == 0)
|
||||||
|
throw new ServiceException("Selected employees not found in the current payroll type.");
|
||||||
|
|
||||||
|
// 2. calculate (bonus, and tax when IsTaxProcess and not disbursed with salary)
|
||||||
|
BonusProcess oProcess = this.CalculateBonus(payrolltypeid, employees, request.BonusID, request.BasicMonth,
|
||||||
|
request.PayDate, request.CuttOfDate, request.CurrProcess, request.IsDisburseWithSalary, request.IsTaxProcess);
|
||||||
|
if (oProcess == null || oProcess.BonusProcessDetails == null || oProcess.BonusProcessDetails.Count == 0)
|
||||||
|
throw new ServiceException("There are no data to save");
|
||||||
|
|
||||||
|
// 3. tax merge: the bonus head's tax line carries the bonus amount, the Tax Deducted line the tax
|
||||||
|
if (request.IsTaxProcess)
|
||||||
|
ApplyTaxMerge(oProcess, employees, payrollType, request.BonusID);
|
||||||
|
|
||||||
|
// 4. save — header as saveBonusProcess set it, then the same rows Save(BonusProcess) writes
|
||||||
|
oProcess.PayrollTypeID = payrolltypeid;
|
||||||
|
oProcess.DisburseDate = request.PayDate;
|
||||||
|
oProcess.IsTaxProcess = request.IsTaxProcess;
|
||||||
|
oProcess.IsDisburseWithSalary = request.IsDisburseWithSalary;
|
||||||
|
oProcess.CreatedBy = userID;
|
||||||
|
oProcess.CreatedDate = DateTime.Today;
|
||||||
|
SaveNewProcess(oProcess);
|
||||||
|
|
||||||
|
// 5. what was saved
|
||||||
|
result.BonusProcessID = oProcess.ID;
|
||||||
|
result.Rows = this.GetGridRows(oProcess.ID);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Upload Data": the rows read from the bonus Excel file (employee + amount,
|
||||||
|
/// RegularDataUploadService.GetBonusData) are saved in the same request — what used to be upload →
|
||||||
|
/// (Tax Re-calculate) → Save, now on the server in one go:
|
||||||
|
/// 1. checks: bonus selected, pay date, not approved; every employee in the current payroll type and
|
||||||
|
/// only once in the file; employees this bonus was already processed for this month are left out;
|
||||||
|
/// 2. with IsTaxProcess, the tax of every row (the same CalculateTax "Tax Re-calculate" ran) and the
|
||||||
|
/// save() tax merge; without it the amounts are saved as they are in the file;
|
||||||
|
/// 3. the same save as the Process button (one transaction, all or nothing);
|
||||||
|
/// 4. returns the saved rows, read back from the database.
|
||||||
|
/// The header is filled the way the screen filled it after an upload (bonus month and basic month =
|
||||||
|
/// the next pay process month, disburse date = pay date).
|
||||||
|
/// </summary>
|
||||||
|
public BonusProcessAndSaveResult UploadAndSave(List<BonusProcess.BonusProcessDetail> uploadedRows,
|
||||||
|
BonusProcessAndSaveRequest request, int payrolltypeid, int userID)
|
||||||
|
{
|
||||||
|
if (request == null || request.BonusID <= 0)
|
||||||
|
throw new ServiceException("Please select a bonus.");
|
||||||
|
if (request.PayDate == DateTime.MinValue)
|
||||||
|
throw new ServiceException("Please select the pay date.");
|
||||||
|
if (uploadedRows == null || uploadedRows.Count == 0)
|
||||||
|
throw new ServiceException("No employee found in the uploaded file.");
|
||||||
|
|
||||||
|
PayrollType payrollType = new PayrollTypeService().Get(payrolltypeid);
|
||||||
|
if (payrollType == null)
|
||||||
|
throw new ServiceException("Payroll type not found.");
|
||||||
|
DateTime bonusMonth = payrollType.NextPayProcessDate;
|
||||||
|
|
||||||
|
// 1. checks
|
||||||
|
if (this.IsApproved(request.BonusID, bonusMonth, payrolltypeid))
|
||||||
|
throw new ServiceException("selected Bonus is already process and Approved");
|
||||||
|
this.CheckAlreadyProcessedInMonth(request.BonusID, bonusMonth, payrolltypeid);
|
||||||
|
|
||||||
|
List<string> problems = new List<string>();
|
||||||
|
var otherPayroll = uploadedRows.Where(x => x.Employee != null && x.Employee.PayrollTypeID != payrolltypeid)
|
||||||
|
.Select(x => x.Employee.EmployeeNo).Distinct().ToList();
|
||||||
|
if (otherPayroll.Count > 0)
|
||||||
|
problems.Add("Not in the current payroll type: " + string.Join(", ", otherPayroll));
|
||||||
|
var duplicates = uploadedRows.GroupBy(x => x.EmployeeID).Where(g => g.Count() > 1)
|
||||||
|
.Select(g => g.First().Employee?.EmployeeNo ?? g.Key.ToString()).ToList();
|
||||||
|
if (duplicates.Count > 0)
|
||||||
|
problems.Add("More than once in the file: " + string.Join(", ", duplicates));
|
||||||
|
var negative = uploadedRows.Where(x => x.BonusAmount < 0).Select(x => x.Employee?.EmployeeNo ?? x.EmployeeID.ToString()).ToList();
|
||||||
|
if (negative.Count > 0)
|
||||||
|
problems.Add("Negative amount: " + string.Join(", ", negative));
|
||||||
|
if (problems.Count > 0)
|
||||||
|
throw new ServiceException("Nothing was saved. " + string.Join(" | ", problems));
|
||||||
|
|
||||||
|
BonusProcessAndSaveResult result = new BonusProcessAndSaveResult();
|
||||||
|
HashSet<int> alreadyProcessed = new HashSet<int>(
|
||||||
|
(this.GetBonusDetails(payrolltypeid, request.BonusID, bonusMonth) ?? new List<BonusProcess.BonusProcessDetail>())
|
||||||
|
.Select(x => x.EmployeeID));
|
||||||
|
|
||||||
|
BonusProcess oProcess = new BonusProcess();
|
||||||
|
oProcess.BonusProcessDetails = new List<BonusProcess.BonusProcessDetail>();
|
||||||
|
oProcess.BonusID = request.BonusID;
|
||||||
|
oProcess.BonusMonth = bonusMonth;
|
||||||
|
oProcess.BasicOnMonth = bonusMonth;
|
||||||
|
oProcess.DisburseDate = request.PayDate;
|
||||||
|
oProcess.IsTaxProcess = request.IsTaxProcess;
|
||||||
|
oProcess.IsDisburseWithSalary = request.IsDisburseWithSalary;
|
||||||
|
oProcess.PayrollTypeID = payrolltypeid;
|
||||||
|
oProcess.CreatedBy = userID;
|
||||||
|
oProcess.CreatedDate = DateTime.Today;
|
||||||
|
|
||||||
|
List<Employee> employees = new List<Employee>();
|
||||||
|
foreach (BonusProcess.BonusProcessDetail row in uploadedRows)
|
||||||
|
{
|
||||||
|
if (alreadyProcessed.Contains(row.EmployeeID))
|
||||||
|
{
|
||||||
|
result.AlreadyProcessedEmployeeIDs.Add(row.EmployeeID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
row.BonusID = request.BonusID;
|
||||||
|
row.BonusMonth = bonusMonth;
|
||||||
|
oProcess.BonusProcessDetails.Add(row);
|
||||||
|
if (row.Employee != null) employees.Add(row.Employee);
|
||||||
|
}
|
||||||
|
if (oProcess.BonusProcessDetails.Count == 0)
|
||||||
|
throw new ServiceException("The selected bonus is already processed for all the employees in the file.");
|
||||||
|
|
||||||
|
// 2. tax (as "Tax Re-calculate" did) and the save() merge
|
||||||
|
if (request.IsTaxProcess)
|
||||||
|
{
|
||||||
|
Bonus obonus = new BonusService().Get(request.BonusID);
|
||||||
|
new BonusCalculator().CalculateTax(oProcess.BonusProcessDetails, employees, obonus, payrolltypeid);
|
||||||
|
ApplyTaxMerge(oProcess, employees, payrollType, request.BonusID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. save
|
||||||
|
SaveNewProcess(oProcess);
|
||||||
|
|
||||||
|
// 4. what was saved
|
||||||
|
result.BonusProcessID = oProcess.ID;
|
||||||
|
result.Rows = this.GetGridRows(oProcess.ID);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tax-merge rule the screen's save() applied: on every row the bonus head's tax line
|
||||||
|
/// (TaxMergeMaster of this bonus) carries the bonus amount and the Tax Deducted line the tax.
|
||||||
|
/// </summary>
|
||||||
|
private void ApplyTaxMerge(BonusProcess oProcess, List<Employee> employees, PayrollType payrollType, int bonusID)
|
||||||
|
{
|
||||||
|
// a row with no bonus gets no tax lines (CalculateTax skips it), so only rows with a bonus need them
|
||||||
|
if (oProcess.BonusProcessDetails.Any(x => x.ChangeBonusAmount > 0 && (x.IncomeTaxcoll == null || x.IncomeTaxcoll.Count == 0)))
|
||||||
|
throw new ServiceException("Tax Calculation not yet done");
|
||||||
|
if (payrollType.TaxParamID == null)
|
||||||
|
throw new ServiceException("Current year Tax paramter setup not found.");
|
||||||
|
|
||||||
|
TaxMergeMaster mitem = new TaxMergeMasterService().Get(payrollType.ID, (int)payrollType.TaxParamID,
|
||||||
|
EnumTaxMergeType.Bonus, bonusID);
|
||||||
|
if (mitem == null)
|
||||||
|
throw new ServiceException("Bonus head not found in the income tax Grouping");
|
||||||
|
|
||||||
|
Dictionary<int, Employee> empByID = employees.GroupBy(x => x.ID).ToDictionary(g => g.Key, g => g.First());
|
||||||
|
foreach (BonusProcess.BonusProcessDetail detail in oProcess.BonusProcessDetails)
|
||||||
|
{
|
||||||
|
if (detail.IncomeTaxcoll == null || detail.IncomeTaxcoll.Count == 0)
|
||||||
|
continue; // no bonus, no tax lines
|
||||||
|
IncomeTax bonusLine = detail.IncomeTaxcoll.Find(y => y.ItemGroup == mitem.ItemGroup && y.ItemID == mitem.ItemID);
|
||||||
|
if (bonusLine == null)
|
||||||
|
{
|
||||||
|
Employee emp;
|
||||||
|
empByID.TryGetValue(detail.EmployeeID, out emp);
|
||||||
|
throw new ServiceException("Income tax amount not found in the collection"
|
||||||
|
+ (emp != null ? " (" + emp.EmployeeNo + " " + emp.Name + ")" : ""));
|
||||||
|
}
|
||||||
|
bonusLine.ThisMonthAmount = detail.ChangeBonusAmount;
|
||||||
|
|
||||||
|
IncomeTax taxLine = detail.IncomeTaxcoll.Find(y => y.ItemGroup == EnumIncomeTaxItemGroup.Tax_Deducted);
|
||||||
|
if (taxLine != null)
|
||||||
|
taxLine.ThisMonthAmount = detail.ChangeTaxAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves a new bonus process in ONE transaction: the header, every detail row (one bulk copy), the
|
||||||
|
/// bonus tax data (BonusITTempData) and the employee cost-center split — the rows Save(BonusProcess)
|
||||||
|
/// writes for a new process. Sets the IDs on oProcess and its details.
|
||||||
|
/// </summary>
|
||||||
|
private void SaveNewProcess(BonusProcess oProcess)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
|
int processID = tc.GenerateID("BONUSPROCESS", "BONUSPROCESSID");
|
||||||
|
base.SetObjectID(oProcess, processID);
|
||||||
|
BonusProcessDA.Insert(tc, oProcess);
|
||||||
|
|
||||||
|
int detailID = tc.GenerateID("BONUSPROCESSDETAIL", "BonusProcessDetailID");
|
||||||
|
List<IncomeTax> incometaxes = new List<IncomeTax>();
|
||||||
|
foreach (BonusProcess.BonusProcessDetail detail in oProcess.BonusProcessDetails)
|
||||||
|
{
|
||||||
|
base.SetObjectID(detail, detailID++);
|
||||||
|
detail.BonusProcessID = oProcess.ID;
|
||||||
|
// IncomeTaxcoll null means tax process not required
|
||||||
|
if (detail.IncomeTaxcoll != null && detail.IncomeTaxcoll.Count > 0)
|
||||||
|
incometaxes.AddRange(detail.IncomeTaxcoll);
|
||||||
|
}
|
||||||
|
BonusProcessDA.InsertBulk(tc, oProcess.BonusProcessDetails);
|
||||||
|
|
||||||
|
if (incometaxes.Count > 0)
|
||||||
|
new IncomeTaxService().SaveBulk(tc, incometaxes, EnumIncomeTaxDataFrom.BonusITTempData);
|
||||||
|
|
||||||
|
SaveBonusEmpCostCenter(tc, oProcess);
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The saved rows of one bonus process, as the Bonus Process grid shows them.</summary>
|
||||||
|
public List<BonusProcessGridRow> GetGridRows(int bonusProcessID)
|
||||||
|
{
|
||||||
|
List<BonusProcessGridRow> rows = new List<BonusProcessGridRow>();
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
|
||||||
|
DataReader dr = new DataReader(BonusProcessDA.GetGridRows(tc, bonusProcessID));
|
||||||
|
while (dr.Read())
|
||||||
|
rows.Add(MapGridRow(dr));
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BonusProcessGridRow MapGridRow(DataReader dr)
|
||||||
|
{
|
||||||
|
return new BonusProcessGridRow
|
||||||
|
{
|
||||||
|
BonusProcessDetailID = dr.GetInt32("BONUSPROCESSDETAILID", 0),
|
||||||
|
BonusProcessID = dr.GetInt32("BONUSPROCESSID", 0),
|
||||||
|
BonusID = dr.GetInt32("BONUSID", 0),
|
||||||
|
EmployeeID = dr.GetInt32("EMPLOYEEID", 0),
|
||||||
|
EmployeeNo = dr.GetString("EMPLOYEENO", string.Empty),
|
||||||
|
Name = dr.GetString("NAME", string.Empty),
|
||||||
|
JoiningDate = dr.GetDateTime("JOININGDATE"),
|
||||||
|
IsConfirmed = dr.GetBoolean("ISCONFIRMED", false),
|
||||||
|
GrossSalary = dr.GetDouble("GROSSSALARY", 0),
|
||||||
|
BasicSalary = dr.GetDouble("BASICSALARY", 0),
|
||||||
|
BonusAmount = dr.GetDouble("BONUSAMOUNT", 0),
|
||||||
|
ChangeBonusAmount = dr.GetDouble("CHANGEBONUSAMOUNT", 0),
|
||||||
|
TaxAmount = dr.GetDouble("TAXAMOUNT", 0),
|
||||||
|
ChangeTaxAmount = dr.GetDouble("CHANGETAXAMOUNT", 0),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>One saved row of the Bonus Process grid (after a Modify-dialog save).</summary>
|
||||||
|
public BonusProcessGridRow GetGridRow(int bonusProcessDetailID)
|
||||||
|
{
|
||||||
|
BonusProcessGridRow row = null;
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
|
||||||
|
DataReader dr = new DataReader(BonusProcessDA.GetGridRow(tc, bonusProcessDetailID));
|
||||||
|
if (dr.Read())
|
||||||
|
row = MapGridRow(dr);
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Modify dialog (one row at a time)
|
||||||
|
|
||||||
|
/// <summary>A saved bonus row and the header fields the Modify dialog needs.</summary>
|
||||||
|
private class ModifyRow
|
||||||
|
{
|
||||||
|
public int BonusProcessDetailID;
|
||||||
|
public int BonusProcessID;
|
||||||
|
public int BonusID;
|
||||||
|
public int EmployeeID;
|
||||||
|
public double TaxAmount;
|
||||||
|
public DateTime BonusMonth;
|
||||||
|
public int PayrollTypeID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads a saved row for the Modify dialog and refuses it when it is not the current payroll type's
|
||||||
|
/// or the bonus is already approved (the same rule as the Process button).
|
||||||
|
/// </summary>
|
||||||
|
private ModifyRow GetRowForModify(int bonusProcessDetailID, int payrolltypeid)
|
||||||
|
{
|
||||||
|
ModifyRow row = null;
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
|
||||||
|
DataReader dr = new DataReader(BonusProcessDA.GetRowWithHeader(tc, bonusProcessDetailID));
|
||||||
|
if (dr.Read())
|
||||||
|
{
|
||||||
|
row = new ModifyRow
|
||||||
|
{
|
||||||
|
BonusProcessDetailID = dr.GetInt32("BONUSPROCESSDETAILID", 0),
|
||||||
|
BonusProcessID = dr.GetInt32("BONUSPROCESSID", 0),
|
||||||
|
BonusID = dr.GetInt32("BONUSID", 0),
|
||||||
|
EmployeeID = dr.GetInt32("EMPLOYEEID", 0),
|
||||||
|
TaxAmount = dr.GetDouble("TAXAMOUNT", 0),
|
||||||
|
BonusMonth = dr.GetDateTime("BONUSMONTH", DateTime.MinValue),
|
||||||
|
PayrollTypeID = dr.GetInt32("PAYROLLTYPEID", 0),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row == null)
|
||||||
|
throw new ServiceException("Bonus row not found. Please process the bonus again.");
|
||||||
|
if (row.PayrollTypeID != payrolltypeid)
|
||||||
|
throw new ServiceException("This bonus row does not belong to the current payroll type.");
|
||||||
|
if (this.IsApproved(row.BonusID, row.BonusMonth, payrolltypeid))
|
||||||
|
throw new ServiceException("selected Bonus is already process and Approved");
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tax of one row for this bonus amount — the same BonusCalculator.CalculateTax that
|
||||||
|
/// "Tax Re-calculate" (CalculateBonusTax) runs, for one employee. Returns the detail with TaxAmount,
|
||||||
|
/// ChangeTaxAmount and IncomeTaxcoll filled in.
|
||||||
|
/// </summary>
|
||||||
|
private BonusProcess.BonusProcessDetail CalculateTaxFor(ModifyRow row, double bonusAmount, int payrolltypeid)
|
||||||
|
{
|
||||||
|
Employee emp = new EmployeeService().Get(row.EmployeeID);
|
||||||
|
if (emp == null)
|
||||||
|
throw new ServiceException("Employee not found.");
|
||||||
|
|
||||||
|
BonusProcess.BonusProcessDetail detail = new BonusProcess.BonusProcessDetail();
|
||||||
|
detail.BonusID = row.BonusID;
|
||||||
|
detail.EmployeeID = row.EmployeeID;
|
||||||
|
detail.BonusMonth = row.BonusMonth;
|
||||||
|
detail.ChangeBonusAmount = bonusAmount;
|
||||||
|
detail.Employee = emp;
|
||||||
|
|
||||||
|
Bonus obonus = new BonusService().Get(row.BonusID);
|
||||||
|
// CalculateTaxForModify: CalculateTax, except that this employee's own (already saved) bonus tax rows
|
||||||
|
// do not block it — only an unfinalized salary does
|
||||||
|
new BonusCalculator().CalculateTaxForModify(new List<BonusProcess.BonusProcessDetail> { detail },
|
||||||
|
new List<Employee> { emp }, obonus, payrolltypeid);
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Modify dialog, "Calculate": the tax for this bonus amount. Nothing is saved.</summary>
|
||||||
|
public BonusProcessRowTaxResult CalculateRowTax(BonusProcessRowTaxRequest request, int payrolltypeid)
|
||||||
|
{
|
||||||
|
if (request == null || request.BonusProcessDetailID <= 0)
|
||||||
|
throw new ServiceException("Please select a bonus row.");
|
||||||
|
if (request.BonusAmount < 0)
|
||||||
|
throw new ServiceException("Bonus amount can not be negative.");
|
||||||
|
|
||||||
|
ModifyRow row = GetRowForModify(request.BonusProcessDetailID, payrolltypeid);
|
||||||
|
BonusProcess.BonusProcessDetail detail = CalculateTaxFor(row, request.BonusAmount, payrolltypeid);
|
||||||
|
return new BonusProcessRowTaxResult
|
||||||
|
{
|
||||||
|
BonusProcessDetailID = row.BonusProcessDetailID,
|
||||||
|
BonusAmount = request.BonusAmount,
|
||||||
|
TaxAmount = detail.ChangeTaxAmount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Modify dialog, "Save": saves ONE row — what Save(BonusProcess) did for every row after
|
||||||
|
/// "Tax Re-calculate", now for one employee, in one transaction:
|
||||||
|
/// - BONUSPROCESSDETAIL: ChangeBonusAmount, ChangeTaxAmount (and TaxAmount when the tax is calculated);
|
||||||
|
/// - this employee's BonusITTempData (BONUSTEMPIT) rows: deleted and written again, with the bonus
|
||||||
|
/// head's line carrying the bonus amount and the Tax Deducted line the tax (the save() merge rule).
|
||||||
|
/// With CalculateTax the tax is worked out again here (the amount the browser sent is not trusted);
|
||||||
|
/// without it the typed tax is used and the employee's existing tax rows are updated, as the old
|
||||||
|
/// screen did when a tax was typed into the grid and saved without recalculating.
|
||||||
|
/// </summary>
|
||||||
|
public BonusProcessGridRow SaveRow(BonusProcessRowSaveRequest request, int payrolltypeid, int userID)
|
||||||
|
{
|
||||||
|
if (request == null || request.BonusProcessDetailID <= 0)
|
||||||
|
throw new ServiceException("Please select a bonus row.");
|
||||||
|
if (request.BonusAmount < 0)
|
||||||
|
throw new ServiceException("Bonus amount can not be negative.");
|
||||||
|
if (!request.CalculateTax && request.TaxAmount < 0)
|
||||||
|
throw new ServiceException("Tax amount can not be negative.");
|
||||||
|
if (request.CalculateTax && request.EditedTaxAmount.HasValue && request.EditedTaxAmount.Value < 0)
|
||||||
|
throw new ServiceException("Edited tax amount can not be negative.");
|
||||||
|
|
||||||
|
ModifyRow row = GetRowForModify(request.BonusProcessDetailID, payrolltypeid);
|
||||||
|
|
||||||
|
double bonusAmount = request.BonusAmount;
|
||||||
|
double changeTaxAmount;
|
||||||
|
double taxAmount = row.TaxAmount; // the calculated tax; kept when a tax is typed in
|
||||||
|
List<IncomeTax> taxLines = null;
|
||||||
|
|
||||||
|
if (request.CalculateTax)
|
||||||
|
{
|
||||||
|
BonusProcess.BonusProcessDetail detail = CalculateTaxFor(row, bonusAmount, payrolltypeid);
|
||||||
|
// the user's "Edited Tax Amount" wins over the calculated one; TAXAMOUNT keeps the calculated tax
|
||||||
|
changeTaxAmount = request.EditedTaxAmount.HasValue ? request.EditedTaxAmount.Value : detail.ChangeTaxAmount;
|
||||||
|
taxAmount = detail.TaxAmount;
|
||||||
|
taxLines = detail.IncomeTaxcoll;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changeTaxAmount = request.TaxAmount;
|
||||||
|
List<IncomeTax> existing = new IncomeTaxService().Get(row.EmployeeID, EnumIncomeTaxDataFrom.BonusITTempData);
|
||||||
|
if (existing != null && existing.Count > 0)
|
||||||
|
taxLines = existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taxLines != null && taxLines.Count > 0)
|
||||||
|
{
|
||||||
|
PayrollType payrollType = new PayrollTypeService().Get(payrolltypeid);
|
||||||
|
if (payrollType == null || payrollType.TaxParamID == null)
|
||||||
|
throw new ServiceException("Current year Tax paramter setup not found.");
|
||||||
|
TaxMergeMaster mitem = new TaxMergeMasterService().Get(payrolltypeid, (int)payrollType.TaxParamID,
|
||||||
|
EnumTaxMergeType.Bonus, row.BonusID);
|
||||||
|
if (mitem == null)
|
||||||
|
throw new ServiceException("Bonus head not found in the income tax Grouping");
|
||||||
|
|
||||||
|
IncomeTax bonusLine = taxLines.Find(y => y.ItemGroup == mitem.ItemGroup && y.ItemID == mitem.ItemID);
|
||||||
|
if (bonusLine == null)
|
||||||
|
throw new ServiceException("Income tax amount not found in the collection");
|
||||||
|
bonusLine.ThisMonthAmount = bonusAmount;
|
||||||
|
|
||||||
|
IncomeTax taxLine = taxLines.Find(y => y.ItemGroup == EnumIncomeTaxItemGroup.Tax_Deducted);
|
||||||
|
if (taxLine != null)
|
||||||
|
taxLine.ThisMonthAmount = changeTaxAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
|
BonusProcessDA.UpdateRowAmounts(tc, row.BonusProcessDetailID, bonusAmount, changeTaxAmount, taxAmount,
|
||||||
|
userID, DateTime.Now);
|
||||||
|
|
||||||
|
if (taxLines != null && taxLines.Count > 0)
|
||||||
|
{
|
||||||
|
IncomeTaxService taxService = new IncomeTaxService();
|
||||||
|
taxService.Delete(tc, row.EmployeeID.ToString(), EnumIncomeTaxDataFrom.BonusITTempData);
|
||||||
|
taxService.SaveBulk(tc, taxLines, EnumIncomeTaxDataFrom.BonusITTempData);
|
||||||
|
}
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.GetGridRow(row.BonusProcessDetailID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Remove (one saved row, deleted straight away)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove button on a saved row: what the old Remove + Save left in the database (the employee simply
|
||||||
|
/// not saved), now deleted at once since Process already saved it — in one transaction:
|
||||||
|
/// - BONUSTEMPIT: this employee's rows (only when the process was saved with Calculate Tax);
|
||||||
|
/// - BonusEmpCostCenter: this employee's rows in this process;
|
||||||
|
/// - BONUSPROCESSDETAIL: the row;
|
||||||
|
/// - BONUSPROCESS: the header too, when that was the process's last employee.
|
||||||
|
/// Refused when the row is not found, not the current payroll type's, or the bonus is already approved
|
||||||
|
/// (the same checks as the Modify dialog). Rows not saved yet are removed in the browser only, as before.
|
||||||
|
/// </summary>
|
||||||
|
public BonusProcessRowRemoveResult RemoveRow(int bonusProcessDetailID, int payrolltypeid)
|
||||||
|
{
|
||||||
|
if (bonusProcessDetailID <= 0)
|
||||||
|
throw new ServiceException("Please select a bonus row.");
|
||||||
|
|
||||||
|
ModifyRow row = GetRowForModify(bonusProcessDetailID, payrolltypeid);
|
||||||
|
BonusProcessRowRemoveResult result = new BonusProcessRowRemoveResult
|
||||||
|
{
|
||||||
|
BonusProcessDetailID = row.BonusProcessDetailID,
|
||||||
|
BonusProcessID = row.BonusProcessID,
|
||||||
|
};
|
||||||
|
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
|
BonusProcessDA.DeleteRowBonusTempTax(tc, row.BonusProcessID, row.EmployeeID);
|
||||||
|
BonusProcessDA.DeleteRowCostCenter(tc, row.BonusProcessID, row.EmployeeID);
|
||||||
|
BonusProcessDA.DeleteRow(tc, row.BonusProcessDetailID);
|
||||||
|
|
||||||
|
if (BonusProcessDA.CountRows(tc, row.BonusProcessID) == 0)
|
||||||
|
{
|
||||||
|
BonusProcessDA.DeleteEmptyProcess(tc, row.BonusProcessID);
|
||||||
|
result.ProcessDeleted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Clear Tax (whole process, saved straight away)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Clear Tax": what the old Clear Tax + Save did, now saved at once (there is no
|
||||||
|
/// Save button any more), for every employee of the process on the screen, in one transaction:
|
||||||
|
/// - BONUSPROCESSDETAIL: CHANGETAXAMOUNT = 0 (TAXAMOUNT, the calculated tax, is kept);
|
||||||
|
/// - BONUSTEMPIT: THISMONTHAMOUNT = 0 on the Tax Deducted line (-212) of those employees.
|
||||||
|
/// Refused when the process is not the current payroll type's or the bonus is already approved.
|
||||||
|
/// The old clearTax() (browser only) is kept as it was.
|
||||||
|
/// </summary>
|
||||||
|
public List<BonusProcessGridRow> ClearTaxAndSave(int bonusProcessID, int payrolltypeid, int userID)
|
||||||
|
{
|
||||||
|
if (bonusProcessID <= 0)
|
||||||
|
throw new ServiceException("Please process the bonus first.");
|
||||||
|
|
||||||
|
int bonusID = 0;
|
||||||
|
int processPayrollTypeID = 0;
|
||||||
|
DateTime bonusMonth = DateTime.MinValue;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
DataReader dr = new DataReader(BonusProcessDA.GetProcessHeaderForClearTax(tc, bonusProcessID));
|
||||||
|
if (dr.Read())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
bonusID = dr.GetInt32("BONUSID", 0);
|
||||||
|
bonusMonth = dr.GetDateTime("BONUSMONTH", DateTime.MinValue);
|
||||||
|
processPayrollTypeID = dr.GetInt32("PAYROLLTYPEID", 0);
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
throw new ServiceException("Bonus process not found. Please process the bonus again.");
|
||||||
|
if (processPayrollTypeID != payrolltypeid)
|
||||||
|
throw new ServiceException("This bonus process does not belong to the current payroll type.");
|
||||||
|
if (this.IsApproved(bonusID, bonusMonth, payrolltypeid))
|
||||||
|
throw new ServiceException("selected Bonus is already process and Approved");
|
||||||
|
|
||||||
|
tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
|
BonusProcessDA.ClearTaxOfProcess(tc, bonusProcessID, userID, DateTime.Now);
|
||||||
|
BonusProcessDA.ClearBonusTempTaxOfProcess(tc, bonusProcessID, (int)EnumIncomeTaxItemGroup.Tax_Deducted);
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.GetGridRows(bonusProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds the employee cost-center split for every employee in the bonus process and
|
/// Builds the employee cost-center split for every employee in the bonus process and
|
||||||
/// bulk-inserts it into BonusEmpCostCenter (mirrors the SalaryEmpCostCenter handling in
|
/// bulk-inserts it into BonusEmpCostCenter (mirrors the SalaryEmpCostCenter handling in
|
||||||
|
|
@ -1157,6 +1844,36 @@ namespace HRM.DA
|
||||||
return isApproved;
|
return isApproved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen (Process and Upload): the same bonus type may be processed only once in a month.
|
||||||
|
/// Throws when this bonus already has a process in this month for this payroll type.
|
||||||
|
/// </summary>
|
||||||
|
public void CheckAlreadyProcessedInMonth(int bonusID, DateTime bonusMonth, int payrolltypeid)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
int count = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
count = BonusProcessDA.CountProcessInMonth(tc, payrolltypeid, bonusID, bonusMonth);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
if (count > 0)
|
||||||
|
throw new ServiceException("This bonus type is already processed for " + bonusMonth.ToString("MMMM yyyy") +
|
||||||
|
". The same bonus type cannot be processed twice in the same month.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public DataTable GetUnApprovedBonuses(DateTime dMonthDate, int payrollTypeID)
|
public DataTable GetUnApprovedBonuses(DateTime dMonthDate, int payrollTypeID)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1860,6 +1860,43 @@ namespace HRM.DA
|
||||||
return employees;
|
return employees;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Same as GetByEmpIDs(string, int), for any number of employees (10k+): the IDs reach SQL Server as
|
||||||
|
/// one parameter and a temp table, not as an IN list in the SQL text.
|
||||||
|
/// </summary>
|
||||||
|
public List<Employee> GetByEmpIDList(List<int> empIDs, int payrollTypeID)
|
||||||
|
{
|
||||||
|
List<Employee> employees = new List<Employee>();
|
||||||
|
if (empIDs == null || empIDs.Count == 0)
|
||||||
|
return employees;
|
||||||
|
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
|
||||||
|
DataReader dr = new DataReader(EmployeeDA.GetByEmpIDList(tc, empIDs.Distinct().ToList(), payrollTypeID));
|
||||||
|
employees = this.CreateObjects<Employee>(dr);
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Employee> GetByEmpIDs(string empIDs)
|
public List<Employee> GetByEmpIDs(string empIDs)
|
||||||
{
|
{
|
||||||
List<Employee> employees = new List<Employee>();
|
List<Employee> employees = new List<Employee>();
|
||||||
|
|
@ -1890,6 +1927,51 @@ namespace HRM.DA
|
||||||
|
|
||||||
return employees;
|
return employees;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A light Employee (EmployeeLite) for each of the given employees — an alternative to GetByEmpIDs
|
||||||
|
/// for screens that need only a few fields for thousands of employees (Bonus Process).
|
||||||
|
/// </summary>
|
||||||
|
public List<EmployeeLite> GetLiteByEmpIDs(List<int> empIDs)
|
||||||
|
{
|
||||||
|
List<EmployeeLite> items = new List<EmployeeLite>();
|
||||||
|
if (empIDs == null || empIDs.Count == 0)
|
||||||
|
return items;
|
||||||
|
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
|
||||||
|
DataReader dr = new DataReader(EmployeeDA.GetLiteByEmpIDs(tc, empIDs.Distinct().ToList()));
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
items.Add(new EmployeeLite
|
||||||
|
{
|
||||||
|
EmployeeID = dr.GetInt32("EmployeeID").Value,
|
||||||
|
IsConfirmed = dr.GetBoolean("IsConfirmed", false),
|
||||||
|
JoiningDate = dr.GetDateTime("JoiningDate")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
public void UpdateBanglaInformation(List<object> employeBanglaInfo)
|
public void UpdateBanglaInformation(List<object> employeBanglaInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,36 @@ namespace HRM.DA
|
||||||
return DataExist;
|
return DataExist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Only SALARYTEMPIT (salary processed, not yet finalized) — unlike hasTaxDataInSalaryTemp, the
|
||||||
|
/// employee's BONUSTEMPIT rows are not counted. For the Bonus Process Modify dialog.
|
||||||
|
/// </summary>
|
||||||
|
public bool hasTaxDataInSalaryTempOnly(int employeeID)
|
||||||
|
{
|
||||||
|
bool DataExist = false;
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
DataExist = IncomeTaxDA.hasTaxDataInSalaryTempOnly(tc, employeeID);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataExist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public EnumIncomeTaxDataFrom currentYeardataSource(int employeeID)
|
public EnumIncomeTaxDataFrom currentYeardataSource(int employeeID)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -329,11 +329,12 @@ namespace HRM.DA
|
||||||
public int Save(Role oRole)
|
public int Save(Role oRole)
|
||||||
{
|
{
|
||||||
TransactionContext tc = null;
|
TransactionContext tc = null;
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tc = TransactionContext.Begin(true);
|
tc = TransactionContext.Begin(true);
|
||||||
|
// Audit of the permission rows, by PermissionCode, read before they are deleted and
|
||||||
|
// re-inserted below, so each kept menu keeps who/when it was created and approved.
|
||||||
|
Dictionary<string, Role.RolePermission> existingPermissions = new Dictionary<string, Role.RolePermission>();
|
||||||
if (oRole.IsNew)
|
if (oRole.IsNew)
|
||||||
{
|
{
|
||||||
int id = tc.GenerateID("Role", "RoleID");
|
int id = tc.GenerateID("Role", "RoleID");
|
||||||
|
|
@ -344,6 +345,15 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DataReader existingReader = new DataReader(RoleDA.GetRolePermissionByRoleID(tc, oRole.ID));
|
||||||
|
while (existingReader.Read())
|
||||||
|
{
|
||||||
|
Role.RolePermission existingPermission = this.CreateRolePermissionObject(existingReader);
|
||||||
|
if (existingPermission.PermissionCode != null && !existingPermissions.ContainsKey(existingPermission.PermissionCode))
|
||||||
|
existingPermissions.Add(existingPermission.PermissionCode, existingPermission);
|
||||||
|
}
|
||||||
|
existingReader.Close();
|
||||||
|
|
||||||
RoleDA.Update(tc, oRole);
|
RoleDA.Update(tc, oRole);
|
||||||
#region Delete Children
|
#region Delete Children
|
||||||
RoleDA.Delete(tc, "RolePermission", "RoleID", oRole.ID);
|
RoleDA.Delete(tc, "RolePermission", "RoleID", oRole.ID);
|
||||||
|
|
@ -351,7 +361,6 @@ namespace HRM.DA
|
||||||
//RoleDA.Delete(tc, "RoleDesignation", "RoleID", oRole.ID);
|
//RoleDA.Delete(tc, "RoleDesignation", "RoleID", oRole.ID);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oRole.RolePermissions != null & oRole.RolePermissions.Count > 0)
|
if (oRole.RolePermissions != null & oRole.RolePermissions.Count > 0)
|
||||||
{
|
{
|
||||||
int maxID = oRole.RolePermissions.Max(x => x.ID);
|
int maxID = oRole.RolePermissions.Max(x => x.ID);
|
||||||
|
|
@ -372,11 +381,31 @@ namespace HRM.DA
|
||||||
|
|
||||||
newid = newid + 1;
|
newid = newid + 1;
|
||||||
}
|
}
|
||||||
|
// Whoever made this change: the editor, or the creator for a new role. On approval
|
||||||
|
// the controller keeps the maker in ModifiedBy, so this is still the maker.
|
||||||
|
int makerID = (oRole.ModifiedBy ?? 0) > 0 ? oRole.ModifiedBy.Value : oRole.CreatedBy;
|
||||||
foreach (Role.RolePermission rolePermission in oRole.RolePermissions)
|
foreach (Role.RolePermission rolePermission in oRole.RolePermissions)
|
||||||
{
|
{
|
||||||
rolePermission.RoleID = oRole.ID;
|
rolePermission.RoleID = oRole.ID;
|
||||||
rolePermission.CreatedBy = oRole.CreatedBy;
|
Role.RolePermission existingPermission = null;
|
||||||
rolePermission.CreatedDate = oRole.CreatedDate;
|
if (rolePermission.PermissionCode != null)
|
||||||
|
existingPermissions.TryGetValue(rolePermission.PermissionCode, out existingPermission);
|
||||||
|
if (existingPermission != null)
|
||||||
|
{
|
||||||
|
// Menu the role already had: keep its original audit.
|
||||||
|
rolePermission.CreatedBy = existingPermission.CreatedBy;
|
||||||
|
rolePermission.CreatedDate = existingPermission.CreatedDate;
|
||||||
|
rolePermission.ApproveBy = existingPermission.ApproveBy;
|
||||||
|
rolePermission.ApproveDate = existingPermission.ApproveDate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Menu added by this change.
|
||||||
|
rolePermission.CreatedBy = makerID;
|
||||||
|
rolePermission.CreatedDate = DateTime.Now;
|
||||||
|
rolePermission.ApproveBy = null;
|
||||||
|
rolePermission.ApproveDate = null;
|
||||||
|
}
|
||||||
//if (oRole.RoleStatus == EnumAuthStatus.Approved )
|
//if (oRole.RoleStatus == EnumAuthStatus.Approved )
|
||||||
//{
|
//{
|
||||||
// if (rolePermission.Status == EnumAuthStatus.DeletedNotYetApprove)
|
// if (rolePermission.Status == EnumAuthStatus.DeletedNotYetApprove)
|
||||||
|
|
@ -391,6 +420,17 @@ namespace HRM.DA
|
||||||
rolePermission.Status = EnumAuthStatus.Approved;
|
rolePermission.Status = EnumAuthStatus.Approved;
|
||||||
else
|
else
|
||||||
rolePermission.Status = EnumAuthStatus.None;
|
rolePermission.Status = EnumAuthStatus.None;
|
||||||
|
|
||||||
|
// A menu approved by this approval (new, or still pending before it) gets this
|
||||||
|
// approver; a menu that was already approved keeps its earlier approver.
|
||||||
|
bool approvedNow = existingPermission == null
|
||||||
|
|| existingPermission.Status == EnumAuthStatus.NewNotYetApprove
|
||||||
|
|| existingPermission.Status == EnumAuthStatus.EditedNotYetApprove;
|
||||||
|
if (rolePermission.Status == EnumAuthStatus.Approved && approvedNow)
|
||||||
|
{
|
||||||
|
rolePermission.ApproveBy = oRole.ApproveBy;
|
||||||
|
rolePermission.ApproveDate = oRole.ApproveDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
147
HRM.DA/Service/Users/SystemAuditHistoryService.cs
Normal file
147
HRM.DA/Service/Users/SystemAuditHistoryService.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
using Ease.Core.DataAccess;
|
||||||
|
using Ease.Core.Model;
|
||||||
|
using Ease.Core.Utility;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using HRM.BO;
|
||||||
|
|
||||||
|
namespace HRM.DA
|
||||||
|
{
|
||||||
|
public class SystemAuditHistoryService : ServiceTemplate, ISystemAuditHistoryService
|
||||||
|
{
|
||||||
|
public SystemAuditHistoryService()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MapObject(SystemAuditHistory oItem, DataReader oReader)
|
||||||
|
{
|
||||||
|
oItem.AuditType = oReader.GetString("AuditType");
|
||||||
|
oItem.AuditDate = oReader.GetDateTime("AuditDate");
|
||||||
|
oItem.LoginID = oReader.GetString("LoginID");
|
||||||
|
oItem.Name = oReader.GetString("Name");
|
||||||
|
oItem.Code = oReader.GetString("Code");
|
||||||
|
oItem.UserType = UserTypeText(oReader.GetString("UserType"));
|
||||||
|
oItem.RoleName = oReader.GetString("RoleName");
|
||||||
|
oItem.RoleType = RoleTypeText(oReader.GetInt32("RoleType"));
|
||||||
|
oItem.MenuKey = oReader.GetString("MenuKey");
|
||||||
|
oItem.MenuName = oReader.GetString("MenuName");
|
||||||
|
oItem.AccessType = oReader.GetString("AccessType");
|
||||||
|
oItem.Activities = oReader.GetString("Activities");
|
||||||
|
oItem.ActionBy = oReader.GetInt32("ActionBy");
|
||||||
|
oItem.ActionByLoginID = oReader.GetString("ActionByLoginID");
|
||||||
|
oItem.ActionByName = oReader.GetString("ActionByName");
|
||||||
|
|
||||||
|
// Z_ROLE has no activities column: show the role's status, as the other triggers write it.
|
||||||
|
int? status = oReader.GetInt32("Status");
|
||||||
|
if (string.IsNullOrWhiteSpace(oItem.Activities) && status.HasValue)
|
||||||
|
oItem.Activities = StatusText(status.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override T CreateObject<T>(DataReader oReader)
|
||||||
|
{
|
||||||
|
SystemAuditHistory oItem = new SystemAuditHistory();
|
||||||
|
MapObject(oItem, oReader);
|
||||||
|
return oItem as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same words the Z_ triggers write into "activities".
|
||||||
|
private static string StatusText(int status)
|
||||||
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case 1: return "Active";
|
||||||
|
case 2: return "New Not Yet Approve";
|
||||||
|
case 3: return "Deleted Not Yet Approve";
|
||||||
|
case 4: return "Edited Not Yet Approve";
|
||||||
|
case 5: return "Approved";
|
||||||
|
case 6: return "Locked";
|
||||||
|
case 7: return "Archived";
|
||||||
|
case 8: return "Inactive";
|
||||||
|
case 9: return "Inactive Not Yet Approve";
|
||||||
|
case 10: return "Rejected";
|
||||||
|
default: return "None";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string RoleTypeText(int? roleType)
|
||||||
|
{
|
||||||
|
if (!roleType.HasValue)
|
||||||
|
return null;
|
||||||
|
switch ((EnumRoleType)roleType.Value)
|
||||||
|
{
|
||||||
|
case EnumRoleType.Admin: return "Admin";
|
||||||
|
case EnumRoleType.Self_Service: return "Self Service";
|
||||||
|
case EnumRoleType.Mobile: return "Mobile";
|
||||||
|
default: return roleType.Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Z_USERS.usertype is the Users.UserType number as text.
|
||||||
|
private static string UserTypeText(string userType)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
if (string.IsNullOrWhiteSpace(userType) || !int.TryParse(userType.Trim(), out value))
|
||||||
|
return userType;
|
||||||
|
switch ((EnumUserType)value)
|
||||||
|
{
|
||||||
|
case EnumUserType.SuperUser: return "Super User";
|
||||||
|
case EnumUserType.User: return "User";
|
||||||
|
case EnumUserType.Employee: return "Employee";
|
||||||
|
default: return userType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Service implementation
|
||||||
|
|
||||||
|
public List<SystemAuditHistory> Get(EnumSystemAuditHistory type, DateTime dtFrom, DateTime dtTo)
|
||||||
|
{
|
||||||
|
List<SystemAuditHistory> items = new List<SystemAuditHistory>();
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
IDataReader reader;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case EnumSystemAuditHistory.Role:
|
||||||
|
reader = SystemAuditHistoryDA.GetRole(tc, dtFrom, dtTo);
|
||||||
|
break;
|
||||||
|
case EnumSystemAuditHistory.RolePermission:
|
||||||
|
reader = SystemAuditHistoryDA.GetRolePermission(tc, dtFrom, dtTo);
|
||||||
|
break;
|
||||||
|
case EnumSystemAuditHistory.User:
|
||||||
|
reader = SystemAuditHistoryDA.GetUser(tc, dtFrom, dtTo);
|
||||||
|
break;
|
||||||
|
case EnumSystemAuditHistory.UserRole:
|
||||||
|
reader = SystemAuditHistoryDA.GetUserRole(tc, dtFrom, dtTo);
|
||||||
|
break;
|
||||||
|
case EnumSystemAuditHistory.UserAccessType:
|
||||||
|
reader = SystemAuditHistoryDA.GetUserAccessType(tc, dtFrom, dtTo);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("Unknown audit history.");
|
||||||
|
}
|
||||||
|
DataReader dr = new DataReader(reader);
|
||||||
|
items = this.CreateObjects<SystemAuditHistory>(dr);
|
||||||
|
dr.Close();
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,13 @@ namespace HRM.DA
|
||||||
base.SetObjectID(oUserAccessType, oReader.GetInt32("UserAccessTypeID").Value);
|
base.SetObjectID(oUserAccessType, oReader.GetInt32("UserAccessTypeID").Value);
|
||||||
oUserAccessType.PayrollTypeID = oReader.GetInt32("PayrollTypeID").Value;
|
oUserAccessType.PayrollTypeID = oReader.GetInt32("PayrollTypeID").Value;
|
||||||
oUserAccessType.UserID = oReader.GetInt32("UserID", 0);
|
oUserAccessType.UserID = oReader.GetInt32("UserID", 0);
|
||||||
|
oUserAccessType.AccessTypeStatus = (EnumAuthStatus)oReader.GetInt32("Status", (int)EnumAuthStatus.Approved);
|
||||||
|
oUserAccessType.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
||||||
|
oUserAccessType.CreatedDate = oReader.GetDateTime("CreatedDate", DateTime.MinValue);
|
||||||
|
oUserAccessType.ModifiedBy = oReader.GetInt32("ModifiedBy");
|
||||||
|
oUserAccessType.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
||||||
|
oUserAccessType.ApprovedBy = oReader.GetInt32("ApprovedBy");
|
||||||
|
oUserAccessType.ApprovedDate = oReader.GetDateTime("ApprovedDate");
|
||||||
this.SetObjectState(oUserAccessType, Ease.Core.ObjectState.Saved);
|
this.SetObjectState(oUserAccessType, Ease.Core.ObjectState.Saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +219,178 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Maker-checker
|
||||||
|
|
||||||
|
public int RequestChange(int userID, List<int> payrollTypeIDs, int makerID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
int changed = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
DataReader dr = new DataReader(UserAccessTypeDA.GetByUserID(tc, userID));
|
||||||
|
List<UserAccessType> current = this.CreateObjects<UserAccessType>(dr);
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
if (current.Any(x => x.AccessTypeStatus == EnumAuthStatus.NewNotYetApprove
|
||||||
|
|| x.AccessTypeStatus == EnumAuthStatus.DeletedNotYetApprove))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("This user already has an access change waiting for approval.");
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
List<int> wanted = (payrollTypeIDs ?? new List<int>()).Distinct().ToList();
|
||||||
|
UserAccessTypeDA.SetAuditUser(tc, makerID);
|
||||||
|
|
||||||
|
// Newly ticked payroll type: requested, not live until approved.
|
||||||
|
foreach (int payrollTypeID in wanted.Where(p => !current.Any(c => c.PayrollTypeID == p)))
|
||||||
|
{
|
||||||
|
UserAccessType item = new UserAccessType();
|
||||||
|
item.UserID = userID;
|
||||||
|
item.PayrollTypeID = payrollTypeID;
|
||||||
|
item.AccessTypeStatus = EnumAuthStatus.NewNotYetApprove;
|
||||||
|
item.CreatedBy = makerID;
|
||||||
|
item.CreatedDate = now;
|
||||||
|
item.ApprovedBy = null;
|
||||||
|
item.ApprovedDate = null;
|
||||||
|
this.Save(tc, item);
|
||||||
|
changed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unticked live access: removal requested, still live until approved.
|
||||||
|
foreach (UserAccessType item in current.Where(c => !wanted.Contains(c.PayrollTypeID)))
|
||||||
|
{
|
||||||
|
UserAccessTypeDA.RequestRemoval(tc, item.ID, makerID, now);
|
||||||
|
changed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Approve(int userID, int approverID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
User oUser = new UserService().Get(tc, userID);
|
||||||
|
|
||||||
|
// Read before approving: the payroll types this approval newly gives access to.
|
||||||
|
List<string> newAccessNames = new List<string>();
|
||||||
|
DataReader dr = new DataReader(UserAccessTypeDA.GetPendingNewDescriptions(tc, userID));
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
string name = dr.GetString("Description");
|
||||||
|
if (!string.IsNullOrWhiteSpace(name) && !newAccessNames.Contains(name))
|
||||||
|
newAccessNames.Add(name);
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
UserAccessTypeDA.SetAuditUser(tc, approverID);
|
||||||
|
UserAccessTypeDA.Approve(tc, userID, approverID, DateTime.Now);
|
||||||
|
|
||||||
|
// The "access granted" notification now goes out when the access is really live.
|
||||||
|
if (oUser != null && oUser.EmployeeID.HasValue && newAccessNames.Any())
|
||||||
|
{
|
||||||
|
var notification = new EmployeeNotification
|
||||||
|
{
|
||||||
|
EmployeeID = oUser.EmployeeID.Value,
|
||||||
|
Header = "New Access Permission Granted",
|
||||||
|
Description = $"You have been granted access to: {string.Join(", ", newAccessNames)}.",
|
||||||
|
Link = "",
|
||||||
|
CreatedDate = DateTime.Now,
|
||||||
|
CreatedBy = approverID,
|
||||||
|
ReferenceID = oUser.ID,
|
||||||
|
IsRead = 0,
|
||||||
|
ReadDate = null,
|
||||||
|
ReadBy = null
|
||||||
|
};
|
||||||
|
new EmployeeNotificationService().Insert(tc, notification);
|
||||||
|
}
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserAccessType> GetPending()
|
||||||
|
{
|
||||||
|
List<UserAccessType> items = new List<UserAccessType>();
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
DataReader dr = new DataReader(UserAccessTypeDA.GetPending(tc));
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
UserAccessType item = this.CreateObject<UserAccessType>(dr);
|
||||||
|
item.Description = dr.GetString("PayrollTypeName");
|
||||||
|
item.LoginID = dr.GetString("UserLoginID");
|
||||||
|
item.UserName = dr.GetString("UserFullName");
|
||||||
|
item.MakerLoginID = dr.GetString("MakerLoginID");
|
||||||
|
bool isRemoval = item.AccessTypeStatus == EnumAuthStatus.DeletedNotYetApprove;
|
||||||
|
item.MakerID = isRemoval ? (item.ModifiedBy ?? 0) : item.CreatedBy;
|
||||||
|
item.RequestDate = isRemoval
|
||||||
|
? item.ModifiedDate
|
||||||
|
: (item.CreatedDate == DateTime.MinValue ? (DateTime?)null : item.CreatedDate);
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reject(int userID, int rejecterID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
UserAccessTypeDA.SetAuditUser(tc, rejecterID);
|
||||||
|
UserAccessTypeDA.Reject(tc, userID);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
internal int Save(TransactionContext tc, UserAccessType oUserAccessType)
|
internal int Save(TransactionContext tc, UserAccessType oUserAccessType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ namespace HRM.DA
|
||||||
oUserRole.ApprovedComputerName = oReader.GetString("ApprovedComputerName");
|
oUserRole.ApprovedComputerName = oReader.GetString("ApprovedComputerName");
|
||||||
oUserRole.UserRoleStatus = (EnumAuthStatus)oReader.GetInt32("Status").Value;
|
oUserRole.UserRoleStatus = (EnumAuthStatus)oReader.GetInt32("Status").Value;
|
||||||
oUserRole.employeeID = oReader.GetInt32("employeeID",true, 0) ==0? null: oReader.GetInt32("employeeID");
|
oUserRole.employeeID = oReader.GetInt32("employeeID",true, 0) ==0? null: oReader.GetInt32("employeeID");
|
||||||
|
// Only the list query (UserRoleDA.Get by role type) carries EmpPayrollTypeID: the employee's payroll type.
|
||||||
|
int empPayrollTypeID = oReader.GetInt32("EmpPayrollTypeID", true, 0);
|
||||||
|
oUserRole.payrollTypeID = empPayrollTypeID == 0 ? null : empPayrollTypeID;
|
||||||
oUserRole.loginIDView = oReader.GetString("LoginID", true, string.Empty);
|
oUserRole.loginIDView = oReader.GetString("LoginID", true, string.Empty);
|
||||||
oUserRole.userNameView = oReader.GetString("userName", true, string.Empty);
|
oUserRole.userNameView = oReader.GetString("userName", true, string.Empty);
|
||||||
oUserRole.roleNameView = oReader.GetString("roleName", true, string.Empty);
|
oUserRole.roleNameView = oReader.GetString("roleName", true, string.Empty);
|
||||||
|
|
@ -437,6 +440,467 @@ namespace HRM.DA
|
||||||
// #endregion
|
// #endregion
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
#region Maker-checker (Authentication > User Role Permission)
|
||||||
|
|
||||||
|
// UserRole.Status (UserRoleMakerChecker_DB_Changes.sql): Approved (5) = live; NewNotYetApprove (2) =
|
||||||
|
// given, not live until approved; DeletedNotYetApprove (3) = being taken away, still live until approved.
|
||||||
|
|
||||||
|
private static bool IsSelfService(UserRoleSubject subject)
|
||||||
|
{
|
||||||
|
return subject.RoleType == EnumRoleType.Self_Service;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPendingStatus(EnumAuthStatus status)
|
||||||
|
{
|
||||||
|
return status == EnumAuthStatus.NewNotYetApprove || status == EnumAuthStatus.DeletedNotYetApprove;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Self Service employee's login, if there is one: by EmployeeID first, then by
|
||||||
|
// LoginID = EmployeeNo (how older employee logins were made).
|
||||||
|
private User FindEmployeeLogin(int employeeID, string employeeNo)
|
||||||
|
{
|
||||||
|
UserService userService = new UserService();
|
||||||
|
User user = userService.Get(employeeID, EnumUserType.Employee);
|
||||||
|
if (user == null && !string.IsNullOrWhiteSpace(employeeNo))
|
||||||
|
{
|
||||||
|
User byLogin = userService.Get(employeeNo);
|
||||||
|
if (byLogin != null && byLogin.UserType == EnumUserType.Employee)
|
||||||
|
user = byLogin;
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserRole rows as the maker-checker screens show them. A row waiting for approval becomes a request:
|
||||||
|
// Status 2 = give the role (maker CreatedBy, asked on EventDate), Status 3 = take it away (maker
|
||||||
|
// ModifiedBy, asked on ModifiedDate).
|
||||||
|
private List<UserRoleRequest> ReadRows(TransactionContext tc, bool pendingOnly, int? userID, EnumRoleType? roleType)
|
||||||
|
{
|
||||||
|
List<UserRoleRequest> items = new List<UserRoleRequest>();
|
||||||
|
DataReader dr = new DataReader(UserRoleDA.GetForMakerChecker(tc, pendingOnly, userID, roleType));
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
UserRoleRequest item = new UserRoleRequest();
|
||||||
|
base.SetObjectID(item, dr.GetInt32("UserRoleID", 0));
|
||||||
|
item.Status = (EnumAuthStatus)dr.GetInt32("Status", (int)EnumAuthStatus.Approved);
|
||||||
|
bool isRemoval = item.Status == EnumAuthStatus.DeletedNotYetApprove;
|
||||||
|
item.RequestType = isRemoval ? EnumUserRoleRequestType.Remove : EnumUserRoleRequestType.Add;
|
||||||
|
item.RoleID = dr.GetInt32("RoleID", 0);
|
||||||
|
item.RoleType = (EnumRoleType)dr.GetInt32("RoleType", 0);
|
||||||
|
item.UserID = dr.GetInt32("UserID");
|
||||||
|
item.EmployeeID = dr.GetInt32("EmployeeID");
|
||||||
|
item.PayrollTypeID = dr.GetInt32("PayrollTypeID");
|
||||||
|
item.CreatedBy = isRemoval ? dr.GetInt32("ModifiedBy", 0) : dr.GetInt32("CreatedBy", 0);
|
||||||
|
item.CreatedDate = isRemoval
|
||||||
|
? dr.GetDateTime("ModifiedDate", DateTime.MinValue)
|
||||||
|
: dr.GetDateTime("EventDate", DateTime.MinValue);
|
||||||
|
item.RoleName = dr.GetString("RoleName");
|
||||||
|
item.LoginID = dr.GetString("LoginID");
|
||||||
|
item.PersonName = dr.GetString("PersonName");
|
||||||
|
item.EmployeeNo = dr.GetString("EmployeeNo");
|
||||||
|
item.MakerLoginID = dr.GetString("MakerLoginID");
|
||||||
|
this.SetObjectState(item, Ease.Core.ObjectState.Saved);
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserRoleState GetRoleState(UserRoleSubject subject)
|
||||||
|
{
|
||||||
|
UserRoleState state = new UserRoleState();
|
||||||
|
state.RoleType = subject.RoleType;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User login = null;
|
||||||
|
if (IsSelfService(subject))
|
||||||
|
{
|
||||||
|
int employeeID = subject.EmployeeID ?? 0;
|
||||||
|
Employee emp = null;
|
||||||
|
if (employeeID <= 0 && (subject.UserID ?? 0) > 0)
|
||||||
|
{
|
||||||
|
// Opened from the list by the employee's login: older logins have no EmployeeID and
|
||||||
|
// are tied to the employee only by LoginID = EmployeeNo.
|
||||||
|
User subjectLogin = new UserService().Get(subject.UserID.Value);
|
||||||
|
employeeID = subjectLogin?.EmployeeID ?? 0;
|
||||||
|
if (employeeID <= 0 && !string.IsNullOrWhiteSpace(subjectLogin?.LoginID))
|
||||||
|
emp = new EmployeeService().GetByEmployeeNo(subjectLogin.LoginID);
|
||||||
|
}
|
||||||
|
if (emp == null || emp.ID <= 0)
|
||||||
|
emp = new EmployeeService().Get(employeeID);
|
||||||
|
if (emp == null || emp.ID <= 0)
|
||||||
|
throw new InvalidOperationException("Employee not found.");
|
||||||
|
state.EmployeeID = emp.ID;
|
||||||
|
state.PayrollTypeID = emp.PayrollTypeID;
|
||||||
|
state.PersonName = emp.Name;
|
||||||
|
state.LoginID = emp.EmployeeNo;
|
||||||
|
login = FindEmployeeLogin(emp.ID, emp.EmployeeNo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
login = new UserService().Get(subject.UserID ?? 0);
|
||||||
|
if (login == null)
|
||||||
|
throw new InvalidOperationException("User not found.");
|
||||||
|
state.PersonName = login.UserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (login != null)
|
||||||
|
{
|
||||||
|
state.UserID = login.ID;
|
||||||
|
state.LoginID = login.LoginID;
|
||||||
|
state.HasLogin = true;
|
||||||
|
state.LoginWaiting = login.UserStatus == EnumAuthStatus.NewNotYetApprove;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.HasLogin)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
List<UserRoleRequest> rows = ReadRows(tc, false, state.UserID, subject.RoleType);
|
||||||
|
tc.End();
|
||||||
|
state.LiveRoleIDs = rows.Where(r => r.Status != EnumAuthStatus.NewNotYetApprove)
|
||||||
|
.Select(r => r.RoleID).Distinct().ToList();
|
||||||
|
state.Pending = rows.Where(r => IsPendingStatus(r.Status)).ToList();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RequestChange(UserRoleChangeRequest request, int makerID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
int changed = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UserRoleState state = this.GetRoleState(request);
|
||||||
|
if (state.Pending.Count > 0)
|
||||||
|
throw new InvalidOperationException("This person already has a role change waiting for approval.");
|
||||||
|
|
||||||
|
List<int> live = state.LiveRoleIDs;
|
||||||
|
List<int> wanted = (request.RoleIDs ?? new List<int>()).Distinct().ToList();
|
||||||
|
List<int> adds = wanted.Where(r => !live.Contains(r)).ToList();
|
||||||
|
List<int> removes = live.Where(r => !wanted.Contains(r)).ToList();
|
||||||
|
if (adds.Count == 0 && removes.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// A Self Service employee with no login gets one now, switched off (Status 2) until approved.
|
||||||
|
User newLogin = null;
|
||||||
|
if (IsSelfService(request) && !state.HasLogin)
|
||||||
|
{
|
||||||
|
Employee emp = new EmployeeService()
|
||||||
|
.GetByEmpIDs(state.EmployeeID.ToString(), request.PayrollTypeID ?? 0).FirstOrDefault();
|
||||||
|
if (emp == null)
|
||||||
|
throw new InvalidOperationException("Employee not found in the selected payroll type.");
|
||||||
|
newLogin = this.NewEmployeeLogin(emp, makerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
|
// Checked again inside the transaction, with a lock: another maker may be sending a change for
|
||||||
|
// the same person at this very moment.
|
||||||
|
if (newLogin != null)
|
||||||
|
{
|
||||||
|
if (UserRoleDA.CountEmployeeLoginsLocked(tc, state.EmployeeID ?? 0) > 0)
|
||||||
|
throw new InvalidOperationException("Someone else has just sent a role change for this employee. Open the employee again to see it.");
|
||||||
|
}
|
||||||
|
else if (UserRoleDA.CountPendingLocked(tc, state.UserID ?? 0, request.RoleType) > 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("This person already has a role change waiting for approval.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int userID = state.UserID ?? 0;
|
||||||
|
if (newLogin != null)
|
||||||
|
userID = new UserService().Save(tc, newLogin);
|
||||||
|
|
||||||
|
foreach (int roleID in adds)
|
||||||
|
{
|
||||||
|
UserRoleDA.InsertPending(tc, tc.GenerateID("UserRole", "UserRoleID"), roleID, userID, makerID, now);
|
||||||
|
changed++;
|
||||||
|
}
|
||||||
|
if (removes.Count > 0)
|
||||||
|
{
|
||||||
|
// One row at a time (see UserRoleDA): every live row of each role being taken away.
|
||||||
|
foreach (UserRoleRequest row in ReadRows(tc, false, userID, request.RoleType)
|
||||||
|
.Where(r => r.Status != EnumAuthStatus.NewNotYetApprove && removes.Contains(r.RoleID)))
|
||||||
|
{
|
||||||
|
UserRoleDA.RequestRemoval(tc, row.ID, makerID, now);
|
||||||
|
}
|
||||||
|
changed += removes.Count;
|
||||||
|
}
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Approve(UserRoleSubject subject, int approverID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
User loginToMail = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UserRoleState state = this.GetRoleState(subject);
|
||||||
|
if (state.Pending.Count == 0)
|
||||||
|
throw new InvalidOperationException("No role change is waiting for approval.");
|
||||||
|
int userID = state.UserID.Value;
|
||||||
|
|
||||||
|
// A login made by the maker for a Self Service employee is switched on now, and mailed as before.
|
||||||
|
if (IsSelfService(subject) && state.LoginWaiting)
|
||||||
|
{
|
||||||
|
loginToMail = new UserService().Get(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
int? notifyEmployeeID = IsSelfService(subject) ? state.EmployeeID : new UserService().Get(userID)?.EmployeeID;
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
// One row at a time (see UserRoleDA): removals go, given roles become live.
|
||||||
|
foreach (UserRoleRequest row in state.Pending)
|
||||||
|
{
|
||||||
|
if (row.RequestType == EnumUserRoleRequestType.Remove)
|
||||||
|
UserRoleDA.DeleteRow(tc, row.ID);
|
||||||
|
else
|
||||||
|
UserRoleDA.ApproveRow(tc, row.ID, approverID, now);
|
||||||
|
}
|
||||||
|
if (loginToMail != null)
|
||||||
|
UserDA.UpdateStatus(tc, userID, EnumAuthStatus.Approved, approverID, now);
|
||||||
|
|
||||||
|
foreach (UserRoleRequest req in state.Pending.Where(p => p.RequestType == EnumUserRoleRequestType.Add))
|
||||||
|
this.NotifyRoleGranted(tc, subject.RoleType, notifyEmployeeID, req.RoleName, req.ID, approverID);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loginToMail != null)
|
||||||
|
this.MailNewEmployeeLogin(loginToMail);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reject(UserRoleSubject subject, int approverID)
|
||||||
|
{
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UserRoleState state = this.GetRoleState(subject);
|
||||||
|
if (state.Pending.Count == 0)
|
||||||
|
throw new InvalidOperationException("No role change is waiting for approval.");
|
||||||
|
int userID = state.UserID.Value;
|
||||||
|
|
||||||
|
tc = TransactionContext.Begin(true);
|
||||||
|
// One row at a time (see UserRoleDA): given roles go, removals stay live.
|
||||||
|
foreach (UserRoleRequest row in state.Pending)
|
||||||
|
{
|
||||||
|
if (row.RequestType == EnumUserRoleRequestType.Remove)
|
||||||
|
UserRoleDA.RestoreRow(tc, row.ID);
|
||||||
|
else
|
||||||
|
UserRoleDA.DeleteRow(tc, row.ID);
|
||||||
|
}
|
||||||
|
// A login the maker made for this change, never switched on and now without any role, goes too.
|
||||||
|
if (IsSelfService(subject) && state.LoginWaiting && UserRoleDA.CountByUser(tc, userID) == 0)
|
||||||
|
UserDA.Delete(tc, userID);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User page rejected a new login (Status 2): its role changes waiting for approval are rejected too,
|
||||||
|
/// in the caller's transaction, exactly as User Role Permission's Reject does them (given roles go,
|
||||||
|
/// removals stay live), one row at a time (see UserRoleDA). Returns how many rows were decided.
|
||||||
|
/// </summary>
|
||||||
|
internal int RejectPendingRolesOfLogin(TransactionContext tc, int userID)
|
||||||
|
{
|
||||||
|
List<UserRoleRequest> pending = ReadRows(tc, true, userID, null);
|
||||||
|
foreach (UserRoleRequest row in pending)
|
||||||
|
{
|
||||||
|
if (row.RequestType == EnumUserRoleRequestType.Remove)
|
||||||
|
UserRoleDA.RestoreRow(tc, row.ID);
|
||||||
|
else
|
||||||
|
UserRoleDA.DeleteRow(tc, row.ID);
|
||||||
|
}
|
||||||
|
return pending.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserRoleRequest> GetPending()
|
||||||
|
{
|
||||||
|
List<UserRoleRequest> items = new List<UserRoleRequest>();
|
||||||
|
TransactionContext tc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tc = TransactionContext.Begin();
|
||||||
|
items = ReadRows(tc, true, null, null);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
#region Handle Exception
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
throw new ServiceException(e.Message, e);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The employee login the old Save created (same values), but switched off (Status 2) until the
|
||||||
|
// role change is approved.
|
||||||
|
private User NewEmployeeLogin(Employee emp, int parentUserID)
|
||||||
|
{
|
||||||
|
User userObject = new User();
|
||||||
|
userObject.LoginID = emp.EmployeeNo;
|
||||||
|
userObject.UserName = emp.Name;
|
||||||
|
userObject.Password = MakePassWord(emp.BirthDate);
|
||||||
|
userObject.ParentID = parentUserID;
|
||||||
|
userObject.PasswordHints = MakePassWord(emp.BirthDate);
|
||||||
|
userObject.EmployeeID = emp.ID;
|
||||||
|
userObject.Email = string.IsNullOrWhiteSpace(emp.EmailAddress) ? null : emp.EmailAddress.Trim();
|
||||||
|
userObject.UserStatus = EnumAuthStatus.NewNotYetApprove;
|
||||||
|
userObject.ChangePasswordAtNextLogon = true;
|
||||||
|
userObject.SISU = false;
|
||||||
|
userObject.CreatedDate = DateTime.Now;
|
||||||
|
userObject.UserType = EnumUserType.Employee;
|
||||||
|
return userObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The "role assigned" notification the old Save sent, now sent when the role is really live.
|
||||||
|
private void NotifyRoleGranted(TransactionContext tc, EnumRoleType roleType, int? employeeID, string roleName,
|
||||||
|
int userRoleID, int approverID)
|
||||||
|
{
|
||||||
|
if (!employeeID.HasValue || (roleType != EnumRoleType.Self_Service && roleType != EnumRoleType.Admin))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool hasRoleName = !string.IsNullOrWhiteSpace(roleName);
|
||||||
|
string description = roleType == EnumRoleType.Admin
|
||||||
|
? (hasRoleName ? $"You have been granted Admin access with the role: {roleName}." : "You have been granted a new Admin role.")
|
||||||
|
: (hasRoleName ? $"You have been assigned to the Self Service role: {roleName}." : "You have been assigned a new Self Service role.");
|
||||||
|
// The menu is loaded at sign-in, so the new role shows from the next sign-in.
|
||||||
|
description += " Sign out and sign in again to see it in your menu.";
|
||||||
|
|
||||||
|
var notification = new EmployeeNotification
|
||||||
|
{
|
||||||
|
EmployeeID = employeeID.Value,
|
||||||
|
Header = roleType == EnumRoleType.Admin ? "New Admin Role Assigned" : "New Self Service Role Assigned",
|
||||||
|
Description = description,
|
||||||
|
Link = "",
|
||||||
|
CreatedDate = DateTime.Now,
|
||||||
|
CreatedBy = approverID,
|
||||||
|
ReferenceID = userRoleID,
|
||||||
|
IsRead = 0,
|
||||||
|
ReadDate = null,
|
||||||
|
ReadBy = null
|
||||||
|
};
|
||||||
|
new EmployeeNotificationService().Insert(tc, notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the existing employee login e-mail (MailNewLogin: Login ID + the birth-date password) when a
|
||||||
|
/// new Self Service employee login is switched on, from either page that can do it: User Role
|
||||||
|
/// Permission approval or User page approval. Sent only while the login still has that first
|
||||||
|
/// birth-date password, i.e. it was made by User Role Permission; any other login is left alone,
|
||||||
|
/// so a wrong password is never mailed. Never throws.
|
||||||
|
/// </summary>
|
||||||
|
internal void MailNewEmployeeLogin(User login)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (login == null || login.UserType != EnumUserType.Employee)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Employee emp = null;
|
||||||
|
if ((login.EmployeeID ?? 0) > 0)
|
||||||
|
emp = new EmployeeService().Get(login.EmployeeID.Value);
|
||||||
|
if ((emp == null || emp.ID <= 0) && !string.IsNullOrWhiteSpace(login.LoginID))
|
||||||
|
emp = new EmployeeService().GetByEmployeeNo(login.LoginID);
|
||||||
|
if (emp == null || emp.ID <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string firstPassword = Ease.Core.Utility.Global.CipherFunctions.Encrypt("CeLiMiTeD.AdMIn", MakePassWord(emp.BirthDate));
|
||||||
|
if (login.Password != firstPassword)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.MailNewLogin(new List<Employee> { emp });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The login e-mail the old Save sent to newly created employee logins (now sent on approval).
|
||||||
|
private void MailNewLogin(List<Employee> oemps)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EmailSettings st = new EmailSettings();
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json");
|
||||||
|
IConfiguration Configuration = builder.Build();
|
||||||
|
Configuration.GetSection("EmailSettings").Bind(st);
|
||||||
|
foreach (Employee emp in oemps)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(emp.EmailAddress))
|
||||||
|
{
|
||||||
|
string password = MakePassWord(emp.BirthDate);
|
||||||
|
MailSender mailSender = new MailSender();
|
||||||
|
mailSender.AddTo(emp.EmailAddress);
|
||||||
|
mailSender.Subject = "Your HR software Login information";
|
||||||
|
mailSender.Body = @"Your HR software Login information are following.
|
||||||
|
<p> <b>Log-in ID : </b> " + emp.EmployeeNo + "</p>";
|
||||||
|
mailSender.Body += "<p> <b>Password : </b> " + password.Trim() + "</p>";
|
||||||
|
mailSender.ThreadSendMail(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// The roles are already approved; a mail failure must not undo that.
|
||||||
|
ExceptionLog.Write(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
internal int Save(TransactionContext tc, UserRole oUserRole, int userRoleID)
|
internal int Save(TransactionContext tc, UserRole oUserRole, int userRoleID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -809,15 +809,27 @@ namespace HRM.DA
|
||||||
TransactionContext tc = null;
|
TransactionContext tc = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// The login as it is before this change: rejecting a new Employee login (Status 2) also rejects
|
||||||
|
// its role changes waiting in User Role Permission (below), so the two never disagree.
|
||||||
|
User before = this.Get(oUser.ID);
|
||||||
|
|
||||||
tc = TransactionContext.Begin(true);
|
tc = TransactionContext.Begin(true);
|
||||||
|
|
||||||
UserDA.DoActiveAndIntacive(tc, oUser);
|
UserDA.DoActiveAndIntacive(tc, oUser);
|
||||||
|
|
||||||
|
if (before != null && before.UserType == EnumUserType.Employee
|
||||||
|
&& before.UserStatus == EnumAuthStatus.NewNotYetApprove
|
||||||
|
&& oUser.UserStatus == EnumAuthStatus.Rejected)
|
||||||
|
{
|
||||||
|
new UserRoleService().RejectPendingRolesOfLogin(tc, oUser.ID);
|
||||||
|
}
|
||||||
|
|
||||||
tc.End();
|
tc.End();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (tc != null)
|
||||||
|
tc.HandleError();
|
||||||
throw new Exception(ex.Message);
|
throw new Exception(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1046,8 +1058,13 @@ namespace HRM.DA
|
||||||
public void Approve(User oUser)
|
public void Approve(User oUser)
|
||||||
{
|
{
|
||||||
TransactionContext tc = null;
|
TransactionContext tc = null;
|
||||||
|
User before = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// The login as it is before this approval: a new login (Status 2) being switched on may need
|
||||||
|
// its login e-mail (below).
|
||||||
|
before = this.Get(oUser.ID);
|
||||||
|
|
||||||
tc = TransactionContext.Begin(true);
|
tc = TransactionContext.Begin(true);
|
||||||
UserDA.Approve(tc, oUser);
|
UserDA.Approve(tc, oUser);
|
||||||
tc.End();
|
tc.End();
|
||||||
|
|
@ -1061,6 +1078,14 @@ namespace HRM.DA
|
||||||
throw new ServiceException(e.Message, e);
|
throw new ServiceException(e.Message, e);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A new Self Service employee login (made by User Role Permission) approved here gets the same
|
||||||
|
// login e-mail it gets when its roles are approved first; MailNewEmployeeLogin decides and never throws.
|
||||||
|
if (before != null && before.UserStatus == EnumAuthStatus.NewNotYetApprove
|
||||||
|
&& oUser.UserStatus == EnumAuthStatus.Approved)
|
||||||
|
{
|
||||||
|
new UserRoleService().MailNewEmployeeLogin(before);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,8 @@ export class UserAccessType extends BaseObject
|
||||||
public description: string = "";
|
public description: string = "";
|
||||||
public userID: number;
|
public userID: number;
|
||||||
public payrollTypeNameview: string;
|
public payrollTypeNameview: string;
|
||||||
|
/** Approved (5) = live; New_Not_Yet_Approve (2) = requested, not live yet; Deleted_Not_Yet_Approve (3) = removal requested, still live. */
|
||||||
public accessTypeStatus: EnumAuthStatus;
|
public accessTypeStatus: EnumAuthStatus;
|
||||||
|
public approvedBy?: number;
|
||||||
|
public approvedDate?: Date;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,3 +48,59 @@ export class UserRole extends BaseObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---------- Maker-checker (Authentication > User Role Permission) ----------
|
||||||
|
|
||||||
|
/** What a role request asks for (EnumUserRoleRequestType on the server). */
|
||||||
|
export enum EnumUserRoleRequestType {
|
||||||
|
Add = 1,
|
||||||
|
Remove = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whose roles: an Admin user (userID) or a Self Service employee (employeeID + payrollTypeID). */
|
||||||
|
export class UserRoleSubject {
|
||||||
|
roleType: EnumRoleType;
|
||||||
|
userID?: number;
|
||||||
|
employeeID?: number;
|
||||||
|
payrollTypeID?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Maker's request: the roles (of the subject's role type) the person should have. */
|
||||||
|
export class UserRoleChangeRequest extends UserRoleSubject {
|
||||||
|
roleIDs: number[] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One UserRole row waiting for approval (Status 2 = give, 3 = take away); id is the UserRoleID. */
|
||||||
|
export class UserRoleRequest {
|
||||||
|
id: number;
|
||||||
|
requestType: EnumUserRoleRequestType;
|
||||||
|
roleID: number;
|
||||||
|
roleType: EnumRoleType;
|
||||||
|
userID?: number;
|
||||||
|
employeeID?: number;
|
||||||
|
payrollTypeID?: number;
|
||||||
|
status: EnumAuthStatus;
|
||||||
|
createdBy: number;
|
||||||
|
createdDate: Date;
|
||||||
|
roleName: string;
|
||||||
|
loginID: string;
|
||||||
|
personName: string;
|
||||||
|
employeeNo: string;
|
||||||
|
makerLoginID: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A person's roles of one role type, as the page shows them. */
|
||||||
|
export class UserRoleState {
|
||||||
|
roleType: EnumRoleType;
|
||||||
|
userID?: number;
|
||||||
|
employeeID?: number;
|
||||||
|
payrollTypeID?: number;
|
||||||
|
loginID: string;
|
||||||
|
personName: string;
|
||||||
|
/** False for a Self Service employee who has no login yet (one is made when a change is sent). */
|
||||||
|
hasLogin: boolean;
|
||||||
|
/** The login was made for a change still waiting for approval: it cannot sign in yet. */
|
||||||
|
loginWaiting: boolean;
|
||||||
|
liveRoleIDs: number[] = [];
|
||||||
|
pending: UserRoleRequest[] = [];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,3 +47,31 @@ export class BadLoginAttemptInfo extends BaseObject {
|
||||||
this.userName = '';
|
this.userName = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Which change history the System Audit Log page asks for (HRM.BO EnumSystemAuditHistory). */
|
||||||
|
export enum EnumSystemAuditHistory {
|
||||||
|
Role = 1,
|
||||||
|
RolePermission = 2,
|
||||||
|
User = 3,
|
||||||
|
UserRole = 4,
|
||||||
|
UserAccessType = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One row of a page's change history (Z_ table), as returned by api/Authentication/getSystemAuditHistory. */
|
||||||
|
export interface SystemAuditHistory {
|
||||||
|
auditType: string;
|
||||||
|
auditDate: Date;
|
||||||
|
loginID: string;
|
||||||
|
name: string;
|
||||||
|
code: string;
|
||||||
|
userType: string;
|
||||||
|
roleName: string;
|
||||||
|
roleType: string;
|
||||||
|
menuKey: string;
|
||||||
|
menuName: string;
|
||||||
|
accessType: string;
|
||||||
|
activities: string;
|
||||||
|
actionBy: number;
|
||||||
|
actionByLoginID: string;
|
||||||
|
actionByName: string;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
// A light Employee: only the few fields screens working on thousands of employees at once need
|
||||||
|
// (api/Employee/getEmployeeLiteByEmpIDs). Mirrors HRM.BO.EmployeeLite — add a field in both.
|
||||||
|
export class EmployeeLite {
|
||||||
|
public employeeID: number;
|
||||||
|
public isConfirmed: boolean;
|
||||||
|
public joiningDate: Date;
|
||||||
|
}
|
||||||
|
|
@ -31,6 +31,8 @@ export class BonusProcess extends BaseObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BonusProcessDetail {
|
export class BonusProcessDetail {
|
||||||
|
// the saved row's BONUSPROCESSDETAILID (set on rows that came back from api/Bonus/processAndSave)
|
||||||
|
bonusProcessDetailID?: number;
|
||||||
isProjectedBonus: boolean;
|
isProjectedBonus: boolean;
|
||||||
bonusProcessID: number;
|
bonusProcessID: number;
|
||||||
bonusID: number;
|
bonusID: number;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
// api/Bonus/processAndSave — mirrors HRM.BO BonusProcessAndSave.cs (add a field in both).
|
||||||
|
|
||||||
|
// What the Process button sends: the header and the employee IDs only.
|
||||||
|
export interface BonusProcessAndSaveRequest {
|
||||||
|
bonusID: number;
|
||||||
|
basicMonth: Date;
|
||||||
|
payDate: Date;
|
||||||
|
cuttOfDate: Date;
|
||||||
|
currProcess: number;
|
||||||
|
isDisburseWithSalary: boolean;
|
||||||
|
isTaxProcess: boolean;
|
||||||
|
employeeIDs: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// One saved row of the Bonus Process grid, read back from the database.
|
||||||
|
export interface BonusProcessGridRow {
|
||||||
|
bonusProcessDetailID: number;
|
||||||
|
bonusProcessID: number;
|
||||||
|
bonusID: number;
|
||||||
|
employeeID: number;
|
||||||
|
employeeNo: string;
|
||||||
|
name: string;
|
||||||
|
joiningDate: Date;
|
||||||
|
isConfirmed: boolean;
|
||||||
|
grossSalary: number;
|
||||||
|
basicSalary: number;
|
||||||
|
bonusAmount: number;
|
||||||
|
changeBonusAmount: number;
|
||||||
|
taxAmount: number;
|
||||||
|
changeTaxAmount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify dialog, Calculate (api/Bonus/calculateRowTax): nothing is saved
|
||||||
|
export interface BonusProcessRowTaxRequest {
|
||||||
|
bonusProcessDetailID: number;
|
||||||
|
bonusAmount: number;
|
||||||
|
}
|
||||||
|
export interface BonusProcessRowTaxResult {
|
||||||
|
bonusProcessDetailID: number;
|
||||||
|
bonusAmount: number;
|
||||||
|
taxAmount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify dialog, Save (api/Bonus/saveRow): with calculateTax the server works the tax out again
|
||||||
|
export interface BonusProcessRowSaveRequest {
|
||||||
|
bonusProcessDetailID: number;
|
||||||
|
bonusAmount: number;
|
||||||
|
taxAmount: number;
|
||||||
|
calculateTax: boolean;
|
||||||
|
// "Edited Tax Amount": with calculateTax, the tax the user settled on (saved as changeTaxAmount); undefined = the calculated tax
|
||||||
|
editedTaxAmount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BonusProcessAndSaveResult {
|
||||||
|
bonusProcessID: number;
|
||||||
|
rows: BonusProcessGridRow[];
|
||||||
|
// employees left out because this bonus was already processed for them this month
|
||||||
|
alreadyProcessedEmployeeIDs: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove on a saved row (api/Bonus/removeRow/{id}): processDeleted = it was the last employee, the header is gone too
|
||||||
|
export interface BonusProcessRowRemoveResult {
|
||||||
|
bonusProcessDetailID: number;
|
||||||
|
bonusProcessID: number;
|
||||||
|
processDeleted: boolean;
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
|
||||||
import {ApiService} from '../../app.api.service';
|
import {ApiService} from '../../app.api.service';
|
||||||
import {HttpClient, HttpEvent, HttpRequest} from '@angular/common/http';
|
import {HttpClient, HttpEvent, HttpRequest} from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { BonusProcessAndSaveRequest, BonusProcessAndSaveResult } from '../../_models/Payroll/bonusProcessAndSave';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
|
@ -35,6 +36,15 @@ export class DataUploadService {
|
||||||
return this.http.request<any>(req);
|
return this.http.request<any>(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bonus Process, Upload Data: the file is read AND saved (with the tax when asked) in one request.
|
||||||
|
// header = the same fields the Process button sends (api/dataUpload/uploadBonusFileAndSave)
|
||||||
|
public uploadBonusFileAndSave(selectedFile: File, header: BonusProcessAndSaveRequest): Observable<BonusProcessAndSaveResult> {
|
||||||
|
const formData: FormData = new FormData();
|
||||||
|
formData.append('excelfile', selectedFile);
|
||||||
|
formData.append('header', JSON.stringify(header));
|
||||||
|
return this.http.post<BonusProcessAndSaveResult>(`${this.apiService.base_url + '/'}dataUpload/uploadBonusFileAndSave`, formData);
|
||||||
|
}
|
||||||
|
|
||||||
public uploadBonusFile(selectedFile: File, payrolltypeid: number):
|
public uploadBonusFile(selectedFile: File, payrolltypeid: number):
|
||||||
Observable<HttpEvent<any>> {
|
Observable<HttpEvent<any>> {
|
||||||
const formData: FormData = new FormData();
|
const formData: FormData = new FormData();
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ import { HRMNotificationService } from '../../app.notification.service';
|
||||||
import { Role, RolePermission } from '../../_models/Authentication/role';
|
import { Role, RolePermission } from '../../_models/Authentication/role';
|
||||||
import { SearchEmployee } from '../../_models/Employee/searchEmployee';
|
import { SearchEmployee } from '../../_models/Employee/searchEmployee';
|
||||||
import { PayrollType } from '../../_models/Authentication/payrollType';
|
import { PayrollType } from '../../_models/Authentication/payrollType';
|
||||||
import { UserRole } from '../../_models/Authentication/UserRole';
|
import { UserRole, UserRoleChangeRequest, UserRoleRequest, UserRoleState, UserRoleSubject } from '../../_models/Authentication/UserRole';
|
||||||
import { UserAccessType } from '../../_models/Authentication/UserAccessType';
|
import { UserAccessType } from '../../_models/Authentication/UserAccessType';
|
||||||
import { PasswordHistory } from '../../_models/Authentication/passwordHistory';
|
import { PasswordHistory } from '../../_models/Authentication/passwordHistory';
|
||||||
import { UserLogInInfo, BadLoginAttemptInfo } from '../../_models/Authentication/auditTrail';
|
import { UserLogInInfo, BadLoginAttemptInfo, EnumSystemAuditHistory, SystemAuditHistory } from '../../_models/Authentication/auditTrail';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Bookmark } from '../../_models/Basic/bookmark';
|
import { Bookmark } from '../../_models/Basic/bookmark';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
@ -146,6 +146,10 @@ export class AuthService {
|
||||||
return this.apiService.httpGet<BadLoginAttemptInfo[]>('/Authentication/getBadLoginAuditTrail/' +
|
return this.apiService.httpGet<BadLoginAttemptInfo[]>('/Authentication/getBadLoginAuditTrail/' +
|
||||||
this.apiService.getApiDateString(fromDate) + '/' + this.apiService.getApiDateString(toDate));
|
this.apiService.getApiDateString(fromDate) + '/' + this.apiService.getApiDateString(toDate));
|
||||||
}
|
}
|
||||||
|
getSystemAuditHistory(type: EnumSystemAuditHistory, fromDate: Date, toDate: Date) {
|
||||||
|
return this.apiService.httpGet<SystemAuditHistory[]>('/Authentication/getSystemAuditHistory/' + type + '/' +
|
||||||
|
this.apiService.getApiDateString(fromDate) + '/' + this.apiService.getApiDateString(toDate));
|
||||||
|
}
|
||||||
getBookmarks() {
|
getBookmarks() {
|
||||||
return this.apiService.httpGet<Bookmark[]>('/Authentication/getBookmarks');
|
return this.apiService.httpGet<Bookmark[]>('/Authentication/getBookmarks');
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +209,31 @@ export class AuthService {
|
||||||
saveUserRole(params: any) {
|
saveUserRole(params: any) {
|
||||||
return this.apiService.httpPost<number>('/Authentication/saveUserRole', params);
|
return this.apiService.httpPost<number>('/Authentication/saveUserRole', params);
|
||||||
}
|
}
|
||||||
|
// ---------- User Role Permission maker-checker ----------
|
||||||
|
GetUserRoleState(roleType: EnumRoleType, userID?: number, employeeID?: number) {
|
||||||
|
return this.apiService.httpGet<UserRoleState>('/Authentication/GetUserRoleState/' + roleType + '/'
|
||||||
|
+ (userID ?? 0) + '/' + (employeeID ?? 0));
|
||||||
|
}
|
||||||
|
SaveUserRoleRequest(request: UserRoleChangeRequest) {
|
||||||
|
return this.apiService.httpPost<boolean>('/Authentication/SaveUserRoleRequest', request);
|
||||||
|
}
|
||||||
|
ApproveUserRole(subject: UserRoleSubject) {
|
||||||
|
return this.apiService.httpPost<boolean>('/Authentication/ApproveUserRole', subject);
|
||||||
|
}
|
||||||
|
RejectUserRole(subject: UserRoleSubject) {
|
||||||
|
return this.apiService.httpPost<boolean>('/Authentication/RejectUserRole', subject);
|
||||||
|
}
|
||||||
|
/** Returns { done: number, failed: { index, message }[] } (index into the list sent). */
|
||||||
|
ApproveUserRoles(subjects: UserRoleSubject[]) {
|
||||||
|
return this.apiService.httpPost<any>('/Authentication/ApproveUserRoles', subjects);
|
||||||
|
}
|
||||||
|
/** Returns { done: number, failed: { index, message }[] } (index into the list sent). */
|
||||||
|
RejectUserRoles(subjects: UserRoleSubject[]) {
|
||||||
|
return this.apiService.httpPost<any>('/Authentication/RejectUserRoles', subjects);
|
||||||
|
}
|
||||||
|
GetPendingUserRoles() {
|
||||||
|
return this.apiService.httpGet<UserRoleRequest[]>('/Authentication/GetPendingUserRoles');
|
||||||
|
}
|
||||||
GetAllPayrollTypes() {
|
GetAllPayrollTypes() {
|
||||||
return this.apiService.httpGet<PayrollType[]>('/Authentication/GetAllPayrollTypes');
|
return this.apiService.httpGet<PayrollType[]>('/Authentication/GetAllPayrollTypes');
|
||||||
}
|
}
|
||||||
|
|
@ -231,6 +260,23 @@ export class AuthService {
|
||||||
return this.apiService.httpPost<boolean>('/Authentication/SaveUserAccessType', acesssTypes);
|
return this.apiService.httpPost<boolean>('/Authentication/SaveUserAccessType', acesssTypes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ApproveUserAccessType(userID: number) {
|
||||||
|
return this.apiService.httpPost<boolean>('/Authentication/ApproveUserAccessType/' + userID, {});
|
||||||
|
}
|
||||||
|
RejectUserAccessType(userID: number) {
|
||||||
|
return this.apiService.httpPost<boolean>('/Authentication/RejectUserAccessType/' + userID, {});
|
||||||
|
}
|
||||||
|
GetPendingUserAccessTypes() {
|
||||||
|
return this.apiService.httpGet<UserAccessType[]>('/Authentication/GetPendingUserAccessTypes');
|
||||||
|
}
|
||||||
|
/** Returns { done: number, failed: { userID, message }[] }. */
|
||||||
|
ApproveUserAccessTypes(userIDs: number[]) {
|
||||||
|
return this.apiService.httpPost<any>('/Authentication/ApproveUserAccessTypes', userIDs);
|
||||||
|
}
|
||||||
|
/** Returns { done: number, failed: { userID, message }[] }. */
|
||||||
|
RejectUserAccessTypes(userIDs: number[]) {
|
||||||
|
return this.apiService.httpPost<any>('/Authentication/RejectUserAccessTypes', userIDs);
|
||||||
|
}
|
||||||
changePassword(userData: any) {
|
changePassword(userData: any) {
|
||||||
return this.apiService.httpPost<any>('/Authentication/changePassword', userData);
|
return this.apiService.httpPost<any>('/Authentication/changePassword', userData);
|
||||||
}
|
}
|
||||||
|
|
@ -297,4 +343,7 @@ export class AuthService {
|
||||||
getIsFromUser(): boolean {
|
getIsFromUser(): boolean {
|
||||||
return this.isFromUserSubject.value;
|
return this.isFromUserSubject.value;
|
||||||
}
|
}
|
||||||
|
CipherMechanism(userData: any) {
|
||||||
|
return this.apiService.httpPost<any>('/Authentication/CipherMechanism', userData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {TrainingType} from '../../_models/Basic/trainingType';
|
||||||
import {EducationType} from '../../_models/HRBasic/education-type';
|
import {EducationType} from '../../_models/HRBasic/education-type';
|
||||||
import {NominationPurpose} from '../../_models/HRBasic/nomination-purpose';
|
import {NominationPurpose} from '../../_models/HRBasic/nomination-purpose';
|
||||||
import {Employee} from '../../_models/Employee/employee';
|
import {Employee} from '../../_models/Employee/employee';
|
||||||
|
import {EmployeeLite} from '../../_models/Employee/employeeLite';
|
||||||
import {EmployeeBankAccount} from '../../_models/Employee/employeeBankAccount';
|
import {EmployeeBankAccount} from '../../_models/Employee/employeeBankAccount';
|
||||||
import {EmployeeCostCenter} from '../../_models/Employee/employeeCostCenter';
|
import {EmployeeCostCenter} from '../../_models/Employee/employeeCostCenter';
|
||||||
import {Relation} from '../../_models/HRBasic/relation';
|
import {Relation} from '../../_models/HRBasic/relation';
|
||||||
|
|
@ -138,6 +139,11 @@ export class EmployeeServices {
|
||||||
getEmployeesByEmpIDs(data: any) {
|
getEmployeesByEmpIDs(data: any) {
|
||||||
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeesByEmpIDs', data);
|
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeesByEmpIDs', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A light Employee (only a few fields) — light enough for 10k+ employees (Bonus Process).
|
||||||
|
getEmployeeLiteByEmpIDs(empIds: number[]) {
|
||||||
|
return this.apiService.httpPost<EmployeeLite[]>('/Employee/getEmployeeLiteByEmpIDs', empIds);
|
||||||
|
}
|
||||||
getEmployeeDetailByEmpIDs(data: any) {
|
getEmployeeDetailByEmpIDs(data: any) {
|
||||||
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeeDetailByEmpIDs', data);
|
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeeDetailByEmpIDs', data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import { ProductionBonusSetup } from '../../_models/Payroll/ProductionBonus/prod
|
||||||
import { ProductionBonusSetupComponent } from 'src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component';
|
import { ProductionBonusSetupComponent } from 'src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component';
|
||||||
import { ProdBonusLine } from 'src/app/_models/Payroll/ProductionBonus/prodBonusLine';
|
import { ProdBonusLine } from 'src/app/_models/Payroll/ProductionBonus/prodBonusLine';
|
||||||
import { Employee } from 'src/app/_models/Employee/employee';
|
import { Employee } from 'src/app/_models/Employee/employee';
|
||||||
|
import { BonusProcessAndSaveRequest, BonusProcessAndSaveResult, BonusProcessGridRow, BonusProcessRowSaveRequest,
|
||||||
|
BonusProcessRowTaxRequest, BonusProcessRowTaxResult, BonusProcessRowRemoveResult } from 'src/app/_models/Payroll/bonusProcessAndSave';
|
||||||
import { ProdBonusAttn } from 'src/app/_models/Payroll/ProductionBonus/prodBonusAttn';
|
import { ProdBonusAttn } from 'src/app/_models/Payroll/ProductionBonus/prodBonusAttn';
|
||||||
import { ProdBonusProcess } from 'src/app/_models/Payroll/ProductionBonus/prodBonusProcess';
|
import { ProdBonusProcess } from 'src/app/_models/Payroll/ProductionBonus/prodBonusProcess';
|
||||||
import { PRBCalculation, PRBCalculationReport, PRBKpi } from '../../_models/Payroll/prbCalculation';
|
import { PRBCalculation, PRBCalculationReport, PRBKpi } from '../../_models/Payroll/prbCalculation';
|
||||||
|
|
@ -44,6 +46,23 @@ export class BonusService {
|
||||||
saveBonusProcess(param: any) {
|
saveBonusProcess(param: any) {
|
||||||
return this.apiService.httpPost<any>('/Bonus/saveBonusProcess/', param);
|
return this.apiService.httpPost<any>('/Bonus/saveBonusProcess/', param);
|
||||||
}
|
}
|
||||||
|
// Process button: calculates and saves in one request; returns the saved rows (see BonusProcessService.ProcessAndSave)
|
||||||
|
processAndSave(param: BonusProcessAndSaveRequest) {
|
||||||
|
return this.apiService.httpPost<BonusProcessAndSaveResult>('/Bonus/processAndSave', param);
|
||||||
|
}
|
||||||
|
// Modify dialog: tax of one saved row (nothing saved), and saving one row
|
||||||
|
calculateRowTax(param: BonusProcessRowTaxRequest) {
|
||||||
|
return this.apiService.httpPost<BonusProcessRowTaxResult>('/Bonus/calculateRowTax', param);
|
||||||
|
}
|
||||||
|
saveRow(param: BonusProcessRowSaveRequest) {
|
||||||
|
return this.apiService.httpPost<BonusProcessGridRow>('/Bonus/saveRow', param);
|
||||||
|
}
|
||||||
|
clearTaxAndSave(bonusProcessID: number) {
|
||||||
|
return this.apiService.httpPost<BonusProcessGridRow[]>('/Bonus/clearTaxAndSave/' + bonusProcessID, {});
|
||||||
|
}
|
||||||
|
removeRow(bonusProcessDetailID: number) {
|
||||||
|
return this.apiService.httpPost<BonusProcessRowRemoveResult>('/Bonus/removeRow/' + bonusProcessDetailID, {});
|
||||||
|
}
|
||||||
GetUnApprovedBonusses() {
|
GetUnApprovedBonusses() {
|
||||||
return this.apiService.httpGet<any>('/Bonus/GetUnApprovedBonusses' );
|
return this.apiService.httpGet<any>('/Bonus/GetUnApprovedBonusses' );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { UserAccessTypeComponent } from './user-access-type/user-access-type.com
|
||||||
import {ChangePasswordComponent} from './change-password/change-password.component';
|
import {ChangePasswordComponent} from './change-password/change-password.component';
|
||||||
import { DataPermssionComponent } from './data-permssion/data-permssion.component';
|
import { DataPermssionComponent } from './data-permssion/data-permssion.component';
|
||||||
import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component';
|
import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component';
|
||||||
|
import { CipherEngineComponent } from './cipher-engine/cipher-engine.component';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22,6 +23,7 @@ export const routes: Routes = [
|
||||||
{ path: 'change-password', component: ChangePasswordComponent, canActivate: [AuthGuard] },
|
{ path: 'change-password', component: ChangePasswordComponent, canActivate: [AuthGuard] },
|
||||||
{ path: 'data-permssion', component: DataPermssionComponent, canActivate: [AuthGuard] },
|
{ path: 'data-permssion', component: DataPermssionComponent, canActivate: [AuthGuard] },
|
||||||
{ path: 'system-auditlog', component: SystemAuditTrailComponent, canActivate: [AuthGuard] },
|
{ path: 'system-auditlog', component: SystemAuditTrailComponent, canActivate: [AuthGuard] },
|
||||||
|
{ path: 'cipher-engine', component: CipherEngineComponent, canActivate: [AuthGuard] },
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ import { KENDO_TREEVIEW } from '@progress/kendo-angular-treeview';
|
||||||
import { LayoutModule } from '@progress/kendo-angular-layout';
|
import { LayoutModule } from '@progress/kendo-angular-layout';
|
||||||
import { ExcelExportModule } from '@progress/kendo-angular-excel-export';
|
import { ExcelExportModule } from '@progress/kendo-angular-excel-export';
|
||||||
import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component';
|
import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component';
|
||||||
|
import { CipherEngineComponent } from './cipher-engine/cipher-engine.component';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
@ -225,7 +226,8 @@ import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail
|
||||||
ChangePasswordComponent,
|
ChangePasswordComponent,
|
||||||
UserComponent,
|
UserComponent,
|
||||||
DataPermssionComponent,
|
DataPermssionComponent,
|
||||||
SystemAuditTrailComponent
|
SystemAuditTrailComponent,
|
||||||
|
CipherEngineComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AppWindowPopUp,
|
AppWindowPopUp,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<app-loading-panel> </app-loading-panel>
|
||||||
|
|
||||||
|
<div class="card grid marginBottomNone" style="margin: auto;">
|
||||||
|
<div class="col-12" style="margin: auto;">
|
||||||
|
<div class="textarea-wrapper">
|
||||||
|
<textarea [(ngModel)]="decryptedvalue"
|
||||||
|
rows="4" class="encryptTextArea"
|
||||||
|
placeholder="Enter text to encrypt..."></textarea>
|
||||||
|
<button *ngIf="decryptedvalue" type="button" class="clear-btn" title="clear" (click)="clearInput()">✖</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid" style="margin: auto;">
|
||||||
|
<div class="col-12" style="margin: auto;" align="middle">
|
||||||
|
<div class="textarea-wrapper">
|
||||||
|
<button kendoButton themeColor="primary"
|
||||||
|
(click)="CipherMechanism()"
|
||||||
|
(keydown.enter)="handleEnterKey($event)"
|
||||||
|
[svgIcon]="apiService.KendoSVGIcon['forward']">Execute</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card grid" style="margin: auto;">
|
||||||
|
<div class="col-12" style="margin: auto;">
|
||||||
|
<div class="textarea-wrapper">
|
||||||
|
<textarea [(ngModel)]="encryptedValue" readonly="true" placeholder="Encrypt text will appear here..."
|
||||||
|
rows="6" class="decryptTextArea">
|
||||||
|
</textarea>
|
||||||
|
<button *ngIf="encryptedValue" [svgIcon]="apiService.KendoSVGIcon['copy']" kendoButton class="copy-btn" title="Copy" (click)="copyDecryptValueToClipboard()"></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
.textarea-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
textarea.encryptTextArea {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 0.75rem 2.5rem 0.75rem 0.75rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
resize: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 78%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
textarea.decryptTextArea {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 0.75rem 2.5rem 0.75rem 0.75rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
resize: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 78%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.clear-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #888;
|
||||||
|
z-index: 10;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
.clear-btn:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.copy-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 17%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #888;
|
||||||
|
z-index: 10;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
.copy-btn:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginBottomNone{
|
||||||
|
margin-bottom: 0px !important;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { loadingPanelService } from './../../hrm-loding panel/loding.panel.service';
|
||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import { AuthService } from 'src/app/_services/auth/auth.service';
|
||||||
|
import { ApiService } from 'src/app/app.api.service';
|
||||||
|
import { HRMNotificationService } from 'src/app/app.notification.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-cipher-engine',
|
||||||
|
templateUrl: './cipher-engine.component.html',
|
||||||
|
styleUrl: './cipher-engine.component.scss',
|
||||||
|
standalone: false,
|
||||||
|
})
|
||||||
|
export class CipherEngineComponent implements OnInit{
|
||||||
|
constructor(public notificationService: HRMNotificationService,
|
||||||
|
public authService: AuthService, public apiService: ApiService,
|
||||||
|
public loadingPanelService : loadingPanelService) {
|
||||||
|
this.apiService.selectedMenuName = 'Cipher Engine';
|
||||||
|
}
|
||||||
|
|
||||||
|
decryptedvalue : any = "";
|
||||||
|
encryptedValue : any = "";
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.decryptedvalue = "";
|
||||||
|
this.encryptedValue = "";
|
||||||
|
}
|
||||||
|
clearInput() {
|
||||||
|
this.decryptedvalue = "";
|
||||||
|
}
|
||||||
|
handleEnterKey(event: KeyboardEvent): void {
|
||||||
|
event.preventDefault();
|
||||||
|
if (this.encryptedValue?.trim()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CipherMechanism(){
|
||||||
|
if(!this.decryptedvalue){
|
||||||
|
this.notificationService.showWarning("Please enter text to encrypt first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
decryptedvalue : this.decryptedvalue
|
||||||
|
}
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.authService.CipherMechanism(data).subscribe(
|
||||||
|
(resp: any) => {
|
||||||
|
this.encryptedValue = resp as string;
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err.error);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
copyDecryptValueToClipboard(){
|
||||||
|
if (!this.encryptedValue) return;
|
||||||
|
navigator.clipboard.writeText(this.encryptedValue).catch(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -121,7 +121,7 @@ export class RolePermissionEntryComponent implements OnInit {
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
this.loadingpanelService.ShowLoadingPanel = true;
|
this.loadingpanelService.ShowLoadingPanel = false;
|
||||||
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -378,7 +378,7 @@ export class RolePermissionEntryComponent implements OnInit {
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
this.loadingpanelService.ShowLoadingPanel = false;
|
this.loadingpanelService.ShowLoadingPanel = false;
|
||||||
this.notificationService.showSuccess(err.error);
|
this.notificationService.showError(err.error);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.loadingpanelService.ShowLoadingPanel = false;
|
this.loadingpanelService.ShowLoadingPanel = false;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,137 @@
|
||||||
|
/* Table design matching the User page grid (users-list.component.scss).
|
||||||
|
This component uses ViewEncapsulation.None, so every rule is scoped under .rl-grid. */
|
||||||
|
|
||||||
|
/* Uniform, compact rows */
|
||||||
|
.rl-grid .k-grid-table td {
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
vertical-align: middle;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .k-grid-toolbar {
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toolbar, same layout as the User page: search + counts on the left, Export + Add on the right */
|
||||||
|
.rl-grid .rl-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-toolbar__filters,
|
||||||
|
.rl-grid .rl-toolbar__actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-search {
|
||||||
|
width: 240px;
|
||||||
|
}
|
||||||
|
/* Count chips (display only) */
|
||||||
|
.rl-grid .rl-chips {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s, border-color 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip:hover {
|
||||||
|
border-color: #52527A;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip:focus-visible {
|
||||||
|
outline: 2px solid #52527A;
|
||||||
|
outline-offset: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip.is-selected {
|
||||||
|
background: #52527A;
|
||||||
|
border-color: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip.is-selected .rl-chip__count {
|
||||||
|
background: rgba(255, 255, 255, 0.22);
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip__count {
|
||||||
|
min-width: 20px;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #F1F1F1;
|
||||||
|
color: #666666;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-chip--pending:not(.is-selected) .rl-chip__count {
|
||||||
|
background: #FFF2DB;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.rl-grid .rl-toolbar__actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status badge */
|
||||||
|
.rl-grid .rl-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-badge__dot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rl-grid .rl-badge--success { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.rl-grid .rl-badge--neutral { background: #EEEEF2; color: #5B5B6B; }
|
||||||
|
.rl-grid .rl-badge--warning { background: #FFF2DB; color: #8A5300; }
|
||||||
|
|
||||||
|
/* Role Type badge, same shape as the Status badge */
|
||||||
|
.rl-grid .rl-badge--admin { background: #E8EEFC; color: #2F4FB5; }
|
||||||
|
.rl-grid .rl-badge--ess { background: #F1EAFB; color: #6B3FA0; }
|
||||||
|
.rl-grid .rl-badge--mobile { background: #E4F5F7; color: #0F6E7A; }
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,48 @@
|
||||||
|
<app-loading-panel></app-loading-panel>
|
||||||
<kendo-grid [data]="roles"
|
<kendo-grid #rlGrid [kendoGridBinding]="gridView"
|
||||||
|
class="rl-grid"
|
||||||
kendoGridSelectBy="id"
|
kendoGridSelectBy="id"
|
||||||
|
[pageSize]="20"
|
||||||
[pageable]="true"
|
[pageable]="true"
|
||||||
[sortable]="true"
|
[sortable]="true"
|
||||||
|
[filterable]="true"
|
||||||
[reorderable]="true"
|
[reorderable]="true"
|
||||||
[resizable]="true"
|
[resizable]="true"
|
||||||
[scrollable]="true"
|
[scrollable]="true"
|
||||||
[columnMenu]="{ filter: true }"
|
[columnMenu]="{ filter: true }"
|
||||||
(add)="addHandler()">
|
(add)="addHandler()">
|
||||||
<ng-template kendoGridToolbarTemplate>
|
<ng-template kendoGridToolbarTemplate>
|
||||||
<button themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']" kendoGridAddCommand>Add new</button>
|
<div class="rl-toolbar">
|
||||||
<input placeholder="Search in all columns..." kendoTextBox (input)="onFilter($event.target.value)" />
|
<div class="rl-toolbar__filters">
|
||||||
<button kendoGridExcelCommand type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']" style="float:right;">Export to Excel</button>
|
<input placeholder="Search in all columns..." kendoTextBox class="rl-search" (input)="onFilter($event.target.value)" />
|
||||||
<button kendoGridPDFCommand [svgIcon]="apiService.KendoSVGIcon['filePdf']" style="float:right;">Export to PDF</button>
|
|
||||||
|
<!-- Status chips (same as the User page): count, and click to filter the grid -->
|
||||||
|
<div class="rl-chips" role="group" aria-label="Filter by status">
|
||||||
|
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'all'" (click)="setStatusFilter('all')">
|
||||||
|
All <span class="rl-chip__count">{{ roleCounts.all }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'active'" (click)="setStatusFilter('active')">
|
||||||
|
Active <span class="rl-chip__count">{{ roleCounts.active }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="rl-chip rl-chip--pending" [class.is-selected]="statusFilter === 'pending'" (click)="setStatusFilter('pending')">
|
||||||
|
Pending approval <span class="rl-chip__count">{{ roleCounts.pending }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'inactive'" (click)="setStatusFilter('inactive')">
|
||||||
|
Inactive <span class="rl-chip__count">{{ roleCounts.inactive }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rl-toolbar__actions">
|
||||||
|
<!-- Plain buttons, not kendoGridExcelCommand/kendoGridPDFCommand: grid toolbar commands take the
|
||||||
|
focus on any toolbar click, which steals it from the search box. -->
|
||||||
|
<button kendoButton type="button" fillMode="outline"
|
||||||
|
[svgIcon]="apiService.KendoSVGIcon['fileExcel']" (click)="rlGrid.saveAsExcel()">Export to Excel</button>
|
||||||
|
<button kendoButton type="button" fillMode="outline"
|
||||||
|
[svgIcon]="apiService.KendoSVGIcon['filePdf']" (click)="rlGrid.saveAsPDF()">Export to PDF</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']" (click)="addHandler()">Add new</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<kendo-grid-column field="code" title="Code">
|
<kendo-grid-column field="code" title="Code">
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
|
@ -20,21 +50,59 @@
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
<kendo-grid-column field="description" title="Description">
|
<kendo-grid-column field="description" title="Description">
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column field="roleType" title="Role Type">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<span class="rl-badge"
|
||||||
|
[class.rl-badge--admin]="dataItem.roleType == 1"
|
||||||
|
[class.rl-badge--ess]="dataItem.roleType == 2"
|
||||||
|
[class.rl-badge--mobile]="dataItem.roleType == 3"
|
||||||
|
[class.rl-badge--neutral]="dataItem.roleType != 1 && dataItem.roleType != 2 && dataItem.roleType != 3">
|
||||||
|
<span class="rl-badge__dot"></span>{{ roleTypeString(dataItem.roleType) }}
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
<kendo-grid-column field="roleStatus" title="Status">
|
<kendo-grid-column field="roleStatus" title="Status">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||||
{{ statusString(dataItem.roleStatus)}}
|
<span class="rl-badge"
|
||||||
|
[class.rl-badge--success]="statusString(dataItem.roleStatus) == 'Active'"
|
||||||
|
[class.rl-badge--warning]="dataItem.roleStatus == 2 || dataItem.roleStatus == 3 || dataItem.roleStatus == 4"
|
||||||
|
[class.rl-badge--neutral]="statusString(dataItem.roleStatus) == 'In-Active'">
|
||||||
|
<span class="rl-badge__dot"></span>{{ statusString(dataItem.roleStatus)}}
|
||||||
|
</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
<kendo-grid-command-column title="Edit/Approve" width="220">
|
<kendo-grid-command-column title="Edit/Approve" width="220">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||||
@if (dataItem.roleStatus ==1 || dataItem.roleStatus ==5) {
|
@if (dataItem.roleStatus ==1 || dataItem.roleStatus ==5) {
|
||||||
<button class="k-button k-primary" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']" (click)="ViewPermission(rowIndex);">Edit</button>
|
<button class="k-button k-primary" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']" (click)="ViewPermission(roles.indexOf(dataItem));">Edit</button>
|
||||||
}
|
}
|
||||||
@if (dataItem.roleStatus !=1 && dataItem.roleStatus !=5) {
|
@if (dataItem.roleStatus !=1 && dataItem.roleStatus !=5) {
|
||||||
<button class="k-button k-primary" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']" (click)="Approve(rowIndex);">Approve</button>
|
<button class="k-button k-primary" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']"
|
||||||
|
[disabled]="isMakerOf(dataItem)"
|
||||||
|
[attr.title]="isMakerOf(dataItem) ? 'You made this change, so another user must approve it.' : null"
|
||||||
|
(click)="Approve(roles.indexOf(dataItem));">Approve</button>
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-command-column>
|
</kendo-grid-command-column>
|
||||||
|
|
||||||
|
<kendo-grid-excel fileName="Roles.xlsx" [fetchData]="allData">
|
||||||
|
<kendo-excelexport-column field="code" title="Code" [width]="120"></kendo-excelexport-column>
|
||||||
|
<kendo-excelexport-column field="name" title="Name" [width]="200"></kendo-excelexport-column>
|
||||||
|
<kendo-excelexport-column field="description" title="Description" [width]="260"></kendo-excelexport-column>
|
||||||
|
<kendo-excelexport-column field="roleTypeText" title="Role Type" [width]="130"></kendo-excelexport-column>
|
||||||
|
<kendo-excelexport-column field="statusText" title="Status" [width]="110"></kendo-excelexport-column>
|
||||||
|
</kendo-grid-excel>
|
||||||
|
<kendo-grid-pdf fileName="Roles.pdf" [allPages]="true" [repeatHeaders]="true" paperSize="A4" [landscape]="true" [scale]="0.7">
|
||||||
|
<kendo-grid-column field="code" title="Code"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="name" title="Name"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="description" title="Description"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="roleType" title="Role Type">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>{{ roleTypeString(dataItem.roleType) }}</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column field="roleStatus" title="Status">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>{{ statusString(dataItem.roleStatus) }}</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
</kendo-grid-pdf>
|
||||||
</kendo-grid>
|
</kendo-grid>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,14 +110,15 @@
|
||||||
|
|
||||||
|
|
||||||
@if (showModal) {
|
@if (showModal) {
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650"
|
<div class="blur-background">
|
||||||
>
|
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650">
|
||||||
<kendo-dialog-titlebar>
|
<kendo-dialog-titlebar>
|
||||||
Role Permission
|
Role Permission
|
||||||
</kendo-dialog-titlebar>
|
</kendo-dialog-titlebar>
|
||||||
<app-role-permission-entry [setviewMode]="viewMode" [setRole]="selectedRole" (saveCompleted)="saveCompleted($event)">
|
<app-role-permission-entry [setviewMode]="viewMode" [setRole]="selectedRole" (saveCompleted)="saveCompleted($event)">
|
||||||
</app-role-permission-entry>
|
</app-role-permission-entry>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!--<p-dialog [(visible)]="showModal" [style]="{width: '700px',height:'800px', position: 'absolute'}" header="Role Information"
|
<!--<p-dialog [(visible)]="showModal" [style]="{width: '700px',height:'800px', position: 'absolute'}" header="Role Information"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import {Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ViewChild, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {State} from '@progress/kendo-data-query';
|
import {process, State} from '@progress/kendo-data-query';
|
||||||
import {Router} from '@angular/router';
|
import {DataBindingDirective, GridComponent} from '@progress/kendo-angular-grid';
|
||||||
|
import {ExcelExportData} from '@progress/kendo-angular-excel-export';import {Router} from '@angular/router';
|
||||||
import {AuthService} from '../../../_services/auth/auth.service';
|
import {AuthService} from '../../../_services/auth/auth.service';
|
||||||
import {Role} from '../../../_models/Authentication/role';
|
import {Role} from '../../../_models/Authentication/role';
|
||||||
import { HRMNotificationService } from '../../../app.notification.service';
|
import { HRMNotificationService } from '../../../app.notification.service';
|
||||||
import { UntilityHandlerService } from '../../../utility.hanldler.service';
|
import { UntilityHandlerService } from '../../../utility.hanldler.service';
|
||||||
import { ApiService } from '../../../app.api.service';
|
import { ApiService } from '../../../app.api.service';
|
||||||
import { EnumAuthStatus } from '../../../_models/enums';
|
import { EnumAuthStatus, EnumExtension, EnumRoleType } from '../../../_models/enums';
|
||||||
|
import { loadingPanelService } from '../../../hrm-loding panel/loding.panel.service';
|
||||||
|
|
||||||
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
||||||
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
||||||
|
|
@ -26,38 +28,90 @@ import { DatePickerModule } from '@progress/kendo-angular-dateinputs';
|
||||||
// This blocks global css to this component
|
// This blocks global css to this component
|
||||||
})
|
})
|
||||||
export class RolePermissionListComponent implements OnInit {
|
export class RolePermissionListComponent implements OnInit {
|
||||||
|
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
|
||||||
|
@ViewChild(GridComponent) grid: GridComponent;
|
||||||
|
/** Rows the grid binds to: `roles` narrowed by the toolbar search box. Column filters, sort and paging are done by kendoGridBinding. */
|
||||||
|
gridView: Role[] = [];
|
||||||
|
searchText = '';
|
||||||
showModal: boolean;
|
showModal: boolean;
|
||||||
IsNew = true;
|
IsNew = true;
|
||||||
roles: Role[];
|
roles: Role[];
|
||||||
selectedRole: Role;
|
selectedRole: Role;
|
||||||
viewMode: number =1; //1 new, 2 edit ,3 approve
|
viewMode: number =1; //1 new, 2 edit ,3 approve
|
||||||
|
|
||||||
|
/** Status chip group of a role: New / Edited / Deleted not yet approved count as Pending. */
|
||||||
|
statusGroup(r: Role): 'active' | 'pending' | 'inactive' {
|
||||||
|
if (r.roleStatus == EnumAuthStatus.Active || r.roleStatus == EnumAuthStatus.Approved) {
|
||||||
|
return 'active';
|
||||||
|
}
|
||||||
|
if (r.roleStatus == EnumAuthStatus.New_Not_Yet_Approve
|
||||||
|
|| r.roleStatus == EnumAuthStatus.Edited_Not_Yet_Approve
|
||||||
|
|| r.roleStatus == EnumAuthStatus.Deleted_Not_Yet_Approve) {
|
||||||
|
return 'pending';
|
||||||
|
}
|
||||||
|
return 'inactive';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toolbar chip counts (all roles, not narrowed by search or chip). */
|
||||||
|
get roleCounts(): { all: number, active: number, pending: number, inactive: number } {
|
||||||
|
const counts = { all: 0, active: 0, pending: 0, inactive: 0 };
|
||||||
|
(this.roles ?? []).forEach(r => {
|
||||||
|
counts.all++;
|
||||||
|
counts[this.statusGroup(r)]++;
|
||||||
|
});
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
constructor(public useService: AuthService,public apiService: ApiService,
|
constructor(public useService: AuthService,public apiService: ApiService,
|
||||||
public router: Router, public utilityService: UntilityHandlerService, public apiservice: ApiService) {
|
public router: Router, public utilityService: UntilityHandlerService, public apiservice: ApiService,
|
||||||
|
public loadingPanel: loadingPanelService) {
|
||||||
this.setSelectableSettings();
|
this.setSelectableSettings();
|
||||||
this.utilityService.ShowLoadingPanel = true;
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
this.apiservice.selectedMenuName="Role Entry"
|
this.apiservice.selectedMenuName="Role Entry"
|
||||||
|
this.allData = this.allData.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.selectedRole = new Role();
|
this.selectedRole = new Role();
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
|
this.useService.GetCurrentUser().subscribe(
|
||||||
|
(resp: any) => {
|
||||||
|
this.currentUserID = resp?.userID;
|
||||||
|
},
|
||||||
|
);
|
||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Logged-in user's ID: the maker of a pending role cannot approve it. */
|
||||||
|
currentUserID: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True when the logged-in user made the role's pending change: whoever last edited it, or its
|
||||||
|
* creator if it was never edited (same rule as the entry dialog and the server). Their Approve is disabled.
|
||||||
|
*/
|
||||||
|
isMakerOf(role: Role): boolean {
|
||||||
|
if (this.currentUserID == undefined || role == undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const makerID = (role.modifiedBy ?? 0) > 0 ? role.modifiedBy : role.createdBy;
|
||||||
|
return makerID == this.currentUserID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
this.useService.getAllRoles()
|
this.useService.getAllRoles()
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(resp: any) => {
|
(resp: any) => {
|
||||||
|
debugger;
|
||||||
this.roles = resp;
|
this.roles = resp;
|
||||||
|
this.refreshGridView();
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -77,6 +131,9 @@ export class RolePermissionListComponent implements OnInit {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case EnumAuthStatus.Active: { str = "Active"; break };
|
case EnumAuthStatus.Active: { str = "Active"; break };
|
||||||
case EnumAuthStatus.Approved: { str = "Active"; break };
|
case EnumAuthStatus.Approved: { str = "Active"; break };
|
||||||
|
case EnumAuthStatus.New_Not_Yet_Approve: { str = "New - Not Yet Approved"; break };
|
||||||
|
case EnumAuthStatus.Edited_Not_Yet_Approve: { str = "Edited - Not Yet Approved"; break };
|
||||||
|
case EnumAuthStatus.Deleted_Not_Yet_Approve: { str = "Deleted - Not Yet Approved"; break };
|
||||||
|
|
||||||
default: str="In-Active"
|
default: str="In-Active"
|
||||||
}
|
}
|
||||||
|
|
@ -104,12 +161,77 @@ export class RolePermissionListComponent implements OnInit {
|
||||||
this.roles[index] = role;
|
this.roles[index] = role;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this.refreshGridView();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel export: every row the grid currently shows across all pages (not just the visible page),
|
||||||
|
* with Role Type and Status as text.
|
||||||
|
*/
|
||||||
|
public allData(): ExcelExportData {
|
||||||
|
const rows = process(this.gridView ?? [], {
|
||||||
|
filter: this.grid?.filter,
|
||||||
|
sort: this.grid?.sort,
|
||||||
|
}).data;
|
||||||
|
return {
|
||||||
|
data: rows.map((r: Role) => ({
|
||||||
|
code: r.code,
|
||||||
|
name: r.name,
|
||||||
|
description: r.description,
|
||||||
|
roleTypeText: this.roleTypeString(r.roleType),
|
||||||
|
statusText: this.statusString(r.roleStatus),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Role Type column text, the same names the entry dialog's Role Type dropdown shows. */
|
||||||
|
roleTypeString(roleType: number): string {
|
||||||
|
return EnumExtension.getName(EnumRoleType, roleType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toolbar search box: keeps the roles whose code, name or description contain the text. */
|
||||||
|
public onFilter(value: string): void {
|
||||||
|
this.searchText = value ?? '';
|
||||||
|
this.refreshGridView();
|
||||||
|
if (this.dataBinding) {
|
||||||
|
this.dataBinding.skip = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toolbar status chip: which group of roles the grid shows. */
|
||||||
|
statusFilter: 'all' | 'active' | 'pending' | 'inactive' = 'all';
|
||||||
|
|
||||||
|
setStatusFilter(filter: 'all' | 'active' | 'pending' | 'inactive'): void {
|
||||||
|
this.statusFilter = filter;
|
||||||
|
this.refreshGridView();
|
||||||
|
if (this.dataBinding) {
|
||||||
|
this.dataBinding.skip = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private refreshGridView(): void {
|
||||||
|
const base = (this.roles ?? []).filter(r => this.statusFilter === 'all' || this.statusGroup(r) === this.statusFilter);
|
||||||
|
const term = this.searchText.trim();
|
||||||
|
if (!term) {
|
||||||
|
this.gridView = base;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.gridView = process(base, {
|
||||||
|
filter: {
|
||||||
|
logic: 'or',
|
||||||
|
filters: [
|
||||||
|
{field: 'code', operator: 'contains', value: term},
|
||||||
|
{field: 'name', operator: 'contains', value: term},
|
||||||
|
{field: 'description', operator: 'contains', value: term},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}).data;
|
||||||
|
}
|
||||||
|
|
||||||
public editHandler(rowIndex: any) {
|
public editHandler(rowIndex: any) {
|
||||||
this.viewMode = 2;
|
this.viewMode = 2;
|
||||||
this.selectedRole = this.roles[rowIndex];
|
this.selectedRole = this.roles[rowIndex];
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,36 @@
|
||||||
|
<div class="sal-page">
|
||||||
<app-loading-panel></app-loading-panel>
|
<app-loading-panel></app-loading-panel>
|
||||||
|
|
||||||
<div class="card card-w-title audit-trail">
|
<!-- ── Page header ── -->
|
||||||
<kendo-tabstrip [keepTabContent]="true">
|
<section class="sal-card sal-header">
|
||||||
|
<span class="sal-header-ico"><i class="pi pi-shield"></i></span>
|
||||||
|
<div class="sal-header-text">
|
||||||
|
<h2>System Audit Log</h2>
|
||||||
|
<p>Who signed in, failed logins, and every change made on the Role, Role Permission, User, User Role and User Access Type pages.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<kendo-tabstrip class="sal-tabs" [keepTabContent]="true" [scrollable]="true">
|
||||||
|
|
||||||
<!-- ── Tab 1: User Audit Trail (dbo.UserLoginInfo) ── -->
|
<!-- ── Tab 1: User Audit Trail (dbo.UserLoginInfo) ── -->
|
||||||
<kendo-tabstrip-tab title="User Audit Trail" [selected]="true">
|
<kendo-tabstrip-tab [selected]="true">
|
||||||
|
<ng-template kendoTabTitle><i class="pi pi-sign-in"></i><span>User Audit Trail</span></ng-template>
|
||||||
<ng-template kendoTabContent>
|
<ng-template kendoTabContent>
|
||||||
<div class="grid audit-trail-filter">
|
<section class="sal-card sal-body">
|
||||||
<div class="col-12 md:col-1 audit-trail-label">
|
<div class="sal-filter">
|
||||||
|
<div class="sal-field">
|
||||||
<label for="dtUserFrom">From Date</label>
|
<label for="dtUserFrom">From Date</label>
|
||||||
|
<kendo-datepicker id="dtUserFrom" [(ngModel)]="userFromDate" [format]="'dd-MMM-yyyy'" [max]="userToDate"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-3">
|
<div class="sal-field">
|
||||||
<kendo-datepicker id="dtUserFrom" [(ngModel)]="userFromDate" [format]="'dd-MMM-yyyy'" [max]="userToDate"
|
|
||||||
style="width: 100%"></kendo-datepicker>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-1 audit-trail-label">
|
|
||||||
<label for="dtUserTo">To Date</label>
|
<label for="dtUserTo">To Date</label>
|
||||||
|
<kendo-datepicker id="dtUserTo" [(ngModel)]="userToDate" [format]="'dd-MMM-yyyy'" [min]="userFromDate"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-3">
|
<button kendoButton themeColor="primary" class="sal-load" [svgIcon]="apiService.KendoSVGIcon['search']"
|
||||||
<kendo-datepicker id="dtUserTo" [(ngModel)]="userToDate" [format]="'dd-MMM-yyyy'" [min]="userFromDate"
|
(click)="loadUserAuditTrail()">Load</button>
|
||||||
style="width: 100%"></kendo-datepicker>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2">
|
|
||||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['search']"
|
|
||||||
(click)="loadUserAuditTrail()" style="width: 100%;">Load</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<kendo-grid #userGridRef
|
<kendo-grid #userGridRef class="sal-grid"
|
||||||
[data]="userGrid.view"
|
[data]="userGrid.view"
|
||||||
[skip]="userGrid.state.skip"
|
[skip]="userGrid.state.skip"
|
||||||
[pageSize]="pageSize"
|
[pageSize]="pageSize"
|
||||||
|
|
@ -42,10 +45,13 @@
|
||||||
(dataStateChange)="userGrid.onStateChange($event)">
|
(dataStateChange)="userGrid.onStateChange($event)">
|
||||||
|
|
||||||
<ng-template kendoGridToolbarTemplate>
|
<ng-template kendoGridToolbarTemplate>
|
||||||
<input kendoTextBox class="audit-trail-search" placeholder="Search in all columns..."
|
<span class="sal-search">
|
||||||
|
<i class="pi pi-search"></i>
|
||||||
|
<input kendoTextBox placeholder="Search in all columns..."
|
||||||
[value]="userGrid.searchText" (input)="userGrid.onSearch($any($event.target).value)" />
|
[value]="userGrid.searchText" (input)="userGrid.onSearch($any($event.target).value)" />
|
||||||
<span class="audit-trail-count">
|
</span>
|
||||||
{{ userGrid.filteredCount | number }} of {{ userGrid.rows.length | number }} records
|
<span class="sal-count">
|
||||||
|
<strong>{{ userGrid.filteredCount | number }}</strong> of {{ userGrid.rows.length | number }} records
|
||||||
</span>
|
</span>
|
||||||
<kendo-grid-spacer></kendo-grid-spacer>
|
<kendo-grid-spacer></kendo-grid-spacer>
|
||||||
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
||||||
|
|
@ -63,7 +69,10 @@
|
||||||
<kendo-grid-column field="deviceId" title="Device ID" [width]="220"></kendo-grid-column>
|
<kendo-grid-column field="deviceId" title="Device ID" [width]="220"></kendo-grid-column>
|
||||||
|
|
||||||
<ng-template kendoGridNoRecordsTemplate>
|
<ng-template kendoGridNoRecordsTemplate>
|
||||||
|
<div class="sal-empty">
|
||||||
|
<i class="pi" [class.pi-inbox]="userGrid.loaded" [class.pi-calendar]="!userGrid.loaded"></i>
|
||||||
{{ userGrid.loaded ? 'No login found for this date range.' : 'Select a date range and press Load.' }}
|
{{ userGrid.loaded ? 'No login found for this date range.' : 'Select a date range and press Load.' }}
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<kendo-grid-excel [fileName]="fileName('UserAuditTrail', userFromDate, userToDate, 'xlsx')"
|
<kendo-grid-excel [fileName]="fileName('UserAuditTrail', userFromDate, userToDate, 'xlsx')"
|
||||||
|
|
@ -82,34 +91,29 @@
|
||||||
<kendo-grid-pdf-margin top="1cm" left="1cm" right="1cm" bottom="1cm"></kendo-grid-pdf-margin>
|
<kendo-grid-pdf-margin top="1cm" left="1cm" right="1cm" bottom="1cm"></kendo-grid-pdf-margin>
|
||||||
</kendo-grid-pdf>
|
</kendo-grid-pdf>
|
||||||
</kendo-grid>
|
</kendo-grid>
|
||||||
|
</section>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-tabstrip-tab>
|
</kendo-tabstrip-tab>
|
||||||
|
|
||||||
<!-- ── Tab 2: Bad Login Attempt (dbo.BadLoginAttemptInfo) ── -->
|
<!-- ── Tab 2: Bad Login Attempt (dbo.BadLoginAttemptInfo) ── -->
|
||||||
<kendo-tabstrip-tab title="Bad Login Attempt">
|
<kendo-tabstrip-tab>
|
||||||
|
<ng-template kendoTabTitle><i class="pi pi-ban"></i><span>Bad Login Attempt</span></ng-template>
|
||||||
<ng-template kendoTabContent>
|
<ng-template kendoTabContent>
|
||||||
<div class="grid audit-trail-filter">
|
<section class="sal-card sal-body">
|
||||||
<div class="col-12 md:col-1 audit-trail-label">
|
<div class="sal-filter">
|
||||||
|
<div class="sal-field">
|
||||||
<label for="dtBadFrom">From Date</label>
|
<label for="dtBadFrom">From Date</label>
|
||||||
|
<kendo-datepicker id="dtBadFrom" [(ngModel)]="badFromDate" [format]="'dd-MMM-yyyy'" [max]="badToDate"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-3">
|
<div class="sal-field">
|
||||||
<kendo-datepicker id="dtBadFrom" [(ngModel)]="badFromDate" [format]="'dd-MMM-yyyy'" [max]="badToDate"
|
|
||||||
style="width: 100%"></kendo-datepicker>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-1 audit-trail-label">
|
|
||||||
<label for="dtBadTo">To Date</label>
|
<label for="dtBadTo">To Date</label>
|
||||||
|
<kendo-datepicker id="dtBadTo" [(ngModel)]="badToDate" [format]="'dd-MMM-yyyy'" [min]="badFromDate"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-3">
|
<button kendoButton themeColor="primary" class="sal-load" [svgIcon]="apiService.KendoSVGIcon['search']"
|
||||||
<kendo-datepicker id="dtBadTo" [(ngModel)]="badToDate" [format]="'dd-MMM-yyyy'" [min]="badFromDate"
|
(click)="loadBadLoginAttempts()">Load</button>
|
||||||
style="width: 100%"></kendo-datepicker>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2">
|
|
||||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['search']"
|
|
||||||
(click)="loadBadLoginAttempts()" style="width: 100%;">Load</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<kendo-grid #badGridRef
|
<kendo-grid #badGridRef class="sal-grid"
|
||||||
[data]="badGrid.view"
|
[data]="badGrid.view"
|
||||||
[skip]="badGrid.state.skip"
|
[skip]="badGrid.state.skip"
|
||||||
[pageSize]="pageSize"
|
[pageSize]="pageSize"
|
||||||
|
|
@ -124,10 +128,13 @@
|
||||||
(dataStateChange)="badGrid.onStateChange($event)">
|
(dataStateChange)="badGrid.onStateChange($event)">
|
||||||
|
|
||||||
<ng-template kendoGridToolbarTemplate>
|
<ng-template kendoGridToolbarTemplate>
|
||||||
<input kendoTextBox class="audit-trail-search" placeholder="Search in all columns..."
|
<span class="sal-search">
|
||||||
|
<i class="pi pi-search"></i>
|
||||||
|
<input kendoTextBox placeholder="Search in all columns..."
|
||||||
[value]="badGrid.searchText" (input)="badGrid.onSearch($any($event.target).value)" />
|
[value]="badGrid.searchText" (input)="badGrid.onSearch($any($event.target).value)" />
|
||||||
<span class="audit-trail-count">
|
</span>
|
||||||
{{ badGrid.filteredCount | number }} of {{ badGrid.rows.length | number }} records
|
<span class="sal-count">
|
||||||
|
<strong>{{ badGrid.filteredCount | number }}</strong> of {{ badGrid.rows.length | number }} records
|
||||||
</span>
|
</span>
|
||||||
<kendo-grid-spacer></kendo-grid-spacer>
|
<kendo-grid-spacer></kendo-grid-spacer>
|
||||||
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
||||||
|
|
@ -144,7 +151,10 @@
|
||||||
<kendo-grid-column field="deviceId" title="Device ID" [width]="220"></kendo-grid-column>
|
<kendo-grid-column field="deviceId" title="Device ID" [width]="220"></kendo-grid-column>
|
||||||
|
|
||||||
<ng-template kendoGridNoRecordsTemplate>
|
<ng-template kendoGridNoRecordsTemplate>
|
||||||
|
<div class="sal-empty">
|
||||||
|
<i class="pi" [class.pi-inbox]="badGrid.loaded" [class.pi-calendar]="!badGrid.loaded"></i>
|
||||||
{{ badGrid.loaded ? 'No bad login attempt found for this date range.' : 'Select a date range and press Load.' }}
|
{{ badGrid.loaded ? 'No bad login attempt found for this date range.' : 'Select a date range and press Load.' }}
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<kendo-grid-excel [fileName]="fileName('BadLoginAttempt', badFromDate, badToDate, 'xlsx')"
|
<kendo-grid-excel [fileName]="fileName('BadLoginAttempt', badFromDate, badToDate, 'xlsx')"
|
||||||
|
|
@ -162,8 +172,98 @@
|
||||||
<kendo-grid-pdf-margin top="1cm" left="1cm" right="1cm" bottom="1cm"></kendo-grid-pdf-margin>
|
<kendo-grid-pdf-margin top="1cm" left="1cm" right="1cm" bottom="1cm"></kendo-grid-pdf-margin>
|
||||||
</kendo-grid-pdf>
|
</kendo-grid-pdf>
|
||||||
</kendo-grid>
|
</kendo-grid>
|
||||||
|
</section>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-tabstrip-tab>
|
</kendo-tabstrip-tab>
|
||||||
|
|
||||||
|
<!-- ── Tabs 3-7: change history of the Authentication pages (Z_ tables) ── -->
|
||||||
|
@for (tab of historyTabs; track tab.type) {
|
||||||
|
<kendo-tabstrip-tab>
|
||||||
|
<ng-template kendoTabTitle><i [class]="tab.icon"></i><span>{{ tab.title }}</span></ng-template>
|
||||||
|
<ng-template kendoTabContent>
|
||||||
|
<section class="sal-card sal-body">
|
||||||
|
<div class="sal-filter">
|
||||||
|
<div class="sal-field">
|
||||||
|
<label [for]="'dtHistFrom' + tab.type">From Date</label>
|
||||||
|
<kendo-datepicker [id]="'dtHistFrom' + tab.type" [(ngModel)]="tab.fromDate" [format]="'dd-MMM-yyyy'"
|
||||||
|
[max]="tab.toDate"></kendo-datepicker>
|
||||||
|
</div>
|
||||||
|
<div class="sal-field">
|
||||||
|
<label [for]="'dtHistTo' + tab.type">To Date</label>
|
||||||
|
<kendo-datepicker [id]="'dtHistTo' + tab.type" [(ngModel)]="tab.toDate" [format]="'dd-MMM-yyyy'"
|
||||||
|
[min]="tab.fromDate"></kendo-datepicker>
|
||||||
|
</div>
|
||||||
|
<button kendoButton themeColor="primary" class="sal-load" [svgIcon]="apiService.KendoSVGIcon['search']"
|
||||||
|
(click)="loadHistory(tab)">Load</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<kendo-grid #historyGridRef class="sal-grid"
|
||||||
|
[data]="tab.grid.view"
|
||||||
|
[skip]="tab.grid.state.skip"
|
||||||
|
[pageSize]="pageSize"
|
||||||
|
[sort]="tab.grid.state.sort"
|
||||||
|
[filter]="tab.grid.state.filter"
|
||||||
|
[sortable]="true"
|
||||||
|
filterable="menu"
|
||||||
|
scrollable="virtual"
|
||||||
|
[rowHeight]="36"
|
||||||
|
[height]="520"
|
||||||
|
[navigable]="true"
|
||||||
|
(dataStateChange)="tab.grid.onStateChange($event)">
|
||||||
|
|
||||||
|
<ng-template kendoGridToolbarTemplate>
|
||||||
|
<span class="sal-search">
|
||||||
|
<i class="pi pi-search"></i>
|
||||||
|
<input kendoTextBox placeholder="Search in all columns..."
|
||||||
|
[value]="tab.grid.searchText" (input)="tab.grid.onSearch($any($event.target).value)" />
|
||||||
|
</span>
|
||||||
|
<span class="sal-count">
|
||||||
|
<strong>{{ tab.grid.filteredCount | number }}</strong> of {{ tab.grid.rows.length | number }} records
|
||||||
|
</span>
|
||||||
|
<kendo-grid-spacer></kendo-grid-spacer>
|
||||||
|
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
||||||
|
(click)="exportExcel(historyGridRef, tab.grid)">Export to Excel</button>
|
||||||
|
<button kendoButton type="button" [svgIcon]="apiService.KendoSVGIcon['filePdf']"
|
||||||
|
(click)="exportPdf(historyGridRef, tab.grid)">Export to PDF</button>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
@for (col of tab.allColumns; track col.field) {
|
||||||
|
@if (col.isDate) {
|
||||||
|
<kendo-grid-column [field]="col.field" [title]="col.title" [width]="col.width" filter="date"
|
||||||
|
[format]="gridDateFormat"></kendo-grid-column>
|
||||||
|
} @else {
|
||||||
|
<kendo-grid-column [field]="col.field" [title]="col.title" [width]="col.width"></kendo-grid-column>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<ng-template kendoGridNoRecordsTemplate>
|
||||||
|
<div class="sal-empty">
|
||||||
|
<i class="pi" [class.pi-inbox]="tab.grid.loaded" [class.pi-calendar]="!tab.grid.loaded"></i>
|
||||||
|
{{ tab.grid.loaded ? 'No change found for this date range.' : 'Select a date range and press Load.' }}
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<kendo-grid-excel [fileName]="fileName(tab.filePrefix, tab.fromDate, tab.toDate, 'xlsx')"
|
||||||
|
[fetchData]="tab.grid.allData">
|
||||||
|
@for (col of tab.allColumns; track col.field) {
|
||||||
|
@if (col.isDate) {
|
||||||
|
<kendo-excelexport-column [field]="col.field" [title]="col.title" [width]="col.width"
|
||||||
|
[cellOptions]="{ format: excelDateFormat }"></kendo-excelexport-column>
|
||||||
|
} @else {
|
||||||
|
<kendo-excelexport-column [field]="col.field" [title]="col.title" [width]="col.width"></kendo-excelexport-column>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</kendo-grid-excel>
|
||||||
|
|
||||||
|
<kendo-grid-pdf [fileName]="fileName(tab.filePrefix, tab.fromDate, tab.toDate, 'pdf')"
|
||||||
|
[allPages]="true" [repeatHeaders]="true" paperSize="A4" [landscape]="true" [scale]="0.7">
|
||||||
|
<kendo-grid-pdf-margin top="1cm" left="1cm" right="1cm" bottom="1cm"></kendo-grid-pdf-margin>
|
||||||
|
</kendo-grid-pdf>
|
||||||
|
</kendo-grid>
|
||||||
|
</section>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-tabstrip-tab>
|
||||||
|
}
|
||||||
|
|
||||||
</kendo-tabstrip>
|
</kendo-tabstrip>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,252 @@
|
||||||
.audit-trail-filter {
|
@use '../../../styles/abstracts/tokens' as *;
|
||||||
margin: 0.5rem 0 0.75rem;
|
|
||||||
|
// Tab colours: the same boxed tabs as Employee Bulk Upload (employee-bulk-upload.component.scss).
|
||||||
|
$sal-tab-text: #2C4A6B;
|
||||||
|
$sal-tab-bg: #F4F8FC;
|
||||||
|
$sal-tab-hover: #D8E4F0;
|
||||||
|
$sal-tab-border: #C9D8E8;
|
||||||
|
$sal-tab-active-border: #9DB4CC;
|
||||||
|
|
||||||
|
:host {
|
||||||
|
@include empcard-host-vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-page {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
// The loading panel is not a card: keep it out of the flex gap (its overlay is absolute).
|
||||||
|
> app-loading-panel {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── card shell ─────────────────────────────────────────────────── */
|
||||||
|
.sal-card {
|
||||||
|
background: var(--brand-card-bg);
|
||||||
|
border: 1px solid var(--brand-card-border);
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: var(--brand-card-shadow);
|
||||||
|
padding: 18px 20px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── page header ────────────────────────────────────────────────── */
|
||||||
|
.sal-header {
|
||||||
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audit-trail-label {
|
.sal-header-ico {
|
||||||
margin: auto;
|
flex: 0 0 auto;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: $sal-tab-hover;
|
||||||
|
color: $sal-tab-text;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.audit-trail-search {
|
.sal-header-text {
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--brand-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 2px 0 0;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--brand-text-sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── tabs ───────────────────────────────────────────────────────── */
|
||||||
|
/*
|
||||||
|
* Each tab a bordered box, the open one white with a blue top edge. The tab items are rendered
|
||||||
|
* by kendo-tabstrip, hence ::ng-deep.
|
||||||
|
*/
|
||||||
|
:host ::ng-deep kendo-tabstrip.sal-tabs {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
> .k-tabstrip-items-wrapper {
|
||||||
|
border-bottom: 1px solid #E2E8F0;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .k-tabstrip-items-wrapper .k-tabstrip-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
margin: 0 6px -1px 0;
|
||||||
|
padding: 10px 16px;
|
||||||
|
border: 1px solid $sal-tab-border;
|
||||||
|
border-radius: 10px 10px 0 0;
|
||||||
|
background: $sal-tab-bg;
|
||||||
|
color: $sal-tab-text;
|
||||||
|
font-weight: 700;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: background .15s ease, border-color .15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: $sal-tab-hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.k-active {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-color: $sal-tab-active-border;
|
||||||
|
border-bottom-color: #FFFFFF;
|
||||||
|
box-shadow: inset 0 3px 0 $sal-tab-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.k-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll arrows when the tabs do not fit.
|
||||||
|
> .k-tabstrip-items-wrapper .k-tabstrip-prev,
|
||||||
|
> .k-tabstrip-items-wrapper .k-tabstrip-next {
|
||||||
|
color: $sal-tab-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .k-tabstrip-content {
|
||||||
|
padding: 10px 0 0;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
&:focus,
|
||||||
|
&.k-focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── tab body: filter bar + grid ────────────────────────────────── */
|
||||||
|
.sal-body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-filter {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 12px 16px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border: 1px solid var(--brand-card-border);
|
||||||
|
border-radius: 14px;
|
||||||
|
background: $sal-tab-bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
width: 220px;
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-size: 0.78rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: .02em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--brand-text-sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
kendo-datepicker {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-load {
|
||||||
|
min-width: 120px;
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep kendo-grid.sal-grid {
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.k-grid-toolbar {
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.k-grid-header .k-header {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-search {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
width: 280px;
|
width: 280px;
|
||||||
|
max-width: 100%;
|
||||||
|
|
||||||
|
i {
|
||||||
|
position: absolute;
|
||||||
|
left: 10px;
|
||||||
|
z-index: 1;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--brand-text-muted);
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audit-trail-count {
|
input {
|
||||||
margin-left: 0.5rem;
|
width: 100%;
|
||||||
font-size: 0.875rem;
|
padding-left: 30px;
|
||||||
opacity: 0.75;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-count {
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: $sal-tab-bg;
|
||||||
|
border: 1px solid $sal-tab-border;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: $sal-tab-text;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sal-empty {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 28px 0;
|
||||||
|
color: var(--brand-text-muted);
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { ApiService } from '../../app.api.service';
|
||||||
import { AuthService } from '../../_services/auth/auth.service';
|
import { AuthService } from '../../_services/auth/auth.service';
|
||||||
import { HRMNotificationService } from '../../app.notification.service';
|
import { HRMNotificationService } from '../../app.notification.service';
|
||||||
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
|
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
|
||||||
import { UserLogInInfo, BadLoginAttemptInfo } from '../../_models/Authentication/auditTrail';
|
import { UserLogInInfo, BadLoginAttemptInfo, EnumSystemAuditHistory, SystemAuditHistory } from '../../_models/Authentication/auditTrail';
|
||||||
|
|
||||||
/** Rows per virtual "page" - enough to fill the grid viewport a few times over. */
|
/** Rows per virtual "page" - enough to fill the grid viewport a few times over. */
|
||||||
const PAGE_SIZE = 60;
|
const PAGE_SIZE = 60;
|
||||||
|
|
@ -24,22 +24,48 @@ export interface AuditTrailRow {
|
||||||
deviceId: string;
|
deviceId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** One row of a change-history grid (Z_ tables), the same shape for every history tab. */
|
||||||
|
export interface AuditHistoryRow {
|
||||||
|
auditDate: Date;
|
||||||
|
auditType: string;
|
||||||
|
loginID: string;
|
||||||
|
name: string;
|
||||||
|
code: string;
|
||||||
|
userType: string;
|
||||||
|
roleName: string;
|
||||||
|
roleType: string;
|
||||||
|
menu: string;
|
||||||
|
accessType: string;
|
||||||
|
activities: string;
|
||||||
|
actionBy: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A column of a change-history tab. */
|
||||||
|
export interface AuditHistoryColumn {
|
||||||
|
field: keyof AuditHistoryRow;
|
||||||
|
title: string;
|
||||||
|
width: number;
|
||||||
|
isDate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State of one audit-trail grid: all loaded rows, the toolbar search, and the
|
* State of one audit-trail grid: all loaded rows, the toolbar search, and the
|
||||||
* grid's sort / filter / virtual-scroll state. Everything is done client side over
|
* grid's sort / filter / virtual-scroll state. Everything is done client side over
|
||||||
* the rows of the selected date range.
|
* the rows of the selected date range.
|
||||||
*/
|
*/
|
||||||
export class AuditTrailGrid {
|
export class AuditTrailGrid<T = AuditTrailRow> {
|
||||||
rows: AuditTrailRow[] = [];
|
rows: T[] = [];
|
||||||
private searched: AuditTrailRow[] = [];
|
private searched: T[] = [];
|
||||||
searchText = '';
|
searchText = '';
|
||||||
loaded = false;
|
loaded = false;
|
||||||
state: State = { skip: 0, take: PAGE_SIZE, sort: [{ field: 'punchTime', dir: 'desc' }], filter: { logic: 'and', filters: [] } };
|
state: State;
|
||||||
view: GridDataResult = { data: [], total: 0 };
|
view: GridDataResult = { data: [], total: 0 };
|
||||||
|
|
||||||
constructor(private searchFields: (keyof AuditTrailRow)[]) { }
|
constructor(private searchFields: (keyof T)[], sortField: string = 'punchTime') {
|
||||||
|
this.state = { skip: 0, take: PAGE_SIZE, sort: [{ field: sortField, dir: 'desc' }], filter: { logic: 'and', filters: [] } };
|
||||||
|
}
|
||||||
|
|
||||||
setRows(rows: AuditTrailRow[]): void {
|
setRows(rows: T[]): void {
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.state = { ...this.state, skip: 0 };
|
this.state = { ...this.state, skip: 0 };
|
||||||
|
|
@ -80,8 +106,8 @@ export class AuditTrailGrid {
|
||||||
this.view = process(this.searched, this.state);
|
this.view = process(this.searched, this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static searchValue(row: AuditTrailRow, field: keyof AuditTrailRow): string {
|
private static searchValue<R>(row: R, field: keyof R): string {
|
||||||
const value = row[field];
|
const value: unknown = row[field];
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +127,31 @@ export class AuditTrailGrid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** One change-history tab: which Z_ table, its own columns, date range and grid state. */
|
||||||
|
export class AuditHistoryTab {
|
||||||
|
fromDate: Date;
|
||||||
|
toDate: Date;
|
||||||
|
readonly grid: AuditTrailGrid<AuditHistoryRow>;
|
||||||
|
/** Every column of the tab: when, what, the page's own columns, then the details and who. */
|
||||||
|
readonly allColumns: AuditHistoryColumn[];
|
||||||
|
|
||||||
|
constructor(public readonly type: EnumSystemAuditHistory,
|
||||||
|
public readonly title: string,
|
||||||
|
public readonly filePrefix: string,
|
||||||
|
columns: AuditHistoryColumn[],
|
||||||
|
/** PrimeIcons class shown in the tab title. */
|
||||||
|
public readonly icon: string) {
|
||||||
|
this.allColumns = [
|
||||||
|
{ field: 'auditDate', title: 'Date', width: 190, isDate: true },
|
||||||
|
{ field: 'auditType', title: 'Action', width: 200 },
|
||||||
|
...columns,
|
||||||
|
{ field: 'activities', title: 'Activities', width: 220 },
|
||||||
|
{ field: 'actionBy', title: 'Action By', width: 220 }
|
||||||
|
];
|
||||||
|
this.grid = new AuditTrailGrid<AuditHistoryRow>(this.allColumns.map(c => c.field), 'auditDate');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-system-audittrail',
|
selector: 'app-system-audittrail',
|
||||||
templateUrl: './system.audittrail.component.html',
|
templateUrl: './system.audittrail.component.html',
|
||||||
|
|
@ -122,6 +173,33 @@ export class SystemAuditTrailComponent implements OnInit {
|
||||||
badToDate: Date;
|
badToDate: Date;
|
||||||
badGrid = new AuditTrailGrid(['loginID', 'punchTime', 'pcNumber', 'ipAddress', 'deviceId']);
|
badGrid = new AuditTrailGrid(['loginID', 'punchTime', 'pcNumber', 'ipAddress', 'deviceId']);
|
||||||
|
|
||||||
|
/** Change-history tabs (Z_ tables), one per Authentication page. */
|
||||||
|
historyTabs: AuditHistoryTab[] = [
|
||||||
|
new AuditHistoryTab(EnumSystemAuditHistory.Role, 'Role History', 'RoleHistory', [
|
||||||
|
{ field: 'code', title: 'Role Code', width: 140 },
|
||||||
|
{ field: 'name', title: 'Role Name', width: 220 },
|
||||||
|
{ field: 'roleType', title: 'Role Type', width: 130 }
|
||||||
|
], 'pi pi-id-card'),
|
||||||
|
new AuditHistoryTab(EnumSystemAuditHistory.RolePermission, 'Role Permission History', 'RolePermissionHistory', [
|
||||||
|
{ field: 'roleName', title: 'Role', width: 200 },
|
||||||
|
{ field: 'menu', title: 'Menu', width: 260 }
|
||||||
|
], 'pi pi-key'),
|
||||||
|
new AuditHistoryTab(EnumSystemAuditHistory.User, 'User History', 'UserHistory', [
|
||||||
|
{ field: 'loginID', title: 'Login ID', width: 150 },
|
||||||
|
{ field: 'name', title: 'Name', width: 220 },
|
||||||
|
{ field: 'userType', title: 'User Type', width: 130 }
|
||||||
|
], 'pi pi-user'),
|
||||||
|
new AuditHistoryTab(EnumSystemAuditHistory.UserRole, 'User Role History', 'UserRoleHistory', [
|
||||||
|
{ field: 'code', title: 'Role Code', width: 140 },
|
||||||
|
{ field: 'roleName', title: 'Role Name', width: 220 }
|
||||||
|
], 'pi pi-users'),
|
||||||
|
new AuditHistoryTab(EnumSystemAuditHistory.UserAccessType, 'User Access Type History', 'UserAccessTypeHistory', [
|
||||||
|
{ field: 'loginID', title: 'Login ID', width: 150 },
|
||||||
|
{ field: 'name', title: 'Name', width: 220 },
|
||||||
|
{ field: 'accessType', title: 'Access Type', width: 200 }
|
||||||
|
], 'pi pi-sitemap')
|
||||||
|
];
|
||||||
|
|
||||||
constructor(public apiService: ApiService,
|
constructor(public apiService: ApiService,
|
||||||
public authService: AuthService,
|
public authService: AuthService,
|
||||||
public notificationService: HRMNotificationService,
|
public notificationService: HRMNotificationService,
|
||||||
|
|
@ -139,6 +217,10 @@ export class SystemAuditTrailComponent implements OnInit {
|
||||||
this.userToDate = new Date(today);
|
this.userToDate = new Date(today);
|
||||||
this.badFromDate = new Date(weekAgo);
|
this.badFromDate = new Date(weekAgo);
|
||||||
this.badToDate = new Date(today);
|
this.badToDate = new Date(today);
|
||||||
|
this.historyTabs.forEach(tab => {
|
||||||
|
tab.fromDate = new Date(weekAgo);
|
||||||
|
tab.toDate = new Date(today);
|
||||||
|
});
|
||||||
this.loadingPanel.ShowLoadingPanel = false;
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,10 +276,44 @@ export class SystemAuditTrailComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- Change-history tabs (Z_ tables) ---------------------------------------
|
||||||
|
|
||||||
|
loadHistory(tab: AuditHistoryTab): void {
|
||||||
|
if (!this.validDateRange(tab.fromDate, tab.toDate)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
this.authService.getSystemAuditHistory(tab.type, tab.fromDate, tab.toDate).subscribe({
|
||||||
|
next: (items: SystemAuditHistory[]) => {
|
||||||
|
tab.grid.setRows((items ?? []).map(x => ({
|
||||||
|
auditDate: x.auditDate ? new Date(x.auditDate) : null,
|
||||||
|
auditType: x.auditType ?? '',
|
||||||
|
loginID: x.loginID ?? '',
|
||||||
|
name: x.name ?? '',
|
||||||
|
code: x.code ?? '',
|
||||||
|
userType: x.userType ?? '',
|
||||||
|
roleName: x.roleName ?? '',
|
||||||
|
roleType: x.roleType ?? '',
|
||||||
|
menu: x.menuName || x.menuKey || '',
|
||||||
|
accessType: x.accessType ?? '',
|
||||||
|
activities: (x.activities ?? '').trim(),
|
||||||
|
actionBy: x.actionByName
|
||||||
|
? x.actionByName + (x.actionByLoginID ? ' (' + x.actionByLoginID + ')' : '')
|
||||||
|
: (x.actionByLoginID ?? '')
|
||||||
|
})));
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? 'Could not load the ' + tab.title.toLowerCase() + '.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// -- Shared ----------------------------------------------------------------
|
// -- Shared ----------------------------------------------------------------
|
||||||
|
|
||||||
/** PDF renders every row into the page first, so refuse it for very large results. */
|
/** PDF renders every row into the page first, so refuse it for very large results. */
|
||||||
exportPdf(grid: GridComponent, auditGrid: AuditTrailGrid): void {
|
exportPdf(grid: GridComponent, auditGrid: { filteredCount: number }): void {
|
||||||
if (auditGrid.filteredCount === 0) {
|
if (auditGrid.filteredCount === 0) {
|
||||||
this.notificationService.showError('There is no data to export.');
|
this.notificationService.showError('There is no data to export.');
|
||||||
return;
|
return;
|
||||||
|
|
@ -210,7 +326,7 @@ export class SystemAuditTrailComponent implements OnInit {
|
||||||
grid.saveAsPDF();
|
grid.saveAsPDF();
|
||||||
}
|
}
|
||||||
|
|
||||||
exportExcel(grid: GridComponent, auditGrid: AuditTrailGrid): void {
|
exportExcel(grid: GridComponent, auditGrid: { filteredCount: number }): void {
|
||||||
if (auditGrid.filteredCount === 0) {
|
if (auditGrid.filteredCount === 0) {
|
||||||
this.notificationService.showError('There is no data to export.');
|
this.notificationService.showError('There is no data to export.');
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,233 @@
|
||||||
|
.sc-page {
|
||||||
|
/* padding: 1.5rem; */
|
||||||
|
}
|
||||||
|
.sc-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
.sc-header-icon {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #f0f0f0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #555;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.sc-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
margin: 0 0 2px;
|
||||||
|
}
|
||||||
|
.sc-subtitle {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #888;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.sc-card {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.85rem;
|
||||||
|
}
|
||||||
|
.sc-field {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
.sc-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #888;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.sc-drop-zone {
|
||||||
|
border: 1.5px dashed #d4d4d4;
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: border-color 0.15s, background 0.15s;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.sc-drop-zone--dragging {
|
||||||
|
border-color: #4a90d9;
|
||||||
|
background: #f0f6fd;
|
||||||
|
}
|
||||||
|
.sc-drop-zone--has-file {
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #c8e0f7;
|
||||||
|
background: #f7fbff;
|
||||||
|
}
|
||||||
|
.sc-drop-empty {
|
||||||
|
padding: 1rem 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.sc-drop-icon {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #bbb;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.sc-drop-label {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #777;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
}
|
||||||
|
.sc-drop-hint {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #aaa;
|
||||||
|
margin: 0 0 12px;
|
||||||
|
}
|
||||||
|
.sc-browse-btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 6px 18px;
|
||||||
|
border: 1px solid #4a90d9;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #4a90d9;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.15s;
|
||||||
|
}
|
||||||
|
.sc-browse-btn:hover {
|
||||||
|
background: #f0f6fd;
|
||||||
|
}
|
||||||
|
.sc-drop-selected {
|
||||||
|
padding: 12px 14px;
|
||||||
|
}
|
||||||
|
.sc-file-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
.sc-file-icon-wrap {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #e8f2fd;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.sc-file-icon {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #4a90d9;
|
||||||
|
}
|
||||||
|
.sc-file-details {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.sc-file-name {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #1a1a1a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.sc-file-size {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #aaa;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
.sc-file-clear {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #bbb;
|
||||||
|
padding: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: color 0.15s, background 0.15s;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.sc-file-clear:hover {
|
||||||
|
color: #e24b4a;
|
||||||
|
background: #fef0f0;
|
||||||
|
}
|
||||||
|
.sc-drop-restriction {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #aaa;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
.sc-drop-restriction code {
|
||||||
|
font-family: monospace;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.sc-divider {
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid #f0f0f0;
|
||||||
|
margin: 1.25rem 0;
|
||||||
|
}
|
||||||
|
.sc-btn-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.sc-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
height: 38px;
|
||||||
|
padding: 0 18px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.15s, opacity 0.15s, transform 0.1s;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
.sc-btn:active:not(:disabled) {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
.sc-btn:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
.sc-btn--primary {
|
||||||
|
background: #1a1a1a;
|
||||||
|
color: #fff;
|
||||||
|
border-color: #1a1a1a;
|
||||||
|
}
|
||||||
|
.sc-btn--primary:hover:not(:disabled) {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
.sc-btn--secondary {
|
||||||
|
background: #fff;
|
||||||
|
color: #1a1a1a;
|
||||||
|
border-color: #ddd;
|
||||||
|
}
|
||||||
|
.sc-btn--secondary:hover:not(:disabled) {
|
||||||
|
background: #f7f7f7;
|
||||||
|
}
|
||||||
|
.sc-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-top: 14px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.sc-status--success {
|
||||||
|
background: #f0faf4;
|
||||||
|
color: #2e7d52;
|
||||||
|
border: 1px solid #c3e8d4;
|
||||||
|
}
|
||||||
|
.sc-status--error {
|
||||||
|
background: #fff5f5;
|
||||||
|
color: #c0392b;
|
||||||
|
border: 1px solid #f5c6c6;
|
||||||
|
}
|
||||||
|
|
@ -1,36 +1,118 @@
|
||||||
<app-loading-panel></app-loading-panel>
|
<app-loading-panel></app-loading-panel>
|
||||||
<div class="card card-w-title">
|
|
||||||
<div class="col-12">
|
<div class="sc-page">
|
||||||
<div class="col-12" style="font-weight: bold;color: red;">
|
|
||||||
<label>Please select respective Configuration Type from the dropboox & choose file to upload the configuration type</label>
|
<!-- Page header -->
|
||||||
|
<div class="sc-header">
|
||||||
|
<div class="sc-header-icon">
|
||||||
|
<i class="pi pi-cog"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div>
|
||||||
<div class="grid">
|
<h2 class="sc-title">System Configuration</h2>
|
||||||
<div class="col-12">
|
<p class="sc-subtitle">Upload or download XML configuration files</p>
|
||||||
<div class="example-wrapper">
|
|
||||||
<p>Configuration Type:</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3" style="margin: auto;">
|
|
||||||
|
<!-- Main card -->
|
||||||
|
<div class="sc-card">
|
||||||
|
|
||||||
|
<!-- Configuration type -->
|
||||||
|
<div class="sc-field">
|
||||||
|
<label class="sc-label" for="configTypeSelect">Configuration type</label>
|
||||||
<kendo-dropdownlist [(ngModel)]="fileTypeid"
|
<kendo-dropdownlist [(ngModel)]="fileTypeid"
|
||||||
[data]="configtypes"
|
[data]="configtypes"
|
||||||
[defaultItem]="{ name: 'Select a configuration type', value: null }"
|
[defaultItem]="{ name: 'Select a configuration type', value: null }"
|
||||||
[textField]="'name'"
|
[textField]="'name'"
|
||||||
[valueField]="'value'"
|
[valueField]="'value'"
|
||||||
[valuePrimitive]="true"
|
[valuePrimitive]="true"
|
||||||
id="itemid" style="width: 100%;">
|
id="configTypeSelect" style="width: 100%;">
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-7">
|
|
||||||
<input id="fupEmpPhoto" kendoTextBox (change)="selectFile($event)" type="file" style="width: 100%;">
|
<!-- File upload drop zone -->
|
||||||
|
<div class="sc-field">
|
||||||
|
<label class="sc-label">Configuration file</label>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="sc-drop-zone"
|
||||||
|
[class.sc-drop-zone--dragging]="isDragging"
|
||||||
|
[class.sc-drop-zone--has-file]="selectedFileName"
|
||||||
|
(dragover)="onDragOver($event)"
|
||||||
|
(dragleave)="onDragLeave()"
|
||||||
|
(drop)="onDrop($event)">
|
||||||
|
|
||||||
|
<!-- Empty state -->
|
||||||
|
<div *ngIf="!selectedFileName" class="sc-drop-empty">
|
||||||
|
<i class="pi pi-upload sc-drop-icon"></i>
|
||||||
|
<p class="sc-drop-label">Drag & drop your XML file here</p>
|
||||||
|
<p class="sc-drop-hint">or</p>
|
||||||
|
<label class="sc-browse-btn" for="fileInputHidden">
|
||||||
|
Browse file
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="fileInputHidden"
|
||||||
|
type="file"
|
||||||
|
accept=".xml"
|
||||||
|
(change)="selectFile($event)"
|
||||||
|
style="display:none">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1" style="margin: auto;">
|
|
||||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['upload']" (click)="upload()" style="width: 100%;">upload</button>
|
<!-- File selected state -->
|
||||||
|
<div *ngIf="selectedFileName" class="sc-drop-selected">
|
||||||
|
<div class="sc-file-info">
|
||||||
|
<div class="sc-file-icon-wrap">
|
||||||
|
<i class="pi pi-file sc-file-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1" style="margin: auto;">
|
<div class="sc-file-details">
|
||||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['download']" (click)="download()" style="width: 100%;">Download</button>
|
<span class="sc-file-name">{{ selectedFileName }}</span>
|
||||||
|
<span class="sc-file-size">{{ selectedFileSize }}</span>
|
||||||
|
</div>
|
||||||
|
<button class="sc-file-clear" (click)="clearFile()" title="Remove file" type="button">
|
||||||
|
<i class="pi pi-times"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p class="sc-drop-restriction">Only <code>.xml</code> files are accepted</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="sc-divider">
|
||||||
|
|
||||||
|
<!-- Action buttons -->
|
||||||
|
<div class="sc-btn-row">
|
||||||
|
<button
|
||||||
|
class="sc-btn sc-btn--primary"
|
||||||
|
[disabled]="!canUpload"
|
||||||
|
(click)="upload()"
|
||||||
|
type="button">
|
||||||
|
<i class="pi pi-upload"></i>
|
||||||
|
Upload
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="sc-btn sc-btn--secondary"
|
||||||
|
[disabled]="!canDownload"
|
||||||
|
(click)="download()"
|
||||||
|
type="button">
|
||||||
|
<i class="pi pi-download"></i>
|
||||||
|
Download
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Status message -->
|
||||||
|
<div
|
||||||
|
*ngIf="statusType"
|
||||||
|
class="sc-status"
|
||||||
|
[class.sc-status--success]="statusType === 'success'"
|
||||||
|
[class.sc-status--error]="statusType === 'error'">
|
||||||
|
<i
|
||||||
|
class="pi"
|
||||||
|
[class.pi-check-circle]="statusType === 'success'"
|
||||||
|
[class.pi-times-circle]="statusType === 'error'">
|
||||||
|
</i>
|
||||||
|
<span>{{ statusMessage }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -59,6 +59,13 @@ export class SystemConfigurationComponent implements OnInit {
|
||||||
_fromValidator: FormGroup;
|
_fromValidator: FormGroup;
|
||||||
selectedFiles?: FileList;
|
selectedFiles?: FileList;
|
||||||
|
|
||||||
|
// UI state for the redesigned template
|
||||||
|
public isDragging = false;
|
||||||
|
public selectedFileName = '';
|
||||||
|
public selectedFileSize = '';
|
||||||
|
public statusType: 'success' | 'error' | '' = '';
|
||||||
|
public statusMessage = '';
|
||||||
|
|
||||||
configtypes: any = EnumExtension.getNamesAndValues(EnumConfigurationType);
|
configtypes: any = EnumExtension.getNamesAndValues(EnumConfigurationType);
|
||||||
|
|
||||||
constructor(public systemConfigService: SystemConfigurationService,
|
constructor(public systemConfigService: SystemConfigurationService,
|
||||||
|
|
@ -160,10 +167,14 @@ export class SystemConfigurationComponent implements OnInit {
|
||||||
(err) => {
|
(err) => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
this.notificationService.showError(err.error);
|
this.notificationService.showError(err.error);
|
||||||
|
this.statusType = 'error';
|
||||||
|
this.statusMessage = err.error;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
this.notificationService.showSuccess("Data uploaded successfully.")
|
this.notificationService.showSuccess("Data uploaded successfully.")
|
||||||
|
this.statusType = 'success';
|
||||||
|
this.statusMessage = 'File uploaded successfully.';
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -279,12 +290,63 @@ export class SystemConfigurationComponent implements OnInit {
|
||||||
selectFile(event: any): void {
|
selectFile(event: any): void {
|
||||||
|
|
||||||
this.selectedFiles = event.target.files;
|
this.selectedFiles = event.target.files;
|
||||||
|
if (this.selectedFiles && this.selectedFiles.length > 0) {
|
||||||
|
const file = this.selectedFiles.item(0);
|
||||||
|
this.selectedFileName = file.name;
|
||||||
|
this.selectedFileSize = this.formatFileSize(file.size);
|
||||||
|
this.statusType = '';
|
||||||
|
this.statusMessage = '';
|
||||||
|
}
|
||||||
|
|
||||||
//if (this.selectedFiles.length > 0) {
|
//if (this.selectedFiles.length > 0) {
|
||||||
// const file: File | null = this.selectedFiles.item(0);
|
// const file: File | null = this.selectedFiles.item(0);
|
||||||
// this.selectedFiles = file;
|
// this.selectedFiles = file;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
onDragOver(event: DragEvent): void {
|
||||||
|
event.preventDefault();
|
||||||
|
this.isDragging = true;
|
||||||
|
}
|
||||||
|
onDragLeave(): void {
|
||||||
|
this.isDragging = false;
|
||||||
|
}
|
||||||
|
onDrop(event: DragEvent): void {
|
||||||
|
event.preventDefault();
|
||||||
|
this.isDragging = false;
|
||||||
|
const files = event.dataTransfer?.files;
|
||||||
|
if (files && files.length > 0) {
|
||||||
|
const file = files[0];
|
||||||
|
if (!file.name.endsWith('.xml')) {
|
||||||
|
this.notificationService.showWarning('Only .xml files are accepted.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const dt = new DataTransfer();
|
||||||
|
dt.items.add(file);
|
||||||
|
this.selectedFiles = dt.files;
|
||||||
|
this.selectedFileName = file.name;
|
||||||
|
this.selectedFileSize = this.formatFileSize(file.size);
|
||||||
|
this.statusType = '';
|
||||||
|
this.statusMessage = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clearFile(): void {
|
||||||
|
this.selectedFiles = null;
|
||||||
|
this.selectedFileName = '';
|
||||||
|
this.selectedFileSize = '';
|
||||||
|
this.statusType = '';
|
||||||
|
this.statusMessage = '';
|
||||||
|
}
|
||||||
|
formatFileSize(bytes: number): string {
|
||||||
|
if (bytes < 1024) return bytes + ' B';
|
||||||
|
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||||
|
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||||
|
}
|
||||||
|
get canUpload(): boolean {
|
||||||
|
return !!this.fileTypeid && !!this.selectedFiles && this.selectedFiles.length > 0;
|
||||||
|
}
|
||||||
|
get canDownload(): boolean {
|
||||||
|
return !!this.fileTypeid;
|
||||||
|
}
|
||||||
public downloadFile(uid: string): void {
|
public downloadFile(uid: string): void {
|
||||||
const temporiginalName = '';
|
const temporiginalName = '';
|
||||||
let tempName = '';
|
let tempName = '';
|
||||||
|
|
|
||||||
|
|
@ -1 +1,598 @@
|
||||||
|
/* User Access Type page. This component uses ViewEncapsulation.None, so every rule carries the uat- prefix.
|
||||||
|
Colours follow the app tokens (src/styles/abstracts/_tokens.scss) and the User / Role page badges. */
|
||||||
|
|
||||||
|
.uat-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- header ---------- */
|
||||||
|
|
||||||
|
.uat-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-header__icon {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #DEDEFF;
|
||||||
|
color: #414278;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-subtitle {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- view switch ---------- */
|
||||||
|
|
||||||
|
.uat-views {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view:hover {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view.is-active {
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view__count {
|
||||||
|
min-width: 20px;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #EEEEF2;
|
||||||
|
color: #5B5B6B;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view__count.has-items {
|
||||||
|
background: #FFF2DB;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-view.is-active .uat-view__count {
|
||||||
|
background: rgba(255, 255, 255, 0.22);
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- pending approvals table ---------- */
|
||||||
|
|
||||||
|
.uat-table-wrap {
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: #F7F7FB;
|
||||||
|
color: #666666;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: left;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #E3E3EC;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #F0F0F4;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table tbody tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table tbody tr:hover {
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table tbody tr.is-selected {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table tbody tr.is-mine {
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table__check {
|
||||||
|
width: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-table__open {
|
||||||
|
width: 70px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-block {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-mine {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- layout ---------- */
|
||||||
|
|
||||||
|
.uat-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 320px minmax(0, 1fr);
|
||||||
|
gap: 14px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-card {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-card__title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pending approvals table, "Requested by" cell: maker, date and "Your change" side by side */
|
||||||
|
.uat-requested {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Left column: user card, then the pending change card under it */
|
||||||
|
.uat-side {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In the narrow left column the note sits above full-width buttons */
|
||||||
|
.uat-side .uat-pending__actions {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-side .uat-pending__actions .uat-btns > button {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* "3 of 12 selected" next to the Payroll access title */
|
||||||
|
.uat-count {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 8px;
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #DEDEFF;
|
||||||
|
color: #414278;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 22px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #888888;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-muted {
|
||||||
|
color: #888888;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-btns {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- user card ---------- */
|
||||||
|
|
||||||
|
.uat-user__select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-user__option {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-user__summary {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-avatar {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 600;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-user__info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-user__name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-stats {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 14px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-stat {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-stat__value {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #414278;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-stat__label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-legend {
|
||||||
|
margin-top: 16px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #F0F0F4;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-legend__title {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #888888;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-legend__row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- empty state ---------- */
|
||||||
|
|
||||||
|
.uat-empty {
|
||||||
|
padding: 48px 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-empty__icon {
|
||||||
|
font-size: 32px;
|
||||||
|
color: #C9C9D6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-empty__title {
|
||||||
|
margin: 10px 0 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #424242;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- pending change ---------- */
|
||||||
|
|
||||||
|
.uat-pending {
|
||||||
|
border-color: #F5D9A8;
|
||||||
|
background: #FFFAF0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__head {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: flex-start;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__head > .pi {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__text {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-change {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-change__label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__actions {
|
||||||
|
margin-top: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-pending__note {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- chips ---------- */
|
||||||
|
|
||||||
|
.uat-chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-chip .pi {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-chip--add { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.uat-chip--remove { background: #FDE8EA; color: #D11A2A; }
|
||||||
|
|
||||||
|
/* ---------- payroll type list ---------- */
|
||||||
|
|
||||||
|
.uat-list__head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list__tools {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-search {
|
||||||
|
width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list {
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
max-height: 579px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-bottom: 1px solid #F0F0F4;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-row:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-row:hover {
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-row.is-ticked {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-row__name {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
color: #1a1a1a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list--locked .uat-row {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list--locked .uat-row:hover {
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list--locked .uat-row.is-ticked:hover {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-list__empty {
|
||||||
|
padding: 24px 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- save bar ---------- */
|
||||||
|
|
||||||
|
.uat-savebar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 14px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #F0F0F4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-savebar__summary {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- badges / pills (same look as the User and Role pages) ---------- */
|
||||||
|
|
||||||
|
.uat-badge,
|
||||||
|
.uat-pill {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-badge__dot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-badge--success,
|
||||||
|
.uat-pill--success { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.uat-badge--warning,
|
||||||
|
.uat-pill--warning { background: #FFF2DB; color: #8A5300; }
|
||||||
|
.uat-badge--neutral { background: #EEEEF2; color: #5B5B6B; }
|
||||||
|
.uat-badge--info { background: #E8EEFC; color: #2F4FB5; }
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.uat-layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uat-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,287 @@
|
||||||
|
<app-loading-panel></app-loading-panel>
|
||||||
|
|
||||||
<div class="card">
|
<div class="uat-page">
|
||||||
<div class="grid form-group" style="margin: auto;">
|
|
||||||
<div class="col-12 md:col-1" style="margin: auto;">
|
<!-- Page header -->
|
||||||
<label for="idUser">Users</label>
|
<div class="uat-header">
|
||||||
|
<div class="uat-header__icon"><i class="pi pi-id-card"></i></div>
|
||||||
|
<div>
|
||||||
|
<h2 class="uat-title">User Access Type</h2>
|
||||||
|
<p class="uat-subtitle">Choose which payroll types a user can work in. Every change is approved by another administrator before it takes effect.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-5">
|
|
||||||
|
|
||||||
<kendo-dropdownlist [data]="_users"
|
<!-- View switch -->
|
||||||
id="idUser"
|
<div class="uat-views" role="tablist">
|
||||||
[defaultItem]="{ name: 'select a User', id: null }"
|
<button type="button" role="tab" class="uat-view" [class.is-active]="activeView === 'manage'" (click)="activeView = 'manage'">
|
||||||
|
<i class="pi pi-user-edit"></i> Manage access
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" class="uat-view" [class.is-active]="activeView === 'pending'" (click)="activeView = 'pending'; loadPending()">
|
||||||
|
<i class="pi pi-clock"></i> Pending approvals
|
||||||
|
<span class="uat-view__count" [class.has-items]="pendingGroups.length > 0">{{ pendingGroups.length }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (activeView === 'pending') {
|
||||||
|
<div class="uat-card">
|
||||||
|
<div class="uat-list__head">
|
||||||
|
<div>
|
||||||
|
<p class="uat-card__title">Pending approvals</p>
|
||||||
|
<p class="uat-muted">Every user whose payroll access change is waiting for approval. Select several and approve or reject them at once.</p>
|
||||||
|
</div>
|
||||||
|
<button kendoButton type="button" fillMode="flat" [svgIcon]="apiService.KendoSVGIcon['arrowRotateCw']" (click)="loadPending()">Refresh</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (pendingGroups.length === 0) {
|
||||||
|
<div class="uat-empty">
|
||||||
|
<i class="pi pi-check-circle uat-empty__icon"></i>
|
||||||
|
<p class="uat-empty__title">Nothing to approve</p>
|
||||||
|
<p class="uat-muted">No user access change is waiting for approval.</p>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="uat-table-wrap">
|
||||||
|
<table class="uat-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="uat-table__check">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="allPendingSelected"
|
||||||
|
[disabled]="selectablePending.length === 0" (change)="toggleAllPending()" title="Select all" />
|
||||||
|
</th>
|
||||||
|
<th>User</th>
|
||||||
|
<th>Will get access to</th>
|
||||||
|
<th>Will lose access to</th>
|
||||||
|
<th>Requested by</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@for (g of pendingGroups; track g.userID) {
|
||||||
|
<tr [class.is-selected]="isPendingSelected(g.userID)" [class.is-mine]="g.isMine">
|
||||||
|
<td class="uat-table__check">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="isPendingSelected(g.userID)" [disabled]="g.isMine"
|
||||||
|
(change)="togglePendingSelection(g.userID)"
|
||||||
|
[attr.title]="g.isMine ? 'You made this change; another administrator must decide it' : null" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="uat-user__name">{{ g.userName }}</span>
|
||||||
|
<span class="uat-muted uat-block">{{ g.loginID }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="uat-chips">
|
||||||
|
@for (n of g.adds; track n) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||||
|
@if (g.adds.length === 0) { <span class="uat-muted">-</span> }
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="uat-chips">
|
||||||
|
@for (n of g.removes; track n) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||||
|
@if (g.removes.length === 0) { <span class="uat-muted">-</span> }
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="uat-requested">
|
||||||
|
<span>{{ g.makers.join(', ') || '-' }}</span>
|
||||||
|
@if (g.requestDate) {
|
||||||
|
<span class="uat-muted">{{ g.requestDate | date: 'dd MMM yyyy, h:mm a' }}</span>
|
||||||
|
}
|
||||||
|
@if (g.isMine) {
|
||||||
|
<span class="uat-badge uat-badge--neutral"><span class="uat-badge__dot"></span>Your change</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="uat-table__open">
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="openPendingUser(g.userID)">Open</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="uat-savebar">
|
||||||
|
<div class="uat-savebar__summary">
|
||||||
|
<span class="uat-muted">{{ selectedPendingIDs.length }} of {{ selectablePending.length }} selected</span>
|
||||||
|
</div>
|
||||||
|
<div class="uat-btns">
|
||||||
|
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||||
|
[disabled]="selectedPendingIDs.length === 0" (click)="bulkReject()">Reject selected</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||||
|
[disabled]="selectedPendingIDs.length === 0" (click)="bulkApprove()">Approve selected</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (activeView === 'manage') {
|
||||||
|
<div class="uat-layout">
|
||||||
|
|
||||||
|
<!-- Left: the user, and below it any change waiting for approval -->
|
||||||
|
<div class="uat-side">
|
||||||
|
<div class="uat-card uat-user">
|
||||||
|
<label class="uat-label" for="idUser">User</label>
|
||||||
|
<kendo-dropdownlist id="idUser"
|
||||||
|
[data]="filteredUsers"
|
||||||
|
[filterable]="true"
|
||||||
|
(filterChange)="onUserFilter($event)"
|
||||||
|
[defaultItem]="{ userName: 'Select a user', id: null }"
|
||||||
[textField]="'userName'"
|
[textField]="'userName'"
|
||||||
[valueField]="'id'"
|
[valueField]="'id'"
|
||||||
[valuePrimitive]="true"
|
[valuePrimitive]="true"
|
||||||
[(ngModel)]="_selectedUserID"
|
[(ngModel)]="_selectedUserID"
|
||||||
(valueChange)="RefreshGrid($event)"
|
(valueChange)="RefreshGrid($event)"
|
||||||
class="form-control form-control-sm input-sm">
|
class="uat-user__select">
|
||||||
|
<ng-template kendoDropDownListItemTemplate let-dataItem>
|
||||||
|
<span class="uat-user__option">
|
||||||
|
<span>{{ dataItem?.userName }}</span>
|
||||||
|
@if (dataItem?.loginID) {
|
||||||
|
<span class="uat-muted">{{ dataItem.loginID }}</span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-6">
|
@if (selectedUser) {
|
||||||
</div>
|
<div class="uat-user__summary">
|
||||||
|
<div class="uat-avatar">{{ (selectedUser.userName || '?').charAt(0) | uppercase }}</div>
|
||||||
|
<div class="uat-user__info">
|
||||||
|
<span class="uat-user__name">{{ selectedUser.userName }}</span>
|
||||||
|
<span class="uat-muted">{{ selectedUser.loginID }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card card-w-title">
|
<div class="uat-stats">
|
||||||
<div class="grid">
|
<div class="uat-stat">
|
||||||
<div class="col-12">
|
<span class="uat-stat__value">{{ liveCount }}</span>
|
||||||
<kendo-grid [kendoGridBinding]="_payrollTypes"
|
<span class="uat-stat__label">payroll types in use</span>
|
||||||
kendoGridSelectBy="id"
|
</div>
|
||||||
[selectable]="selectableSettings"
|
<div class="uat-stat">
|
||||||
[(selectedKeys)]="_selectedPayrollTypes"
|
@if (hasPending) {
|
||||||
|
<span class="uat-pill uat-pill--warning"><span class="uat-badge__dot"></span>Waiting for approval</span>
|
||||||
|
} @else {
|
||||||
|
<span class="uat-pill uat-pill--success"><span class="uat-badge__dot"></span>Up to date</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
>
|
<div class="uat-legend">
|
||||||
<kendo-grid-checkbox-column [width]="40"
|
<span class="uat-legend__title">Status</span>
|
||||||
[headerClass]="{'text-center': true}"
|
<div class="uat-legend__row"><span class="uat-badge uat-badge--success"><span class="uat-badge__dot"></span>Active</span><span class="uat-muted">user can use it</span></div>
|
||||||
[class]="{'text-center': true}"
|
<div class="uat-legend__row"><span class="uat-badge uat-badge--warning"><span class="uat-badge__dot"></span>New - Not Yet Approved</span><span class="uat-muted">not usable until approved</span></div>
|
||||||
[resizable]="false"
|
<div class="uat-legend__row"><span class="uat-badge uat-badge--warning"><span class="uat-badge__dot"></span>Removal - Not Yet Approved</span><span class="uat-muted">still usable until approved</span></div>
|
||||||
[columnMenu]="false"
|
|
||||||
showSelectAll="true"></kendo-grid-checkbox-column>
|
|
||||||
<kendo-grid-column field="description" title="Access Type" [width]="220">
|
|
||||||
</kendo-grid-column>
|
|
||||||
</kendo-grid>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" class="k-button k-primary" (click)="onSave()">Save</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- A change waiting for approval -->
|
||||||
|
@if (selectedUser && hasPending) {
|
||||||
|
<div class="uat-card uat-pending">
|
||||||
|
<div class="uat-pending__head">
|
||||||
|
<i class="pi pi-clock"></i>
|
||||||
|
<div>
|
||||||
|
<p class="uat-pending__title">Change waiting for approval</p>
|
||||||
|
<p class="uat-pending__text">Until it is approved, {{ selectedUser.userName }} keeps the current access.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (pendingAddNames.length > 0) {
|
||||||
|
<div class="uat-change">
|
||||||
|
<span class="uat-change__label">Will get access to</span>
|
||||||
|
<div class="uat-chips">
|
||||||
|
@for (n of pendingAddNames; track n) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (pendingRemoveNames.length > 0) {
|
||||||
|
<div class="uat-change">
|
||||||
|
<span class="uat-change__label">Will lose access to</span>
|
||||||
|
<div class="uat-chips">
|
||||||
|
@for (n of pendingRemoveNames; track n) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="uat-pending__actions">
|
||||||
|
@if (isMakerOfPending) {
|
||||||
|
<span class="uat-pending__note"><i class="pi pi-info-circle"></i> You made this change, so another administrator must approve or reject it.</span>
|
||||||
|
}
|
||||||
|
<div class="uat-btns">
|
||||||
|
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||||
|
[disabled]="isMakerOfPending" (click)="onReject()">Reject</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||||
|
[disabled]="isMakerOfPending" (click)="onApprove()">Approve</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right: the access -->
|
||||||
|
<div class="uat-main">
|
||||||
|
|
||||||
|
@if (!selectedUser) {
|
||||||
|
<div class="uat-card uat-empty">
|
||||||
|
<i class="pi pi-user uat-empty__icon"></i>
|
||||||
|
<p class="uat-empty__title">Select a user</p>
|
||||||
|
<p class="uat-muted">Their payroll access and any change waiting for approval will show here.</p>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
|
||||||
|
<!-- Payroll types -->
|
||||||
|
<div class="uat-card">
|
||||||
|
<div class="uat-list__head">
|
||||||
|
<div>
|
||||||
|
<p class="uat-card__title">
|
||||||
|
Payroll access
|
||||||
|
<span class="uat-count">{{ _selectedPayrollTypes.length }} of {{ _payrollTypes?.length || 0 }} selected</span>
|
||||||
|
</p>
|
||||||
|
<p class="uat-muted">{{ hasPending ? 'Locked while the change waits for approval.' : 'Tick the payroll types this user should have.' }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="uat-list__tools">
|
||||||
|
<kendo-textbox class="uat-search" placeholder="Search payroll type" [clearButton]="true"
|
||||||
|
[value]="payrollSearch" (valueChange)="payrollSearch = $event ?? ''"></kendo-textbox>
|
||||||
|
@if (!hasPending) {
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="selectAllVisible()">Select all</button>
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="clearAllVisible()">Clear</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="uat-list" [class.uat-list--locked]="hasPending">
|
||||||
|
@for (p of visiblePayrollTypes; track p.id) {
|
||||||
|
<label class="uat-row" [class.is-ticked]="isTicked(p.id)">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="isTicked(p.id)" [disabled]="hasPending" (change)="toggle(p.id)" />
|
||||||
|
<span class="uat-row__name">{{ p.description }}</span>
|
||||||
|
<span class="uat-badge uat-badge--{{ rowBadge(p.id).tone }}">
|
||||||
|
<span class="uat-badge__dot"></span>{{ rowBadge(p.id).text }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
} @empty {
|
||||||
|
<div class="uat-list__empty uat-muted">No payroll type matches the search.</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Save bar -->
|
||||||
|
@if (!hasPending) {
|
||||||
|
<div class="uat-savebar">
|
||||||
|
<div class="uat-savebar__summary">
|
||||||
|
@if (hasDraftChanges) {
|
||||||
|
@if (draftAddNames.length > 0) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ draftAddNames.length }} to add</span> }
|
||||||
|
@if (draftRemoveNames.length > 0) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ draftRemoveNames.length }} to remove</span> }
|
||||||
|
} @else {
|
||||||
|
<span class="uat-muted">No changes yet.</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="uat-btns">
|
||||||
|
<button kendoButton type="button" fillMode="flat" [disabled]="!hasDraftChanges" (click)="resetSelection()">Reset</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['paperPlane']"
|
||||||
|
[disabled]="!hasDraftChanges" (click)="onSave()">Send for approval</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {EnumUserType, EnumAuthStatus} from '../../_models/enums';
|
||||||
import {SelectableSettings} from '@progress/kendo-angular-grid';
|
import {SelectableSettings} from '@progress/kendo-angular-grid';
|
||||||
import {ApiService} from '../../app.api.service';
|
import {ApiService} from '../../app.api.service';
|
||||||
import {HRMNotificationService} from '../../app.notification.service';
|
import {HRMNotificationService} from '../../app.notification.service';
|
||||||
|
import {loadingPanelService} from '../../hrm-loding panel/loding.panel.service';
|
||||||
|
|
||||||
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
||||||
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
||||||
|
|
@ -38,18 +39,30 @@ export class UserAccessTypeComponent implements OnInit {
|
||||||
_selectedUserID: number;
|
_selectedUserID: number;
|
||||||
_selectedPayrollTypes: number[]=[];
|
_selectedPayrollTypes: number[]=[];
|
||||||
public selectableSettings: SelectableSettings;
|
public selectableSettings: SelectableSettings;
|
||||||
|
/** Logged-in user's ID: the maker of a pending change cannot approve or reject it. */
|
||||||
|
currentUserID: number;
|
||||||
|
|
||||||
constructor(public notificationService: HRMNotificationService, public useService: AuthService, public apiService: ApiService) {
|
constructor(public notificationService: HRMNotificationService, public useService: AuthService, public apiService: ApiService,
|
||||||
|
public loadingPanel: loadingPanelService) {
|
||||||
this.apiService.selectedMenuName = ' User Access-Type Entry';
|
this.apiService.selectedMenuName = ' User Access-Type Entry';
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this._selectedUserID = undefined;
|
this._selectedUserID = undefined;
|
||||||
this._selectedPayrollTypes = [];
|
this._selectedPayrollTypes = [];
|
||||||
|
this._userAcessTypes = [];
|
||||||
|
this.useService.GetCurrentUser().subscribe(
|
||||||
|
(resp: any) => {
|
||||||
|
this.currentUserID = resp?.userID;
|
||||||
|
// After the current user is known, so "your own change" can be marked.
|
||||||
|
this.loadPending();
|
||||||
|
},
|
||||||
|
);
|
||||||
this.useService.GetUsers(EnumUserType.User)
|
this.useService.GetUsers(EnumUserType.User)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(resp: any) => {
|
(resp: any) => {
|
||||||
this._users = resp;
|
this._users = resp;
|
||||||
|
this.filteredUsers = (resp ?? []).slice();
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
|
|
@ -78,6 +91,153 @@ export class UserAccessTypeComponent implements OnInit {
|
||||||
this.setSelectableSettings();
|
this.setSelectableSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- Pending approvals (many users at once) ----------
|
||||||
|
|
||||||
|
/** Which view the page shows. */
|
||||||
|
activeView: 'manage' | 'pending' = 'manage';
|
||||||
|
/** One entry per user with a change waiting for approval. */
|
||||||
|
pendingGroups: {
|
||||||
|
userID: number, userName: string, loginID: string,
|
||||||
|
adds: string[], removes: string[], makers: string[], requestDate: Date, isMine: boolean,
|
||||||
|
}[] = [];
|
||||||
|
selectedPendingIDs: number[] = [];
|
||||||
|
|
||||||
|
loadPending(): void {
|
||||||
|
this.useService.GetPendingUserAccessTypes().subscribe(
|
||||||
|
(rows: any[]) => {
|
||||||
|
const groups = new Map<number, any>();
|
||||||
|
(rows ?? []).forEach(r => {
|
||||||
|
let g = groups.get(r.userID);
|
||||||
|
if (!g) {
|
||||||
|
g = { userID: r.userID, userName: r.userName, loginID: r.loginID,
|
||||||
|
adds: [], removes: [], makers: [], makerIDs: [], requestDate: null, isMine: false };
|
||||||
|
groups.set(r.userID, g);
|
||||||
|
}
|
||||||
|
if (r.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve) {
|
||||||
|
g.removes.push(r.description);
|
||||||
|
} else {
|
||||||
|
g.adds.push(r.description);
|
||||||
|
}
|
||||||
|
const maker = r.makerLoginID || (r.makerID ? '#' + r.makerID : '');
|
||||||
|
if (maker && !g.makers.includes(maker)) {
|
||||||
|
g.makers.push(maker);
|
||||||
|
}
|
||||||
|
if (r.makerID && !g.makerIDs.includes(r.makerID)) {
|
||||||
|
g.makerIDs.push(r.makerID);
|
||||||
|
}
|
||||||
|
const d = r.requestDate ? new Date(r.requestDate) : null;
|
||||||
|
if (d && (!g.requestDate || d > g.requestDate)) {
|
||||||
|
g.requestDate = d;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.pendingGroups = Array.from(groups.values()).map(g => ({
|
||||||
|
...g, isMine: g.makerIDs.includes(this.currentUserID),
|
||||||
|
}));
|
||||||
|
// Keep only selections that are still pending and selectable.
|
||||||
|
this.selectedPendingIDs = this.selectedPendingIDs.filter(id =>
|
||||||
|
this.pendingGroups.some(g => g.userID == id && !g.isMine));
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.pendingGroups = [];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pending users the logged-in user may decide (not their own changes). */
|
||||||
|
get selectablePending() {
|
||||||
|
return this.pendingGroups.filter(g => !g.isMine);
|
||||||
|
}
|
||||||
|
|
||||||
|
isPendingSelected(userID: number): boolean {
|
||||||
|
return this.selectedPendingIDs.includes(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePendingSelection(userID: number): void {
|
||||||
|
const g = this.pendingGroups.find(x => x.userID == userID);
|
||||||
|
if (!g || g.isMine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.selectedPendingIDs = this.isPendingSelected(userID)
|
||||||
|
? this.selectedPendingIDs.filter(x => x != userID)
|
||||||
|
: [...this.selectedPendingIDs, userID];
|
||||||
|
}
|
||||||
|
|
||||||
|
get allPendingSelected(): boolean {
|
||||||
|
return this.selectablePending.length > 0 && this.selectablePending.every(g => this.isPendingSelected(g.userID));
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleAllPending(): void {
|
||||||
|
this.selectedPendingIDs = this.allPendingSelected ? [] : this.selectablePending.map(g => g.userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Opens one pending user in the Manage access view. */
|
||||||
|
openPendingUser(userID: number): void {
|
||||||
|
this.activeView = 'manage';
|
||||||
|
this._selectedUserID = userID;
|
||||||
|
this.RefreshGrid(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
bulkApprove(): void {
|
||||||
|
this.bulkDecide(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bulkReject(): void {
|
||||||
|
this.bulkDecide(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bulkDecide(approve: boolean): void {
|
||||||
|
const ids = this.selectedPendingIDs.slice();
|
||||||
|
if (ids.length == 0) {
|
||||||
|
this.notificationService.showWarning('Select at least one user.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const count = ids.length + (ids.length == 1 ? ' user' : ' users');
|
||||||
|
const question = approve
|
||||||
|
? `Are you sure you want to approve the access changes of ${count}?`
|
||||||
|
: `Are you sure you want to reject the access changes of ${count}?`;
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', question).then((isConfirmed) => {
|
||||||
|
if (isConfirmed) {
|
||||||
|
this.sendBulkDecision(approve, ids);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private sendBulkDecision(approve: boolean, ids: number[]): void {
|
||||||
|
const call = approve ? this.useService.ApproveUserAccessTypes(ids) : this.useService.RejectUserAccessTypes(ids);
|
||||||
|
let result: any;
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
call.subscribe(
|
||||||
|
(resp: any) => {
|
||||||
|
result = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
const done = result?.done ?? 0;
|
||||||
|
const failed: any[] = result?.failed ?? [];
|
||||||
|
if (done > 0) {
|
||||||
|
this.notificationService.showSuccess(
|
||||||
|
(approve ? 'Approved' : 'Rejected') + ' for ' + done + (done == 1 ? ' user.' : ' users.'));
|
||||||
|
}
|
||||||
|
if (failed.length > 0) {
|
||||||
|
const names = failed.map(f => {
|
||||||
|
const g = this.pendingGroups.find(x => x.userID == f.userID);
|
||||||
|
return (g?.userName ?? ('User ' + f.userID)) + ': ' + f.message;
|
||||||
|
});
|
||||||
|
this.notificationService.showError(names.join(' | '));
|
||||||
|
}
|
||||||
|
this.selectedPendingIDs = [];
|
||||||
|
this.loadPending();
|
||||||
|
if (this._selectedUserID && ids.includes(this._selectedUserID)) {
|
||||||
|
this.RefreshGrid(this._selectedUserID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
setSelectableSettings(): void {
|
setSelectableSettings(): void {
|
||||||
this.selectableSettings = {
|
this.selectableSettings = {
|
||||||
checkboxOnly: true,
|
checkboxOnly: true,
|
||||||
|
|
@ -85,12 +245,209 @@ export class UserAccessTypeComponent implements OnInit {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- view helpers (screen only; saving and approval logic is below) ----------
|
||||||
|
|
||||||
|
/** Users dropdown, narrowed by what is typed in it. */
|
||||||
|
filteredUsers: User[] = [];
|
||||||
|
/** Search box over the payroll type list. */
|
||||||
|
payrollSearch = '';
|
||||||
|
|
||||||
|
onUserFilter(term: string): void {
|
||||||
|
const t = (term ?? '').trim().toLowerCase();
|
||||||
|
this.filteredUsers = (this._users ?? []).filter(u =>
|
||||||
|
!t || (u.userName ?? '').toLowerCase().includes(t) || (u.loginID ?? '').toLowerCase().includes(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
get selectedUser(): User {
|
||||||
|
return (this._users ?? []).find(u => u.id == this._selectedUserID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Payroll types shown in the list, after the search box. */
|
||||||
|
get visiblePayrollTypes(): PayrollType[] {
|
||||||
|
const t = this.payrollSearch.trim().toLowerCase();
|
||||||
|
return (this._payrollTypes ?? []).filter(p => !t || (p.description ?? '').toLowerCase().includes(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
isTicked(payrollTypeID: number): boolean {
|
||||||
|
return this._selectedPayrollTypes.includes(payrollTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ticks or unticks one payroll type. Locked while a change waits for approval. */
|
||||||
|
toggle(payrollTypeID: number): void {
|
||||||
|
if (this.hasPending || !this._selectedUserID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._selectedPayrollTypes = this.isTicked(payrollTypeID)
|
||||||
|
? this._selectedPayrollTypes.filter(x => x != payrollTypeID)
|
||||||
|
: [...this._selectedPayrollTypes, payrollTypeID];
|
||||||
|
}
|
||||||
|
|
||||||
|
selectAllVisible(): void {
|
||||||
|
if (this.hasPending || !this._selectedUserID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ids = this.visiblePayrollTypes.map(p => p.id).filter(id => !this.isTicked(id));
|
||||||
|
this._selectedPayrollTypes = [...this._selectedPayrollTypes, ...ids];
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAllVisible(): void {
|
||||||
|
if (this.hasPending || !this._selectedUserID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ids = this.visiblePayrollTypes.map(p => p.id);
|
||||||
|
this._selectedPayrollTypes = this._selectedPayrollTypes.filter(x => !ids.includes(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Undoes unsaved ticks: back to what the user has now. */
|
||||||
|
resetSelection(): void {
|
||||||
|
this._selectedPayrollTypes = (this._userAcessTypes ?? [])
|
||||||
|
.filter(x => x.accessTypeStatus != EnumAuthStatus.Deleted_Not_Yet_Approve)
|
||||||
|
.map(x => x.payrollTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
payrollName(payrollTypeID: number): string {
|
||||||
|
return (this._payrollTypes ?? []).find(p => p.id == payrollTypeID)?.description ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Payroll types the user can use right now (approved, or a removal not yet approved). */
|
||||||
|
get liveCount(): number {
|
||||||
|
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus != EnumAuthStatus.New_Not_Yet_Approve).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Waiting for approval: access to be given. */
|
||||||
|
get pendingAddNames(): string[] {
|
||||||
|
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus == EnumAuthStatus.New_Not_Yet_Approve)
|
||||||
|
.map(x => this.payrollName(x.payrollTypeID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Waiting for approval: access to be taken away. */
|
||||||
|
get pendingRemoveNames(): string[] {
|
||||||
|
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve)
|
||||||
|
.map(x => this.payrollName(x.payrollTypeID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unsaved ticks that would give new access. */
|
||||||
|
get draftAddNames(): string[] {
|
||||||
|
return this._selectedPayrollTypes
|
||||||
|
.filter(id => !(this._userAcessTypes ?? []).some(x => x.payrollTypeID == id))
|
||||||
|
.map(id => this.payrollName(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unsaved unticks that would take access away. */
|
||||||
|
get draftRemoveNames(): string[] {
|
||||||
|
return (this._userAcessTypes ?? [])
|
||||||
|
.filter(x => !this.isPendingStatus(x.accessTypeStatus) && !this.isTicked(x.payrollTypeID))
|
||||||
|
.map(x => this.payrollName(x.payrollTypeID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Badge on one payroll type row: unsaved ticks first, then the saved status. */
|
||||||
|
rowBadge(payrollTypeID: number): { text: string, tone: string } {
|
||||||
|
const saved = this.statusOf(payrollTypeID);
|
||||||
|
if (!this.hasPending) {
|
||||||
|
const row = (this._userAcessTypes ?? []).find(x => x.payrollTypeID == payrollTypeID);
|
||||||
|
if (!row && this.isTicked(payrollTypeID)) {
|
||||||
|
return { text: 'To be added', tone: 'info' };
|
||||||
|
}
|
||||||
|
if (row && !this.isTicked(payrollTypeID)) {
|
||||||
|
return { text: 'To be removed', tone: 'info' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saved;
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasDraftChanges(): boolean {
|
||||||
|
return this.draftAddNames.length > 0 || this.draftRemoveNames.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- maker-checker ----------
|
||||||
|
|
||||||
|
private isPendingStatus(status: EnumAuthStatus): boolean {
|
||||||
|
return status == EnumAuthStatus.New_Not_Yet_Approve || status == EnumAuthStatus.Deleted_Not_Yet_Approve;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The selected user has an access change waiting for approval. */
|
||||||
|
get hasPending(): boolean {
|
||||||
|
return (this._userAcessTypes ?? []).some(x => this.isPendingStatus(x.accessTypeStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The logged-in user made (part of) the pending change, so cannot approve or reject it. */
|
||||||
|
get isMakerOfPending(): boolean {
|
||||||
|
return (this._userAcessTypes ?? []).some(x => {
|
||||||
|
const row: any = x;
|
||||||
|
const maker = x.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve ? row.modifiedBy : row.createdBy;
|
||||||
|
return this.isPendingStatus(x.accessTypeStatus) && maker == this.currentUserID;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Status column: the access the user has, or what is waiting for approval. */
|
||||||
|
statusOf(payrollTypeID: number): { text: string, tone: string } {
|
||||||
|
const row = (this._userAcessTypes ?? []).find(x => x.payrollTypeID == payrollTypeID);
|
||||||
|
if (row == undefined) {
|
||||||
|
return { text: 'No access', tone: 'neutral' };
|
||||||
|
}
|
||||||
|
switch (row.accessTypeStatus) {
|
||||||
|
case EnumAuthStatus.New_Not_Yet_Approve:
|
||||||
|
return { text: 'New - Not Yet Approved', tone: 'warning' };
|
||||||
|
case EnumAuthStatus.Deleted_Not_Yet_Approve:
|
||||||
|
return { text: 'Removal - Not Yet Approved', tone: 'warning' };
|
||||||
|
default:
|
||||||
|
return { text: 'Active', tone: 'success' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onApprove(): void {
|
||||||
|
this.decide(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
onReject(): void {
|
||||||
|
this.decide(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private decide(approve: boolean): void {
|
||||||
|
const userID = this._selectedUserID;
|
||||||
|
if (userID == undefined || !this.hasPending) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const who = this.selectedUser?.userName ?? '';
|
||||||
|
const question = approve
|
||||||
|
? `Are you sure you want to approve the access change of ${who}?`
|
||||||
|
: `Are you sure you want to reject the access change of ${who}?`;
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', question).then((isConfirmed) => {
|
||||||
|
if (isConfirmed) {
|
||||||
|
this.sendDecision(approve, userID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private sendDecision(approve: boolean, userID: number): void {
|
||||||
|
const call = approve ? this.useService.ApproveUserAccessType(userID) : this.useService.RejectUserAccessType(userID);
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
call.subscribe(
|
||||||
|
() => { },
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showSuccess(approve ? 'Approved Successfully.' : 'Rejected Successfully.');
|
||||||
|
this.RefreshGrid(userID);
|
||||||
|
this.loadPending();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
RefreshGrid(selectedUser: any) {
|
RefreshGrid(selectedUser: any) {
|
||||||
this._selectedPayrollTypes = [];
|
this._selectedPayrollTypes = [];
|
||||||
|
this._userAcessTypes = [];
|
||||||
|
this.setSelectableSettings();
|
||||||
|
if (selectedUser == undefined || selectedUser == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.useService.GetUserAccessType(selectedUser)
|
this.useService.GetUserAccessType(selectedUser)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(resp: any) => {
|
(resp: any) => {
|
||||||
this._userAcessTypes = resp;
|
this._userAcessTypes = resp ?? [];
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
|
|
@ -98,13 +455,17 @@ export class UserAccessTypeComponent implements OnInit {
|
||||||
() => {
|
() => {
|
||||||
|
|
||||||
this._userAcessTypes.forEach(x => {
|
this._userAcessTypes.forEach(x => {
|
||||||
|
// A removal waiting for approval shows unticked: the ticks show the requested state.
|
||||||
|
if (x.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var ptype: PayrollType = this._payrollTypes.find(y => y.id == x.payrollTypeID);
|
var ptype: PayrollType = this._payrollTypes.find(y => y.id == x.payrollTypeID);
|
||||||
if (ptype != undefined) {
|
if (ptype != undefined) {
|
||||||
this._selectedPayrollTypes.push(ptype.id);
|
this._selectedPayrollTypes.push(ptype.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._selectedPayrollTypes = [... this._selectedPayrollTypes];
|
this._selectedPayrollTypes = [... this._selectedPayrollTypes];
|
||||||
|
this.setSelectableSettings();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -119,57 +480,49 @@ export class UserAccessTypeComponent implements OnInit {
|
||||||
public onSave(): void {
|
public onSave(): void {
|
||||||
|
|
||||||
this._userAcessTypesforSave= [];
|
this._userAcessTypesforSave= [];
|
||||||
if (this._selectedPayrollTypes.length <= 0) {
|
if (this._selectedUserID == undefined || this._selectedUserID == null) {
|
||||||
|
this.notificationService.showWarning('Select a user.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// New Item
|
if (this.hasPending) {
|
||||||
|
this.notificationService.showWarning('This user already has an access change waiting for approval. Approve or reject it first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this._selectedPayrollTypes.length <= 0) {
|
||||||
|
this.notificationService.showWarning('Select at least one payroll type.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The ticked payroll types are sent as they are; the server works out what is new
|
||||||
|
// (New - Not Yet Approved) and what was unticked (Removal - Not Yet Approved).
|
||||||
this._selectedPayrollTypes.forEach(x => {
|
this._selectedPayrollTypes.forEach(x => {
|
||||||
|
var ptype: UserAccessType = new UserAccessType();
|
||||||
var ptype: UserAccessType = this._userAcessTypes.find(y => x == y.payrollTypeID);
|
|
||||||
if (ptype == undefined) {
|
|
||||||
var newItem: UserAccessType = new UserAccessType();
|
|
||||||
newItem.userID = this._selectedUserID;
|
|
||||||
newItem.payrollTypeID = x;
|
|
||||||
this._userAcessTypes.push(newItem);
|
|
||||||
|
|
||||||
ptype = new UserAccessType();
|
|
||||||
ptype.userID = this._selectedUserID;
|
ptype.userID = this._selectedUserID;
|
||||||
ptype.payrollTypeID = x;
|
ptype.payrollTypeID = x;
|
||||||
|
let payrollType = this._payrollTypes.find(p => p.id === x);
|
||||||
|
if (payrollType) {
|
||||||
|
ptype.description = payrollType.description;
|
||||||
}
|
}
|
||||||
this._userAcessTypesforSave.push(ptype);
|
this._userAcessTypesforSave.push(ptype);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
|
||||||
|
|
||||||
// Modify Existing which unchecked
|
|
||||||
this._userAcessTypes.forEach(x => {
|
|
||||||
|
|
||||||
var ptype: number = this._selectedPayrollTypes.find(y => x.payrollTypeID == y);
|
|
||||||
if (ptype == undefined) {
|
|
||||||
x.accessTypeStatus = EnumAuthStatus.Deleted_Not_Yet_Approve;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this._userAcessTypesforSave.forEach(x =>{
|
|
||||||
let payrollType = this._payrollTypes.find(p => p.id === x.payrollTypeID);
|
|
||||||
if(payrollType){
|
|
||||||
x.description = payrollType.description;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.useService.SaveUserAccessType(this._userAcessTypesforSave)
|
this.useService.SaveUserAccessType(this._userAcessTypesforSave)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(resp: any) => {
|
(resp: any) => {
|
||||||
|
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
this.notificationService.showError(err);
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
//ON ERROR
|
//ON ERROR
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
//ON Success
|
//ON Success
|
||||||
this.notificationService.showSuccess('Saved Successfully.');
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showSuccess('Saved. The change is waiting for approval.');
|
||||||
// this.loadGrid();
|
// this.loadGrid();
|
||||||
this.RefreshGrid(this._userAcessTypesforSave[0].userID);
|
this.RefreshGrid(this._userAcessTypesforSave[0].userID);
|
||||||
|
this.loadPending();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,407 @@
|
||||||
|
/* User-Role Assignment dialog. Scoped to this component (default emulated encapsulation).
|
||||||
|
Same look as the User Access Type page (user-access-type.component.css). */
|
||||||
|
|
||||||
|
.ura {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 330px minmax(0, 1fr);
|
||||||
|
gap: 14px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-side {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-card {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-card__title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #888888;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-label--gap {
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-muted {
|
||||||
|
color: #888888;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-option {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Admin / Self Service switch */
|
||||||
|
.ura-switch {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-switch__btn {
|
||||||
|
flex: 1;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
height: 32px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-switch__btn:hover:not(:disabled) {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-switch__btn.is-active {
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-switch__btn:disabled:not(.is-active) {
|
||||||
|
opacity: 0.45;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Person */
|
||||||
|
.ura-person {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-avatar {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 600;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-person__info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-person__name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-stats {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 14px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-stat {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-stat__value {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #414278;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-stat__label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-note {
|
||||||
|
margin: 12px 0 0;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #E8EEFC;
|
||||||
|
color: #2F4FB5;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pending change */
|
||||||
|
.ura-pending {
|
||||||
|
border-color: #F5D9A8;
|
||||||
|
background: #FFFAF0;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-pending__head {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-pending__head > .pi {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-pending__title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-pending__text {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-change__label {
|
||||||
|
display: block;
|
||||||
|
margin: 12px 0 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-pending__note {
|
||||||
|
margin: 12px 0 0;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chips */
|
||||||
|
.ura-chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-chip .pi {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-chip--add { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.ura-chip--remove { background: #FDE8EA; color: #D11A2A; }
|
||||||
|
|
||||||
|
/* Buttons */
|
||||||
|
.ura-btns {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-btns--full {
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-btns--full > button {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Roles list */
|
||||||
|
.ura-main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list__head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list__tools {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-search {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-count {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 8px;
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #DEDEFF;
|
||||||
|
color: #414278;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 22px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list {
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
max-height: 550px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-bottom: 1px solid #F0F0F4;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-row:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-row:hover {
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-row.is-ticked {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-row__name {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
color: #1a1a1a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list--locked .ura-row {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list--locked .ura-row:hover {
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list--locked .ura-row.is-ticked:hover {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-list__empty {
|
||||||
|
padding: 24px 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Footer */
|
||||||
|
.ura-footer {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #F0F0F4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-footer__summary {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Badges (same look as the User, Role and User Access Type pages) */
|
||||||
|
.ura-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-badge__dot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-badge--success { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.ura-badge--warning { background: #FFF2DB; color: #8A5300; }
|
||||||
|
.ura-badge--neutral { background: #EEEEF2; color: #5B5B6B; }
|
||||||
|
.ura-badge--info { background: #E8EEFC; color: #2F4FB5; }
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.ura-layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ura-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,196 @@
|
||||||
<app-loading-panel></app-loading-panel>
|
<app-loading-panel></app-loading-panel>
|
||||||
<div class="grid form-group" style="margin: auto;">
|
|
||||||
<div class="col-12 md:col-2" style="margin: auto;">
|
|
||||||
<label for="idRoleType">Role Type</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2">
|
|
||||||
|
|
||||||
<kendo-dropdownlist [data]="roleTypes"
|
<div class="ura">
|
||||||
id="idRoleType"
|
<div class="ura-layout">
|
||||||
[defaultItem]="{ name: 'select a Type', value: null }"
|
|
||||||
[textField]="'name'"
|
<!-- Left: whose roles -->
|
||||||
[valueField]="'value'"
|
<div class="ura-side">
|
||||||
[valuePrimitive]="true"
|
<div class="ura-card">
|
||||||
class="form-control form-control-sm input-sm"
|
<span class="ura-label">Role type</span>
|
||||||
(valueChange)="onRoleChange($event)"
|
<div class="ura-switch" role="tablist">
|
||||||
[(ngModel)]="_selectedRoleType">
|
<button type="button" role="tab" class="ura-switch__btn" [class.is-active]="roleType == roletypeEnum.Admin"
|
||||||
</kendo-dropdownlist>
|
[disabled]="!!openFor" (click)="setRoleType(roletypeEnum.Admin)">
|
||||||
|
<i class="pi pi-shield"></i> Admin
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" class="ura-switch__btn" [class.is-active]="roleType == roletypeEnum.Self_Service"
|
||||||
|
[disabled]="!!openFor" (click)="setRoleType(roletypeEnum.Self_Service)">
|
||||||
|
<i class="pi pi-users"></i> Self Service
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-8">
|
|
||||||
</div>
|
@if (roleType == roletypeEnum.Admin) {
|
||||||
</div>
|
<label class="ura-label ura-label--gap" for="uraUser">User</label>
|
||||||
@if (_selectedRoleType == roletypeEnum.Admin) {
|
<kendo-dropdownlist id="uraUser" class="ura-select"
|
||||||
<div >
|
[data]="filteredUsers"
|
||||||
<div class="grid form-group" style="margin: auto;">
|
[filterable]="true"
|
||||||
<div class="col-12 md:col-2" style="margin: auto;">
|
(filterChange)="onUserFilter($event)"
|
||||||
<label for="idUser">Users</label>
|
[defaultItem]="{ userName: 'Select a user', id: null }"
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2">
|
|
||||||
<kendo-dropdownlist [data]="_users"
|
|
||||||
id="idUser"
|
|
||||||
[defaultItem]="{ name: 'select a Type', value: null }"
|
|
||||||
[textField]="'userName'"
|
[textField]="'userName'"
|
||||||
[valueField]="'id'"
|
[valueField]="'id'"
|
||||||
[valuePrimitive]="true"
|
[valuePrimitive]="true"
|
||||||
[(ngModel)]="_selectedUserID"
|
[disabled]="!!openFor"
|
||||||
class="form-control form-control-sm input-sm">
|
[(ngModel)]="selectedUserID"
|
||||||
|
(valueChange)="onUserChange($event)">
|
||||||
|
<ng-template kendoDropDownListItemTemplate let-dataItem>
|
||||||
|
<span class="ura-option">
|
||||||
|
<span>{{ dataItem?.userName }}</span>
|
||||||
|
@if (dataItem?.loginID) { <span class="ura-muted">{{ dataItem.loginID }}</span> }
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-8" align="right">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['plus']" class="k-button k-primary" (click)="AddUser()">Add User</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
@if (_selectedRoleType == roletypeEnum.Self_Service) {
|
|
||||||
<div >
|
@if (roleType == roletypeEnum.Self_Service) {
|
||||||
<div class="grid form-group" style="margin: auto;">
|
<label class="ura-label ura-label--gap" for="uraPayroll">Payroll type</label>
|
||||||
<div class="col-12 md:col-2" style="margin: auto;">
|
<kendo-dropdownlist id="uraPayroll" class="ura-select"
|
||||||
<label for="idpayrollType">Payroll Type</label>
|
[data]="payrollTypes"
|
||||||
</div>
|
[defaultItem]="{ description: 'Select a payroll type', id: null }"
|
||||||
<div class="col-12 md:col-4">
|
|
||||||
<kendo-dropdownlist [data]="_payrollTypes"
|
|
||||||
id="idpayrollType"
|
|
||||||
[defaultItem]="{ description: 'select a Type', id: null }"
|
|
||||||
[textField]="'description'"
|
[textField]="'description'"
|
||||||
[valueField]="'id'"
|
[valueField]="'id'"
|
||||||
[valuePrimitive]="true"
|
[valuePrimitive]="true"
|
||||||
class="form-control form-control-sm input-sm"
|
[disabled]="!!openFor"
|
||||||
[(ngModel)]="_selectedPayrollTypeid">
|
[(ngModel)]="selectedPayrollTypeID"
|
||||||
|
(valueChange)="onPayrollTypeChange()">
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
|
|
||||||
|
@if (!openFor) {
|
||||||
|
<label class="ura-label ura-label--gap">Employee</label>
|
||||||
|
@if (selectedPayrollTypeID) {
|
||||||
|
<app-employee-picker (ItemSelected)="onEmployeeSelected($event)"
|
||||||
|
[payrollTypeID]="selectedPayrollTypeID"
|
||||||
|
[isActive]="true"
|
||||||
|
[MultiSelect]="false"></app-employee-picker>
|
||||||
|
} @else {
|
||||||
|
<p class="ura-muted">Select a payroll type first.</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (state) {
|
||||||
|
<div class="ura-person">
|
||||||
|
<div class="ura-avatar">{{ (state.personName || '?').charAt(0) | uppercase }}</div>
|
||||||
|
<div class="ura-person__info">
|
||||||
|
<span class="ura-person__name">{{ state.personName }}</span>
|
||||||
|
<span class="ura-muted">{{ state.loginID }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-2" style="margin: auto;">
|
|
||||||
<label for="idemployeeselection">Select Employee:</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 md:col-4">
|
<div class="ura-stats">
|
||||||
<app-employee-picker id="idemployeeselection" (ItemSelected)="GetSelectedEmployee($event)"
|
<div class="ura-stat">
|
||||||
[payrollTypeID]="_selectedPayrollTypeid"
|
<span class="ura-stat__value">{{ state.liveRoleIDs.length }}</span>
|
||||||
[isActive]="_selectedPayrollTypeid != undefined"
|
<span class="ura-stat__label">{{ state.liveRoleIDs.length == 1 ? 'role' : 'roles' }} now</span>
|
||||||
[MultiSelect]="true"></app-employee-picker>
|
|
||||||
</div>
|
</div>
|
||||||
<!--<div class="col-12 md:col-4">
|
@if (hasPending) {
|
||||||
<button class="k-button" (click)="SearchUnAssingedEmp()">Find all un-Assinged Employees</button>
|
<span class="ura-badge ura-badge--warning"><span class="ura-badge__dot"></span>Waiting for approval</span>
|
||||||
</div>-->
|
} @else {
|
||||||
|
<span class="ura-badge ura-badge--success"><span class="ura-badge__dot"></span>Up to date</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
@if (!state.hasLogin) {
|
||||||
|
<p class="ura-note"><i class="pi pi-info-circle"></i> No login yet. Sending this change creates one, switched off; it can sign in, and the login details are e-mailed, only after approval.</p>
|
||||||
|
} @else if (state.loginWaiting) {
|
||||||
|
<p class="ura-note"><i class="pi pi-info-circle"></i> The login is waiting for this change to be approved and cannot sign in yet.</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- A change waiting for approval -->
|
||||||
|
@if (state && hasPending) {
|
||||||
|
<div class="ura-card ura-pending">
|
||||||
|
<div class="ura-pending__head">
|
||||||
|
<i class="pi pi-clock"></i>
|
||||||
|
<div>
|
||||||
|
<p class="ura-pending__title">Change waiting for approval</p>
|
||||||
|
<p class="ura-pending__text">
|
||||||
|
Requested by <b>{{ pendingMaker || '-' }}</b>
|
||||||
|
@if (pendingDate) { on {{ pendingDate | date: 'dd MMM yyyy, h:mm a' }} }.
|
||||||
|
Until it is approved, {{ state.personName }} keeps the current roles.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (pendingAddNames.length > 0) {
|
||||||
|
<span class="ura-change__label">Will get</span>
|
||||||
|
<div class="ura-chips">
|
||||||
|
@for (n of pendingAddNames; track n) { <span class="ura-chip ura-chip--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (pendingRemoveNames.length > 0) {
|
||||||
|
<span class="ura-change__label">Will lose</span>
|
||||||
|
<div class="ura-chips">
|
||||||
|
@for (n of pendingRemoveNames; track n) { <span class="ura-chip ura-chip--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (isMakerOfPending) {
|
||||||
|
<p class="ura-pending__note"><i class="pi pi-info-circle"></i> You made this change, so another administrator must approve or reject it.</p>
|
||||||
|
}
|
||||||
|
<div class="ura-btns ura-btns--full">
|
||||||
|
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||||
|
[disabled]="isMakerOfPending" (click)="onReject()">Reject</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||||
|
[disabled]="isMakerOfPending" (click)="onApprove()">Approve</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="grid ">
|
|
||||||
<div class="col-12 lg:col-3">
|
|
||||||
<kendo-grid [data]="_gridRoles" style="height: 300px; width: 100%;"
|
|
||||||
[(selectedKeys)]="_selectedRoles"
|
|
||||||
[selectable]="selectableSettings"
|
|
||||||
[kendoGridSelectBy]="'id'"
|
|
||||||
(selectionChange)="onSelectionRoleChange($event)">
|
|
||||||
<kendo-grid-checkbox-column width="25%" [headerClass]="{'text-center': true}" [class]="{'text-center': true}"></kendo-grid-checkbox-column>
|
|
||||||
<kendo-grid-column field="name" title="Role-Name" width="75%">
|
|
||||||
</kendo-grid-column>
|
|
||||||
</kendo-grid>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 lg:col-9">
|
<!-- Right: roles -->
|
||||||
<kendo-grid [data]="_gridUsers" style="height: 300px; width: 100%;"
|
<div class="ura-card ura-main">
|
||||||
[selectedKeys]="_selectedLoginIDs"
|
<div class="ura-list__head">
|
||||||
[selectable]="selectableSettings"
|
<div>
|
||||||
[kendoGridSelectBy]="'loginID'">
|
<p class="ura-card__title">
|
||||||
<kendo-grid-column field="loginID" title="Login-ID" width="15%">
|
Roles
|
||||||
</kendo-grid-column>
|
@if (state) { <span class="ura-count">{{ selectedRoleIDs.length }} of {{ rolesForType.length }} selected</span> }
|
||||||
<kendo-grid-column field="userName" title="Name" width="15%">
|
</p>
|
||||||
</kendo-grid-column>
|
<p class="ura-muted">
|
||||||
<kendo-grid-column field="roleNames" title="Role-Name" width="35%">
|
@if (!state) { Select {{ roleType == roletypeEnum.Admin ? 'a user' : 'an employee' }} to see and change their roles. }
|
||||||
</kendo-grid-column>
|
@else if (hasPending) { Locked while the change waits for approval. }
|
||||||
<kendo-grid-column title="Status" width="15%">
|
@else { Tick the roles this person should have. Only approved roles can be given. }
|
||||||
</kendo-grid-column>
|
</p>
|
||||||
<kendo-grid-command-column title="Edit/Delete" width="20%" [style]="{'text-align':'center'}">
|
</div>
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<div class="ura-list__tools">
|
||||||
<button kendoGridRemoveCommand [svgIcon]="apiService.KendoSVGIcon['delete']" class="kt-delete" (click)="Remove( rowIndex )"></button>
|
<kendo-textbox class="ura-search" placeholder="Search role" [clearButton]="true"
|
||||||
</ng-template>
|
[value]="roleSearch" (valueChange)="roleSearch = $event ?? ''"></kendo-textbox>
|
||||||
</kendo-grid-command-column>
|
@if (state && !hasPending) {
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="selectAllVisible()">Select all</button>
|
||||||
</kendo-grid>
|
<button kendoButton type="button" fillMode="flat" (click)="clearAllVisible()">Clear</button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
|
||||||
<div class="col-12" align="right">
|
<div class="ura-list" [class.ura-list--locked]="locked">
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['cross']" class="k-button k-primary" (click)="onCancel($event)" style="margin-right: 5px;">Cancel</button>
|
@for (r of visibleRoles; track r.id) {
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" class="k-button k-primary" (click)="onSave()">Save</button>
|
<label class="ura-row" [class.is-ticked]="state && isTicked(r.id)">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="state && isTicked(r.id)" [disabled]="locked" (change)="toggle(r.id)" />
|
||||||
|
<span class="ura-row__name">{{ r.name }}</span>
|
||||||
|
@if (state) {
|
||||||
|
<span class="ura-badge ura-badge--{{ roleBadge(r.id).tone }}">
|
||||||
|
<span class="ura-badge__dot"></span>{{ roleBadge(r.id).text }}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
} @empty {
|
||||||
|
<div class="ura-list__empty ura-muted">No role matches.</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<div class="ura-footer">
|
||||||
|
<div class="ura-footer__summary">
|
||||||
|
@if (hasDraftChanges) {
|
||||||
|
@if (draftAddNames.length > 0) { <span class="ura-chip ura-chip--add"><i class="pi pi-plus"></i>{{ draftAddNames.length }} to add</span> }
|
||||||
|
@if (draftRemoveNames.length > 0) { <span class="ura-chip ura-chip--remove"><i class="pi pi-minus"></i>{{ draftRemoveNames.length }} to remove</span> }
|
||||||
|
} @else if (state && !hasPending) {
|
||||||
|
<span class="ura-muted">No changes yet.</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="ura-btns">
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="onCancel()">Close</button>
|
||||||
|
@if (state && !hasPending) {
|
||||||
|
<button kendoButton type="button" fillMode="flat" [disabled]="!hasDraftChanges" (click)="resetSelection()">Reset</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['paperPlane']"
|
||||||
|
[disabled]="!hasDraftChanges" (click)="sendForApproval()">Send for approval</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,23 @@
|
||||||
import {Component, EventEmitter, OnInit, Output, Input, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, EventEmitter, OnInit, Output, Input, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {FormControl, FormGroup} from '@angular/forms';
|
|
||||||
import {Role} from '../../../_models/Authentication/role';
|
import {Role} from '../../../_models/Authentication/role';
|
||||||
import {User} from '../../../_models/Authentication/user';
|
import {User} from '../../../_models/Authentication/user';
|
||||||
import {AuthService} from '../../../_services/auth/auth.service';
|
import {AuthService} from '../../../_services/auth/auth.service';
|
||||||
import {HRMNotificationService} from '../../../app.notification.service';
|
import {HRMNotificationService} from '../../../app.notification.service';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {EnumAuthStatus, EnumRoleType, EnumUserType} from '../../../_models/enums';
|
||||||
import {EnumExtension, EnumRoleType, EnumUserType, EnumAuthStatus} from '../../../_models/enums';
|
import {
|
||||||
import {SelectableSettings} from '@progress/kendo-angular-grid';
|
EnumUserRoleRequestType, UserRoleChangeRequest, UserRoleState, UserRoleSubject,
|
||||||
import {UserRole} from '../../../_models/Authentication/UserRole';
|
} from '../../../_models/Authentication/UserRole';
|
||||||
import { SearchEmployee } from '../../../_models/Employee/searchEmployee';
|
import { SearchEmployee } from '../../../_models/Employee/searchEmployee';
|
||||||
import { PayrollType } from '../../../_models/Authentication/payrollType';
|
import { PayrollType } from '../../../_models/Authentication/payrollType';
|
||||||
import { EmployeeServices } from '../../../_services/employee/employee.service';
|
|
||||||
import { UntilityHandlerService } from '../../../utility.hanldler.service';
|
|
||||||
|
|
||||||
import { LoadingPanelComponent } from 'src/app/hrm-loding panel/loading-panel.component';
|
|
||||||
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
|
||||||
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { KENDO_GRID } from '@progress/kendo-angular-grid';
|
|
||||||
import { DatePickerModule } from '@progress/kendo-angular-dateinputs';
|
|
||||||
import { ApiService } from 'src/app/app.api.service';
|
import { ApiService } from 'src/app/app.api.service';
|
||||||
|
import { loadingPanelService } from '../../../hrm-loding panel/loding.panel.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User-Role Assignment dialog (Authentication > User Role Permission).
|
||||||
|
* Pick whose roles (an Admin user, or a Self Service employee), tick the roles they should have and
|
||||||
|
* send the change for approval; a change waiting for approval is shown, and another administrator
|
||||||
|
* approves or rejects it here. Nothing is live until it is approved (server-side maker-checker).
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-role-entry',
|
selector: 'app-user-role-entry',
|
||||||
templateUrl: './user-role-entry.component.html',
|
templateUrl: './user-role-entry.component.html',
|
||||||
|
|
@ -29,342 +25,342 @@ import { ApiService } from 'src/app/app.api.service';
|
||||||
changeDetection: ChangeDetectionStrategy.Eager,
|
changeDetection: ChangeDetectionStrategy.Eager,
|
||||||
standalone: false,
|
standalone: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
export class UserRoleEntryComponent implements OnInit {
|
export class UserRoleEntryComponent implements OnInit {
|
||||||
userRolePermissionForm: FormGroup;
|
readonly roletypeEnum: typeof EnumRoleType = EnumRoleType;
|
||||||
public active = false;
|
|
||||||
_userRoles: UserRole[];
|
/** Emits true when something changed (sent, approved or rejected), false on cancel. */
|
||||||
_allroles: Role[];
|
|
||||||
_gridRoles: Role[];
|
|
||||||
_users: User[];
|
|
||||||
_gridUsers: User[];
|
|
||||||
_selectedUserID: number;
|
|
||||||
_previousRoles: number[] = [];
|
|
||||||
_selectedRoles: number[] = [];
|
|
||||||
_selectedRoleType: EnumRoleType ;
|
|
||||||
roletypeEnum: typeof EnumRoleType = EnumRoleType;
|
|
||||||
_payrollTypes: PayrollType[];
|
|
||||||
_selectedPayrollTypeid: number;
|
|
||||||
roleTypes: any = EnumExtension.getNamesAndValues(EnumRoleType);
|
|
||||||
public selectableSettings: SelectableSettings;
|
|
||||||
@Output() saveCompleted: EventEmitter<boolean> = new EventEmitter();
|
@Output() saveCompleted: EventEmitter<boolean> = new EventEmitter();
|
||||||
_selectedEmployees: SearchEmployee[];
|
|
||||||
_selectedLoginIDs: string[];
|
/** Kept for the list page: true when the dialog is opened. */
|
||||||
_initializeValue : boolean;
|
@Input() public set InitializeForm(initializeValue: boolean) {
|
||||||
|
if (initializeValue === true) {
|
||||||
|
this.resetPerson();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Open the dialog on this person (from the list or the Pending approvals view). */
|
||||||
|
@Input() openFor: UserRoleSubject;
|
||||||
|
|
||||||
|
roleType: EnumRoleType = EnumRoleType.Admin;
|
||||||
|
users: User[] = [];
|
||||||
|
filteredUsers: User[] = [];
|
||||||
|
payrollTypes: PayrollType[] = [];
|
||||||
|
allRoles: Role[] = [];
|
||||||
|
currentUserID: number;
|
||||||
|
|
||||||
|
selectedUserID: number;
|
||||||
|
selectedPayrollTypeID: number;
|
||||||
|
selectedEmployee: SearchEmployee;
|
||||||
|
|
||||||
|
state: UserRoleState;
|
||||||
|
selectedRoleIDs: number[] = [];
|
||||||
|
roleSearch = '';
|
||||||
|
|
||||||
constructor(public userService: AuthService,
|
constructor(public userService: AuthService,
|
||||||
public apiService: ApiService,
|
public apiService: ApiService,
|
||||||
public notificationService: HRMNotificationService,
|
public notificationService: HRMNotificationService,
|
||||||
public router: Router,
|
public loadingPanel: loadingPanelService) {
|
||||||
public route: ActivatedRoute, public employeeService: EmployeeServices,
|
|
||||||
public utilityService: UntilityHandlerService) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input() public set InitializeForm(initializeValue: boolean) {
|
|
||||||
this._initializeValue = initializeValue;
|
|
||||||
if (this._initializeValue == true) {
|
|
||||||
this._gridRoles = [];
|
|
||||||
this._gridUsers = [];
|
|
||||||
this._selectedEmployees = [];
|
|
||||||
this._selectedLoginIDs = [];
|
|
||||||
this._selectedPayrollTypeid = undefined;
|
|
||||||
this._selectedRoleType = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.utilityService.ShowLoadingPanel = true;
|
this.userService.GetCurrentUser().subscribe((resp: any) => {
|
||||||
this._selectedRoleType = null;
|
this.currentUserID = resp?.userID;
|
||||||
this._gridUsers = [];
|
});
|
||||||
this._gridRoles = [];
|
this.userService.GetUsers(EnumUserType.User).subscribe((resp: any) => {
|
||||||
this._selectedUserID = 0;
|
this.users = resp ?? [];
|
||||||
this._selectedLoginIDs = [];
|
this.filteredUsers = this.users.slice();
|
||||||
this.userRolePermissionForm = new FormGroup({
|
});
|
||||||
selectedUsers: new FormControl()
|
this.userService.GetAllPayrollTypes().subscribe((resp: any) => {
|
||||||
|
this.payrollTypes = resp ?? [];
|
||||||
|
});
|
||||||
|
this.userService.getAllRoles().subscribe((resp: any) => {
|
||||||
|
this.allRoles = resp ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userService.GetUsers(EnumUserType.User)
|
if (this.openFor) {
|
||||||
.subscribe(
|
this.roleType = this.openFor.roleType;
|
||||||
(resp: any) => {
|
if (this.roleType == EnumRoleType.Self_Service) {
|
||||||
this._users = resp;
|
this.selectedPayrollTypeID = this.openFor.payrollTypeID;
|
||||||
},
|
} else {
|
||||||
(err: any) => {
|
this.selectedUserID = this.openFor.userID;
|
||||||
// ON ERROR
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
// ON Success
|
|
||||||
// this.loadGrid();
|
|
||||||
}
|
}
|
||||||
);
|
this.loadState(this.openFor.userID, this.openFor.employeeID);
|
||||||
|
|
||||||
|
|
||||||
this.userService.getAllRoles()
|
|
||||||
.subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
this._allroles = resp;
|
|
||||||
},
|
|
||||||
(err: any) => {
|
|
||||||
// ON ERROR
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.pageLoaded();
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
this.userService.GetAllPayrollTypes()
|
|
||||||
.subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
this._payrollTypes = resp;
|
|
||||||
},
|
|
||||||
(err: any) => {
|
|
||||||
//ON ERROR
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setSelectableSettings();
|
|
||||||
}
|
|
||||||
pageLoaded() {
|
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectableSettings(): void {
|
// ---------- whose roles ----------
|
||||||
this.selectableSettings = {
|
|
||||||
checkboxOnly: true,
|
|
||||||
mode: 'multiple', // this.mode
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
onRoleChange(value: any) {
|
setRoleType(type: EnumRoleType): void {
|
||||||
this._gridRoles = [];
|
if (this.roleType == type) {
|
||||||
this._selectedRoles = [];
|
|
||||||
this._gridUsers = [];
|
|
||||||
this._gridRoles = this._allroles.filter(x => x.roleType === this._selectedRoleType);
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchUnAssingedEmp() {
|
|
||||||
this.utilityService.ShowLoadingPanel = true;
|
|
||||||
this.employeeService.GetEmployeeNotYetUser(this._selectedPayrollTypeid)
|
|
||||||
.subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
this._selectedEmployees = resp;
|
|
||||||
},
|
|
||||||
(err: any) => {
|
|
||||||
//ON ERROR
|
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
|
||||||
|
|
||||||
this._selectedEmployees.forEach(x => {
|
|
||||||
var ouser: User = new User();
|
|
||||||
ouser.loginID = x.employeeNo;
|
|
||||||
ouser.userName = x.name;
|
|
||||||
ouser.employeeID = x.employeeID;
|
|
||||||
var Item = this._gridUsers.find(u => u.employeeID == x.employeeID);
|
|
||||||
if (Item == undefined)
|
|
||||||
this._gridUsers.push(ouser)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public onSelectionRoleChange(event: any): void {
|
|
||||||
// this._selectedRoles = event.selectedRows.map(r => r.dataItem.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Remove(nIndex:number) {
|
|
||||||
this._gridUsers.splice(nIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public onSave(): void {
|
|
||||||
if (this._gridUsers.length == 0) {
|
|
||||||
this.notificationService.showError("There is no user/employee selected");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._selectedRoles.length == 0) {
|
this.roleType = type;
|
||||||
this.notificationService.showError("please select a role");
|
this.resetPerson();
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let userRoles: UserRole[] = [];
|
private resetPerson(): void {
|
||||||
this._gridUsers.forEach(u => {
|
this.selectedUserID = undefined;
|
||||||
this._selectedRoles.forEach(r => {
|
this.selectedEmployee = undefined;
|
||||||
var userRole: UserRole = new UserRole();
|
this.state = undefined;
|
||||||
if (this._selectedRoleType == EnumRoleType.Self_Service) {
|
this.selectedRoleIDs = [];
|
||||||
userRole.payrollTypeID = this._selectedPayrollTypeid;
|
this.roleSearch = '';
|
||||||
userRole.employeeID = u.employeeID;
|
|
||||||
userRole.roleType = EnumRoleType.Self_Service;
|
|
||||||
}
|
}
|
||||||
if (this._selectedRoleType == EnumRoleType.Admin)
|
|
||||||
{
|
|
||||||
userRole.userID = u.id;
|
|
||||||
userRole.roleType = EnumRoleType.Admin;
|
|
||||||
}
|
|
||||||
userRole.loginIDView = u.loginID;
|
|
||||||
userRole.roleID = r;
|
|
||||||
userRoles.push(userRole);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
onUserFilter(term: string): void {
|
||||||
this.utilityService.ShowLoadingPanel = true;
|
const t = (term ?? '').trim().toLowerCase();
|
||||||
if(userRoles && userRoles.length > 0)
|
this.filteredUsers = this.users.filter(u =>
|
||||||
{
|
!t || (u.userName ?? '').toLowerCase().includes(t) || (u.loginID ?? '').toLowerCase().includes(t));
|
||||||
userRoles.forEach(x=> {
|
}
|
||||||
let isFind = this._previousRoles.some(y => y === x.roleID);
|
|
||||||
if(!isFind){
|
onUserChange(userID: number): void {
|
||||||
x.isOld = false;
|
this.state = undefined;
|
||||||
let role = this._gridRoles.find(z => z.id === x.roleID);
|
this.selectedRoleIDs = [];
|
||||||
if(role && role.id > 0){
|
if (userID) {
|
||||||
x.newRoleName = role.name;
|
this.loadState(userID, undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
onPayrollTypeChange(): void {
|
||||||
|
this.selectedEmployee = undefined;
|
||||||
|
this.state = undefined;
|
||||||
|
this.selectedRoleIDs = [];
|
||||||
}
|
}
|
||||||
this.userService.saveUserRole(userRoles)
|
|
||||||
.subscribe(
|
onEmployeeSelected(emp: any): void {
|
||||||
(resp: any) => {
|
this.selectedEmployee = emp && !Array.isArray(emp) ? emp : undefined;
|
||||||
|
this.state = undefined;
|
||||||
|
this.selectedRoleIDs = [];
|
||||||
|
if (this.selectedEmployee?.employeeID) {
|
||||||
|
this.loadState(undefined, this.selectedEmployee.employeeID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadState(userID: number, employeeID: number): void {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
this.userService.GetUserRoleState(this.roleType, userID, employeeID).subscribe(
|
||||||
|
(resp: UserRoleState) => {
|
||||||
|
this.state = resp;
|
||||||
|
if (this.roleType == EnumRoleType.Self_Service && !this.selectedPayrollTypeID) {
|
||||||
|
this.selectedPayrollTypeID = resp?.payrollTypeID;
|
||||||
|
}
|
||||||
|
this.resetSelection();
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
this.notificationService.showSuccess(err.error);
|
this.notificationService.showError(err?.error ?? err);
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- roles ----------
|
||||||
|
|
||||||
|
private isApprovedRole(r: Role): boolean {
|
||||||
|
return r.roleStatus == EnumAuthStatus.Approved || r.roleStatus == EnumAuthStatus.Active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Roles of the selected role type: approved ones, plus any the person has or has asked for. */
|
||||||
|
get rolesForType(): Role[] {
|
||||||
|
const live = this.state?.liveRoleIDs ?? [];
|
||||||
|
const pending = (this.state?.pending ?? []).map(p => p.roleID);
|
||||||
|
return this.allRoles
|
||||||
|
.filter(r => r.roleType == this.roleType && (this.isApprovedRole(r) || live.includes(r.id) || pending.includes(r.id)))
|
||||||
|
.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
get visibleRoles(): Role[] {
|
||||||
|
const t = this.roleSearch.trim().toLowerCase();
|
||||||
|
return this.rolesForType.filter(r => !t || (r.name ?? '').toLowerCase().includes(t)
|
||||||
|
|| ((r as any).code ?? '').toString().toLowerCase().includes(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
isTicked(roleID: number): boolean {
|
||||||
|
return this.selectedRoleIDs.includes(roleID);
|
||||||
|
}
|
||||||
|
|
||||||
|
get locked(): boolean {
|
||||||
|
return !this.state || this.hasPending;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle(roleID: number): void {
|
||||||
|
if (this.locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.selectedRoleIDs = this.isTicked(roleID)
|
||||||
|
? this.selectedRoleIDs.filter(x => x != roleID)
|
||||||
|
: [...this.selectedRoleIDs, roleID];
|
||||||
|
}
|
||||||
|
|
||||||
|
selectAllVisible(): void {
|
||||||
|
if (this.locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ids = this.visibleRoles.map(r => r.id).filter(id => !this.isTicked(id));
|
||||||
|
this.selectedRoleIDs = [...this.selectedRoleIDs, ...ids];
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAllVisible(): void {
|
||||||
|
if (this.locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ids = this.visibleRoles.map(r => r.id);
|
||||||
|
this.selectedRoleIDs = this.selectedRoleIDs.filter(x => !ids.includes(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ticks show what the person has now, or what is asked for while a change waits for approval. */
|
||||||
|
resetSelection(): void {
|
||||||
|
const live = this.state?.liveRoleIDs ?? [];
|
||||||
|
const pending = this.state?.pending ?? [];
|
||||||
|
const removing = pending.filter(p => p.requestType == EnumUserRoleRequestType.Remove).map(p => p.roleID);
|
||||||
|
const adding = pending.filter(p => p.requestType == EnumUserRoleRequestType.Add).map(p => p.roleID);
|
||||||
|
this.selectedRoleIDs = [...live.filter(id => !removing.includes(id)), ...adding.filter(id => !live.includes(id))];
|
||||||
|
}
|
||||||
|
|
||||||
|
roleName(roleID: number): string {
|
||||||
|
return this.allRoles.find(r => r.id == roleID)?.name ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Badge of one role row. */
|
||||||
|
roleBadge(roleID: number): { text: string, tone: string } {
|
||||||
|
const live = (this.state?.liveRoleIDs ?? []).includes(roleID);
|
||||||
|
const pending = (this.state?.pending ?? []).find(p => p.roleID == roleID);
|
||||||
|
if (pending) {
|
||||||
|
return pending.requestType == EnumUserRoleRequestType.Remove
|
||||||
|
? { text: 'Removal - Not Yet Approved', tone: 'warning' }
|
||||||
|
: { text: 'New - Not Yet Approved', tone: 'warning' };
|
||||||
|
}
|
||||||
|
if (!this.hasPending && this.state) {
|
||||||
|
if (!live && this.isTicked(roleID)) {
|
||||||
|
return { text: 'To be added', tone: 'info' };
|
||||||
|
}
|
||||||
|
if (live && !this.isTicked(roleID)) {
|
||||||
|
return { text: 'To be removed', tone: 'info' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return live ? { text: 'Active', tone: 'success' } : { text: 'Not assigned', tone: 'neutral' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- maker-checker ----------
|
||||||
|
|
||||||
|
get hasPending(): boolean {
|
||||||
|
return (this.state?.pending ?? []).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
get isMakerOfPending(): boolean {
|
||||||
|
return (this.state?.pending ?? []).some(p => p.createdBy == this.currentUserID);
|
||||||
|
}
|
||||||
|
|
||||||
|
get pendingAddNames(): string[] {
|
||||||
|
return (this.state?.pending ?? []).filter(p => p.requestType == EnumUserRoleRequestType.Add).map(p => p.roleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
get pendingRemoveNames(): string[] {
|
||||||
|
return (this.state?.pending ?? []).filter(p => p.requestType == EnumUserRoleRequestType.Remove).map(p => p.roleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
get pendingMaker(): string {
|
||||||
|
const p = (this.state?.pending ?? [])[0];
|
||||||
|
return p ? (p.makerLoginID || '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
get pendingDate(): Date {
|
||||||
|
const p = (this.state?.pending ?? [])[0];
|
||||||
|
return p?.createdDate ? new Date(p.createdDate) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
get draftAddNames(): string[] {
|
||||||
|
const live = this.state?.liveRoleIDs ?? [];
|
||||||
|
return this.selectedRoleIDs.filter(id => !live.includes(id)).map(id => this.roleName(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
get draftRemoveNames(): string[] {
|
||||||
|
return (this.state?.liveRoleIDs ?? []).filter(id => !this.isTicked(id)).map(id => this.roleName(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasDraftChanges(): boolean {
|
||||||
|
return !this.hasPending && (this.draftAddNames.length > 0 || this.draftRemoveNames.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private subject(): UserRoleSubject {
|
||||||
|
const s = new UserRoleSubject();
|
||||||
|
s.roleType = this.roleType;
|
||||||
|
s.userID = this.state?.userID ?? (this.roleType == EnumRoleType.Admin ? this.selectedUserID : undefined);
|
||||||
|
s.employeeID = this.state?.employeeID;
|
||||||
|
s.payrollTypeID = this.state?.payrollTypeID ?? this.selectedPayrollTypeID;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendForApproval(): void {
|
||||||
|
if (!this.state) {
|
||||||
|
this.notificationService.showWarning(this.roleType == EnumRoleType.Admin ? 'Select a user.' : 'Select an employee.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.hasDraftChanges) {
|
||||||
|
this.notificationService.showWarning('Nothing changed.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const request = Object.assign(new UserRoleChangeRequest(), this.subject());
|
||||||
|
request.roleIDs = this.selectedRoleIDs.slice();
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
this.userService.SaveUserRoleRequest(request).subscribe(
|
||||||
|
() => { },
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showSuccess('Sent for approval. Nothing changes until another administrator approves it.');
|
||||||
this.saveCompleted.emit(true);
|
this.saveCompleted.emit(true);
|
||||||
this.utilityService.ShowLoadingPanel = false;
|
|
||||||
this.notificationService.showSuccess("Data Saved Successfully.");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetSelectedEmployee(childData) {
|
onApprove(): void {
|
||||||
this._selectedEmployees = childData;
|
this.decide(true);
|
||||||
if (this._selectedEmployees == undefined) {
|
}
|
||||||
|
|
||||||
|
onReject(): void {
|
||||||
|
this.decide(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private decide(approve: boolean): void {
|
||||||
|
if (!this.hasPending) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const who = this.state?.personName ?? '';
|
||||||
this._selectedEmployees.forEach(x => {
|
const question = approve
|
||||||
|
? `Are you sure you want to approve the role change of ${who}?`
|
||||||
var ouser: User = new User();
|
: `Are you sure you want to reject the role change of ${who}?`;
|
||||||
ouser.loginID = x.employeeNo;
|
this.notificationService.showActiveConfirm('Confirmation', question).then((isConfirmed) => {
|
||||||
ouser.userName = x.name;
|
if (isConfirmed) {
|
||||||
ouser.employeeID = x.employeeID;
|
this.sendDecision(approve);
|
||||||
|
|
||||||
var Item = this._gridUsers.find(u => u.employeeID == x.employeeID);
|
|
||||||
if (Item == undefined)
|
|
||||||
this._gridUsers.push(ouser);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
this.AddEmployeeAsUser();
|
|
||||||
}
|
|
||||||
AddUser() {
|
|
||||||
this.userService.getUserRoles(EnumRoleType.Admin, this._selectedUserID);
|
|
||||||
let oUser: User = this._users.find(x => x.id === this._selectedUserID);
|
|
||||||
let userRole: UserRole[];
|
|
||||||
this.userService.getUserRoles(EnumRoleType.Admin, this._selectedUserID)
|
|
||||||
|
|
||||||
.subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
this._userRoles = resp;
|
|
||||||
},
|
|
||||||
(err: any) => {
|
|
||||||
// ON ERROR
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
|
|
||||||
const Users: User[] = [];
|
|
||||||
Users.push(oUser);
|
|
||||||
var uRole: UserRole = new UserRole();
|
|
||||||
|
|
||||||
var Item = this._gridUsers.find(u => u.id == oUser.id);
|
|
||||||
if (Item == undefined)
|
|
||||||
this._gridUsers.push(oUser);
|
|
||||||
|
|
||||||
this.setPrviousRole();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
private setPrviousRole() {
|
|
||||||
this._gridUsers.forEach(x => {
|
|
||||||
var empUseRoles: UserRole[] = this._userRoles.filter(t => t.loginIDView == x.loginID)
|
|
||||||
if (empUseRoles != undefined) {
|
|
||||||
empUseRoles.forEach(u => {
|
|
||||||
if (x.roleNames == undefined) x.roleNames = '';
|
|
||||||
x.roleNames = x.roleNames + u.roleNameView + ", ";
|
|
||||||
x.id = u.userID;
|
|
||||||
|
|
||||||
if (this._selectedRoles.findIndex(r => r == u.roleID) == -1) {
|
|
||||||
this._selectedRoles.push(u.roleID);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._selectedRoles = [...this._selectedRoles];
|
|
||||||
this._previousRoles = [...this._selectedRoles];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEmployeeAsUser() {
|
private sendDecision(approve: boolean): void {
|
||||||
this.userService.GetEmpUserRole(this._selectedEmployees).subscribe(
|
const call = approve ? this.userService.ApproveUserRole(this.subject()) : this.userService.RejectUserRole(this.subject());
|
||||||
(resp: any) => {
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
this._userRoles = resp;
|
call.subscribe(
|
||||||
|
() => { },
|
||||||
},
|
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.setPrviousRole();
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
}
|
this.notificationService.showSuccess(approve
|
||||||
);
|
? 'Approved. The roles are now live; the person sees the new menu from their next sign-in.'
|
||||||
|
: 'Rejected. The roles stay as they were.');
|
||||||
return;
|
this.saveCompleted.emit(true);
|
||||||
|
|
||||||
this._users = [];
|
|
||||||
this._selectedEmployees.forEach(x => {
|
|
||||||
var ouser: User = new User();
|
|
||||||
ouser.loginID = x.employeeNo;
|
|
||||||
ouser.userName = x.name;
|
|
||||||
oUser.userStatus = EnumAuthStatus.New_Not_Yet_Approve;
|
|
||||||
this._users.push(oUser);
|
|
||||||
});
|
|
||||||
this.userService.getUserRoles(EnumRoleType.Admin, this._selectedUserID);
|
|
||||||
let oUser: User = this._users.find(x => x.id === this._selectedUserID);
|
|
||||||
let userRole: UserRole[];
|
|
||||||
this.userService.getUserRoles(EnumRoleType.Admin, this._selectedUserID)
|
|
||||||
|
|
||||||
.subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
userRole = resp;
|
|
||||||
},
|
|
||||||
(err: any) => {
|
|
||||||
// ON ERROR
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
|
|
||||||
const Users: User[] = [];
|
|
||||||
Users.push(oUser);
|
|
||||||
/*var uRole: UserRole = new UserRole();
|
|
||||||
uRole.getRoleNames(Users, this.userRoles);*/
|
|
||||||
var uRole: UserRole = new UserRole();
|
|
||||||
// uRole.getRoleNames(Users, userRole);
|
|
||||||
this._gridUsers.push(oUser);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCancel(e): void {
|
public onCancel(): void {
|
||||||
this.saveCompleted.emit(false);
|
this.saveCompleted.emit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private closeForm(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1,463 @@
|
||||||
|
/* User Role Permission page. This component uses ViewEncapsulation.None, so every rule carries the
|
||||||
|
url- prefix (grid rules sit under .url-grid). Same look as User Access Type / Role / User pages. */
|
||||||
|
|
||||||
|
.url-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- header ---------- */
|
||||||
|
|
||||||
|
.url-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-header__icon {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #DEDEFF;
|
||||||
|
color: #414278;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-subtitle {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-muted {
|
||||||
|
color: #888888;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-block {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- view switch ---------- */
|
||||||
|
|
||||||
|
.url-views {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view:hover {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view.is-active {
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view__count {
|
||||||
|
min-width: 20px;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #EEEEF2;
|
||||||
|
color: #5B5B6B;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view__count.has-items {
|
||||||
|
background: #FFF2DB;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-view.is-active .url-view__count {
|
||||||
|
background: rgba(255, 255, 255, 0.22);
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- grid toolbar ---------- */
|
||||||
|
|
||||||
|
.url-grid .k-grid-toolbar {
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-grid .k-grid-table td {
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-toolbar__filters,
|
||||||
|
.url-toolbar__actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-search {
|
||||||
|
width: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-switch {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 2px;
|
||||||
|
padding: 3px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-switch__btn {
|
||||||
|
height: 28px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-switch__btn:hover {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-switch__btn.is-active {
|
||||||
|
background: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status chips (same as the User and Role pages) */
|
||||||
|
.url-chips {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
color: #424242;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s, border-color 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip:hover {
|
||||||
|
border-color: #52527A;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip.is-selected {
|
||||||
|
background: #52527A;
|
||||||
|
border-color: #52527A;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip__count {
|
||||||
|
min-width: 20px;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #F1F1F1;
|
||||||
|
color: #666666;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip.is-selected .url-chip__count {
|
||||||
|
background: rgba(255, 255, 255, 0.22);
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chip--pending:not(.is-selected) .url-chip__count {
|
||||||
|
background: #FFF2DB;
|
||||||
|
color: #8A5300;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- grid cells ---------- */
|
||||||
|
|
||||||
|
.url-login {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #424242;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-roles {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-role {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #F3F3FF;
|
||||||
|
color: #414278;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-badge__dot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-badge--success { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.url-badge--warning { background: #FFF2DB; color: #8A5300; }
|
||||||
|
.url-badge--neutral { background: #EEEEF2; color: #5B5B6B; }
|
||||||
|
|
||||||
|
.url-empty {
|
||||||
|
padding: 32px 16px;
|
||||||
|
color: #888888;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-empty--big {
|
||||||
|
padding: 48px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-empty__icon {
|
||||||
|
font-size: 32px;
|
||||||
|
color: #C9C9D6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-empty__title {
|
||||||
|
margin: 10px 0 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #424242;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- pending approvals ---------- */
|
||||||
|
|
||||||
|
.url-card {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-card__head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-card__title {
|
||||||
|
margin: 0 0 2px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table-wrap {
|
||||||
|
border: 1px solid #E3E3EC;
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: #F7F7FB;
|
||||||
|
color: #666666;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: left;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #E3E3EC;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #F0F0F4;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table tbody tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table tbody tr:hover {
|
||||||
|
background: #F7F7FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table tbody tr.is-selected {
|
||||||
|
background: #F3F3FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table tbody tr.is-mine {
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table__check {
|
||||||
|
width: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-table__open {
|
||||||
|
width: 70px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-person {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-type {
|
||||||
|
padding: 0 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #E8EEFC;
|
||||||
|
color: #2F4FB5;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-type--ess {
|
||||||
|
background: #F1EAFB;
|
||||||
|
color: #6B3FA0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-chips-inline {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-mini {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 1px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-mini .pi {
|
||||||
|
font-size: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-mini--add { background: #E6F4EC; color: #137A4B; }
|
||||||
|
.url-mini--remove { background: #FDE8EA; color: #D11A2A; }
|
||||||
|
|
||||||
|
.url-requested {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-savebar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 14px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #F0F0F4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-btns {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.url-toolbar__actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.url-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,222 @@
|
||||||
<div class="card">
|
<app-loading-panel></app-loading-panel>
|
||||||
<div class="grid " style="margin: auto;">
|
|
||||||
<div class="col-12 md:col-1" style="margin: auto;">
|
|
||||||
<label for="idRoleType">Role Type</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2">
|
|
||||||
|
|
||||||
<kendo-dropdownlist [data]="roleTypes"
|
<div class="url-page">
|
||||||
id="idRoleType"
|
|
||||||
[defaultItem]="{ name: 'select a Type', value: null }"
|
<!-- Page header -->
|
||||||
[textField]="'name'"
|
<div class="url-header">
|
||||||
[valueField]="'value'"
|
<div class="url-header__icon"><i class="pi pi-key"></i></div>
|
||||||
[valuePrimitive]="true"
|
<div>
|
||||||
class="form-control form-control-sm input-sm"
|
<h2 class="url-title">User Role Permission</h2>
|
||||||
[(ngModel)]="_selectedRoleType">
|
<p class="url-subtitle">Give users and employees their roles. Every change is approved by another administrator before it takes effect.</p>
|
||||||
</kendo-dropdownlist>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-2" style="margin: auto;">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['redo']" class="k-button k-primary" (click)="RefreshControl()">Refresh</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 md:col-7">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- View switch -->
|
||||||
|
<div class="url-views" role="tablist">
|
||||||
|
<button type="button" role="tab" class="url-view" [class.is-active]="activeView === 'assignments'" (click)="activeView = 'assignments'">
|
||||||
|
<i class="pi pi-list"></i> All assignments
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" class="url-view" [class.is-active]="activeView === 'pending'" (click)="activeView = 'pending'; loadPending()">
|
||||||
|
<i class="pi pi-clock"></i> Pending approvals
|
||||||
|
<span class="url-view__count" [class.has-items]="pendingGroups.length > 0">{{ pendingGroups.length }}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-w-title">
|
|
||||||
<kendo-grid [data]="userRoles"
|
<!-- All assignments -->
|
||||||
(add)="addHandler()">
|
@if (activeView === 'assignments') {
|
||||||
|
<kendo-grid #urlGrid class="url-grid"
|
||||||
|
[kendoGridBinding]="gridView"
|
||||||
|
[pageSize]="20"
|
||||||
|
[pageable]="true"
|
||||||
|
[sortable]="true"
|
||||||
|
[filterable]="true"
|
||||||
|
[resizable]="true">
|
||||||
<ng-template kendoGridToolbarTemplate>
|
<ng-template kendoGridToolbarTemplate>
|
||||||
<button themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']" kendoGridAddCommand>Add new</button>
|
<div class="url-toolbar">
|
||||||
<input placeholder="Search in all columns..." kendoTextBox (input)="onFilter($event.target.value)" />
|
<div class="url-toolbar__filters">
|
||||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['save']">Approve All</button>
|
<div class="url-switch" role="tablist" aria-label="Role type">
|
||||||
<button kendoGridExcelCommand type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']" style="float:right;">Export to Excel</button>
|
<button type="button" class="url-switch__btn" [class.is-active]="listRoleType == roletypeEnum.Admin"
|
||||||
<button kendoGridPDFCommand [svgIcon]="apiService.KendoSVGIcon['filePdf']" style="float:right;">Export to PDF</button>
|
(click)="setListRoleType(roletypeEnum.Admin)">Admin</button>
|
||||||
</ng-template>
|
<button type="button" class="url-switch__btn" [class.is-active]="listRoleType == roletypeEnum.Self_Service"
|
||||||
|
(click)="setListRoleType(roletypeEnum.Self_Service)">Self Service</button>
|
||||||
<kendo-grid-column field="loginIDView" title="Login Id">
|
|
||||||
</kendo-grid-column>
|
|
||||||
<kendo-grid-column field="userNameView" title="Name">
|
|
||||||
</kendo-grid-column>
|
|
||||||
<kendo-grid-column field="roleNameView" title="Role">
|
|
||||||
</kendo-grid-column>
|
|
||||||
<!--<kendo-grid-column field="" title="Status">
|
|
||||||
<kendo-grid-column field="roleStatus" title="Status">
|
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
|
||||||
{{ statusString(dataItem.userRoleStatus)}}
|
|
||||||
</ng-template>
|
|
||||||
</kendo-grid-column>
|
|
||||||
</kendo-grid-column>-->
|
|
||||||
</kendo-grid>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<input kendoTextBox class="url-search" placeholder="Search login ID, name or role"
|
||||||
|
[value]="searchText" (input)="onSearch($event.target.value)" />
|
||||||
|
<div class="url-chips" role="group" aria-label="Filter by status">
|
||||||
|
<button type="button" class="url-chip" [class.is-selected]="statusFilter === 'all'" (click)="setStatusFilter('all')">
|
||||||
|
All <span class="url-chip__count">{{ counts.all }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="url-chip url-chip--pending" [class.is-selected]="statusFilter === 'pending'" (click)="setStatusFilter('pending')">
|
||||||
|
Waiting for approval <span class="url-chip__count">{{ counts.pending }}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="url-chip" [class.is-selected]="statusFilter === 'uptodate'" (click)="setStatusFilter('uptodate')">
|
||||||
|
Up to date <span class="url-chip__count">{{ counts.uptodate }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="url-toolbar__actions">
|
||||||
|
<button kendoButton type="button" fillMode="flat" [svgIcon]="apiService.KendoSVGIcon['arrowRotateCw']"
|
||||||
|
title="Reload list" aria-label="Reload list" (click)="RefreshControl(); loadPending()"></button>
|
||||||
|
<button kendoButton type="button" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['fileExcel']"
|
||||||
|
(click)="urlGrid.saveAsExcel()">Export to Excel</button>
|
||||||
|
<button kendoButton type="button" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['filePdf']"
|
||||||
|
(click)="urlGrid.saveAsPDF()">Export to PDF</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']"
|
||||||
|
(click)="addHandler()">Assign roles</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
<div class="card card-w-title">
|
<kendo-grid-column field="loginID" title="Login ID" [width]="170">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<span class="url-login">{{ dataItem.loginID }}</span>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column field="userName" title="Name" [width]="220"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="payrollTypeName" title="Payroll Type" [width]="180"
|
||||||
|
[hidden]="listRoleType != roletypeEnum.Self_Service"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="rolesText" title="Roles">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<div class="url-roles">
|
||||||
|
@for (r of dataItem.roles; track r) { <span class="url-role">{{ r }}</span> }
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column field="statusText" title="Status" [width]="190">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<span class="url-badge" [class.url-badge--warning]="dataItem.pending" [class.url-badge--success]="!dataItem.pending">
|
||||||
|
<span class="url-badge__dot"></span>{{ dataItem.statusText }}
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column title="Actions" [width]="120" [filterable]="false" [sortable]="false">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<button class="k-button k-primary" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']"
|
||||||
|
(click)="openRow(dataItem)">{{ dataItem.pending ? 'Review' : 'Edit' }}</button>
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
|
||||||
|
<ng-template kendoGridNoRecordsTemplate>
|
||||||
|
<div class="url-empty">
|
||||||
|
@if (rows.length === 0) { No {{ listRoleType == roletypeEnum.Admin ? 'admin user' : 'self service user' }} has a role yet. }
|
||||||
|
@else { No one matches the current search or filters. }
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
@if (showModal) {
|
<kendo-grid-excel fileName="UserRoles.xlsx" [fetchData]="allData">
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="750"
|
<kendo-excelexport-column field="loginID" title="Login ID" [width]="140"></kendo-excelexport-column>
|
||||||
[width]="850">
|
<kendo-excelexport-column field="userName" title="Name" [width]="200"></kendo-excelexport-column>
|
||||||
<kendo-dialog-titlebar>
|
<kendo-excelexport-column field="rolesText" title="Roles" [width]="360"></kendo-excelexport-column>
|
||||||
User-Role Assignment
|
<kendo-excelexport-column field="statusText" title="Status" [width]="150"></kendo-excelexport-column>
|
||||||
</kendo-dialog-titlebar>
|
</kendo-grid-excel>
|
||||||
<app-user-role-entry [InitializeForm]="initializeEntryFrom" (saveCompleted)="saveCompleted($event)">
|
<kendo-grid-pdf fileName="UserRoles.pdf" [allPages]="true" [repeatHeaders]="true" paperSize="A4" [landscape]="true" [scale]="0.7">
|
||||||
</app-user-role-entry>
|
<kendo-grid-column field="loginID" title="Login ID"></kendo-grid-column>
|
||||||
</kendo-dialog>
|
<kendo-grid-column field="userName" title="Name"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="rolesText" title="Roles"></kendo-grid-column>
|
||||||
|
<kendo-grid-column field="statusText" title="Status"></kendo-grid-column>
|
||||||
|
</kendo-grid-pdf>
|
||||||
|
</kendo-grid>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<!-- Pending approvals -->
|
||||||
|
@if (activeView === 'pending') {
|
||||||
|
<div class="url-card">
|
||||||
|
<div class="url-card__head">
|
||||||
|
<div>
|
||||||
|
<p class="url-card__title">Pending approvals</p>
|
||||||
|
<p class="url-muted">Everyone whose role change is waiting for approval. Select several and approve or reject them at once.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<button kendoButton type="button" fillMode="flat" [svgIcon]="apiService.KendoSVGIcon['arrowRotateCw']" (click)="loadPending()">Refresh</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (pendingGroups.length === 0) {
|
||||||
|
<div class="url-empty url-empty--big">
|
||||||
|
<i class="pi pi-check-circle url-empty__icon"></i>
|
||||||
|
<p class="url-empty__title">Nothing to approve</p>
|
||||||
|
<p class="url-muted">No role change is waiting for approval.</p>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="url-table-wrap">
|
||||||
|
<table class="url-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="url-table__check">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="allPendingSelected"
|
||||||
|
[disabled]="selectablePending.length === 0" (change)="toggleAllPending()" title="Select all" />
|
||||||
|
</th>
|
||||||
|
<th>Person</th>
|
||||||
|
<th>Will get</th>
|
||||||
|
<th>Will lose</th>
|
||||||
|
<th>Requested by</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@for (g of pendingGroups; track g.key) {
|
||||||
|
<tr [class.is-selected]="isPendingSelected(g.key)" [class.is-mine]="g.isMine">
|
||||||
|
<td class="url-table__check">
|
||||||
|
<input type="checkbox" kendoCheckBox [checked]="isPendingSelected(g.key)" [disabled]="g.isMine"
|
||||||
|
(change)="togglePendingSelection(g)"
|
||||||
|
[attr.title]="g.isMine ? 'You made this change; another administrator must decide it' : null" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="url-person">
|
||||||
|
<span class="url-login">{{ g.personName }}</span>
|
||||||
|
<span class="url-type" [class.url-type--ess]="g.roleType == roletypeEnum.Self_Service">
|
||||||
|
{{ g.roleType == roletypeEnum.Self_Service ? 'Self Service' : 'Admin' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="url-muted url-block">{{ g.loginID }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="url-chips-inline">
|
||||||
|
@for (n of g.adds; track n) { <span class="url-mini url-mini--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||||
|
@if (g.adds.length === 0) { <span class="url-muted">-</span> }
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="url-chips-inline">
|
||||||
|
@for (n of g.removes; track n) { <span class="url-mini url-mini--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||||
|
@if (g.removes.length === 0) { <span class="url-muted">-</span> }
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="url-requested">
|
||||||
|
<span>{{ g.makers.join(', ') || '-' }}</span>
|
||||||
|
@if (g.requestDate) { <span class="url-muted">{{ g.requestDate | date: 'dd MMM yyyy, h:mm a' }}</span> }
|
||||||
|
@if (g.isMine) { <span class="url-badge url-badge--neutral"><span class="url-badge__dot"></span>Your change</span> }
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="url-table__open">
|
||||||
|
<button kendoButton type="button" fillMode="flat" (click)="openPending(g)">Open</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="url-savebar">
|
||||||
|
<span class="url-muted">{{ selectedPendingKeys.length }} of {{ selectablePending.length }} selected</span>
|
||||||
|
<div class="url-btns">
|
||||||
|
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||||
|
[disabled]="selectedPendingKeys.length === 0" (click)="bulkReject()">Reject selected</button>
|
||||||
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||||
|
[disabled]="selectedPendingKeys.length === 0" (click)="bulkApprove()">Approve selected</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- User-Role Assignment dialog (blurred background) -->
|
||||||
|
@if (showModal) {
|
||||||
|
<div class="blur-background">
|
||||||
|
<kendo-dialog title="User-Role Assignment" [width]="1080" maxHeight="92vh"
|
||||||
|
(close)="onPopUpClose()" (keydown.escape)="$event.stopPropagation()">
|
||||||
|
<app-user-role-entry [InitializeForm]="initializeEntryFrom" [openFor]="openFor" (saveCompleted)="saveCompleted($event)">
|
||||||
|
</app-user-role-entry>
|
||||||
|
</kendo-dialog>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,122 +1,373 @@
|
||||||
import { Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { HRMNotificationService } from '../../../app.notification.service';
|
import { HRMNotificationService } from '../../../app.notification.service';
|
||||||
import { DataTransferService } from '../../../data.transfer.service';
|
|
||||||
import { UntilityHandlerService } from '../../../utility.hanldler.service';
|
|
||||||
import { AuthService } from '../../../_services/auth/auth.service';
|
import { AuthService } from '../../../_services/auth/auth.service';
|
||||||
import { EnumRoleType, EnumUserType, EnumExtension, EnumAuthStatus } from '../../../_models/enums';
|
import { EnumAuthStatus, EnumRoleType } from '../../../_models/enums';
|
||||||
import { User } from '../../../_models/Authentication/user';
|
import { ExcelExportData } from '@progress/kendo-angular-excel-export';
|
||||||
import { DataStateChangeEvent, GridDataResult } from '@progress/kendo-angular-grid';
|
import { process } from '@progress/kendo-data-query';
|
||||||
import { process, State } from '@progress/kendo-data-query';
|
|
||||||
import { ApiService } from '../../../app.api.service';
|
import { ApiService } from '../../../app.api.service';
|
||||||
|
import { loadingPanelService } from '../../../hrm-loding panel/loding.panel.service';
|
||||||
|
import { EnumUserRoleRequestType, UserRoleSubject } from '../../../_models/Authentication/UserRole';
|
||||||
|
|
||||||
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
/** One person in the All assignments grid (one row per person, roles as chips). */
|
||||||
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
interface AssignmentRow {
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
key: string;
|
||||||
import { FormsModule } from '@angular/forms';
|
userID: number;
|
||||||
|
employeeID: number;
|
||||||
|
loginID: string;
|
||||||
|
userName: string;
|
||||||
|
/** Self Service only: the employee's payroll type. */
|
||||||
|
payrollTypeID: number;
|
||||||
|
payrollTypeName: string;
|
||||||
|
roles: string[];
|
||||||
|
rolesText: string;
|
||||||
|
pending: boolean;
|
||||||
|
statusText: string;
|
||||||
|
}
|
||||||
|
|
||||||
import { KENDO_GRID } from '@progress/kendo-angular-grid';
|
/** One person with a role change waiting for approval. */
|
||||||
import { DatePickerModule } from '@progress/kendo-angular-dateinputs';
|
interface PendingGroup {
|
||||||
|
key: string;
|
||||||
|
roleType: EnumRoleType;
|
||||||
|
userID: number;
|
||||||
|
employeeID: number;
|
||||||
|
payrollTypeID: number;
|
||||||
|
personName: string;
|
||||||
|
loginID: string;
|
||||||
|
adds: string[];
|
||||||
|
removes: string[];
|
||||||
|
makers: string[];
|
||||||
|
makerIDs: number[];
|
||||||
|
requestDate: Date;
|
||||||
|
isMine: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication > User Role Permission: who has which roles (All assignments), the role changes
|
||||||
|
* waiting for approval (Pending approvals, many at once), and the User-Role Assignment dialog.
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-role-list',
|
selector: 'app-user-role-list',
|
||||||
templateUrl: './user-role-list.component.html',
|
templateUrl: './user-role-list.component.html',
|
||||||
|
styleUrls: ['./user-role-list.component.css'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
changeDetection: ChangeDetectionStrategy.Eager,
|
changeDetection: ChangeDetectionStrategy.Eager,
|
||||||
standalone: false,
|
standalone: false,
|
||||||
|
|
||||||
})
|
})
|
||||||
/** user-role-list component*/
|
|
||||||
export class UserRoleListComponent implements OnInit {
|
export class UserRoleListComponent implements OnInit {
|
||||||
public isNew: boolean;
|
readonly roletypeEnum: typeof EnumRoleType = EnumRoleType;
|
||||||
userRole: any;
|
|
||||||
users: User[];
|
activeView: 'assignments' | 'pending' = 'assignments';
|
||||||
userRoles: any[];
|
listRoleType: EnumRoleType = EnumRoleType.Admin;
|
||||||
showModal = false;
|
currentUserID: number;
|
||||||
_selectedRoleType: EnumRoleType;
|
/** Payroll type names by ID, for the Self Service Payroll Type column. */
|
||||||
roleTypes: any = EnumExtension.getNamesAndValues(EnumRoleType);
|
payrollTypeNames = new Map<number, string>();
|
||||||
initializeEntryFrom: boolean;
|
|
||||||
gridView: GridDataResult;
|
// All assignments
|
||||||
public state: State = {
|
rows: AssignmentRow[] = [];
|
||||||
skip: 0,
|
gridView: AssignmentRow[] = [];
|
||||||
take: 10
|
searchText = '';
|
||||||
};
|
statusFilter: 'all' | 'pending' | 'uptodate' = 'all';
|
||||||
|
|
||||||
|
// Pending approvals
|
||||||
|
pendingGroups: PendingGroup[] = [];
|
||||||
|
selectedPendingKeys: string[] = [];
|
||||||
|
|
||||||
|
// Dialog
|
||||||
|
showModal = false;
|
||||||
|
initializeEntryFrom = false;
|
||||||
|
openFor: UserRoleSubject;
|
||||||
|
|
||||||
/** user-role-list ctor */
|
|
||||||
constructor(public userService: AuthService,
|
constructor(public userService: AuthService,
|
||||||
public notificationService: HRMNotificationService,
|
public notificationService: HRMNotificationService,
|
||||||
public datatransferservice: DataTransferService,
|
public apiService: ApiService,
|
||||||
public utilityHandlerService: UntilityHandlerService, public apiService: ApiService,) {
|
public loadingPanel: loadingPanelService) {
|
||||||
this.apiService.selectedMenuName="User Role Permission Entry"
|
this.apiService.selectedMenuName = 'User Role Permission Entry';
|
||||||
|
this.allData = this.allData.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.showModal = false;
|
this.userService.GetCurrentUser().subscribe((resp: any) => {
|
||||||
this.initializeEntryFrom = false;
|
this.currentUserID = resp?.userID;
|
||||||
|
this.loadPending();
|
||||||
|
});
|
||||||
|
this.userService.GetAllPayrollTypes().subscribe((resp: any[]) => {
|
||||||
|
this.payrollTypeNames = new Map((resp ?? []).map(p => [p.id, p.description] as [number, string]));
|
||||||
|
this.rows.forEach(r => r.payrollTypeName = this.payrollTypeName(r));
|
||||||
|
});
|
||||||
|
this.RefreshControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefreshControl() {
|
// ---------- All assignments ----------
|
||||||
this.userService.getUserRoles(this._selectedRoleType)
|
|
||||||
.subscribe(
|
setListRoleType(type: EnumRoleType): void {
|
||||||
(resp: any) => {
|
if (this.listRoleType == type) {
|
||||||
this.userRoles = resp;
|
return;
|
||||||
|
}
|
||||||
|
this.listRoleType = type;
|
||||||
|
this.RefreshControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Loads who has which roles of the selected role type. */
|
||||||
|
public RefreshControl(): void {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
this.userService.getUserRoles(this.listRoleType).subscribe(
|
||||||
|
(resp: any[]) => {
|
||||||
|
const byUser = new Map<number, AssignmentRow>();
|
||||||
|
(resp ?? []).forEach(r => {
|
||||||
|
let row = byUser.get(r.userID);
|
||||||
|
if (!row) {
|
||||||
|
row = {
|
||||||
|
key: 'u' + r.userID, userID: r.userID, employeeID: r.employeeID, loginID: r.loginIDView,
|
||||||
|
userName: r.userNameView, payrollTypeID: r.payrollTypeID, payrollTypeName: '', roles: [], rolesText: '', pending: false, statusText: '',
|
||||||
|
};
|
||||||
|
byUser.set(r.userID, row);
|
||||||
|
}
|
||||||
|
// Only live roles are shown: a role given but not approved yet (Status 2) is not live.
|
||||||
|
if (r.userRoleStatus != EnumAuthStatus.New_Not_Yet_Approve
|
||||||
|
&& r.roleNameView && !row.roles.includes(r.roleNameView)) {
|
||||||
|
row.roles.push(r.roleNameView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.rows = Array.from(byUser.values());
|
||||||
|
this.rows.forEach(r => {
|
||||||
|
r.rolesText = r.roles.join(', ');
|
||||||
|
r.payrollTypeName = this.payrollTypeName(r);
|
||||||
|
});
|
||||||
|
this.markPendingRows();
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
//ON ERROR
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.gridView = process(this.userRoles, this.state);
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public dataStateChange(state: DataStateChangeEvent): void {
|
|
||||||
this.state = state;
|
private payrollTypeName(row: AssignmentRow): string {
|
||||||
this.gridView = process(this.userRoles, this.state);
|
const id = row.payrollTypeID;
|
||||||
}
|
return id ? (this.payrollTypeNames.get(id) ?? '') : '';
|
||||||
public onFilter(inputValue: string): void {
|
|
||||||
}
|
|
||||||
onRoleChange() {
|
|
||||||
this.userRoles = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addHandler() {
|
private pendingFor(row: AssignmentRow): PendingGroup {
|
||||||
|
return this.pendingGroups.find(g => g.roleType == this.listRoleType && g.userID == row.userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private markPendingRows(): void {
|
||||||
|
this.rows.forEach(r => {
|
||||||
|
r.pending = !!this.pendingFor(r);
|
||||||
|
r.statusText = r.pending ? 'Waiting for approval' : 'Up to date';
|
||||||
|
});
|
||||||
|
this.applyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
get counts() {
|
||||||
|
const pending = this.rows.filter(r => r.pending).length;
|
||||||
|
return { all: this.rows.length, pending, uptodate: this.rows.length - pending };
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearch(value: string): void {
|
||||||
|
this.searchText = value ?? '';
|
||||||
|
this.applyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatusFilter(filter: 'all' | 'pending' | 'uptodate'): void {
|
||||||
|
this.statusFilter = filter;
|
||||||
|
this.applyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private applyView(): void {
|
||||||
|
const t = this.searchText.trim().toLowerCase();
|
||||||
|
this.gridView = this.rows.filter(r =>
|
||||||
|
(this.statusFilter === 'all' || (this.statusFilter === 'pending') === r.pending) &&
|
||||||
|
(!t || (r.loginID ?? '').toLowerCase().includes(t) || (r.userName ?? '').toLowerCase().includes(t)
|
||||||
|
|| r.rolesText.toLowerCase().includes(t)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Excel export: every row the grid shows (all pages). */
|
||||||
|
public allData(): ExcelExportData {
|
||||||
|
return { data: process(this.gridView, {}).data };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Pending approvals ----------
|
||||||
|
|
||||||
|
/** Every pending row has a login (made with the change for a new Self Service employee). */
|
||||||
|
private subjectKey(roleType: EnumRoleType, userID: number): string {
|
||||||
|
return (roleType == EnumRoleType.Self_Service ? 's' : 'a') + userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadPending(): void {
|
||||||
|
this.userService.GetPendingUserRoles().subscribe(
|
||||||
|
(items: any[]) => {
|
||||||
|
const groups = new Map<string, PendingGroup>();
|
||||||
|
(items ?? []).forEach(p => {
|
||||||
|
const key = this.subjectKey(p.roleType, p.userID);
|
||||||
|
let g = groups.get(key);
|
||||||
|
if (!g) {
|
||||||
|
g = {
|
||||||
|
key, roleType: p.roleType, userID: p.userID, employeeID: p.employeeID,
|
||||||
|
payrollTypeID: p.payrollTypeID, personName: p.personName, loginID: p.loginID,
|
||||||
|
adds: [], removes: [], makers: [], makerIDs: [], requestDate: null, isMine: false,
|
||||||
|
};
|
||||||
|
groups.set(key, g);
|
||||||
|
}
|
||||||
|
(p.requestType == EnumUserRoleRequestType.Remove ? g.removes : g.adds).push(p.roleName);
|
||||||
|
if (p.makerLoginID && !g.makers.includes(p.makerLoginID)) {
|
||||||
|
g.makers.push(p.makerLoginID);
|
||||||
|
}
|
||||||
|
if (p.createdBy && !g.makerIDs.includes(p.createdBy)) {
|
||||||
|
g.makerIDs.push(p.createdBy);
|
||||||
|
}
|
||||||
|
const d = p.createdDate ? new Date(p.createdDate) : null;
|
||||||
|
if (d && (!g.requestDate || d > g.requestDate)) {
|
||||||
|
g.requestDate = d;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.pendingGroups = Array.from(groups.values());
|
||||||
|
this.pendingGroups.forEach(g => g.isMine = g.makerIDs.includes(this.currentUserID));
|
||||||
|
this.selectedPendingKeys = this.selectedPendingKeys.filter(k =>
|
||||||
|
this.pendingGroups.some(g => g.key == k && !g.isMine));
|
||||||
|
this.markPendingRows();
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.pendingGroups = [];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get selectablePending(): PendingGroup[] {
|
||||||
|
return this.pendingGroups.filter(g => !g.isMine);
|
||||||
|
}
|
||||||
|
|
||||||
|
isPendingSelected(key: string): boolean {
|
||||||
|
return this.selectedPendingKeys.includes(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePendingSelection(g: PendingGroup): void {
|
||||||
|
if (g.isMine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.selectedPendingKeys = this.isPendingSelected(g.key)
|
||||||
|
? this.selectedPendingKeys.filter(k => k != g.key)
|
||||||
|
: [...this.selectedPendingKeys, g.key];
|
||||||
|
}
|
||||||
|
|
||||||
|
get allPendingSelected(): boolean {
|
||||||
|
return this.selectablePending.length > 0 && this.selectablePending.every(g => this.isPendingSelected(g.key));
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleAllPending(): void {
|
||||||
|
this.selectedPendingKeys = this.allPendingSelected ? [] : this.selectablePending.map(g => g.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private toSubject(g: PendingGroup): UserRoleSubject {
|
||||||
|
const s = new UserRoleSubject();
|
||||||
|
s.roleType = g.roleType;
|
||||||
|
s.userID = g.userID ?? undefined;
|
||||||
|
s.employeeID = g.employeeID ?? undefined;
|
||||||
|
s.payrollTypeID = g.payrollTypeID ?? undefined;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
bulkApprove(): void {
|
||||||
|
this.bulkDecide(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bulkReject(): void {
|
||||||
|
this.bulkDecide(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bulkDecide(approve: boolean): void {
|
||||||
|
const groups = this.pendingGroups.filter(g => this.isPendingSelected(g.key));
|
||||||
|
if (groups.length == 0) {
|
||||||
|
this.notificationService.showWarning('Select at least one person.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const count = groups.length + (groups.length == 1 ? ' person' : ' people');
|
||||||
|
const question = approve
|
||||||
|
? `Are you sure you want to approve the role changes of ${count}?`
|
||||||
|
: `Are you sure you want to reject the role changes of ${count}?`;
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', question).then((isConfirmed) => {
|
||||||
|
if (isConfirmed) {
|
||||||
|
this.sendBulkDecision(approve, groups);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private sendBulkDecision(approve: boolean, groups: PendingGroup[]): void {
|
||||||
|
const subjects = groups.map(g => this.toSubject(g));
|
||||||
|
const call = approve ? this.userService.ApproveUserRoles(subjects) : this.userService.RejectUserRoles(subjects);
|
||||||
|
let result: any;
|
||||||
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
|
call.subscribe(
|
||||||
|
(resp: any) => { result = resp; },
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showError(err?.error ?? err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
|
const done = result?.done ?? 0;
|
||||||
|
const failed: any[] = result?.failed ?? [];
|
||||||
|
if (done > 0) {
|
||||||
|
this.notificationService.showSuccess(
|
||||||
|
(approve ? 'Approved' : 'Rejected') + ' for ' + done + (done == 1 ? ' person.' : ' people.')
|
||||||
|
+ (approve ? ' New menus show from their next sign-in.' : ''));
|
||||||
|
}
|
||||||
|
if (failed.length > 0) {
|
||||||
|
this.notificationService.showError(failed.map(f =>
|
||||||
|
(groups[f.index]?.personName ?? 'Person ' + (f.index + 1)) + ': ' + f.message).join(' | '));
|
||||||
|
}
|
||||||
|
this.selectedPendingKeys = [];
|
||||||
|
this.loadPending();
|
||||||
|
this.RefreshControl();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- User-Role Assignment dialog ----------
|
||||||
|
|
||||||
|
/** New assignment: pick the person in the dialog. */
|
||||||
|
public addHandler(): void {
|
||||||
|
this.openFor = undefined;
|
||||||
|
this.openDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Change one person's roles from the All assignments grid. */
|
||||||
|
openRow(row: AssignmentRow): void {
|
||||||
|
const s = new UserRoleSubject();
|
||||||
|
s.roleType = this.listRoleType;
|
||||||
|
if (this.listRoleType == EnumRoleType.Self_Service && row.employeeID) {
|
||||||
|
s.employeeID = row.employeeID;
|
||||||
|
} else {
|
||||||
|
s.userID = row.userID;
|
||||||
|
}
|
||||||
|
this.openFor = s;
|
||||||
|
this.openDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Review one person's pending change in the dialog. */
|
||||||
|
openPending(g: PendingGroup): void {
|
||||||
|
this.openFor = this.toSubject(g);
|
||||||
|
this.openDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private openDialog(): void {
|
||||||
this.initializeEntryFrom = true;
|
this.initializeEntryFrom = true;
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public editHandler({ dataItem }) {
|
onPopUpClose(): void {
|
||||||
}
|
|
||||||
|
|
||||||
onPopUpClose() {
|
|
||||||
this.initializeEntryFrom = false;
|
this.initializeEntryFrom = false;
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
saveCompleted(changed: boolean): void {
|
||||||
statusString(roleStatus: number): string {
|
this.onPopUpClose();
|
||||||
var str = "";
|
if (changed === true) {
|
||||||
var status: EnumAuthStatus = roleStatus;
|
this.loadPending();
|
||||||
switch (status) {
|
|
||||||
case EnumAuthStatus.Active: { str = "Active"; break };
|
|
||||||
|
|
||||||
default: str = "In-Active"
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
saveCompleted(faction: any) {
|
|
||||||
if (faction !== undefined) {
|
|
||||||
if (faction === true) {
|
|
||||||
this.RefreshControl();
|
this.RefreshControl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.showModal = false;
|
|
||||||
this.initializeEntryFrom = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
saveHandler(userRole: any) {
|
|
||||||
}
|
|
||||||
|
|
||||||
removeHandler({ dataItem }) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1 @@
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<app-user-role-list></app-user-role-list>
|
<app-user-role-list></app-user-role-list>
|
||||||
</div>
|
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,8 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
|
|
||||||
<kendo-textbox
|
<input kendoTextBox class="ul-search" placeholder="Search login ID or name"
|
||||||
class="ul-search"
|
[value]="searchText" (input)="onSearch($event.target.value)" />
|
||||||
placeholder="Search login ID or name"
|
|
||||||
[clearButton]="true"
|
|
||||||
[value]="searchText"
|
|
||||||
(valueChange)="onSearch($event)">
|
|
||||||
</kendo-textbox>
|
|
||||||
|
|
||||||
<div class="ul-chips" role="group" aria-label="Filter by status">
|
<div class="ul-chips" role="group" aria-label="Filter by status">
|
||||||
<button type="button" class="ul-chip" [class.is-selected]="statusFilter === 'all'" (click)="setStatusFilter('all')">
|
<button type="button" class="ul-chip" [class.is-selected]="statusFilter === 'all'" (click)="setStatusFilter('all')">
|
||||||
|
|
@ -57,13 +52,10 @@
|
||||||
<div class="ul-toolbar__actions">
|
<div class="ul-toolbar__actions">
|
||||||
<button kendoButton type="button" fillMode="flat" [svgIcon]="icons.refresh"
|
<button kendoButton type="button" fillMode="flat" [svgIcon]="icons.refresh"
|
||||||
title="Reload list" aria-label="Reload list" (click)="RefreshControl()"></button>
|
title="Reload list" aria-label="Reload list" (click)="RefreshControl()"></button>
|
||||||
<kendo-dropdownbutton
|
<!-- Plain buttons, not kendoGridExcelCommand/kendoGridPDFCommand: grid toolbar commands take the
|
||||||
[data]="exportItems"
|
focus on any toolbar click, which closed the User type dropdown before it could open. -->
|
||||||
[svgIcon]="icons.export"
|
<button kendoButton type="button" fillMode="outline" [svgIcon]="icons.excel" (click)="grid.saveAsExcel()">Export to Excel</button>
|
||||||
fillMode="outline"
|
<button kendoButton type="button" fillMode="outline" [svgIcon]="icons.pdf" (click)="grid.saveAsPDF()">Export to PDF</button>
|
||||||
(itemClick)="onExport($event)">
|
|
||||||
Export
|
|
||||||
</kendo-dropdownbutton>
|
|
||||||
<button kendoButton type="button" themeColor="primary" [svgIcon]="icons.add" (click)="addHandler()">Add user</button>
|
<button kendoButton type="button" themeColor="primary" [svgIcon]="icons.add" (click)="addHandler()">Add user</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -92,22 +84,19 @@
|
||||||
<span>{{ dataItem.createdDate | date: 'dd MMM yyyy' }}</span>
|
<span>{{ dataItem.createdDate | date: 'dd MMM yyyy' }}</span>
|
||||||
}
|
}
|
||||||
@if (dataItem.createdByName) {
|
@if (dataItem.createdByName) {
|
||||||
<span class="ul-muted"> · {{ dataItem.createdByName }}</span>
|
<span class="ul-badge ul-badge--info ul-created-by" title="Created by"><span class="ul-badge__dot"></span>{{ dataItem.createdByName }}</span>
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
|
||||||
<kendo-grid-column title="" [width]="64" [filterable]="false" [sortable]="false" class="ul-actions-cell" headerClass="ul-actions-cell">
|
<!-- Same look as the Role page's last column: one button per action. Which actions a row gets
|
||||||
|
is still decided by actionsFor() (dataItem.actions), and a click still runs onRowAction(). -->
|
||||||
|
<kendo-grid-column title="Actions" [width]="180" [filterable]="false" [sortable]="false">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem>
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
<kendo-dropdownbutton
|
@for (a of dataItem.actions; track a.action) {
|
||||||
[data]="dataItem.actions"
|
<button class="k-button k-primary ul-row-action" kendoButton [svgIcon]="a.svgIcon"
|
||||||
[svgIcon]="icons.more"
|
(click)="onRowAction(a, dataItem)">{{ a.text }}</button>
|
||||||
fillMode="flat"
|
}
|
||||||
[popupSettings]="{ align: 'right' }"
|
|
||||||
[attr.aria-label]="'Actions for ' + dataItem.loginID"
|
|
||||||
title="Actions"
|
|
||||||
(itemClick)="onRowAction($event, dataItem)">
|
|
||||||
</kendo-dropdownbutton>
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
|
||||||
|
|
@ -139,12 +128,14 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (showModal) {
|
@if (showModal) {
|
||||||
|
<div class="blur-background">
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="750" [width]="650">
|
<kendo-dialog (close)="onPopUpClose()" [minWidth]="750" [width]="650">
|
||||||
<kendo-dialog-titlebar>
|
<kendo-dialog-titlebar>
|
||||||
Add/Edit User
|
Add/Edit User
|
||||||
</kendo-dialog-titlebar>
|
</kendo-dialog-titlebar>
|
||||||
<app-users-entry [inputObject]="_user" (saveCompleted)="saveCompleted($event)"></app-users-entry>
|
<app-users-entry [inputObject]="_user" (saveCompleted)="saveCompleted($event)"></app-users-entry>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (showReason) {
|
@if (showReason) {
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,15 @@
|
||||||
// ---------- grid ----------
|
// ---------- grid ----------
|
||||||
|
|
||||||
:host ::ng-deep .ul-grid {
|
:host ::ng-deep .ul-grid {
|
||||||
|
// The global `.k-dropdownlist { width: 100% !important }` (styles/vendors/kendo/_calendar.scss)
|
||||||
|
// made the User type dropdown fill the whole toolbar row and pushed the rest onto the next line.
|
||||||
|
// Keep it compact so dropdown, search, chips and buttons stay on one line, like the Role page.
|
||||||
|
.ul-type.k-dropdownlist {
|
||||||
|
width: 170px !important;
|
||||||
|
}
|
||||||
|
|
||||||
// Uniform, compact rows
|
// Uniform, compact rows
|
||||||
.k-grid-table td {
|
.k-grid-table td {
|
||||||
height: 44px;
|
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
@ -126,6 +132,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Row action buttons (last column), side by side like the Role page
|
||||||
|
.ul-row-action + .ul-row-action {
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.ul-login {
|
.ul-login {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: $gray-700;
|
color: $gray-700;
|
||||||
|
|
@ -160,6 +171,12 @@
|
||||||
.ul-badge--warning { background: $userlist-warning-bg; color: $userlist-warning; }
|
.ul-badge--warning { background: $userlist-warning-bg; color: $userlist-warning; }
|
||||||
.ul-badge--neutral { background: $userlist-neutral-bg; color: $userlist-neutral; }
|
.ul-badge--neutral { background: $userlist-neutral-bg; color: $userlist-neutral; }
|
||||||
.ul-badge--danger { background: $userlist-danger-bg; color: $danger; }
|
.ul-badge--danger { background: $userlist-danger-bg; color: $danger; }
|
||||||
|
// "Created by" name next to the date in the Created column
|
||||||
|
.ul-badge--info { background: #E8EEFC; color: #2F4FB5; }
|
||||||
|
|
||||||
|
.ul-created-by {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.ul-empty {
|
.ul-empty {
|
||||||
padding: 32px 16px;
|
padding: 32px 16px;
|
||||||
|
|
@ -194,4 +211,8 @@
|
||||||
.ul-search {
|
.ul-search {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep .ul-grid .ul-type.k-dropdownlist {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,13 @@ export class UsersListComponent implements OnInit {
|
||||||
ouser.modifiedBy = oselecteduser.userID;
|
ouser.modifiedBy = oselecteduser.userID;
|
||||||
ouser.modifiedDate = new Date();
|
ouser.modifiedDate = new Date();
|
||||||
|
|
||||||
|
const question = this.actionselected == "deactivate-approve"
|
||||||
|
? `Are you sure you want to approve the deactivation of ${oselecteduser.userName ?? ''} (${oselecteduser.loginID ?? ''})?`
|
||||||
|
: `Are you sure you want to approve ${oselecteduser.userName ?? ''} (${oselecteduser.loginID ?? ''})?`;
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', question).then((isConfirmed) => {
|
||||||
|
if (!isConfirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.loadingPanel.ShowLoadingPanel = true;
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
this.userService.ApproveUser(ouser).subscribe(
|
this.userService.ApproveUser(ouser).subscribe(
|
||||||
(x: User) => {
|
(x: User) => {
|
||||||
|
|
@ -389,6 +396,7 @@ export class UsersListComponent implements OnInit {
|
||||||
this.notificationService.showError(x.error);
|
this.notificationService.showError(x.error);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- deactivate ----------
|
// ---------- deactivate ----------
|
||||||
|
|
@ -442,7 +450,19 @@ export class UsersListComponent implements OnInit {
|
||||||
changed.modifiedBy = target.userID;
|
changed.modifiedBy = target.userID;
|
||||||
changed.modifiedDate = new Date();
|
changed.modifiedDate = new Date();
|
||||||
|
|
||||||
|
if (this.actionselected == 'reject') {
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation',
|
||||||
|
`Are you sure you want to reject ${target.userName ?? ''} (${target.loginID ?? ''})?`).then((isConfirmed) => {
|
||||||
|
if (isConfirmed) {
|
||||||
|
this.saveStatusChange(target, changed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.saveStatusChange(target, changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private saveStatusChange(target: User, changed: User) {
|
||||||
this.loadingPanel.ShowLoadingPanel = true;
|
this.loadingPanel.ShowLoadingPanel = true;
|
||||||
this.userService.DoActiveAndIntacive(changed).subscribe(
|
this.userService.DoActiveAndIntacive(changed).subscribe(
|
||||||
() => {
|
() => {
|
||||||
|
|
|
||||||
|
|
@ -673,6 +673,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (showModal) {
|
@if (showModal) {
|
||||||
|
<div class="card" class="blur-background">
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="390">
|
<kendo-dialog (close)="onPopUpClose()" [minWidth]="390">
|
||||||
<kendo-dialog-titlebar>Access Types</kendo-dialog-titlebar>
|
<kendo-dialog-titlebar>Access Types</kendo-dialog-titlebar>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|
@ -690,6 +691,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (showAttachment) {
|
@if (showAttachment) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@ import {
|
||||||
imageIcon,
|
imageIcon,
|
||||||
shareIcon,
|
shareIcon,
|
||||||
zoomInIcon,
|
zoomInIcon,
|
||||||
zoomOutIcon
|
zoomOutIcon,
|
||||||
|
copyIcon,
|
||||||
|
forwardIcon
|
||||||
} from '@progress/kendo-svg-icons';
|
} from '@progress/kendo-svg-icons';
|
||||||
|
|
||||||
@NgModule({})
|
@NgModule({})
|
||||||
|
|
@ -93,6 +95,8 @@ export class KendoIconsModule {
|
||||||
image: imageIcon,
|
image: imageIcon,
|
||||||
share: shareIcon,
|
share: shareIcon,
|
||||||
zoomIn: zoomInIcon,
|
zoomIn: zoomInIcon,
|
||||||
zoomOut: zoomOutIcon
|
zoomOut: zoomOutIcon,
|
||||||
|
copy : copyIcon,
|
||||||
|
forward : forwardIcon
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
.customGrid{
|
.customGrid{
|
||||||
margin: 0px 100px 0px 100px !important;
|
margin: 0px 80px 0px 80px !important;
|
||||||
}
|
}
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.customGrid {
|
.customGrid {
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
}
|
}
|
||||||
@if (isWorkflowRequired) {
|
@if (isWorkflowRequired) {
|
||||||
<kendo-grid-column field="count" title="Add Attachment" width="20%">
|
<kendo-grid-column field="count" title="Add Attachment" width="15%">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||||
<button kendoButton (click)="showAddApprovalAttachment(dataItem)" [svgIcon]="apiService.KendoSVGIcon['add']">Approve</button>
|
<button kendoButton (click)="showAddApprovalAttachment(dataItem)" [svgIcon]="apiService.KendoSVGIcon['clip']">Attachment</button>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
}
|
}
|
||||||
<kendo-grid-command-column title="Action" width="10%">
|
<kendo-grid-command-column title="Action" width="15%">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||||
@if (!isWorkflowRequired) {
|
@if (!isWorkflowRequired) {
|
||||||
<button kendoButton (click)="ApproveBonus(dataItem.bonusid)" [svgIcon]="apiService.KendoSVGIcon['delete']">Approve</button>
|
<button kendoButton (click)="ApproveBonus(dataItem.bonusid)" [svgIcon]="apiService.KendoSVGIcon['delete']">Approve</button>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* Bonus Process: the input panels at the top (colors are the app's $brand-* / $gray-* tokens as literals) */
|
||||||
|
.bp-panel {
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #E4E4EE;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px 16px 6px 16px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-panel-title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #414278;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
border-bottom: 1px solid #DEDEFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-label {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-required {
|
||||||
|
color: #d9534f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-options {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 24px;
|
||||||
|
min-height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-option {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-option label {
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process / Clear Tax / Upload Data: pushed to the far right of the options row */
|
||||||
|
.bp-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bp-message {
|
||||||
|
padding: 6px 2px 8px 2px;
|
||||||
|
color: #414278;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* in the grid toolbar: no extra height, kept on the far right */
|
||||||
|
span.bp-message {
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|
||||||
<div class="md:col-6 col-12">
|
<!-- Inputs grouped in two panels; every control keeps its bindings (ngModel, formControlName, events) -->
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="bp-panel">
|
||||||
|
<div class="bp-panel-title">Bonus Information</div>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="col-5" style="margin: auto;">
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
<label>Bonus Type</label>
|
<label class="bp-label">Bonus Type <span class="bp-required">*</span></label>
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<kendo-dropdownlist [(ngModel)]="selectedbonusID"
|
<kendo-dropdownlist [(ngModel)]="selectedbonusID"
|
||||||
[data]="bonuses"
|
[data]="bonuses"
|
||||||
[defaultItem]="{ name: 'Select Bonus Type..', id: null }"
|
[defaultItem]="{ name: 'Select Bonus Type..', id: null }"
|
||||||
|
|
@ -21,40 +22,30 @@
|
||||||
style="width:100%">
|
style="width:100%">
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
</div>
|
<label class="bp-label">Consider Basic Of <span class="bp-required">*</span></label>
|
||||||
<div class="md:col-6 col-12">
|
|
||||||
<div class="grid">
|
|
||||||
<div class="col-5" style="margin: auto;">
|
|
||||||
<label>Consider Basic Of</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
||||||
[(ngModel)]="basicDate"
|
[(ngModel)]="basicDate"
|
||||||
formControlName="basicDate"
|
formControlName="basicDate"
|
||||||
style="width:100%"></kendo-datepicker>
|
style="width:100%"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
|
<label class="bp-label">Currently Process For Basic <span class="bp-required">*</span></label>
|
||||||
|
<kendo-numerictextbox
|
||||||
|
[(ngModel)]="processFor"
|
||||||
|
style="width:100%"
|
||||||
|
formControlName="processFor">
|
||||||
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
<div class="md:col-6 col-12">
|
<label class="bp-label">Pay Date <span class="bp-required">*</span></label>
|
||||||
<div class="grid">
|
|
||||||
<div class="col-5" style="margin: auto;">
|
|
||||||
<label>Pay Date</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
||||||
[(ngModel)]="payDate"
|
[(ngModel)]="payDate"
|
||||||
formControlName="payDate"
|
formControlName="payDate"
|
||||||
style="width:100%"></kendo-datepicker>
|
style="width:100%"></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
</div>
|
<label class="bp-label">Bonus Cut Off Date <span class="bp-required">*</span></label>
|
||||||
<div class="md:col-6 col-12">
|
|
||||||
<div class="grid">
|
|
||||||
<div class="col-5" style="margin: auto;">
|
|
||||||
<label>Bonus Cut Off Date</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
<kendo-datepicker [format]="'dd-MMM-yyyy'"
|
||||||
[(ngModel)]="cuttofDate"
|
[(ngModel)]="cuttofDate"
|
||||||
formControlName="cutOffDate"
|
formControlName="cutOffDate"
|
||||||
|
|
@ -62,81 +53,60 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="md:col-6 col-12">
|
|
||||||
<div class="grid">
|
|
||||||
<div class="col-5" style="margin: auto;">
|
|
||||||
<label>Currently Process For Basic</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<kendo-numerictextbox
|
|
||||||
[(ngModel)]="processFor"
|
|
||||||
style="width:100%"
|
|
||||||
formControlName="processFor">
|
|
||||||
</kendo-numerictextbox>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
<div class="bp-panel" style="margin-bottom: 0px !important;">
|
||||||
</div>
|
<div class="bp-panel-title">Employees & Options</div>
|
||||||
<div class="md:col-6 col-12">
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="col-5" style="margin: auto;">
|
<div class="col-12 md:col-6 lg:col-4 bp-field">
|
||||||
<label>Select Employee: </label>
|
<label class="bp-label">Select Employee</label>
|
||||||
</div>
|
|
||||||
<div class="col-7">
|
|
||||||
<app-employee-picker [MultiSelect]="true" (ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker>
|
<app-employee-picker [MultiSelect]="true" (ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker>
|
||||||
<b> {{returnMessage}}</b>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-12 md:col-6 lg:col-8 bp-field">
|
||||||
</div>
|
<label class="bp-label">Options</label>
|
||||||
<div class="md:col-6 col-12">
|
<div class="bp-options">
|
||||||
<div class="grid" style="margin-top: 8px;">
|
<span class="bp-option">
|
||||||
<div class="col-5">
|
<input id="bpDisburseWithSalary" formControlName="disburseWithSalary" kendoCheckBox
|
||||||
<div class="p-field-checkbox">
|
[(ngModel)]="disburseWithSalary" (change)="checkWithOrTax(1, disburseWithSalary)"
|
||||||
<input formControlName="disburseWithSalary" kendoCheckBox
|
|
||||||
[(ngModel)]="disburseWithSalary" (change)="checkWithOrTax(1, disburseWithSalary)" style="margin-right: 10px"
|
|
||||||
type="checkbox" />
|
type="checkbox" />
|
||||||
<label>Disburse With Salary</label>
|
<label for="bpDisburseWithSalary">Disburse With Salary</label>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
<span class="bp-option">
|
||||||
<div class="col-7">
|
<input id="bpCalculateTax" formControlName="calculateTax" kendoCheckBox (change)="checkWithOrTax(2, isTaxProcess)"
|
||||||
<div class="p-field-checkbox">
|
[(ngModel)]="isTaxProcess"
|
||||||
<input formControlName="calculateTax" kendoCheckBox (change)="checkWithOrTax(2, isTaxProcess)"
|
|
||||||
[(ngModel)]="isTaxProcess" style="margin-right: 10px"
|
|
||||||
type="checkbox" />
|
type="checkbox" />
|
||||||
<label>Calculate Tax</label>
|
<label for="bpCalculateTax">Calculate Tax</label>
|
||||||
|
</span>
|
||||||
|
<!-- Process, Clear Tax and Upload Data on the right of the same row (moved here from the row under the panel) -->
|
||||||
|
<span class="bp-actions">
|
||||||
|
<button type="button" kendoButton [svgIcon]="apiService.KendoSVGIcon['gear']" themeColor="primary" (click)="process()">Process</button>
|
||||||
|
<!-- Clear Tax now saves at once (clearTaxAndSave); the old browser-only clearTax() is kept in the .ts -->
|
||||||
|
<button type="button" kendoButton [svgIcon]="apiService.KendoSVGIcon['cross']" themeColor="primary" (click)="clearTaxAndSave()">Clear Tax</button>
|
||||||
|
<button type="button" kendoButton [svgIcon]="apiService.KendoSVGIcon['upload']" themeColor="primary" (click)="showBonusUploadPopUp()">Upload Data</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- the message now shows on the right of the grid toolbar (next to Export to Excel). Kept for reference.
|
||||||
|
@if (returnMessage) {
|
||||||
|
<div class="bp-message"><b>{{returnMessage}}</b></div>
|
||||||
|
}
|
||||||
<div class="md:col-12 col-12">
|
-->
|
||||||
<div class="grid" style="margin-left: 5px; margin-right: 5px;">
|
|
||||||
<div class="col-12" align="right">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['gear']" themeColor="primary" (click)="process()" style="margin-right:5px;">Process</button>
|
|
||||||
<!--<button kendoButton [svgIcon]="apiService.KendoSVGIcon['upload']" themeColor="primary" (click)="uploadData()" style="margin-right:5px; float:right;">Upload</button>-->
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['upload']" themeColor="primary" (click)="showBonusUploadPopUp()" style="margin-right:5px;">Upload Data</button>
|
|
||||||
<!--<button kendoButton [svgIcon]="apiService.KendoSVGIcon['upload']" themeColor="primary" (click)="uploadData()" style="margin-right:5px; float:right;">Upload</button>-->
|
|
||||||
</div>
|
|
||||||
<div class="col-6" align="right">
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['cross']" themeColor="primary" (click)="clearTax()" style="margin-right:5px;">Clear Tax</button>
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['gear']" themeColor="primary" (click)="TaxRecalculate()" style="margin-right:5px;">Tax Re-calculate</button>
|
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" themeColor="primary" (click)="save()" style="margin-right:5px;">Save</button>
|
|
||||||
<!--<button kendoButton [svgIcon]="apiService.KendoSVGIcon['upload']" themeColor="primary" (click)="uploadData()" style="margin-right:5px; float:right;">Upload</button>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<kendo-grid [data]="$safeNavigationMigration(bonusProcess?.bonusProcessDetails)">
|
<!-- virtual scrolling: only the rows on screen are rendered, so 10k+ employees (two numeric
|
||||||
|
textboxes per row) do not freeze the page. kendoGridBinding pages the array itself. -->
|
||||||
|
<kendo-grid [kendoGridBinding]="$safeNavigationMigration(bonusProcess?.bonusProcessDetails)"
|
||||||
|
scrollable="virtual" [pageSize]="50" [rowHeight]="40" [height]="500">
|
||||||
<ng-template kendoGridToolbarTemplate>
|
<ng-template kendoGridToolbarTemplate>
|
||||||
<button type="button" kendoGridExcelCommand [svgIcon]="apiService.KendoSVGIcon['fileExcel']">
|
<button type="button" kendoGridExcelCommand [svgIcon]="apiService.KendoSVGIcon['fileExcel']">
|
||||||
Export to Excel
|
Export to Excel
|
||||||
</button>
|
</button>
|
||||||
Count: {{ bonusProcess?.bonusProcessDetails.length}}
|
Count: {{ bonusProcess?.bonusProcessDetails.length}}
|
||||||
|
@if (returnMessage) {
|
||||||
|
<kendo-grid-spacer></kendo-grid-spacer>
|
||||||
|
<span class="bp-message"><b>{{returnMessage}}</b></span>
|
||||||
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<kendo-grid-column field="employee.employeeNo" title="Emp. ID" width="10%">
|
<kendo-grid-column field="employee.employeeNo" title="Emp. ID" width="10%">
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
|
@ -164,6 +134,8 @@
|
||||||
{{dataItem.employee.basicSalary | number:'1.2-2'}}
|
{{dataItem.employee.basicSalary | number:'1.2-2'}}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
<!-- Bonus Amount and Bonus Tax are read-only: they are changed one employee at a time in the Modify dialog.
|
||||||
|
The old editable cells are kept below for reference.
|
||||||
<kendo-grid-column field="bonusAmount" title="Bonus Amount" width="10%">
|
<kendo-grid-column field="bonusAmount" title="Bonus Amount" width="10%">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem>
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
<kendo-numerictextbox [(ngModel)]="dataItem.changeBonusAmount"
|
<kendo-numerictextbox [(ngModel)]="dataItem.changeBonusAmount"
|
||||||
|
|
@ -184,30 +156,46 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
-->
|
||||||
|
<kendo-grid-column field="changeBonusAmount" title="Bonus Amount" width="10%">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
{{dataItem.changeBonusAmount | number:'1.2-2'}}
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
|
<kendo-grid-column field="changeTaxAmount" title="Bonus Tax" width="10%">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
{{dataItem.changeTaxAmount | number:'1.2-2'}}
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-column>
|
||||||
<kendo-grid-column field="totalAmount" title="Total Amount" width="10%">
|
<kendo-grid-column field="totalAmount" title="Total Amount" width="10%">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem>
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
{{(dataItem.changeBonusAmount - dataItem.changeTaxAmount) | number:'1.2-2'}}
|
{{(dataItem.changeBonusAmount - dataItem.changeTaxAmount) | number:'1.2-2'}}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
<kendo-grid-command-column title="Remove" width="8%" style="height:98%;">
|
<!-- Modify is for the bonus tax: hidden when the process was saved with Disburse With Salary (no bonus tax then) -->
|
||||||
|
<kendo-grid-command-column title="Modify" width="8%" [hidden]="bonusProcess?.isDisburseWithSalary == true"
|
||||||
|
[style]="{ 'text-align': 'center' }" [headerStyle]="{ 'text-align': 'center' }">
|
||||||
|
<ng-template kendoGridCellTemplate let-dataItem>
|
||||||
|
<!-- only saved rows (after Process) can be modified -->
|
||||||
|
@if (dataItem.bonusProcessDetailID) {
|
||||||
|
<button type="button" kendoButton [svgIcon]="apiService.KendoSVGIcon['edit']" themeColor="primary"
|
||||||
|
title="Modify" (click)="openModify(dataItem)">Modify</button>
|
||||||
|
}
|
||||||
|
</ng-template>
|
||||||
|
</kendo-grid-command-column>
|
||||||
|
<kendo-grid-command-column title="Remove" width="8%"
|
||||||
|
[style]="{ 'text-align': 'center' }" [headerStyle]="{ 'text-align': 'center' }">
|
||||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||||
<button (click)="removefromList(rowIndex)" class="kt-delete" kendoButton [svgIcon]="apiService.KendoSVGIcon['delete']">
|
<!-- old: (click)="removefromList(rowIndex)". removeRow keeps that for unsaved rows and deletes saved rows in the DB -->
|
||||||
|
<button type="button" (click)="removeRow(dataItem, rowIndex)" class="kt-delete" kendoButton [svgIcon]="apiService.KendoSVGIcon['delete']">
|
||||||
</button>
|
</button>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-command-column>
|
</kendo-grid-command-column>
|
||||||
<kendo-grid-excel fileName="BonusProcess.xlsx"></kendo-grid-excel>
|
<kendo-grid-excel fileName="BonusProcess.xlsx" [fetchData]="allBonusRows"></kendo-grid-excel>
|
||||||
</kendo-grid>
|
</kendo-grid>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@if (showModal) {
|
@if (showModal) {
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650"
|
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650"
|
||||||
[width]="650">
|
[width]="650">
|
||||||
|
|
@ -232,8 +220,6 @@
|
||||||
</div>
|
</div>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@if (showBonusUpload) {
|
@if (showBonusUpload) {
|
||||||
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650"
|
<kendo-dialog (close)="onPopUpClose()" [minWidth]="650"
|
||||||
[width]="650">
|
[width]="650">
|
||||||
|
|
@ -252,8 +238,9 @@
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="col-12" align="right">
|
<div class="col-12" align="right">
|
||||||
<app-loading-panel></app-loading-panel>
|
<app-loading-panel></app-loading-panel>
|
||||||
<input id="fupEmpPhoto" kendoTextBox title="Upload"
|
<!-- the file is checked, read and saved on the server in one go (old handler uploadBonusFile kept) -->
|
||||||
(change)="uploadBonusFile($event)" type="file">
|
<input id="fupEmpPhoto" kendoTextBox title="Upload" accept=".xlsx,.xls"
|
||||||
|
(change)="uploadBonusFileAndSave($event)" type="file">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|
@ -263,3 +250,61 @@
|
||||||
</div>
|
</div>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<!-- Modify dialog: one employee's bonus and tax, saved on its own (api/Bonus/calculateRowTax, api/Bonus/saveRow) -->
|
||||||
|
@if (showModify && modifyRow) {
|
||||||
|
<div class="blur-background">
|
||||||
|
<kendo-dialog title="Modify Bonus" [width]="520" maxHeight="90vh" (close)="closeModify()"
|
||||||
|
(keydown.escape)="$event.stopPropagation()">
|
||||||
|
<app-loading-panel></app-loading-panel>
|
||||||
|
<div class="grid">
|
||||||
|
<div class="col-4"><label>Employee</label></div>
|
||||||
|
<div class="col-8"><b>{{modifyRow.employee?.employeeNo}} - {{modifyRow.employee?.name}}</b></div>
|
||||||
|
<div class="col-4" style="margin: auto;"><label>Bonus Amount</label></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<kendo-numerictextbox [(ngModel)]="modifyBonusAmount" [ngModelOptions]="{standalone: true}"
|
||||||
|
[min]="0" [autoCorrect]="true" [spinners]="false" [format]="'n2'"
|
||||||
|
(valueChange)="onModifyBonusChange()" style="width: 100%;">
|
||||||
|
</kendo-numerictextbox>
|
||||||
|
</div>
|
||||||
|
<div class="col-4" style="margin: auto;"><label>Calculated tax</label></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="checkbox" kendoCheckBox [(ngModel)]="modifyCalculateTax" [ngModelOptions]="{standalone: true}"
|
||||||
|
(ngModelChange)="onModifyCalculateTaxChange()" />
|
||||||
|
<button type="button" kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||||
|
[disabled]="!modifyCalculateTax || modifyBusy" (click)="calculateModifyTax()" style="margin-left: 10px;">
|
||||||
|
Calculate
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-4" style="margin: auto;"><label>Tax Amount</label></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<kendo-numerictextbox [(ngModel)]="modifyTaxAmount" [ngModelOptions]="{standalone: true}"
|
||||||
|
[min]="0" [autoCorrect]="true" [spinners]="false" [format]="'n2'"
|
||||||
|
[readonly]="modifyCalculateTax" style="width: 100%;">
|
||||||
|
</kendo-numerictextbox>
|
||||||
|
@if (modifyCalculateTax && !modifyTaxCalculated) {
|
||||||
|
<small>Press Calculate to see the tax. On Save the tax is calculated again for this bonus.</small>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<!-- Edited Tax Amount: the calculated tax lands here, the user may change it; this one is saved (changeTaxAmount) -->
|
||||||
|
@if (modifyCalculateTax) {
|
||||||
|
<div class="col-4" style="margin: auto;"><label>Edited Tax Amount</label></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<kendo-numerictextbox [(ngModel)]="modifyEditedTaxAmount" [ngModelOptions]="{standalone: true}"
|
||||||
|
[min]="0" [autoCorrect]="true" [spinners]="false" [format]="'n2'"
|
||||||
|
[readonly]="!modifyTaxCalculated" style="width: 100%;">
|
||||||
|
</kendo-numerictextbox>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="col-4"><label>Total</label></div>
|
||||||
|
<div class="col-8"><b>{{ ((modifyBonusAmount || 0) - ((modifyCalculateTax ? modifyEditedTaxAmount : modifyTaxAmount) || 0)) | number:'1.2-2' }}</b></div>
|
||||||
|
</div>
|
||||||
|
<kendo-dialog-actions>
|
||||||
|
<button type="button" kendoButton [svgIcon]="apiService.KendoSVGIcon['cancel']" (click)="closeModify()">Cancel</button>
|
||||||
|
<button type="button" kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['save']"
|
||||||
|
[disabled]="modifyBusy" (click)="saveModify()">Save</button>
|
||||||
|
</kendo-dialog-actions>
|
||||||
|
</kendo-dialog>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ import {loadingPanelService} from '../../hrm-loding panel/loding.panel.service';
|
||||||
import {PayrollType} from '../../_models/Authentication/payrollType';
|
import {PayrollType} from '../../_models/Authentication/payrollType';
|
||||||
import {Bonus} from '../../_models/Basic/bonus';
|
import {Bonus} from '../../_models/Basic/bonus';
|
||||||
import {Employee} from '../../_models/Employee/employee';
|
import {Employee} from '../../_models/Employee/employee';
|
||||||
|
import {EmployeeLite} from '../../_models/Employee/employeeLite';
|
||||||
import {SearchEmployee} from '../../_models/Employee/searchEmployee';
|
import {SearchEmployee} from '../../_models/Employee/searchEmployee';
|
||||||
import {EnumIncomeTaxItemGroup, EnumStatus, EnumTaxMergeType} from '../../_models/enums';
|
import {EnumIncomeTaxItemGroup, EnumStatus, EnumTaxMergeType} from '../../_models/enums';
|
||||||
import {BonusProcess, BonusProcessDetail} from '../../_models/Payroll/bonusProcess';
|
import {BonusProcess, BonusProcessDetail} from '../../_models/Payroll/bonusProcess';
|
||||||
|
import {BonusProcessAndSaveRequest, BonusProcessAndSaveResult, BonusProcessGridRow, BonusProcessRowTaxResult, BonusProcessRowRemoveResult} from '../../_models/Payroll/bonusProcessAndSave';
|
||||||
import {TaxMergeMaster} from '../../_models/Payroll/Tax/taxMergeMaster';
|
import {TaxMergeMaster} from '../../_models/Payroll/Tax/taxMergeMaster';
|
||||||
import {AuthService} from '../../_services/auth/auth.service';
|
import {AuthService} from '../../_services/auth/auth.service';
|
||||||
import {BasicService} from '../../_services/Basic/basic.service';
|
import {BasicService} from '../../_services/Basic/basic.service';
|
||||||
|
|
@ -65,6 +67,17 @@ export class BonusProcessComponent implements OnInit {
|
||||||
processCompleted: boolean = false;
|
processCompleted: boolean = false;
|
||||||
showBonusUpload: boolean = false;
|
showBonusUpload: boolean = false;
|
||||||
|
|
||||||
|
// Modify dialog (one saved row at a time)
|
||||||
|
showModify: boolean = false;
|
||||||
|
modifyRow: BonusProcessDetail;
|
||||||
|
modifyBonusAmount: number = 0;
|
||||||
|
modifyTaxAmount: number = 0;
|
||||||
|
// "Edited Tax Amount" (with Calculated tax): starts as the calculated tax, the user may change it; saved as changeTaxAmount
|
||||||
|
modifyEditedTaxAmount: number = 0;
|
||||||
|
modifyCalculateTax: boolean = false;
|
||||||
|
modifyTaxCalculated: boolean = false; // the tax shown was calculated for the bonus shown
|
||||||
|
modifyBusy: boolean = false;
|
||||||
|
|
||||||
constructor(public basicService: BasicService, public notificationService: HRMNotificationService,
|
constructor(public basicService: BasicService, public notificationService: HRMNotificationService,
|
||||||
public loadingPanelService: loadingPanelService, public empService: EmployeeServices,
|
public loadingPanelService: loadingPanelService, public empService: EmployeeServices,
|
||||||
public datatransferservice: DataTransferService,
|
public datatransferservice: DataTransferService,
|
||||||
|
|
@ -96,7 +109,6 @@ export class BonusProcessComponent implements OnInit {
|
||||||
() => {
|
() => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.authSerivce.GetPayrollTypeByLoginID().subscribe(
|
this.authSerivce.GetPayrollTypeByLoginID().subscribe(
|
||||||
(x) => {
|
(x) => {
|
||||||
this.payrollType = x;
|
this.payrollType = x;
|
||||||
|
|
@ -110,8 +122,14 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.cuttofDate = new Date(this.payrollType.nextPayProcessDate);
|
this.cuttofDate = new Date(this.payrollType.nextPayProcessDate);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetSelectedEmployee(searchEmp: SearchEmployee[]) {
|
public GetSelectedEmployee(searchEmp: SearchEmployee[]) {
|
||||||
|
// the already-processed check needs the bonus: stop here (nothing added to the grid) until one is chosen
|
||||||
|
if (this.selectedbonusID == undefined || this.selectedbonusID <= 0) {
|
||||||
|
const message = 'Please select a Bonus Type first, then select the employees.';
|
||||||
|
this.notificationService.showWarning(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.processCompleted = false;
|
this.processCompleted = false;
|
||||||
this.selectedEmps = searchEmp;
|
this.selectedEmps = searchEmp;
|
||||||
if (this.bonusProcessDetails == undefined) {
|
if (this.bonusProcessDetails == undefined) {
|
||||||
|
|
@ -134,7 +152,6 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.RefreshDefaultGrid();
|
this.RefreshDefaultGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshDefaultGrid() {
|
RefreshDefaultGrid() {
|
||||||
if (this.selectedEmps != undefined && this.bonusProcessDetails != undefined) {
|
if (this.selectedEmps != undefined && this.bonusProcessDetails != undefined) {
|
||||||
if (this.bonusProcess == undefined) {
|
if (this.bonusProcess == undefined) {
|
||||||
|
|
@ -159,6 +176,7 @@ export class BonusProcessComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.bonusProcess.bonusProcessDetails = [...this.bonusProcess.bonusProcessDetails];
|
||||||
this.RefreshEmployees();
|
this.RefreshEmployees();
|
||||||
if (this.alreadyProcessesList.length > 0) {
|
if (this.alreadyProcessesList.length > 0) {
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
|
|
@ -167,27 +185,21 @@ export class BonusProcessComponent implements OnInit {
|
||||||
}
|
}
|
||||||
RefreshEmployees() {
|
RefreshEmployees() {
|
||||||
if (this.selectedEmps == undefined) return;
|
if (this.selectedEmps == undefined) return;
|
||||||
var ids = SearchEmployee.getEmpIds(this.selectedEmps);
|
const empIds: number[] = this.selectedEmps.map(e => e.employeeID);
|
||||||
|
var emps: EmployeeLite[];
|
||||||
const data = {
|
|
||||||
dataList: ids,
|
|
||||||
};
|
|
||||||
var emps: Employee[];
|
|
||||||
|
|
||||||
this.loadingPanelService.ShowLoadingPanel = true;
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
this.empService.getEmployeesByEmpIDs(data).subscribe(
|
this.empService.getEmployeeLiteByEmpIDs(empIds).subscribe(
|
||||||
(resp: any) => {
|
(resp: any) => {
|
||||||
emps = resp;
|
emps = resp;
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
this.notificationService.showWarning(err.error);
|
this.notificationService.showWarning(err.error);
|
||||||
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
emps.forEach(x => {
|
emps.forEach(x => {
|
||||||
let bindex = this.bonusProcess.bonusProcessDetails.findIndex(b => b.employeeID == x.id);
|
let bindex = this.bonusProcess.bonusProcessDetails.findIndex(b => b.employeeID == x.employeeID);
|
||||||
if (bindex != -1) {
|
if (bindex != -1) {
|
||||||
this.bonusProcess.bonusProcessDetails[bindex].employee.isConfirmed = x.isConfirmed;
|
this.bonusProcess.bonusProcessDetails[bindex].employee.isConfirmed = x.isConfirmed;
|
||||||
this.bonusProcess.bonusProcessDetails[bindex].employee.joiningDate = x.joiningDate;
|
this.bonusProcess.bonusProcessDetails[bindex].employee.joiningDate = x.joiningDate;
|
||||||
|
|
@ -195,9 +207,7 @@ export class BonusProcessComponent implements OnInit {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkWithOrTax(from: number, value: boolean) {
|
checkWithOrTax(from: number, value: boolean) {
|
||||||
debugger;
|
|
||||||
if (from == 1) {
|
if (from == 1) {
|
||||||
if (value == true) {
|
if (value == true) {
|
||||||
this.isTaxProcess = false;
|
this.isTaxProcess = false;
|
||||||
|
|
@ -208,35 +218,38 @@ export class BonusProcessComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPopUpClose() {
|
onPopUpClose() {
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
this.showBonusUpload = false;
|
this.showBonusUpload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
showBonusUploadPopUp() {
|
showBonusUploadPopUp() {
|
||||||
this.showBonusUpload = true;
|
this.showBonusUpload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentlyProcess($event) {
|
currentlyProcess($event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remainingBasic($event) {
|
remainingBasic($event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process() {
|
process() {
|
||||||
if (this.bonusProcess == undefined || this.bonusProcess.bonusProcessDetails.length == 0) {
|
if (this.bonusProcess == undefined || this.bonusProcess.bonusProcessDetails.length == 0) {
|
||||||
this.notificationService.showWarning('Please select employee for the proces');
|
this.notificationService.showWarning('Please select employee for the proces');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Process saves straight to the database, so ask first
|
||||||
|
// tell the user which option the process runs with (the two checkboxes can't both be ticked)
|
||||||
|
const option = this.disburseWithSalary ? 'with Disburse With Salary'
|
||||||
|
: this.isTaxProcess ? 'with Calculate Tax'
|
||||||
|
: 'without Disburse With Salary and Calculate Tax';
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', 'Are you sure you want to process the bonus ' + option + '?').then((isConfirmed) => {
|
||||||
|
if (isConfirmed)
|
||||||
|
{
|
||||||
|
this.processConfirmed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// the rest of Process, run only after the user confirmed
|
||||||
|
private processConfirmed() {
|
||||||
var isApproved = false;
|
var isApproved = false;
|
||||||
this.loadingPanelService.ShowLoadingPanel = true;
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
this.bonusService.IsBonusApproved(this.selectedbonusID, this.payrollType.nextPayProcessDate).subscribe(
|
this.bonusService.IsBonusApproved(this.selectedbonusID, this.payrollType.nextPayProcessDate).subscribe(
|
||||||
|
|
@ -255,48 +268,281 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.returnMessage = 'selected Bonus is already process and Approved';
|
this.returnMessage = 'selected Bonus is already process and Approved';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Process = calculate + save on the server in one request (no separate Save step).
|
||||||
|
// Only the header and the employee IDs are sent; the saved rows come back from the database.
|
||||||
var returnID: number;
|
const request: BonusProcessAndSaveRequest = {
|
||||||
this.processRequest = [];
|
bonusID: this.selectedbonusID,
|
||||||
var index: number = 0;
|
basicMonth: this.basicDate,
|
||||||
this.bonusProcess.bonusProcessDetails.forEach(x => {
|
payDate: this.payDate,
|
||||||
|
cuttOfDate: this.cuttofDate,
|
||||||
this.processRequest.push({
|
currProcess: this.processFor,
|
||||||
'bonusid': this.selectedbonusID,
|
isDisburseWithSalary: this.disburseWithSalary,
|
||||||
'basicMonth': this.basicDate,
|
isTaxProcess: this.isTaxProcess,
|
||||||
'payDate': this.payDate,
|
employeeIDs: this.bonusProcess.bonusProcessDetails.map(x => x.employeeID),
|
||||||
'cuttOfDate': this.cuttofDate,
|
};
|
||||||
'currProcess': this.processFor,
|
var result: BonusProcessAndSaveResult;
|
||||||
'isDisburseWithSalary': this.disburseWithSalary,
|
|
||||||
'isTaxProcess': this.isTaxProcess,
|
|
||||||
'empid': x.employeeID
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
this.errorOrSucessList = [];
|
this.errorOrSucessList = [];
|
||||||
this.bonusService.BonusProcess(this.processRequest).subscribe(
|
this.bonusService.processAndSave(request).subscribe(
|
||||||
(resp: any) => {
|
(resp: BonusProcessAndSaveResult) => {
|
||||||
this.bonusProcess = resp;
|
result = resp;
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
this.notificationService.showWarning(err.error);
|
const message = (typeof err?.error === 'string' && err.error) ? err.error
|
||||||
this.returnMessage = err.error;
|
: 'Bonus process failed. Please check the connection and try again.';
|
||||||
|
this.notificationService.showWarning(message);
|
||||||
|
this.returnMessage = message;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
this.bonusProcess = new BonusProcess();
|
||||||
|
this.bonusProcess.id = result?.bonusProcessID;
|
||||||
|
// kept so the grid knows how this process was saved (Modify is hidden for Disburse With Salary)
|
||||||
|
this.bonusProcess.isDisburseWithSalary = request.isDisburseWithSalary;
|
||||||
|
this.bonusProcess.bonusProcessDetails = (result?.rows ?? []).map(r => this.toGridDetail(r));
|
||||||
|
// the already-processed list changed: read it again on the next employee selection
|
||||||
|
this.bonusProcessDetails = undefined;
|
||||||
|
this.alreadyProcessesList = [];
|
||||||
this.processCompleted = true;
|
this.processCompleted = true;
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
this.pbuttonEnalble = false;
|
this.pbuttonEnalble = false;
|
||||||
this.notificationService.showSuccess('Bonus processed successfully');
|
const skipped = result?.alreadyProcessedEmployeeIDs?.length ?? 0;
|
||||||
this.returnMessage = 'Bonus processed successfully';
|
const message = 'Bonus processed and saved successfully'
|
||||||
|
+ (skipped > 0 ? ' (' + skipped + ' already processed employee(s) left out)' : '');
|
||||||
|
this.notificationService.showSuccess(message);
|
||||||
|
this.returnMessage = message;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// ---- Upload Data: check every input, then the server reads the file, calculates the tax (when asked)
|
||||||
|
// and saves, in one request (api/dataUpload/uploadBonusFileAndSave). The old uploadBonusFile is kept. ----
|
||||||
|
uploadBonusFileAndSave(event: any): void {
|
||||||
|
const input: HTMLInputElement = event?.target;
|
||||||
|
const file: File | null = input?.files && input.files.length > 0 ? input.files.item(0) : null;
|
||||||
|
const clearInput = () => { if (input) input.value = ''; }; // so the same file can be chosen again
|
||||||
|
|
||||||
|
const problems: string[] = [];
|
||||||
|
if (this.selectedbonusID == undefined || this.selectedbonusID <= 0) problems.push('Bonus Type');
|
||||||
|
if (this.basicDate == undefined) problems.push('Consider Basic Of');
|
||||||
|
if (this.payDate == undefined) problems.push('Pay Date');
|
||||||
|
if (this.cuttofDate == undefined) problems.push('Bonus Cut Off Date');
|
||||||
|
if (this.processFor == undefined || this.processFor <= 0) problems.push('Currently Process For Basic (must be greater than 0)');
|
||||||
|
if (this.payrollType == undefined) problems.push('Payroll type (please reload the page)');
|
||||||
|
if (problems.length > 0) {
|
||||||
|
this.notificationService.showWarning('Please give: ' + problems.join(', '));
|
||||||
|
clearInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file == null) {
|
||||||
|
this.notificationService.showWarning('please select a file');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const name = (file.name || '').toLowerCase();
|
||||||
|
if (!name.endsWith('.xlsx') && !name.endsWith('.xls')) {
|
||||||
|
this.notificationService.showWarning('Please select an Excel file (.xlsx or .xls)');
|
||||||
|
clearInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const header: BonusProcessAndSaveRequest = {
|
||||||
|
bonusID: this.selectedbonusID,
|
||||||
|
basicMonth: this.basicDate,
|
||||||
|
payDate: this.payDate,
|
||||||
|
cuttOfDate: this.cuttofDate,
|
||||||
|
currProcess: this.processFor,
|
||||||
|
isDisburseWithSalary: this.disburseWithSalary,
|
||||||
|
isTaxProcess: this.isTaxProcess,
|
||||||
|
employeeIDs: [],
|
||||||
|
};
|
||||||
|
var isApproved = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.bonusService.IsBonusApproved(this.selectedbonusID, this.payrollType.nextPayProcessDate).subscribe(
|
||||||
|
(resp: any) => {
|
||||||
|
isApproved = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showWarning(this.errorText(err, 'Could not check the bonus. Please try again.'));
|
||||||
|
clearInput();
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
if (isApproved == true) {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showWarning('selected Bonus is already process and Approved');
|
||||||
|
this.returnMessage = 'selected Bonus is already process and Approved';
|
||||||
|
clearInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var result: BonusProcessAndSaveResult;
|
||||||
|
this.dataUploadService.uploadBonusFileAndSave(file, header).subscribe(
|
||||||
|
(resp: BonusProcessAndSaveResult) => {
|
||||||
|
result = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
const message = this.errorText(err, 'Upload failed. Please check the connection and try again.');
|
||||||
|
this.notificationService.showWarning(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
clearInput();
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.bonusProcess = new BonusProcess();
|
||||||
|
this.bonusProcess.id = result?.bonusProcessID;
|
||||||
|
// kept so the grid knows how this process was saved (Modify is hidden for Disburse With Salary)
|
||||||
|
this.bonusProcess.isDisburseWithSalary = header.isDisburseWithSalary;
|
||||||
|
this.bonusProcess.bonusProcessDetails = (result?.rows ?? []).map(r => this.toGridDetail(r));
|
||||||
|
// the already-processed list changed: read it again on the next employee selection
|
||||||
|
this.bonusProcessDetails = undefined;
|
||||||
|
this.alreadyProcessesList = [];
|
||||||
|
this.processCompleted = true;
|
||||||
|
this.showBonusUpload = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
const skipped = result?.alreadyProcessedEmployeeIDs?.length ?? 0;
|
||||||
|
const message = 'Bonus uploaded and saved successfully (' + (result?.rows?.length ?? 0) + ' employee(s))'
|
||||||
|
+ (skipped > 0 ? '; ' + skipped + ' already processed employee(s) left out' : '');
|
||||||
|
this.notificationService.showSuccess(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
clearInput();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// ---- Modify dialog: one saved row at a time (api/Bonus/calculateRowTax, api/Bonus/saveRow) ----
|
||||||
|
openModify(row: BonusProcessDetail) {
|
||||||
|
if (row == undefined || !row.bonusProcessDetailID) {
|
||||||
|
this.notificationService.showWarning('Please process the Bonus first');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.modifyRow = row;
|
||||||
|
this.modifyBonusAmount = row.changeBonusAmount ?? 0;
|
||||||
|
this.modifyCalculateTax = this.isTaxProcess == true;
|
||||||
|
// with Calculated tax: Tax Amount = the system's tax (taxAmount), Edited Tax Amount = the saved one (changeTaxAmount);
|
||||||
|
// without it the Tax Amount field is typed in as before and starts at the saved tax
|
||||||
|
this.modifyTaxAmount = this.modifyCalculateTax ? (row.taxAmount ?? 0) : (row.changeTaxAmount ?? 0);
|
||||||
|
this.modifyEditedTaxAmount = row.changeTaxAmount ?? 0;
|
||||||
|
this.modifyTaxCalculated = true; // the saved tax belongs to the saved bonus
|
||||||
|
this.modifyBusy = false;
|
||||||
|
this.showModify = true;
|
||||||
|
}
|
||||||
|
closeModify() {
|
||||||
|
this.showModify = false;
|
||||||
|
this.modifyRow = undefined;
|
||||||
|
this.modifyBusy = false;
|
||||||
|
}
|
||||||
|
onModifyBonusChange() {
|
||||||
|
// the tax shown no longer matches the bonus until Calculate is pressed again
|
||||||
|
if (this.modifyCalculateTax) this.modifyTaxCalculated = false;
|
||||||
|
}
|
||||||
|
onModifyCalculateTaxChange() {
|
||||||
|
if (this.modifyCalculateTax) this.modifyTaxCalculated = false;
|
||||||
|
}
|
||||||
|
private errorText(err: any, fallback: string): string {
|
||||||
|
return (typeof err?.error === 'string' && err.error) ? err.error : fallback;
|
||||||
|
}
|
||||||
|
calculateModifyTax() {
|
||||||
|
if (this.modifyRow == undefined) return;
|
||||||
|
if (this.modifyBonusAmount == undefined || this.modifyBonusAmount < 0) {
|
||||||
|
this.notificationService.showWarning('Please enter a valid bonus amount');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.modifyBusy = true;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.bonusService.calculateRowTax({
|
||||||
|
bonusProcessDetailID: this.modifyRow.bonusProcessDetailID,
|
||||||
|
bonusAmount: this.modifyBonusAmount,
|
||||||
|
}).subscribe(
|
||||||
|
(resp: BonusProcessRowTaxResult) => {
|
||||||
|
this.modifyTaxAmount = resp?.taxAmount ?? 0;
|
||||||
|
// the user sees the new tax in Edited Tax Amount and may change it before Save
|
||||||
|
this.modifyEditedTaxAmount = this.modifyTaxAmount;
|
||||||
|
this.modifyTaxCalculated = true;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.modifyBusy = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showWarning(this.errorText(err, 'Tax calculation failed. Please try again.'));
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.modifyBusy = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
saveModify() {
|
||||||
|
if (this.modifyRow == undefined) return;
|
||||||
|
if (this.modifyBonusAmount == undefined || this.modifyBonusAmount < 0) {
|
||||||
|
this.notificationService.showWarning('Please enter a valid bonus amount');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.modifyCalculateTax && (this.modifyTaxAmount == undefined || this.modifyTaxAmount < 0)) {
|
||||||
|
this.notificationService.showWarning('Please enter a valid tax amount');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.modifyCalculateTax && !this.modifyTaxCalculated) {
|
||||||
|
// the Edited Tax Amount must be chosen against the tax of THIS bonus amount
|
||||||
|
this.notificationService.showWarning('Please press Calculate first, then check the Edited Tax Amount');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.modifyCalculateTax && (this.modifyEditedTaxAmount == undefined || this.modifyEditedTaxAmount < 0)) {
|
||||||
|
this.notificationService.showWarning('Please enter a valid edited tax amount');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const row = this.modifyRow;
|
||||||
|
var saved: BonusProcessGridRow;
|
||||||
|
this.modifyBusy = true;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.bonusService.saveRow({
|
||||||
|
bonusProcessDetailID: row.bonusProcessDetailID,
|
||||||
|
bonusAmount: this.modifyBonusAmount,
|
||||||
|
taxAmount: this.modifyTaxAmount ?? 0,
|
||||||
|
calculateTax: this.modifyCalculateTax == true,
|
||||||
|
editedTaxAmount: this.modifyCalculateTax == true ? (this.modifyEditedTaxAmount ?? 0) : undefined,
|
||||||
|
}).subscribe(
|
||||||
|
(resp: BonusProcessGridRow) => {
|
||||||
|
saved = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.modifyBusy = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showWarning(this.errorText(err, 'Save failed. Please try again.'));
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.modifyBusy = false;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
if (saved != undefined) {
|
||||||
|
// only this row changes in the grid, with what the database now holds
|
||||||
|
const updated = this.toGridDetail(saved);
|
||||||
|
row.changeBonusAmount = updated.changeBonusAmount;
|
||||||
|
row.changeTaxAmount = updated.changeTaxAmount;
|
||||||
|
row.taxAmount = updated.taxAmount;
|
||||||
|
row.bonusAmount = updated.bonusAmount;
|
||||||
|
row.basicSalary = updated.basicSalary;
|
||||||
|
row.employee = updated.employee;
|
||||||
|
}
|
||||||
|
this.notificationService.showSuccess('Bonus saved for ' + (row.employee?.employeeNo ?? 'the employee'));
|
||||||
|
this.closeModify();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// a saved row from processAndSave, in the shape the grid binds to (dataItem.employee.*, changeBonusAmount, ...)
|
||||||
|
private toGridDetail(r: BonusProcessGridRow): BonusProcessDetail {
|
||||||
|
const item: BonusProcessDetail = new BonusProcessDetail();
|
||||||
|
item.bonusProcessDetailID = r.bonusProcessDetailID;
|
||||||
|
item.bonusProcessID = r.bonusProcessID;
|
||||||
|
item.bonusID = r.bonusID;
|
||||||
|
item.employeeID = r.employeeID;
|
||||||
|
item.basicSalary = r.basicSalary;
|
||||||
|
item.bonusAmount = r.bonusAmount;
|
||||||
|
item.changeBonusAmount = r.changeBonusAmount;
|
||||||
|
item.taxAmount = r.taxAmount;
|
||||||
|
item.changeTaxAmount = r.changeTaxAmount;
|
||||||
|
item.employee = new Employee();
|
||||||
|
item.employee.id = r.employeeID;
|
||||||
|
item.employee.employeeID = r.employeeID;
|
||||||
|
item.employee.employeeNo = r.employeeNo;
|
||||||
|
item.employee.name = r.name;
|
||||||
|
item.employee.joiningDate = r.joiningDate;
|
||||||
|
item.employee.isConfirmed = r.isConfirmed;
|
||||||
|
item.employee.grossSalary = r.grossSalary;
|
||||||
|
item.employee.basicSalary = r.basicSalary;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
public BonusvalueChange(value: any): void {
|
public BonusvalueChange(value: any): void {
|
||||||
this.alreadyProcessesList = [];
|
this.alreadyProcessesList = [];
|
||||||
this.bonusProcess = new BonusProcess();
|
this.bonusProcess = new BonusProcess();
|
||||||
|
|
@ -304,9 +550,7 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.selectedEmps = [];
|
this.selectedEmps = [];
|
||||||
this.processCompleted = false;
|
this.processCompleted = false;
|
||||||
this.pbuttonEnalble = false;
|
this.pbuttonEnalble = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaxRecalculate() {
|
TaxRecalculate() {
|
||||||
this.loadingPanelService.ShowLoadingPanel = true;
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
|
||||||
|
|
@ -329,13 +573,9 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.pbuttonEnalble = false;
|
this.pbuttonEnalble = false;
|
||||||
this.notificationService.showSuccess('Tax Recalculated processed successfully');
|
this.notificationService.showSuccess('Tax Recalculated processed successfully');
|
||||||
this.returnMessage = 'Tax Recalculated processed successfully';
|
this.returnMessage = 'Tax Recalculated processed successfully';
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadBonusFile(event: any): void {
|
uploadBonusFile(event: any): void {
|
||||||
debugger;
|
|
||||||
let tempResponse: any;
|
let tempResponse: any;
|
||||||
this.selectedFiles = event.target.files;
|
this.selectedFiles = event.target.files;
|
||||||
if (this.selectedFiles.length > 0) {
|
if (this.selectedFiles.length > 0) {
|
||||||
|
|
@ -381,41 +621,28 @@ export class BonusProcessComponent implements OnInit {
|
||||||
this.notificationService.showWarning('please select a file');
|
this.notificationService.showWarning('please select a file');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
edit() {
|
edit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll() {
|
clearAll() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
if (this.processCompleted == false) {
|
if (this.processCompleted == false) {
|
||||||
this.notificationService.showWarning('Please process the Bonus first');
|
this.notificationService.showWarning('Please process the Bonus first');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.bonusProcess == undefined || this.bonusProcess?.bonusProcessDetails.length == 0) {
|
if (this.bonusProcess == undefined || this.bonusProcess?.bonusProcessDetails.length == 0) {
|
||||||
this.notificationService.showWarning('There are no data to save');
|
this.notificationService.showWarning('There are no data to save');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isTaxProcess == true && (this.bonusProcess.bonusProcessDetails[0].incomeTaxcoll == undefined
|
if (this.isTaxProcess == true && (this.bonusProcess.bonusProcessDetails[0].incomeTaxcoll == undefined
|
||||||
|| this.bonusProcess.bonusProcessDetails[0].incomeTaxcoll.length == 0)) {
|
|| this.bonusProcess.bonusProcessDetails[0].incomeTaxcoll.length == 0)) {
|
||||||
this.notificationService.showWarning('Tax Calculation not yet done');
|
this.notificationService.showWarning('Tax Calculation not yet done');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isTaxProcess == true) {
|
if (this.isTaxProcess == true) {
|
||||||
var mitem: TaxMergeMaster = undefined;
|
var mitem: TaxMergeMaster = undefined;
|
||||||
this.taxService.getTaxMergeMaster(EnumTaxMergeType.Bonus, this.selectedbonusID).subscribe(
|
this.taxService.getTaxMergeMaster(EnumTaxMergeType.Bonus, this.selectedbonusID).subscribe(
|
||||||
|
|
@ -429,18 +656,14 @@ export class BonusProcessComponent implements OnInit {
|
||||||
() => {
|
() => {
|
||||||
if (mitem != undefined) {
|
if (mitem != undefined) {
|
||||||
console.log(mitem);
|
console.log(mitem);
|
||||||
|
|
||||||
this.bonusProcess.bonusProcessDetails.every(x => {
|
this.bonusProcess.bonusProcessDetails.every(x => {
|
||||||
//console.log(x.incomeTaxcoll);
|
|
||||||
var item = x.incomeTaxcoll.find(y => y.itemGroup == mitem.itemGroup && y.itemID == mitem.itemID);
|
var item = x.incomeTaxcoll.find(y => y.itemGroup == mitem.itemGroup && y.itemID == mitem.itemID);
|
||||||
if (item != undefined) {
|
if (item != undefined) {
|
||||||
item.thisMonthAmount = x.changeBonusAmount;
|
item.thisMonthAmount = x.changeBonusAmount;
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.showWarning('Income tax amount not found in the collection');
|
this.notificationService.showWarning('Income tax amount not found in the collection');
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item = x.incomeTaxcoll.find(y => y.itemGroup == EnumIncomeTaxItemGroup.Tax_Deducted);
|
item = x.incomeTaxcoll.find(y => y.itemGroup == EnumIncomeTaxItemGroup.Tax_Deducted);
|
||||||
if (item != undefined) {
|
if (item != undefined) {
|
||||||
item.thisMonthAmount = x.changeTaxAmount;
|
item.thisMonthAmount = x.changeTaxAmount;
|
||||||
|
|
@ -453,17 +676,116 @@ export class BonusProcessComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.saveData();
|
this.saveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private logSavePayloadSize() {
|
||||||
|
try {
|
||||||
|
const enc = new TextEncoder();
|
||||||
|
const bytes = (v: any): number => { const s = JSON.stringify(v); return s === undefined ? 0 : enc.encode(s).length; };
|
||||||
|
const MB = (b: number) => (b / 1024 / 1024).toFixed(2) + ' MB';
|
||||||
|
const KB = (b: number) => (b / 1024).toFixed(2) + ' KB';
|
||||||
|
const LIMIT = 30000000; // IIS / ASP.NET Core default request body limit (bytes)
|
||||||
|
|
||||||
|
// size of every field over a list of objects (bytes of "key":value, per field), biggest first
|
||||||
|
const fieldTable = (objs: any[], total: number, top = 999) => {
|
||||||
|
const sum: { [k: string]: { b: number, nulls: number, objs: number } } = {};
|
||||||
|
objs.forEach(o => {
|
||||||
|
if (o == null || typeof o !== 'object') return;
|
||||||
|
Object.keys(o).forEach(k => {
|
||||||
|
const v = o[k];
|
||||||
|
const e = sum[k] || (sum[k] = { b: 0, nulls: 0, objs: 0 });
|
||||||
|
if (v === undefined) return;
|
||||||
|
e.b += enc.encode(JSON.stringify(k)).length + 2 + bytes(v);
|
||||||
|
if (v === null) e.nulls++;
|
||||||
|
else if (typeof v === 'object') e.objs++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return Object.keys(sum)
|
||||||
|
.map(k => ({ field: k, size: MB(sum[k].b), percent: (total ? (sum[k].b * 100 / total) : 0).toFixed(1) + '%', nullRows: sum[k].nulls, objectRows: sum[k].objs, _b: sum[k].b }))
|
||||||
|
.sort((a, b) => b._b - a._b)
|
||||||
|
.slice(0, top)
|
||||||
|
.map(({ _b, ...r }) => r);
|
||||||
|
};
|
||||||
|
const stats = (counts: number[]) => {
|
||||||
|
if (counts.length == 0) return { total: 0, min: 0, max: 0, avg: '0' };
|
||||||
|
let total = 0, min = counts[0], max = counts[0];
|
||||||
|
counts.forEach(c => { total += c; if (c < min) min = c; if (c > max) max = c; });
|
||||||
|
return { total, min, max, avg: (total / counts.length).toFixed(1) };
|
||||||
|
};
|
||||||
|
|
||||||
|
const d: any[] = this.bonusProcess?.bonusProcessDetails ?? [];
|
||||||
|
|
||||||
|
// 1. Overview
|
||||||
|
const t0 = performance.now();
|
||||||
|
const totalBytes = bytes(this.bonusProcess);
|
||||||
|
const stringifyMs = Math.round(performance.now() - t0);
|
||||||
|
const header = { ...this.bonusProcess, bonusProcessDetails: undefined };
|
||||||
|
console.log('%c[SAVE SIZE] 1. Overview', 'font-weight:bold');
|
||||||
|
console.table({
|
||||||
|
rows: d.length,
|
||||||
|
totalRequest: MB(totalBytes),
|
||||||
|
serverLimit: MB(LIMIT),
|
||||||
|
overLimitBy: totalBytes > LIMIT ? MB(totalBytes - LIMIT) + ' (' + (totalBytes / LIMIT).toFixed(1) + 'x the limit)' : 'within the limit',
|
||||||
|
header_withoutDetails: KB(bytes(header)),
|
||||||
|
averagePerRow: d.length ? KB(totalBytes / d.length) : '0',
|
||||||
|
jsonStringifyTime: stringifyMs + ' ms',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Every field of a BonusProcessDetail (employee / bonus / incomeTaxcoll are fields too)
|
||||||
|
console.log('%c[SAVE SIZE] 2. Fields of each detail row (all rows together)', 'font-weight:bold');
|
||||||
|
console.table(fieldTable(d, totalBytes));
|
||||||
|
|
||||||
|
// 3. employee
|
||||||
|
const emps = d.map(x => x.employee).filter(x => x != null);
|
||||||
|
const empBytes = bytes(emps);
|
||||||
|
console.log('%c[SAVE SIZE] 3. employee — ' + MB(empBytes) + ', ' + emps.length + ' objects, ' + new Set(emps).size + ' distinct; top 25 fields', 'font-weight:bold');
|
||||||
|
console.table(fieldTable(emps, empBytes, 25));
|
||||||
|
|
||||||
|
// 4. bonus
|
||||||
|
const bonuses = d.map(x => x.bonus).filter(x => x != null);
|
||||||
|
const bonusBytes = bytes(bonuses);
|
||||||
|
console.log('%c[SAVE SIZE] 4. bonus — ' + MB(bonusBytes) + ', ' + bonuses.length + ' objects, ' + new Set(bonuses).size
|
||||||
|
+ ' distinct (' + new Set(bonuses.map(b => b?.id)).size + ' distinct ids); one copy = ' + KB(bytes(bonuses[0])), 'font-weight:bold');
|
||||||
|
if (bonuses.length) console.table(fieldTable(bonuses, bonusBytes, 25));
|
||||||
|
|
||||||
|
// 5. incomeTaxcoll
|
||||||
|
const taxCounts = d.map(x => (x.incomeTaxcoll ?? []).length);
|
||||||
|
const taxItems = ([] as any[]).concat(...d.map(x => x.incomeTaxcoll ?? []));
|
||||||
|
const taxBytes = bytes(taxItems);
|
||||||
|
console.log('%c[SAVE SIZE] 5. incomeTaxcoll — ' + MB(taxBytes) + '; items per row:', 'font-weight:bold', stats(taxCounts),
|
||||||
|
'; rows with no items:', taxCounts.filter(c => c == 0).length, '; one item ≈', taxItems.length ? (taxBytes / taxItems.length).toFixed(0) + ' bytes' : '-');
|
||||||
|
if (taxItems.length) console.table(fieldTable(taxItems, taxBytes));
|
||||||
|
|
||||||
|
// 6. bonusEmpCostCenters
|
||||||
|
const ccCounts = d.map(x => (x.bonusEmpCostCenters ?? []).length);
|
||||||
|
const ccItems = ([] as any[]).concat(...d.map(x => x.bonusEmpCostCenters ?? []));
|
||||||
|
console.log('%c[SAVE SIZE] 6. bonusEmpCostCenters — ' + MB(bytes(ccItems)) + '; items per row:', 'font-weight:bold', stats(ccCounts));
|
||||||
|
|
||||||
|
// 7. What the server actually saves: BonusProcessDA.Insert (detail) + IncomeTaxService.SaveBulk (tax)
|
||||||
|
const pick = (o: any, keys: string[]) => { const r: any = {}; keys.forEach(k => { if (o?.[k] !== undefined) r[k] = o[k]; }); return r; };
|
||||||
|
const detailKeys = ['employeeID', 'bonusID', 'bonusMonth', 'bonusAmount', 'grossSalary', 'basicSalary', 'changeBonusAmount', 'changeTaxAmount',
|
||||||
|
'changeAdjustAmount', 'changeSalaryItemAmount', 'calculatedAdjustAmount', 'calculatedSalaryItemAmount', 'taxAmount'];
|
||||||
|
const taxKeys = ['employeeID', 'itemGroup', 'itemID', 'description', 'totalAmount', 'previousAmount', 'thisMonthAmount', 'projectedAmount',
|
||||||
|
'side', 'position', 'isChanged', 'taxParameterID'];
|
||||||
|
const minimal = {
|
||||||
|
...header,
|
||||||
|
bonusProcessDetails: d.map(x => ({ ...pick(x, detailKeys), incomeTaxcoll: (x.incomeTaxcoll ?? []).map((t: any) => pick(t, taxKeys)) })),
|
||||||
|
};
|
||||||
|
const minimalBytes = bytes(minimal);
|
||||||
|
console.log('%c[SAVE SIZE] 7. Only the fields the server saves', 'font-weight:bold');
|
||||||
|
console.table({
|
||||||
|
minimalRequest: MB(minimalBytes),
|
||||||
|
ofWhichTax: MB(bytes(minimal.bonusProcessDetails.map(x => x.incomeTaxcoll))),
|
||||||
|
smallerBy: minimalBytes ? (totalBytes / minimalBytes).toFixed(1) + 'x' : '-',
|
||||||
|
fitsInLimit: minimalBytes <= LIMIT ? 'yes' : 'NO',
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log('[SAVE SIZE] could not measure:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
saveData() {
|
saveData() {
|
||||||
debugger;
|
|
||||||
this.loadingPanelService.ShowLoadingPanel = true;
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
this.bonusProcess.disburseDate = this.payDate;
|
this.bonusProcess.disburseDate = this.payDate;
|
||||||
this.bonusProcess.isTaxProcess = this.isTaxProcess;
|
this.bonusProcess.isTaxProcess = this.isTaxProcess;
|
||||||
|
|
@ -488,8 +810,52 @@ export class BonusProcessComponent implements OnInit {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTax() {
|
clearTax() {
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', "Are you sure you want to clear the tax?").then((isConfirmed) => {
|
||||||
|
if (isConfirmed)
|
||||||
|
{
|
||||||
|
this.clearTaxConfirmed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
clearTaxAndSave() {
|
||||||
|
const bonusProcessID = this.bonusProcess?.id;
|
||||||
|
if (bonusProcessID == undefined || bonusProcessID <= 0
|
||||||
|
|| !(this.bonusProcess.bonusProcessDetails ?? []).some(x => x.bonusProcessDetailID)) {
|
||||||
|
this.notificationService.showWarning('Please process the bonus first, then clear the tax.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', "Are you sure you want to clear the tax?").then((isConfirmed) => {
|
||||||
|
if (isConfirmed)
|
||||||
|
{
|
||||||
|
this.clearTaxAndSaveConfirmed(bonusProcessID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private clearTaxAndSaveConfirmed(bonusProcessID: number) {
|
||||||
|
var rows: BonusProcessGridRow[];
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.bonusService.clearTaxAndSave(bonusProcessID).subscribe(
|
||||||
|
(resp: BonusProcessGridRow[]) => {
|
||||||
|
rows = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
const message = this.errorText(err, 'Clear tax failed. Please check the connection and try again.');
|
||||||
|
this.notificationService.showWarning(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
// the saved rows, read back from the database (new array, so the virtual grid re-reads it)
|
||||||
|
this.bonusProcess.bonusProcessDetails = (rows ?? []).map(r => this.toGridDetail(r));
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
const message = 'Tax cleared and saved successfully';
|
||||||
|
this.notificationService.showSuccess(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// the old Clear Tax body, run only after the user confirmed
|
||||||
|
private clearTaxConfirmed() {
|
||||||
|
|
||||||
this.loadingPanelService.ShowLoadingPanel = true;
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
|
||||||
|
|
@ -498,28 +864,72 @@ export class BonusProcessComponent implements OnInit {
|
||||||
});
|
});
|
||||||
this.loadingPanelService.ShowLoadingPanel = false;
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
undo() {
|
undo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadData() {
|
uploadData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removefromList(rowIndex: number) {
|
removefromList(rowIndex: number) {
|
||||||
this.bonusProcess.bonusProcessDetails.splice(rowIndex, 1);
|
this.bonusProcess.bonusProcessDetails.splice(rowIndex, 1);
|
||||||
|
// new array reference so the (virtual) grid re-reads it
|
||||||
|
this.bonusProcess.bonusProcessDetails = [...this.bonusProcess.bonusProcessDetails];
|
||||||
}
|
}
|
||||||
|
// ---- Remove button: a row not saved yet is only taken off the grid (removefromList, as before); a saved
|
||||||
|
// row (after Process / Upload) is deleted from the database at once (api/Bonus/removeRow). ----
|
||||||
|
removeRow(dataItem: BonusProcessDetail, rowIndex: number) {
|
||||||
|
if (!dataItem?.bonusProcessDetailID) {
|
||||||
|
this.removefromList(rowIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const who = (dataItem.employee?.employeeNo ? dataItem.employee.employeeNo + ' - ' : '') + (dataItem.employee?.name ?? '');
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation',
|
||||||
|
'Are you sure you want to remove ' + who + '? The saved bonus of this employee will be deleted.').then((isConfirmed) => {
|
||||||
|
if (isConfirmed)
|
||||||
|
{
|
||||||
|
this.removeRowConfirmed(dataItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private removeRowConfirmed(dataItem: BonusProcessDetail) {
|
||||||
|
var result: BonusProcessRowRemoveResult;
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = true;
|
||||||
|
this.bonusService.removeRow(dataItem.bonusProcessDetailID).subscribe(
|
||||||
|
(resp: BonusProcessRowRemoveResult) => {
|
||||||
|
result = resp;
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
const message = this.errorText(err, 'Remove failed. Please check the connection and try again.');
|
||||||
|
this.notificationService.showWarning(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
// take that row off the grid (new array, so the virtual grid re-reads it)
|
||||||
|
this.bonusProcess.bonusProcessDetails = this.bonusProcess.bonusProcessDetails
|
||||||
|
.filter(x => x.bonusProcessDetailID !== dataItem.bonusProcessDetailID);
|
||||||
|
// the already-processed list changed: read it again on the next employee selection
|
||||||
|
this.bonusProcessDetails = undefined;
|
||||||
|
let message = 'Employee removed successfully';
|
||||||
|
if (result?.processDeleted) {
|
||||||
|
// that was the last employee: the bonus process itself is gone
|
||||||
|
this.bonusProcess.id = undefined;
|
||||||
|
message = 'Last employee removed, so the bonus process was deleted too';
|
||||||
|
}
|
||||||
|
this.loadingPanelService.ShowLoadingPanel = false;
|
||||||
|
this.notificationService.showSuccess(message);
|
||||||
|
this.returnMessage = message;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Excel export: every row, not only the rows the virtual grid has on screen
|
||||||
|
public allBonusRows = (): any => {
|
||||||
|
const rows = this.bonusProcess?.bonusProcessDetails ?? [];
|
||||||
|
return { data: rows, total: rows.length };
|
||||||
|
};
|
||||||
removeHandler({dataItem}) {
|
removeHandler({dataItem}) {
|
||||||
console.log(dataItem);
|
console.log(dataItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
editHandler({dataItem}) {
|
editHandler({dataItem}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addHandler() {
|
addHandler() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,186 @@ kendo-numerictextbox{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkBoxGrid.grid {
|
/* .checkBoxGrid.grid {
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
|
} */
|
||||||
|
|
||||||
|
/* ---- Layout only (alignment / spacing); no behaviour depends on these classes ---- */
|
||||||
|
.adp-card {
|
||||||
|
padding: 14px 16px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-section-title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #495057;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-required {
|
||||||
|
color: #dc3545;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* label + control on one line, labels the same width so the controls line up */
|
||||||
|
.adp-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-label {
|
||||||
|
flex: 0 0 110px;
|
||||||
|
margin: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-control {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* every input on the page the same height, so the rows line up */
|
||||||
|
.adp-page kendo-dropdownlist,
|
||||||
|
.adp-page kendo-numerictextbox,
|
||||||
|
.adp-page kendo-datepicker {
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-page kendo-dropdownlist.form-control {
|
||||||
|
padding: 0;
|
||||||
|
font-size: inherit;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the four check boxes in two even columns, starting under the inputs (label width + gap) */
|
||||||
|
.adp-checks {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 8px 12px;
|
||||||
|
margin: 4px 0 0 120px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #fafbfc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-check {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
margin: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-check .k-checkbox-label {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the tab panels on this page are empty (only the headers are used), so drop their padding */
|
||||||
|
:host ::ng-deep .adp-card .tab-view-compat-panels {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-detail-text {
|
||||||
|
margin: 12px 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* employee entry: label above each control, all on one row */
|
||||||
|
.adp-entry-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 12px 16px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-entry-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
flex: 0 1 200px;
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-entry-emp {
|
||||||
|
flex-basis: 140px;
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the picker (icon + count) sits in a 32px box like the inputs */
|
||||||
|
.adp-entry-emp app-employee-picker {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the picker sizes its search button and count as 15% of its box; on this page give them a fixed size
|
||||||
|
(this page only — the picker component itself is unchanged) */
|
||||||
|
/* direct path only, so the buttons inside the picker's pop-up dialog are not touched */
|
||||||
|
:host ::ng-deep .adp-entry-emp app-employee-picker > div > div > div > button {
|
||||||
|
width: 32px !important;
|
||||||
|
max-width: none !important;
|
||||||
|
height: 32px;
|
||||||
|
flex: 0 0 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep .adp-entry-emp app-employee-picker > div > div > div > label {
|
||||||
|
width: auto !important;
|
||||||
|
max-width: none !important;
|
||||||
|
margin: 0 0 0 8px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep .adp-entry-emp app-employee-picker > div > div > div {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* every label the same height (the To Date one has a check box), so all inputs start on one line */
|
||||||
|
.adp-entry-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
height: 22px;
|
||||||
|
margin: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-entry-label .k-checkbox-label {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sum on the left, buttons on the right */
|
||||||
|
.adp-action-bar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 0;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
border-top: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* virtual scrolling needs every row the same height ([rowHeight]="40"): 32px inputs + 4px padding */
|
||||||
|
:host ::ng-deep .adp-emp-grid .k-grid-content td {
|
||||||
|
height: 40px;
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-sum {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adp-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 400px) {
|
@media screen and (max-width: 400px) {
|
||||||
|
|
@ -17,4 +195,11 @@ kendo-numerictextbox{
|
||||||
flex-flow: column wrap;
|
flex-flow: column wrap;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
.adp-checks {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
.adp-entry-item {
|
||||||
|
flex: 1 1 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
<app-loading-panel></app-loading-panel>
|
<app-loading-panel></app-loading-panel>
|
||||||
<form [formGroup]="_fromValidator">
|
<form [formGroup]="_fromValidator" class="adp-page">
|
||||||
<div class="card" style="padding: 1%">
|
<!-- Setup: layout only was tidied; every control, binding and event is the same as before. -->
|
||||||
|
<div class="card adp-card">
|
||||||
<div class="topGrid grid">
|
<div class="topGrid grid">
|
||||||
<div class="col-5">
|
<!-- General -->
|
||||||
<div class="grid">
|
<div class="col-12 lg:col-5 adp-section">
|
||||||
<div class="col-4" style="margin: auto;">
|
<div class="adp-section-title">General</div>
|
||||||
<label class="form-control-label" for="ddlAllowance">Allowance *</label>
|
<div class="adp-field">
|
||||||
</div>
|
<label class="adp-label form-control-label" for="ddlAllowance">Allowance <span class="adp-required">*</span></label>
|
||||||
<div class="col-8">
|
<div class="adp-control">
|
||||||
<kendo-dropdownlist
|
<kendo-dropdownlist
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
class="form-control form-control-sm input-sm"
|
class="form-control form-control-sm input-sm"
|
||||||
|
|
@ -30,11 +31,9 @@
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="ddlPeriodicity">Periodicity <span class="adp-required">*</span></label>
|
||||||
<label for="ddlPeriodicity">Periodicity *</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-dropdownlist
|
<kendo-dropdownlist
|
||||||
class="form-control form-control-sm input-sm"
|
class="form-control form-control-sm input-sm"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
|
@ -54,11 +53,9 @@
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="ddlGender">Gender</label>
|
||||||
<label for="ddlGender">Gender</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-dropdownlist
|
<kendo-dropdownlist
|
||||||
class="form-control form-control-sm input-sm"
|
class="form-control form-control-sm input-sm"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
|
@ -76,9 +73,8 @@
|
||||||
</kendo-dropdownlist>
|
</kendo-dropdownlist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="checkBoxGrid" class="grid" style="margin-top: 0px;">
|
<div class="checkBoxGrid adp-checks">
|
||||||
<div class="col-6" style="margin: auto;">
|
<label class="k-form-field right adp-check">
|
||||||
<label class="k-form-field right">
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
formControlName="isForConfirmOnly"
|
formControlName="isForConfirmOnly"
|
||||||
|
|
@ -87,9 +83,7 @@
|
||||||
kendoCheckBox/>
|
kendoCheckBox/>
|
||||||
<label class="k-checkbox-label" for="enableConfirmCheck">Confirmation Required</label>
|
<label class="k-checkbox-label" for="enableConfirmCheck">Confirmation Required</label>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
<label class="k-form-field right adp-check">
|
||||||
<div class="col-6" style="margin: auto;">
|
|
||||||
<label class="k-form-field right">
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
formControlName="isDependsOnAttendance"
|
formControlName="isDependsOnAttendance"
|
||||||
|
|
@ -98,9 +92,7 @@
|
||||||
kendoCheckBox/>
|
kendoCheckBox/>
|
||||||
<label class="k-checkbox-label" for="enableDepandentCheck">Is Dependence on Attendance</label>
|
<label class="k-checkbox-label" for="enableDepandentCheck">Is Dependence on Attendance</label>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
<label class="k-form-field right adp-check">
|
||||||
<div class="col-6" style="margin: auto;">
|
|
||||||
<label class="k-form-field right">
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
formControlName="isFractionateApplicable"
|
formControlName="isFractionateApplicable"
|
||||||
|
|
@ -109,9 +101,7 @@
|
||||||
kendoCheckBox/>
|
kendoCheckBox/>
|
||||||
<label class="k-checkbox-label" for="enableFractionateCheck">Is fractionate Available</label>
|
<label class="k-checkbox-label" for="enableFractionateCheck">Is fractionate Available</label>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
<label class="k-form-field right adp-check">
|
||||||
<div class="col-6" style="margin: auto;">
|
|
||||||
<label class="k-form-field right">
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
formControlName="isTaxable"
|
formControlName="isTaxable"
|
||||||
|
|
@ -122,13 +112,13 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col-3">
|
<!-- Amount -->
|
||||||
<div class="grid">
|
<div class="col-12 md:col-6 lg:col-3 adp-section">
|
||||||
<div class="col-4" style="margin: auto;">
|
<div class="adp-section-title">Amount</div>
|
||||||
<label for="txtFlatAmount">Flat Amount</label>
|
<div class="adp-field">
|
||||||
</div>
|
<label class="adp-label" for="txtFlatAmount">Flat Amount</label>
|
||||||
<div class="col-8">
|
<div class="adp-control">
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-10000000"
|
[min]="-10000000"
|
||||||
[max]="10000000"
|
[max]="10000000"
|
||||||
|
|
@ -138,11 +128,9 @@
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="txtBasic">% of Basic</label>
|
||||||
<label for="txtBasic">% of Basic</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-1000"
|
[min]="-1000"
|
||||||
[max]="1000"
|
[max]="1000"
|
||||||
|
|
@ -152,11 +140,9 @@
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="txtGross">% of Gross</label>
|
||||||
<label for="txtGross">% of Gross</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-1000"
|
[min]="-1000"
|
||||||
[max]="1000"
|
[max]="1000"
|
||||||
|
|
@ -166,11 +152,9 @@
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="txtMininmum">Mininmum</label>
|
||||||
<label for="txtMininmum" style="margin: auto;">Mininmum</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-10000000"
|
[min]="-10000000"
|
||||||
[max]="10000000"
|
[max]="10000000"
|
||||||
|
|
@ -180,11 +164,9 @@
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
<div class="adp-field">
|
||||||
<div class="col-4" style="margin: auto;">
|
<label class="adp-label" for="txtMaximum">Maximum</label>
|
||||||
<label for="txtMaximum" style="margin: auto;">Maximum</label>
|
<div class="adp-control">
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-10000000"
|
[min]="-10000000"
|
||||||
[max]="10000000"
|
[max]="10000000"
|
||||||
|
|
@ -195,10 +177,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
|
||||||
|
<!-- Grades -->
|
||||||
|
<div class="col-12 md:col-6 lg:col-4 adp-section">
|
||||||
|
<div class="adp-section-title">Grade <span class="adp-required">*</span></div>
|
||||||
<kendo-grid
|
<kendo-grid
|
||||||
[data]="_grades"
|
[data]="_grades"
|
||||||
height="180"
|
height="220"
|
||||||
[(selectedKeys)]="_selectedgrades"
|
[(selectedKeys)]="_selectedgrades"
|
||||||
[kendoGridSelectBy]="'id'"
|
[kendoGridSelectBy]="'id'"
|
||||||
>
|
>
|
||||||
|
|
@ -355,9 +340,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="card" style="padding: 1%">
|
|
||||||
<div class="grid">
|
<!-- Employees -->
|
||||||
<div class="col-12">
|
<div class="card adp-card">
|
||||||
<app-tab-view (onChange)="IndividualChecked($event)">
|
<app-tab-view (onChange)="IndividualChecked($event)">
|
||||||
@if (_selectedPeriodicity == 1) {
|
@if (_selectedPeriodicity == 1) {
|
||||||
<app-tab-panel
|
<app-tab-panel
|
||||||
|
|
@ -387,35 +372,24 @@
|
||||||
</app-tab-panel>
|
</app-tab-panel>
|
||||||
}
|
}
|
||||||
</app-tab-view>
|
</app-tab-view>
|
||||||
<div class="grid">
|
|
||||||
<div class="col-12">
|
<div class="adp-detail-text">
|
||||||
<b> {{ _detailLevelText }}</b>
|
<b> {{ _detailLevelText }}</b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid" style="margin-top: 5px;">
|
<div class="adp-entry-row">
|
||||||
<div class="col-2">
|
<div class="adp-entry-item adp-entry-emp">
|
||||||
<div class="grid">
|
<label class="adp-entry-label" for="txtEmp">Select Emp</label>
|
||||||
<div class="col-5" style="margin: auto;">
|
|
||||||
<label for="txtEmp"> Select Emp</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-7" align="left">
|
|
||||||
<app-employee-picker [MultiSelect]="true"
|
<app-employee-picker [MultiSelect]="true"
|
||||||
[fixedGrades]="_selectedgrades"
|
[fixedGrades]="_selectedgrades"
|
||||||
(ItemSelected)="GetSelectedEmployee($event)"
|
(ItemSelected)="GetSelectedEmployee($event)"
|
||||||
style="width: 80%;"></app-employee-picker>
|
></app-employee-picker>
|
||||||
<!-- <app-employee-picker for="chkIsnew" id="idself" [isActive]="!newEmployee" [setSelectedEmp]="selectedEmployee"
|
<!-- <app-employee-picker for="chkIsnew" id="idself" [isActive]="!newEmployee" [setSelectedEmp]="selectedEmployee"
|
||||||
(ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker> -->
|
(ItemSelected)="GetSelectedEmployee($event)"></app-employee-picker> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (!_ischecknotapplicable) {
|
@if (!_ischecknotapplicable) {
|
||||||
<div class="col-10">
|
<div class="adp-entry-item">
|
||||||
<div class="grid">
|
<label class="adp-entry-label" for="txtEmp">Amount</label>
|
||||||
<div class="col-1" style="margin: auto;" align="right">
|
|
||||||
<label for="txtEmp">Amount</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-3">
|
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox
|
||||||
[min]="-10000000"
|
[min]="-10000000"
|
||||||
[max]="10000000"
|
[max]="10000000"
|
||||||
|
|
@ -425,10 +399,8 @@
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</div>
|
</div>
|
||||||
@if (!_ischeckException) {
|
@if (!_ischeckException) {
|
||||||
<div class="col-1" style="margin: auto;" align="right">
|
<div class="adp-entry-item">
|
||||||
<label for="dtpFromDate">From Date</label>
|
<label class="adp-entry-label" for="dtpFromDate">From Date</label>
|
||||||
</div>
|
|
||||||
<div class="col-3">
|
|
||||||
<kendo-datepicker
|
<kendo-datepicker
|
||||||
id="dtpFromDate"
|
id="dtpFromDate"
|
||||||
[format]="'dd-MMM-yyyy'"
|
[format]="'dd-MMM-yyyy'"
|
||||||
|
|
@ -438,8 +410,8 @@
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
></kendo-datepicker>
|
></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1" style="margin: auto;" align="right">
|
<div class="adp-entry-item">
|
||||||
<label class="k-form-field right">
|
<label class="k-form-field right adp-entry-label">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
[(ngModel)]="_checkedToDate"
|
[(ngModel)]="_checkedToDate"
|
||||||
|
|
@ -453,8 +425,6 @@
|
||||||
To Date
|
To Date
|
||||||
</label>
|
</label>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
<div class="col-3">
|
|
||||||
<kendo-datepicker
|
<kendo-datepicker
|
||||||
id="dtpToDate"
|
id="dtpToDate"
|
||||||
[format]="'dd-MMM-yyyy'"
|
[format]="'dd-MMM-yyyy'"
|
||||||
|
|
@ -468,31 +438,37 @@
|
||||||
></kendo-datepicker>
|
></kendo-datepicker>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid">
|
|
||||||
<div class="col-2" style="font-weight: bold;">
|
<div class="adp-action-bar">
|
||||||
|
<div class="adp-sum">
|
||||||
Sum: {{get2FloatingPoint(sumofIndividualAmount())}}
|
Sum: {{get2FloatingPoint(sumofIndividualAmount())}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-10" align="right">
|
<div class="adp-actions">
|
||||||
<button kendoButton
|
<button kendoButton
|
||||||
[svgIcon]="apiService.KendoSVGIcon['plus']"
|
[svgIcon]="apiService.KendoSVGIcon['plus']"
|
||||||
class="k-button k-primary"
|
class="k-button k-primary"
|
||||||
(click)="AddEmployee()">
|
(click)="AddEmployee()">
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
<button kendoButton style="margin-left:3px" [svgIcon]="apiService.KendoSVGIcon['delete']" class="kt-delete" (click)="RemoveAll()">Remove All</button>
|
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['delete']" class="kt-delete" (click)="RemoveAll()">Remove All</button>
|
||||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" themeColor="primary" style="margin-left:3px" (click)="Save()" >Save</button>
|
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" themeColor="primary" (click)="Save()" >Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
<!-- <kendo-grid [data]="_individualEmplyees"
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid">
|
|
||||||
<div class="col-12">
|
|
||||||
<kendo-grid [data]="_individualEmplyees"
|
|
||||||
height="300"
|
height="300"
|
||||||
|
(remove)="removeHandler($event)"> -->
|
||||||
|
<!-- virtual scrolling: only the rows on screen are built (empGridView = a window of _individualEmplyees) -->
|
||||||
|
<kendo-grid [data]="empGridView"
|
||||||
|
class="adp-emp-grid"
|
||||||
|
[height]="360"
|
||||||
|
scrollable="virtual"
|
||||||
|
[rowHeight]="40"
|
||||||
|
[skip]="empGridSkip"
|
||||||
|
[pageSize]="empGridPageSize"
|
||||||
|
(pageChange)="onEmpGridPageChange($event)"
|
||||||
(remove)="removeHandler($event)">
|
(remove)="removeHandler($event)">
|
||||||
<kendo-grid-column field="employeeNo" title="Emp ID">
|
<kendo-grid-column field="employeeNo" title="Emp ID">
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
|
|
@ -538,7 +514,7 @@
|
||||||
{{ statusString(dataItem.approvalStatus)}}
|
{{ statusString(dataItem.approvalStatus)}}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</kendo-grid-column>
|
</kendo-grid-column>
|
||||||
<kendo-grid-command-column title="Action" width="220">
|
<kendo-grid-command-column title="Action" width="120">
|
||||||
<ng-template kendoGridCellTemplate
|
<ng-template kendoGridCellTemplate
|
||||||
let-dataItem
|
let-dataItem
|
||||||
let-rowIndex="rowIndex">
|
let-rowIndex="rowIndex">
|
||||||
|
|
@ -547,11 +523,4 @@
|
||||||
</kendo-grid-command-column>
|
</kendo-grid-command-column>
|
||||||
</kendo-grid>
|
</kendo-grid>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid">
|
|
||||||
<div class="col-12" align="right">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ChangeDetectionStrategy, DoCheck} from '@angular/core';
|
||||||
|
import { GridDataResult, PageChangeEvent } from '@progress/kendo-angular-grid';
|
||||||
import {FormGroup, FormControl, FormBuilder, Validators} from '@angular/forms';
|
import {FormGroup, FormControl, FormBuilder, Validators} from '@angular/forms';
|
||||||
import {SearchEmployee} from '../../../../_models/Employee/searchEmployee';
|
import {SearchEmployee} from '../../../../_models/Employee/searchEmployee';
|
||||||
import {AdparameterService} from '../../../../_services/payroll/adparameter.service';
|
import {AdparameterService} from '../../../../_services/payroll/adparameter.service';
|
||||||
|
|
@ -34,7 +35,7 @@ import { EmployeePickerComponent } from 'src/app/picker/employee-picker.componen
|
||||||
standalone: false,
|
standalone: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AllowanceDeductionParameterizationEntryComponent implements OnInit {
|
export class AllowanceDeductionParameterizationEntryComponent implements OnInit, DoCheck {
|
||||||
_adPram: ADParameter;
|
_adPram: ADParameter;
|
||||||
_allowDeducts: AllowanceDeduction[];
|
_allowDeducts: AllowanceDeduction[];
|
||||||
_grades: Grade[];
|
_grades: Grade[];
|
||||||
|
|
@ -262,10 +263,16 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveAll() {
|
RemoveAll() {
|
||||||
if (!confirm("Are you sure to delete all employees allowance entry")) {
|
// if (!confirm("Are you sure to delete all employees allowance entry")) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
// this._individualEmplyees.splice(0, this._individualEmplyees.length);
|
||||||
|
this.notificationService.showActiveConfirm('Confirmation', "Are you sure to delete all employees allowance entry?").then((isConfirmed) => {
|
||||||
|
if (isConfirmed)
|
||||||
|
{
|
||||||
this._individualEmplyees.splice(0, this._individualEmplyees.length);
|
this._individualEmplyees.splice(0, this._individualEmplyees.length);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
AddEmployee() {
|
AddEmployee() {
|
||||||
|
|
@ -277,7 +284,6 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
this.notificationService.showWarning("Please enter an Amount");
|
this.notificationService.showWarning("Please enter an Amount");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._selectedEmps == undefined) return;
|
if (this._selectedEmps == undefined) return;
|
||||||
this._selectedEmps.forEach(x => {
|
this._selectedEmps.forEach(x => {
|
||||||
let newItem: ADParameterEmployee = this._individualEmplyees.find(e => e.employeeID == x.employeeID);
|
let newItem: ADParameterEmployee = this._individualEmplyees.find(e => e.employeeID == x.employeeID);
|
||||||
|
|
@ -301,19 +307,14 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
newItem.tillDate = this._individualToDate;
|
newItem.tillDate = this._individualToDate;
|
||||||
newItem.monthlyAmount = this._individualAmount;
|
newItem.monthlyAmount = this._individualAmount;
|
||||||
newItem.adEmpType = this._adEmpType;
|
newItem.adEmpType = this._adEmpType;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public GetSelectedEmployee(searchEmp: SearchEmployee[]) {
|
public GetSelectedEmployee(searchEmp: SearchEmployee[]) {
|
||||||
|
|
||||||
if (searchEmp != null) {
|
if (searchEmp != null) {
|
||||||
this._selectedEmps = [];
|
this._selectedEmps = [];
|
||||||
searchEmp.forEach(x => {
|
searchEmp.forEach(x => { this._selectedEmps.push(x); });
|
||||||
this._selectedEmps.push(x);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepareGradeData(usedGrades: ADParameterGrade[]) {
|
PrepareGradeData(usedGrades: ADParameterGrade[]) {
|
||||||
|
|
@ -363,7 +364,6 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
public Save() {
|
public Save() {
|
||||||
debugger;
|
|
||||||
if (this._fromValidator.invalid) {
|
if (this._fromValidator.invalid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -389,7 +389,6 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
}
|
}
|
||||||
if (this._adPram.adParameterEmployees.length > 0) {
|
if (this._adPram.adParameterEmployees.length > 0) {
|
||||||
this._adPram.adParameterEmployees.forEach(x => {
|
this._adPram.adParameterEmployees.forEach(x => {
|
||||||
debugger;
|
|
||||||
let adParamEmpItem: ADParameterEmployee = this.prADParameterEmployees.find(y => y.id === x.id);
|
let adParamEmpItem: ADParameterEmployee = this.prADParameterEmployees.find(y => y.id === x.id);
|
||||||
let oPayrollType: PayrollType = new PayrollType();
|
let oPayrollType: PayrollType = new PayrollType();
|
||||||
if (adParamEmpItem) {
|
if (adParamEmpItem) {
|
||||||
|
|
@ -402,8 +401,6 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
x.oldTillDate = adParamEmpItem.tillDate;
|
x.oldTillDate = adParamEmpItem.tillDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
debugger;
|
debugger;
|
||||||
|
|
@ -451,6 +448,49 @@ export class AllowanceDeductionParameterizationEntryComponent implements OnInit
|
||||||
return parseFloat((value).toFixed(2));
|
return parseFloat((value).toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#region Employee grid: virtual scrolling (display only)
|
||||||
|
// The employee grid shows only the rows on screen (a window of empGridPageSize rows), so 12k-20k
|
||||||
|
// employees load at once. _individualEmplyees stays the one full list that every existing function
|
||||||
|
// (Add, Remove, Remove All, Sum, Save, tabs) works on; each window holds the same row objects, so an
|
||||||
|
// amount or date typed in the grid lands in that list exactly as before.
|
||||||
|
empGridView: GridDataResult = { data: [], total: 0 };
|
||||||
|
empGridSkip = 0;
|
||||||
|
empGridPageSize = 50;
|
||||||
|
private empGridSource: ADParameterEmployee[];
|
||||||
|
private empGridLength = -1;
|
||||||
|
|
||||||
|
/** Rebuilds the window when the list is replaced (tab change, load) or grows / shrinks (Add, Remove, Remove All). */
|
||||||
|
ngDoCheck(): void {
|
||||||
|
const list = this._individualEmplyees;
|
||||||
|
const length = list ? list.length : 0;
|
||||||
|
if (list !== this.empGridSource || length !== this.empGridLength) {
|
||||||
|
if (list !== this.empGridSource) {
|
||||||
|
this.empGridSkip = 0; // another list (tab): start from the top
|
||||||
|
}
|
||||||
|
this.empGridSource = list;
|
||||||
|
this.empGridLength = length;
|
||||||
|
this.loadEmpGridView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The grid scrolled: show the rows of the new window. */
|
||||||
|
onEmpGridPageChange(event: PageChangeEvent): void {
|
||||||
|
this.empGridSkip = event.skip;
|
||||||
|
this.loadEmpGridView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadEmpGridView(): void {
|
||||||
|
const list = this._individualEmplyees || [];
|
||||||
|
if (this.empGridSkip >= list.length) { // rows were removed below the current window
|
||||||
|
this.empGridSkip = Math.max(0, list.length - this.empGridPageSize);
|
||||||
|
}
|
||||||
|
this.empGridView = {
|
||||||
|
data: list.slice(this.empGridSkip, this.empGridSkip + this.empGridPageSize),
|
||||||
|
total: list.length
|
||||||
|
};
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<kendo-grid [data]="gridView" (pageChange)="onDataChange($event)" [pageSize]="pageSize"
|
<kendo-grid [data]="gridView" (pageChange)="onDataChange($event)" [pageSize]="pageSize"
|
||||||
[pageable]="true" scrollable="virtual" [skip]="skip" [rowHeight]="36"
|
[pageable]="false" scrollable="virtual" [skip]="skip" [rowHeight]="36"
|
||||||
[(selectedKeys)]="selectedItems" [state]="selectAllState" [style.height.px]="gridHeight"
|
[(selectedKeys)]="selectedItems" [state]="selectAllState" [style.height.px]="gridHeight"
|
||||||
(selectedKeysChange)="onSelectedKeysChange($event)" [selectable]="selectableSettings"
|
(selectedKeysChange)="onSelectedKeysChange($event)" [selectable]="selectableSettings"
|
||||||
[kendoGridSelectBy]="'employeeID'">
|
[kendoGridSelectBy]="'employeeID'">
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ export class DiscontinueEmployeeDetailsComponent implements OnInit {
|
||||||
this.notificationService.showWarning('From Date cannot be after To Date.', 'Warning');
|
this.notificationService.showWarning('From Date cannot be after To Date.', 'Warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
debugger;
|
// debugger;
|
||||||
this.grid.load({ fromDate: this.fromDate, toDate: this.toDate });
|
this.grid.load({ fromDate: this.fromDate, toDate: this.toDate });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"version": "20261108-01",
|
"version": "20261115-03",
|
||||||
"buildTime": "2026-11-08T05:31:24.9714459Z"
|
"buildTime": "2026-11-15T08:30:42.0805569Z"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ namespace HRM.UI.Configuration.DI
|
||||||
services.AddTransient<IUserService, UserService>();
|
services.AddTransient<IUserService, UserService>();
|
||||||
services.AddTransient<IUserLogInInfoService, UserLogInInfoService>();
|
services.AddTransient<IUserLogInInfoService, UserLogInInfoService>();
|
||||||
services.AddTransient<IBadLoginAttemptInfoService, BadLoginAttemptInfoService>();
|
services.AddTransient<IBadLoginAttemptInfoService, BadLoginAttemptInfoService>();
|
||||||
|
services.AddTransient<ISystemAuditHistoryService, SystemAuditHistoryService>();
|
||||||
services.AddTransient<IPasswordHistoryService, PasswordHistoryService>();
|
services.AddTransient<IPasswordHistoryService, PasswordHistoryService>();
|
||||||
services.AddTransient<ISearchEmployeeService, SearchEmployeeService>();
|
services.AddTransient<ISearchEmployeeService, SearchEmployeeService>();
|
||||||
services.AddTransient<IHREmployeeService, HREmployeeService>();
|
services.AddTransient<IHREmployeeService, HREmployeeService>();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ namespace HRM.UI.Controllers
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
private readonly IUserLogInInfoService _userLogInInfoService;
|
private readonly IUserLogInInfoService _userLogInInfoService;
|
||||||
private readonly IBadLoginAttemptInfoService _badLoginAttemptInfoService;
|
private readonly IBadLoginAttemptInfoService _badLoginAttemptInfoService;
|
||||||
|
private readonly ISystemAuditHistoryService _systemAuditHistoryService;
|
||||||
|
|
||||||
public AuthController(IConfiguration config,
|
public AuthController(IConfiguration config,
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
|
|
@ -73,7 +74,8 @@ namespace HRM.UI.Controllers
|
||||||
ISmsService smsService,
|
ISmsService smsService,
|
||||||
IMemoryCache cache,
|
IMemoryCache cache,
|
||||||
IUserLogInInfoService userLogInInfoService,
|
IUserLogInInfoService userLogInInfoService,
|
||||||
IBadLoginAttemptInfoService badLoginAttemptInfoService)
|
IBadLoginAttemptInfoService badLoginAttemptInfoService,
|
||||||
|
ISystemAuditHistoryService systemAuditHistoryService)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_jwt = jwtOptions.Value;
|
_jwt = jwtOptions.Value;
|
||||||
|
|
@ -94,6 +96,7 @@ namespace HRM.UI.Controllers
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_userLogInInfoService = userLogInInfoService;
|
_userLogInInfoService = userLogInInfoService;
|
||||||
_badLoginAttemptInfoService = badLoginAttemptInfoService;
|
_badLoginAttemptInfoService = badLoginAttemptInfoService;
|
||||||
|
_systemAuditHistoryService = systemAuditHistoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|
@ -294,6 +297,14 @@ namespace HRM.UI.Controllers
|
||||||
if (userForLoginDto.IsSSO)
|
if (userForLoginDto.IsSSO)
|
||||||
{
|
{
|
||||||
userFromRepo = _userService.GetByEmail(userForLoginDto.Email);
|
userFromRepo = _userService.GetByEmail(userForLoginDto.Email);
|
||||||
|
// Same rule as the password sign-in (UserDA.GetByLoginIDAndPassword: Status 1 or 5): a login that
|
||||||
|
// is not switched on (waiting for approval, rejected, inactive, ...) cannot sign in by SSO either.
|
||||||
|
if (userFromRepo != null
|
||||||
|
&& userFromRepo.UserStatus != EnumAuthStatus.Active
|
||||||
|
&& userFromRepo.UserStatus != EnumAuthStatus.Approved)
|
||||||
|
{
|
||||||
|
userFromRepo = null;
|
||||||
|
}
|
||||||
if (userFromRepo != null && userForLoginDto.nextPayProcessDate == null)
|
if (userFromRepo != null && userForLoginDto.nextPayProcessDate == null)
|
||||||
{
|
{
|
||||||
List<PayrollType> payrollTypes = new List<PayrollType>();
|
List<PayrollType> payrollTypes = new List<PayrollType>();
|
||||||
|
|
@ -424,6 +435,12 @@ namespace HRM.UI.Controllers
|
||||||
{
|
{
|
||||||
return BadRequest("Access Type and process date is not valid.");
|
return BadRequest("Access Type and process date is not valid.");
|
||||||
}
|
}
|
||||||
|
else if (userFromRepo.UserType == EnumUserType.User
|
||||||
|
&& !this._payrollTypeService.GetPayrollTypes(userFromRepo.LoginID).Any(p => p.ID == userForLoginDto.payrollTypeid))
|
||||||
|
{
|
||||||
|
// Only an approved (live) access type may be used to sign in; a requested one is not live yet.
|
||||||
|
return BadRequest("You do not have approved access to the selected Access Type.");
|
||||||
|
}
|
||||||
else if (userFromRepo.UserType == EnumUserType.Employee)
|
else if (userFromRepo.UserType == EnumUserType.Employee)
|
||||||
{
|
{
|
||||||
DateTime eocd= _userService.GetEndofContractDate(userForLoginDto.Username);
|
DateTime eocd= _userService.GetEndofContractDate(userForLoginDto.Username);
|
||||||
|
|
@ -739,6 +756,26 @@ namespace HRM.UI.Controllers
|
||||||
return Ok(new { userToken });
|
return Ok(new { userToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("CipherMechanism")]
|
||||||
|
public ActionResult CipherMechanism(dynamic data)
|
||||||
|
{
|
||||||
|
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
||||||
|
string decryptedvalue = (string)item["decryptedvalue"].ToObject<string>();
|
||||||
|
var encryptedValue = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(decryptedvalue))
|
||||||
|
{
|
||||||
|
encryptedValue = Ease.NetCore.Utility.Global.CipherFunctions.Encrypt("CeLiMiTeD.AdMIn", decryptedvalue.Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
return Ok(encryptedValue);
|
||||||
|
}
|
||||||
|
|
||||||
// Clears the HttpOnly "JWToken" cookie the API authenticates from (see Startup), so the
|
// Clears the HttpOnly "JWToken" cookie the API authenticates from (see Startup), so the
|
||||||
// session really ends on logout. Anonymous so an invalid/expired cookie can still be removed.
|
// session really ends on logout. Anonymous so an invalid/expired cookie can still be removed.
|
||||||
[HttpPost("logOut")]
|
[HttpPost("logOut")]
|
||||||
|
|
@ -827,6 +864,11 @@ namespace HRM.UI.Controllers
|
||||||
{
|
{
|
||||||
PayrollType optype = new PayrollTypeService().Get(payrollTypeId);
|
PayrollType optype = new PayrollTypeService().Get(payrollTypeId);
|
||||||
User oempUser = new UserService().Get(ouser.ID);
|
User oempUser = new UserService().Get(ouser.ID);
|
||||||
|
// Only an approved (live) access type may be switched to.
|
||||||
|
if (oempUser == null || !this._payrollTypeService.GetPayrollTypes(oempUser.LoginID).Any(p => p.ID == payrollTypeId))
|
||||||
|
{
|
||||||
|
return BadRequest("You do not have approved access to this Access Type.");
|
||||||
|
}
|
||||||
token = this.CreateToten(oempUser, optype.ID, optype.NextPayProcessDate);
|
token = this.CreateToten(oempUser, optype.ID, optype.NextPayProcessDate);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -897,6 +939,21 @@ namespace HRM.UI.Controllers
|
||||||
return BadRequest("Your account is now locked. Please contact with your Line Manager.");
|
return BadRequest("Your account is now locked. Please contact with your Line Manager.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only an approved (live) access type may be switched to: the same list the ESS
|
||||||
|
// switch shows (getAdminPayrollTypes).
|
||||||
|
List<PayrollType> liveAccessTypes = this._payrollTypeService.GetUsersAdminPayrollTypes((int)currentUser.EmployeeID);
|
||||||
|
if (!liveAccessTypes.Any(p => p.ID == payrollTypeId))
|
||||||
|
{
|
||||||
|
if (item["payrollTypeId"] != null || liveAccessTypes.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("You do not have approved access to this Access Type.");
|
||||||
|
}
|
||||||
|
// No type was chosen and the employee's own one is not an approved access:
|
||||||
|
// use the first approved one instead.
|
||||||
|
payrollTypeId = liveAccessTypes[0].ID;
|
||||||
|
optype = new PayrollTypeService().Get(payrollTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
#region Save User Login History
|
#region Save User Login History
|
||||||
if (guser != null)
|
if (guser != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1243,8 +1300,14 @@ namespace HRM.UI.Controllers
|
||||||
public ActionResult SaveRole(Role role)
|
public ActionResult SaveRole(Role role)
|
||||||
{
|
{
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User actingUser = this._userService.Get(currentUser.UserID);
|
||||||
|
if (actingUser == null || (actingUser.UserType != EnumUserType.SuperUser && actingUser.SISU != true))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to create, edit or approve roles.");
|
||||||
|
}
|
||||||
if (role.IsNew == true)
|
if (role.IsNew == true)
|
||||||
{
|
{
|
||||||
role.CreatedBy = currentUser.UserID;
|
role.CreatedBy = currentUser.UserID;
|
||||||
|
|
@ -1253,20 +1316,56 @@ namespace HRM.UI.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Role existingRole = this._roleService.Get(role.ID);
|
||||||
|
if (existingRole == null)
|
||||||
|
{
|
||||||
|
return BadRequest("Role not found.");
|
||||||
|
}
|
||||||
|
bool isPending = existingRole.RoleStatus == EnumAuthStatus.NewNotYetApprove
|
||||||
|
|| existingRole.RoleStatus == EnumAuthStatus.EditedNotYetApprove
|
||||||
|
|| existingRole.RoleStatus == EnumAuthStatus.DeletedNotYetApprove;
|
||||||
|
if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||||
|
{
|
||||||
|
if (!isPending)
|
||||||
|
{
|
||||||
|
return BadRequest("This role has no pending change to approve.");
|
||||||
|
}
|
||||||
|
int makerID = (existingRole.ModifiedBy ?? 0) > 0 ? existingRole.ModifiedBy.Value : existingRole.CreatedBy;
|
||||||
|
if (makerID == currentUser.UserID)
|
||||||
|
{
|
||||||
|
return BadRequest("You cannot approve a change you made yourself. Another user must approve it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isPending)
|
||||||
|
{
|
||||||
|
return BadRequest("This role is waiting for approval and cannot be edited.");
|
||||||
|
}
|
||||||
|
role.RoleStatus = EnumAuthStatus.EditedNotYetApprove;
|
||||||
|
}
|
||||||
|
role.CreatedBy = existingRole.CreatedBy;
|
||||||
|
role.CreatedDate = existingRole.CreatedDate;
|
||||||
|
// The browser does not send Sequence either; keep the role's own value instead of 0.
|
||||||
|
role.Sequence = existingRole.Sequence;
|
||||||
role.ApproveDate = null;
|
role.ApproveDate = null;
|
||||||
role.ApproveBy = null;
|
role.ApproveBy = null;
|
||||||
|
if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||||
|
{
|
||||||
|
role.ModifiedBy = existingRole.ModifiedBy;
|
||||||
|
role.ModifiedDate = existingRole.ModifiedDate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
role.ModifiedBy = currentUser.UserID;
|
role.ModifiedBy = currentUser.UserID;
|
||||||
role.ModifiedDate = DateTime.Now;
|
role.ModifiedDate = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (role.RoleStatus == EnumAuthStatus.Approved)
|
if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||||
{
|
{
|
||||||
role.ApproveDate = DateTime.Today;
|
role.ApproveDate = DateTime.Today;
|
||||||
role.ApproveBy = currentUser.UserID;
|
role.ApproveBy = currentUser.UserID;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
id = this._roleService.Save(role);
|
id = this._roleService.Save(role);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -1276,6 +1375,43 @@ namespace HRM.UI.Controllers
|
||||||
|
|
||||||
return Ok(id);
|
return Ok(id);
|
||||||
}
|
}
|
||||||
|
//[HttpPost("saveRole")]
|
||||||
|
//public ActionResult SaveRole(Role role)
|
||||||
|
//{
|
||||||
|
// int id = 0;
|
||||||
|
|
||||||
|
// CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
// if (role.IsNew == true)
|
||||||
|
// {
|
||||||
|
// role.CreatedBy = currentUser.UserID;
|
||||||
|
// role.CreatedDate = DateTime.Now;
|
||||||
|
// role.RoleStatus = EnumAuthStatus.NewNotYetApprove;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// role.ApproveDate = null;
|
||||||
|
// role.ApproveBy = null;
|
||||||
|
// role.ModifiedBy = currentUser.UserID;
|
||||||
|
// role.ModifiedDate = DateTime.Now;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||||
|
// {
|
||||||
|
// role.ApproveDate = DateTime.Today;
|
||||||
|
// role.ApproveBy = currentUser.UserID;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// id = this._roleService.Save(role);
|
||||||
|
// }
|
||||||
|
// catch (Exception e)
|
||||||
|
// {
|
||||||
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return Ok(id);
|
||||||
|
//}
|
||||||
|
|
||||||
[HttpPost("GetEmpUserRole")]
|
[HttpPost("GetEmpUserRole")]
|
||||||
public ActionResult GetEmpUserRole(List<SearchEmployee> searchEmps)
|
public ActionResult GetEmpUserRole(List<SearchEmployee> searchEmps)
|
||||||
|
|
@ -1284,6 +1420,12 @@ namespace HRM.UI.Controllers
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Admin screens only (Employee Profile's access permission): a self-service login may not read roles.
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (currentUser.UserType == EnumUserType.Employee)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to see user roles.");
|
||||||
|
}
|
||||||
ouroles = this._userRoleService.Get(searchEmps);
|
ouroles = this._userRoleService.Get(searchEmps);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -1302,6 +1444,12 @@ namespace HRM.UI.Controllers
|
||||||
int? nroleid = GlobalFunctions.GetApiDefaultIntData(roleid);
|
int? nroleid = GlobalFunctions.GetApiDefaultIntData(roleid);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Only the User Role Permission page reads this list (super users only, like its other endpoints).
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to see user roles.");
|
||||||
|
}
|
||||||
items = this._userRoleService.Get(roletype, nuserid, nroleid);
|
items = this._userRoleService.Get(roletype, nuserid, nroleid);
|
||||||
|
|
||||||
// employee Name, Login-Status, status1, statu2, statu3
|
// employee Name, Login-Status, status1, statu2, statu3
|
||||||
|
|
@ -1411,6 +1559,291 @@ namespace HRM.UI.Controllers
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region User Role Permission maker-checker
|
||||||
|
|
||||||
|
// Only super users manage role assignments (the page is in WebMenu.AdminMenus only), the same
|
||||||
|
// rule as User Access Type.
|
||||||
|
private bool CanManageUserRole(CurrentUser currentUser)
|
||||||
|
{
|
||||||
|
return CanManageUserAccessType(currentUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin requests are about a User-type login; Self Service requests about an employee + payroll type.
|
||||||
|
private static string CheckUserRoleSubject(UserRoleSubject subject)
|
||||||
|
{
|
||||||
|
if (subject == null)
|
||||||
|
return "Select a user or an employee.";
|
||||||
|
if (subject.RoleType == EnumRoleType.Admin)
|
||||||
|
return (subject.UserID ?? 0) > 0 ? null : "Select a user.";
|
||||||
|
if (subject.RoleType == EnumRoleType.Self_Service)
|
||||||
|
return (subject.EmployeeID ?? 0) > 0 || (subject.UserID ?? 0) > 0 ? null : "Select an employee.";
|
||||||
|
return "Select Admin or Self Service.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Who made the pending change (the same maker for every request of one change).
|
||||||
|
private static bool IsUserRoleMaker(UserRoleState state, int userID)
|
||||||
|
{
|
||||||
|
return state.Pending.Any(p => p.CreatedBy == userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The person's live roles of one role type, and any change waiting for approval.
|
||||||
|
[HttpGet("GetUserRoleState/{roleType}/{userID}/{employeeID}")]
|
||||||
|
public ActionResult GetUserRoleState(EnumRoleType roleType, int userID, int employeeID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to manage user roles.");
|
||||||
|
}
|
||||||
|
UserRoleSubject subject = new UserRoleSubject
|
||||||
|
{
|
||||||
|
RoleType = roleType,
|
||||||
|
UserID = userID > 0 ? userID : (int?)null,
|
||||||
|
EmployeeID = employeeID > 0 ? employeeID : (int?)null,
|
||||||
|
};
|
||||||
|
string problem = CheckUserRoleSubject(subject);
|
||||||
|
if (problem != null)
|
||||||
|
{
|
||||||
|
return BadRequest(problem);
|
||||||
|
}
|
||||||
|
return Ok(this._userRoleService.GetRoleState(subject));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maker: the ticked roles become pending requests; nothing is live until approved.
|
||||||
|
[HttpPost("SaveUserRoleRequest")]
|
||||||
|
public ActionResult SaveUserRoleRequest(UserRoleChangeRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to change user roles.");
|
||||||
|
}
|
||||||
|
string problem = CheckUserRoleSubject(request);
|
||||||
|
if (problem != null)
|
||||||
|
{
|
||||||
|
return BadRequest(problem);
|
||||||
|
}
|
||||||
|
if (request.RoleType == EnumRoleType.Admin)
|
||||||
|
{
|
||||||
|
User target = this._userService.Get(request.UserID.Value);
|
||||||
|
if (target == null || target.UserType != EnumUserType.User)
|
||||||
|
{
|
||||||
|
return BadRequest("Select a valid admin user.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UserRoleState state = this._userRoleService.GetRoleState(request);
|
||||||
|
if (state.Pending.Count > 0)
|
||||||
|
{
|
||||||
|
return BadRequest("This person already has a role change waiting for approval. Approve or reject it first.");
|
||||||
|
}
|
||||||
|
// A Self Service employee with no login gets one with this change: it needs the payroll type.
|
||||||
|
if (request.RoleType == EnumRoleType.Self_Service && !state.HasLogin && (request.PayrollTypeID ?? 0) <= 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Select a payroll type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every wanted role must be of this role type; a role the person does not have yet must
|
||||||
|
// also be approved (a role still waiting for its own approval cannot be given).
|
||||||
|
List<int> wanted = (request.RoleIDs ?? new List<int>()).Distinct().ToList();
|
||||||
|
List<Role> allRoles = this._roleService.GetAllRole();
|
||||||
|
foreach (int roleID in wanted)
|
||||||
|
{
|
||||||
|
Role role = allRoles.FirstOrDefault(r => r.ID == roleID);
|
||||||
|
if (role == null || role.RoleType != request.RoleType)
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid role for this role type.");
|
||||||
|
}
|
||||||
|
bool live = state.LiveRoleIDs.Contains(roleID);
|
||||||
|
bool approved = role.RoleStatus == EnumAuthStatus.Approved || role.RoleStatus == EnumAuthStatus.Active;
|
||||||
|
if (!live && !approved)
|
||||||
|
{
|
||||||
|
return BadRequest("Role '" + role.Name + "' is not approved yet, so it cannot be given.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.RoleIDs = wanted;
|
||||||
|
int changed = this._userRoleService.RequestChange(request, currentUser.UserID);
|
||||||
|
if (changed == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nothing changed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker: makes the person's pending role change live. The maker cannot approve.
|
||||||
|
[HttpPost("ApproveUserRole")]
|
||||||
|
public ActionResult ApproveUserRole(UserRoleSubject subject)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
string problem;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to approve user roles.");
|
||||||
|
}
|
||||||
|
problem = DecideUserRole(subject, true, currentUser);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
return problem == null ? Ok(true) : BadRequest(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker: drops the person's pending role change; live roles stay as they were. The maker cannot reject.
|
||||||
|
[HttpPost("RejectUserRole")]
|
||||||
|
public ActionResult RejectUserRole(UserRoleSubject subject)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
string problem;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to reject user roles.");
|
||||||
|
}
|
||||||
|
problem = DecideUserRole(subject, false, currentUser);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
return problem == null ? Ok(true) : BadRequest(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker, many people at once: each one is decided on its own, with the same checks, so one
|
||||||
|
// that cannot be decided does not stop the rest. Returns { done, failed: [{ index, message }] }.
|
||||||
|
[HttpPost("ApproveUserRoles")]
|
||||||
|
public ActionResult ApproveUserRoles(List<UserRoleSubject> subjects)
|
||||||
|
{
|
||||||
|
return DecideUserRoles(subjects, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("RejectUserRoles")]
|
||||||
|
public ActionResult RejectUserRoles(List<UserRoleSubject> subjects)
|
||||||
|
{
|
||||||
|
return DecideUserRoles(subjects, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every role change waiting for approval, of everyone (Pending approvals list).
|
||||||
|
[HttpGet("GetPendingUserRoles")]
|
||||||
|
public ActionResult GetPendingUserRoles()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to see user role approvals.");
|
||||||
|
}
|
||||||
|
return Ok(this._userRoleService.GetPending());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionResult DecideUserRoles(List<UserRoleSubject> subjects, bool approve)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!CanManageUserRole(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to approve or reject user roles.");
|
||||||
|
}
|
||||||
|
if (subjects == null || subjects.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Select at least one person.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
int done = 0;
|
||||||
|
var failed = new List<object>();
|
||||||
|
for (int i = 0; i < subjects.Count; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string problem = DecideUserRole(subjects[i], approve, currentUser);
|
||||||
|
if (problem == null)
|
||||||
|
done++;
|
||||||
|
else
|
||||||
|
failed.Add(new { index = i, message = problem });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
failed.Add(new { index = i, message = e.Message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ok(new { done, failed });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns null when decided, or why it could not be.
|
||||||
|
private string DecideUserRole(UserRoleSubject subject, bool approve, CurrentUser currentUser)
|
||||||
|
{
|
||||||
|
string problem = CheckUserRoleSubject(subject);
|
||||||
|
if (problem != null)
|
||||||
|
return problem;
|
||||||
|
|
||||||
|
UserRoleState state = this._userRoleService.GetRoleState(subject);
|
||||||
|
if (state.Pending.Count == 0)
|
||||||
|
return "No role change is waiting for approval.";
|
||||||
|
if (IsUserRoleMaker(state, currentUser.UserID))
|
||||||
|
return approve
|
||||||
|
? "You cannot approve a change you made yourself. Another user must approve it."
|
||||||
|
: "You cannot reject a change you made yourself. Another user must reject it.";
|
||||||
|
|
||||||
|
if (approve)
|
||||||
|
{
|
||||||
|
// A role given in this change must still be approved now: it may have been edited (and be
|
||||||
|
// waiting for its own approval) on the Role page since the change was sent.
|
||||||
|
List<int> giving = state.Pending
|
||||||
|
.Where(p => p.RequestType == EnumUserRoleRequestType.Add)
|
||||||
|
.Select(p => p.RoleID).Distinct().ToList();
|
||||||
|
if (giving.Count > 0)
|
||||||
|
{
|
||||||
|
List<Role> allRoles = this._roleService.GetAllRole();
|
||||||
|
foreach (int roleID in giving)
|
||||||
|
{
|
||||||
|
Role role = allRoles.FirstOrDefault(r => r.ID == roleID);
|
||||||
|
if (role == null)
|
||||||
|
return "A role in this change no longer exists. Reject the change and send it again.";
|
||||||
|
if (role.RoleStatus != EnumAuthStatus.Approved && role.RoleStatus != EnumAuthStatus.Active)
|
||||||
|
return "Role '" + role.Name + "' is not approved now (it may be waiting for its own approval on the Role page), so it cannot be given yet. Approve the role first, or reject this change.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (approve)
|
||||||
|
this._userRoleService.Approve(subject, currentUser.UserID);
|
||||||
|
else
|
||||||
|
this._userRoleService.Reject(subject, currentUser.UserID);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
[HttpGet("GetUserAccessType/{userid}")]
|
[HttpGet("GetUserAccessType/{userid}")]
|
||||||
public ActionResult GetUserAccessType(int userid)
|
public ActionResult GetUserAccessType(int userid)
|
||||||
{
|
{
|
||||||
|
|
@ -1427,20 +1860,65 @@ namespace HRM.UI.Controllers
|
||||||
return Ok(items);
|
return Ok(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maker-checker for User Access Type. The page is in the super-user menu only
|
||||||
|
// (WebMenu.AdminMenus, given to SuperUser / SISU users), so only they may request or decide.
|
||||||
|
private bool CanManageUserAccessType(CurrentUser currentUser)
|
||||||
|
{
|
||||||
|
User actingUser = this._userService.Get(currentUser.UserID);
|
||||||
|
return actingUser != null && (actingUser.UserType == EnumUserType.SuperUser || actingUser.SISU == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPendingAccess(UserAccessType x)
|
||||||
|
{
|
||||||
|
return x.AccessTypeStatus == EnumAuthStatus.NewNotYetApprove
|
||||||
|
|| x.AccessTypeStatus == EnumAuthStatus.DeletedNotYetApprove;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Who made a pending row: the requester of a new access, or of a removal.
|
||||||
|
private static int AccessMakerID(UserAccessType x)
|
||||||
|
{
|
||||||
|
return x.AccessTypeStatus == EnumAuthStatus.DeletedNotYetApprove ? (x.ModifiedBy ?? 0) : x.CreatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maker: the ticked payroll types become pending changes; nothing is live until approved.
|
||||||
[HttpPost("SaveUserAccessType")]
|
[HttpPost("SaveUserAccessType")]
|
||||||
public ActionResult SaveUserAccessType(List<UserAccessType> userAccessTypes)
|
public ActionResult SaveUserAccessType(List<UserAccessType> userAccessTypes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
userAccessTypes.ForEach(x =>
|
if (!CanManageUserAccessType(currentUser))
|
||||||
{
|
{
|
||||||
x.CreatedBy = currentUser.UserID;
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to change user access types.");
|
||||||
x.CreatedDate = DateTime.Today;
|
}
|
||||||
x.ApprovedBy = currentUser.UserID;
|
if (userAccessTypes == null || userAccessTypes.Count == 0)
|
||||||
x.ApprovedDate = DateTime.Today;
|
{
|
||||||
});
|
return BadRequest("Select at least one payroll type.");
|
||||||
this._userAccessTypeService.Save(userAccessTypes);
|
}
|
||||||
|
|
||||||
|
int userID = userAccessTypes[0].UserID;
|
||||||
|
if (userID <= 0 || userAccessTypes.Any(x => x.UserID != userID))
|
||||||
|
{
|
||||||
|
return BadRequest("Select a user.");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> payrollTypeIDs = userAccessTypes.Select(x => x.PayrollTypeID).Distinct().ToList();
|
||||||
|
List<PayrollType> allPayrollTypes = this._payrollTypeService.Get();
|
||||||
|
if (payrollTypeIDs.Any(id => !allPayrollTypes.Any(p => p.ID == id)))
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid payroll type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._userAccessTypeService.GetByUserID(userID).Any(IsPendingAccess))
|
||||||
|
{
|
||||||
|
return BadRequest("This user already has an access change waiting for approval. Approve or reject it first.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int changed = this._userAccessTypeService.RequestChange(userID, payrollTypeIDs, currentUser.UserID);
|
||||||
|
if (changed == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Nothing changed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -1450,6 +1928,156 @@ namespace HRM.UI.Controllers
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checker: makes the user's pending access changes live. The maker cannot approve.
|
||||||
|
[HttpPost("ApproveUserAccessType/{userID}")]
|
||||||
|
public ActionResult ApproveUserAccessType(int userID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserAccessType(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to approve user access types.");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserAccessType> pending = this._userAccessTypeService.GetByUserID(userID).Where(IsPendingAccess).ToList();
|
||||||
|
if (pending.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("This user has no access change waiting for approval.");
|
||||||
|
}
|
||||||
|
if (pending.Any(x => AccessMakerID(x) == currentUser.UserID))
|
||||||
|
{
|
||||||
|
return BadRequest("You cannot approve a change you made yourself. Another user must approve it.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this._userAccessTypeService.Approve(userID, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker: drops the user's pending access changes; access stays as it was. The maker cannot reject.
|
||||||
|
[HttpPost("RejectUserAccessType/{userID}")]
|
||||||
|
public ActionResult RejectUserAccessType(int userID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserAccessType(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to reject user access types.");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserAccessType> pending = this._userAccessTypeService.GetByUserID(userID).Where(IsPendingAccess).ToList();
|
||||||
|
if (pending.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("This user has no access change waiting for approval.");
|
||||||
|
}
|
||||||
|
if (pending.Any(x => AccessMakerID(x) == currentUser.UserID))
|
||||||
|
{
|
||||||
|
return BadRequest("You cannot reject a change you made yourself. Another user must reject it.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this._userAccessTypeService.Reject(userID, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pending approvals list: every user access change waiting for approval, one row per payroll type.
|
||||||
|
[HttpGet("GetPendingUserAccessTypes")]
|
||||||
|
public ActionResult GetPendingUserAccessTypes()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (!CanManageUserAccessType(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to see user access type approvals.");
|
||||||
|
}
|
||||||
|
return Ok(this._userAccessTypeService.GetPending());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker, many users at once: approves each user's pending change on its own, with the same
|
||||||
|
// checks as ApproveUserAccessType, so one user that cannot be approved does not stop the rest.
|
||||||
|
[HttpPost("ApproveUserAccessTypes")]
|
||||||
|
public ActionResult ApproveUserAccessTypes(List<int> userIDs)
|
||||||
|
{
|
||||||
|
return DecideUserAccessTypes(userIDs, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checker, many users at once: rejects each user's pending change on its own (see ApproveUserAccessTypes).
|
||||||
|
[HttpPost("RejectUserAccessTypes")]
|
||||||
|
public ActionResult RejectUserAccessTypes(List<int> userIDs)
|
||||||
|
{
|
||||||
|
return DecideUserAccessTypes(userIDs, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionResult DecideUserAccessTypes(List<int> userIDs, bool approve)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!CanManageUserAccessType(currentUser))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to approve or reject user access types.");
|
||||||
|
}
|
||||||
|
if (userIDs == null || userIDs.Count == 0)
|
||||||
|
{
|
||||||
|
return BadRequest("Select at least one user.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
int done = 0;
|
||||||
|
var failed = new List<object>();
|
||||||
|
foreach (int userID in userIDs.Distinct())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<UserAccessType> pending = this._userAccessTypeService.GetByUserID(userID).Where(IsPendingAccess).ToList();
|
||||||
|
if (pending.Count == 0)
|
||||||
|
{
|
||||||
|
failed.Add(new { userID, message = "No access change waiting for approval." });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pending.Any(x => AccessMakerID(x) == currentUser.UserID))
|
||||||
|
{
|
||||||
|
failed.Add(new { userID, message = "You made this change yourself; another user must decide it." });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (approve)
|
||||||
|
this._userAccessTypeService.Approve(userID, currentUser.UserID);
|
||||||
|
else
|
||||||
|
this._userAccessTypeService.Reject(userID, currentUser.UserID);
|
||||||
|
done++;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
failed.Add(new { userID, message = e.Message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(new { done, failed });
|
||||||
|
}
|
||||||
|
|
||||||
// password history
|
// password history
|
||||||
//[HttpGet]
|
//[HttpGet]
|
||||||
//[Route("getPasswordHistoryList")]
|
//[Route("getPasswordHistoryList")]
|
||||||
|
|
@ -1832,6 +2460,38 @@ namespace HRM.UI.Controllers
|
||||||
return Ok(items);
|
return Ok(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change history of the Role, Role Permission, User, User Role and User Access Type pages,
|
||||||
|
// read from their Z_ tables (SystemAuditHistory_DB_Changes.sql). type = EnumSystemAuditHistory.
|
||||||
|
[HttpGet]
|
||||||
|
[Route("getSystemAuditHistory/{type}/{fromDate}/{toDate}")]
|
||||||
|
public ActionResult GetSystemAuditHistory(int type, string fromDate, string toDate)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
if (currentUser.UserType == EnumUserType.Employee)
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to view the audit trail.");
|
||||||
|
if (!Enum.IsDefined(typeof(EnumSystemAuditHistory), type))
|
||||||
|
return StatusCode(StatusCodes.Status400BadRequest, "Unknown audit history.");
|
||||||
|
|
||||||
|
List<SystemAuditHistory> items = new List<SystemAuditHistory>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime dFromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
||||||
|
DateTime dToDate = GlobalFunctions.GetApiDefaultDateData(toDate);
|
||||||
|
if (dFromDate == DateTime.MinValue || dToDate == DateTime.MinValue)
|
||||||
|
return StatusCode(StatusCodes.Status400BadRequest, "From date and To date are required.");
|
||||||
|
if (dFromDate.Date > dToDate.Date)
|
||||||
|
return StatusCode(StatusCodes.Status400BadRequest, "From date can not be after To date.");
|
||||||
|
|
||||||
|
items = _systemAuditHistoryService.Get((EnumSystemAuditHistory)type, dFromDate, dToDate);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(items);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,21 @@ namespace HRM.UI.Controllers.Payroll
|
||||||
private readonly ISalaryMasterBulkUploadService _salaryMasterBulkUploadService;
|
private readonly ISalaryMasterBulkUploadService _salaryMasterBulkUploadService;
|
||||||
private readonly IEmployeePhotoBulkUploadService _employeePhotoBulkUploadService;
|
private readonly IEmployeePhotoBulkUploadService _employeePhotoBulkUploadService;
|
||||||
private readonly ICacheManager _cashManager;
|
private readonly ICacheManager _cashManager;
|
||||||
|
private readonly IBonusProcessService _bonusProcessService;
|
||||||
|
|
||||||
public DataUploadController(IDataUploadColumnDefinition columnDefination,
|
public DataUploadController(IDataUploadColumnDefinition columnDefination,
|
||||||
IEmployeeBulkUploadService employeeBulkUploadService,
|
IEmployeeBulkUploadService employeeBulkUploadService,
|
||||||
ISalaryMasterBulkUploadService salaryMasterBulkUploadService,
|
ISalaryMasterBulkUploadService salaryMasterBulkUploadService,
|
||||||
IEmployeePhotoBulkUploadService employeePhotoBulkUploadService,
|
IEmployeePhotoBulkUploadService employeePhotoBulkUploadService,
|
||||||
ICacheManager cashManager)
|
ICacheManager cashManager,
|
||||||
|
IBonusProcessService bonusProcessService)
|
||||||
{
|
{
|
||||||
this._columnDefination = columnDefination;
|
this._columnDefination = columnDefination;
|
||||||
this._employeeBulkUploadService = employeeBulkUploadService;
|
this._employeeBulkUploadService = employeeBulkUploadService;
|
||||||
this._salaryMasterBulkUploadService = salaryMasterBulkUploadService;
|
this._salaryMasterBulkUploadService = salaryMasterBulkUploadService;
|
||||||
this._employeePhotoBulkUploadService = employeePhotoBulkUploadService;
|
this._employeePhotoBulkUploadService = employeePhotoBulkUploadService;
|
||||||
this._cashManager = cashManager;
|
this._cashManager = cashManager;
|
||||||
|
this._bonusProcessService = bonusProcessService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// loan
|
// loan
|
||||||
|
|
@ -156,6 +159,53 @@ namespace HRM.UI.Controllers.Payroll
|
||||||
return Ok(items);
|
return Ok(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Upload Data": reads the bonus file (sheet EmpBonus: Employee No, Amount — the
|
||||||
|
/// same reader as uploadBonusFile) and saves it in the same request, with the tax when the header asks
|
||||||
|
/// for it (BonusProcessService.UploadAndSave). Form fields: excelfile, and header = the JSON of a
|
||||||
|
/// BonusProcessAndSaveRequest (bonus, dates, flags). Returns the saved rows.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("uploadBonusFileAndSave")]
|
||||||
|
public ActionResult uploadBonusFileAndSave()
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
BonusProcessAndSaveResult result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int payrolltypeid = (int)currentUser.PayrollTypeID;
|
||||||
|
string headerJson = Convert.ToString(Request.Form["header"]);
|
||||||
|
if (string.IsNullOrWhiteSpace(headerJson))
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Bonus information not found.");
|
||||||
|
// same JSON reading as the Process button's request (Newtonsoft defaults), so dates arrive the same way
|
||||||
|
BonusProcessAndSaveRequest request = JsonConvert.DeserializeObject<BonusProcessAndSaveRequest>(headerJson);
|
||||||
|
|
||||||
|
IFormFile formFile = Request.Form.Files.FirstOrDefault();
|
||||||
|
if (formFile == null || formFile.Length == 0)
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Please select a file.");
|
||||||
|
string extension = Path.GetExtension(formFile.FileName ?? string.Empty).ToLowerInvariant();
|
||||||
|
if (extension != ".xlsx" && extension != ".xls")
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Please select an Excel file (.xlsx or .xls).");
|
||||||
|
|
||||||
|
DataUploadColumnDefinition oColumnDefination = this._columnDefination.GetColumnDefinition(
|
||||||
|
(int)EnumRegularDataUpload.Bonus, null, payrolltypeid);
|
||||||
|
List<BonusProcess.BonusProcessDetail> items;
|
||||||
|
using (Stream stream = formFile.OpenReadStream())
|
||||||
|
{
|
||||||
|
items = new RegularDataUploadService().GetBonusData((int)EnumRegularDataUpload.Bonus, oColumnDefination,
|
||||||
|
stream, payrolltypeid);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = _bonusProcessService.UploadAndSave(items, request, payrolltypeid, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Employee Bulk Upload layout — groups, sub-groups and columns — that the page shows
|
/// The Employee Bulk Upload layout — groups, sub-groups and columns — that the page shows
|
||||||
/// as section checkboxes and in its template guide.
|
/// as section checkboxes and in its template guide.
|
||||||
|
|
|
||||||
|
|
@ -2313,6 +2313,27 @@ namespace HRM.UI.Controllers
|
||||||
|
|
||||||
return Ok(employeeList);
|
return Ok(employeeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A light Employee (EmployeeLite) for each posted employee ID (body: [1, 2, 3]).
|
||||||
|
/// For screens that pick 10k+ employees and need only a few fields (Bonus Process);
|
||||||
|
/// getEmployeesByEmpIDs returns the whole Employee row and is too heavy for that.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("getEmployeeLiteByEmpIDs")]
|
||||||
|
public ActionResult GetEmployeeLiteByEmpIDs([FromBody] List<int> empIds)
|
||||||
|
{
|
||||||
|
List<EmployeeLite> items = new List<EmployeeLite>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
items = _EmployeeService.GetLiteByEmpIDs(empIds);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(items);
|
||||||
|
}
|
||||||
[HttpPost("updateBanglaInformation")]
|
[HttpPost("updateBanglaInformation")]
|
||||||
public ActionResult updateBanglaInformation(dynamic data)
|
public ActionResult updateBanglaInformation(dynamic data)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,105 @@ namespace HRM.UI.Controllers.Payroll
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bonus Process screen, "Process" button: calculates the bonus (and tax) of the posted employees and
|
||||||
|
/// saves it in the same request — there is no separate Save step. Body: the header and the employee
|
||||||
|
/// IDs only. Returns the saved rows read back from the database. See BonusProcessService.ProcessAndSave.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("processAndSave")]
|
||||||
|
public ActionResult ProcessAndSave([FromBody] BonusProcessAndSaveRequest request)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
BonusProcessAndSaveResult result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = _bonusProcessService.ProcessAndSave(request, (int)currentUser.PayrollTypeID, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Modify dialog, "Calculate": the tax of one saved row for a bonus amount. Nothing is saved.</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("calculateRowTax")]
|
||||||
|
public ActionResult CalculateRowTax([FromBody] BonusProcessRowTaxRequest request)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
BonusProcessRowTaxResult result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = _bonusProcessService.CalculateRowTax(request, (int)currentUser.PayrollTypeID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Modify dialog, "Save": saves one row (amounts + that employee's bonus tax data); returns the saved row.</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("saveRow")]
|
||||||
|
public ActionResult SaveRow([FromBody] BonusProcessRowSaveRequest request)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
BonusProcessGridRow row = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
row = _bonusProcessService.SaveRow(request, (int)currentUser.PayrollTypeID, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>"Clear Tax": the tax of every row of the process becomes 0 and is saved at once; returns the saved rows.</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("clearTaxAndSave/{bonusProcessID}")]
|
||||||
|
public ActionResult ClearTaxAndSave(int bonusProcessID)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
List<BonusProcessGridRow> rows = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rows = _bonusProcessService.ClearTaxAndSave(bonusProcessID, (int)currentUser.PayrollTypeID, currentUser.UserID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Remove button on a saved row: deletes that employee's saved bonus data (and the header when it was the last).</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("removeRow/{bonusProcessDetailID}")]
|
||||||
|
public ActionResult RemoveRow(int bonusProcessDetailID)
|
||||||
|
{
|
||||||
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||||
|
BonusProcessRowRemoveResult result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = _bonusProcessService.RemoveRow(bonusProcessDetailID, (int)currentUser.PayrollTypeID);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("CalculateBonusTax")]
|
[Route("CalculateBonusTax")]
|
||||||
public ActionResult CalculateBonusTax(List<BonusProcess.BonusProcessDetail> items)
|
public ActionResult CalculateBonusTax(List<BonusProcess.BonusProcessDetail> items)
|
||||||
|
|
|
||||||
|
|
@ -217,3 +217,5 @@
|
||||||
[10-Sep-2026 11:02:56 AM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1250-Jamal Hossain, has applied Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Your Approval is required. Body: Dear Shikdar Mamun,<br/><br/>D1250-Jamal Hossain, has applied Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
[10-Sep-2026 11:02:56 AM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1250-Jamal Hossain, has applied Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Your Approval is required. Body: Dear Shikdar Mamun,<br/><br/>D1250-Jamal Hossain, has applied Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
||||||
[10-Sep-2026 12:28:14 PM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1250-Jamal Hossain, has applied Sick Leave from 11 Sep 2026 to 11 Sep 2026 days:1. Your Approval is required. Body: Dear Shikdar Mamun,<br/><br/>D1250-Jamal Hossain, has applied Sick Leave from 11 Sep 2026 to 11 Sep 2026 days:1. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
[10-Sep-2026 12:28:14 PM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1250-Jamal Hossain, has applied Sick Leave from 11 Sep 2026 to 11 Sep 2026 days:1. Your Approval is required. Body: Dear Shikdar Mamun,<br/><br/>D1250-Jamal Hossain, has applied Sick Leave from 11 Sep 2026 to 11 Sep 2026 days:1. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
||||||
[13-Sep-2026 04:52:45 PM] - Mail Sent to salauddin.shamim@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1265-Shikdar Mamun, has approved your Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1.. Body: Dear Jamal Hossain,<br/><br/>D1265-Shikdar Mamun, has approved your Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Please click on this http://37.61.216.162/sanofi/ to access.<br/><br/>This is a system generated mail, Please do not reply.
|
[13-Sep-2026 04:52:45 PM] - Mail Sent to salauddin.shamim@celimited.com, From: gtlm@celimited.com, CC: . Subject: D1265-Shikdar Mamun, has approved your Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1.. Body: Dear Jamal Hossain,<br/><br/>D1265-Shikdar Mamun, has approved your Casual Leave from 10 Sep 2026 to 10 Sep 2026 days:1. Please click on this http://37.61.216.162/sanofi/ to access.<br/><br/>This is a system generated mail, Please do not reply.
|
||||||
|
[12-Nov-2026 03:10:27 PM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: Bonus process (Festival Bonus) for month - October 2025. Your Approval is required.. Body: Dear Shikdar Mamun,<br/><br/>Bonus process (Festival Bonus) for month - October 2025. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
||||||
|
[12-Nov-2026 03:24:45 PM] - Mail Sent to rashedul@celimited.com, From: gtlm@celimited.com, CC: . Subject: Bonus process (Festival Bonus) for month - October 2025. Your Approval is required.. Body: Dear Shikdar Mamun,<br/><br/>Bonus process (Festival Bonus) for month - October 2025. Your Approval is required. To accept the reliever request during the mentioned period, please click on this http://37.61.216.162/sanofi/.<br/><br/>This is a system generated mail, Please do not reply.
|
||||||
|
|
|
||||||
143
HRM.UI/appsettings.json
Normal file
143
HRM.UI/appsettings.json
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Jwt": {
|
||||||
|
"Secret": "6A2609257D581456601B1F5367702414311F0C2E1B31110F4B383B0C3D2226043F1D7E5B170D255C3245",
|
||||||
|
"Issuer": "492609050A061C37055E31",
|
||||||
|
"Audience": "4C2629050A061C37055B250D28270D26",
|
||||||
|
"TokenLifetimeMinutes": 86400
|
||||||
|
},
|
||||||
|
"LDAPSettings": {
|
||||||
|
"ADServer": "100.100.100.40", // Ad Server
|
||||||
|
"ADServerPort": 389, //636 for LDAPS (SSL)
|
||||||
|
"MasterDomain": "celimited.com",
|
||||||
|
"Domain": "ease.local",
|
||||||
|
"isADLogin": "false", // only true or false
|
||||||
|
"isMFA": "false", // only true or false
|
||||||
|
"MFATimer": "2"
|
||||||
|
},
|
||||||
|
"AppSettings": {
|
||||||
|
"DefaultDB": "spadb3",
|
||||||
|
"AttendanceDataLocation": "C:\\Local\\",
|
||||||
|
"AttendanceDataPassword": "1235",
|
||||||
|
"AttendanceCollectionType": 5,
|
||||||
|
//"Secret": "Computer ease limited, dhaka, bangladesh",
|
||||||
|
"Secret": "fB5fx0XD0nu7Xw7DJy7fLctn+Uq7haV8wngouK3/TuZM9HDoj0ksFimbVGlF+eJI",
|
||||||
|
// JWT signing key (HS512). Must be 64+ ASCII chars since the .NET 10 upgrade (IdentityModel 8 rejects shorter HS512 keys, IDX10720; Ease.Core.Utility.JwtSigningKey stretches a shorter one). Random, one per client/server, never commit it. Changing it signs everyone out once.
|
||||||
|
"downloadFolder": "D:\\Local\\ionic\\Ease.ERP.Api\\Ease.ERP.Api\\DownloadedFiles",
|
||||||
|
"API": {
|
||||||
|
"Title": "FSIE API",
|
||||||
|
"Description": "REST API"
|
||||||
|
},
|
||||||
|
"Swagger": {
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
"DbConfig": [
|
||||||
|
{
|
||||||
|
"ConnectionNode": {
|
||||||
|
"ConnectionString": "server=CEL70;Database=EFT;User ID=sa;Password=;",
|
||||||
|
"Key": "spadb",
|
||||||
|
"Provider": "sql",
|
||||||
|
"SqlSyntax": "SQL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dbSettings": {
|
||||||
|
//master project DB
|
||||||
|
|
||||||
|
//"Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDB;User Id=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;",
|
||||||
|
//"SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=autocrop;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", // Development
|
||||||
|
|
||||||
|
"Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDBBRAC;User Id= DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;",
|
||||||
|
"SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=MasterProjectDBBRAC;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;" // Development
|
||||||
|
|
||||||
|
},
|
||||||
|
"Calendar": {
|
||||||
|
"RemindersEnabled": true,
|
||||||
|
"SendMail": true,
|
||||||
|
"RedirectAllMailTo": "",
|
||||||
|
"ReminderGraceMinutes": 60,
|
||||||
|
"TimeZoneId": "",
|
||||||
|
"IcsDomain": "",
|
||||||
|
"OutlookSync": "Ics", // None | Ics | Graph
|
||||||
|
"MaxAttendees": 500,
|
||||||
|
"ScheduleJobsEnabled": true,
|
||||||
|
"ScheduleEmailsEnabled": true
|
||||||
|
},
|
||||||
|
"EmailSettings": {
|
||||||
|
//"WebAddress": "https://celclouds.com/synoviahr/",
|
||||||
|
// live
|
||||||
|
"WebAddress": "http://37.61.216.162/sanofi/", // UAT
|
||||||
|
"SendMethod": "SMTP",
|
||||||
|
"EmailServer": "celimited.com",
|
||||||
|
"FromAddress": "gtlm@celimited.com",
|
||||||
|
"UserID": "gtlm@celimited.com",
|
||||||
|
"Password": "4A2218420C245F295C76",
|
||||||
|
"isSSO": "false",
|
||||||
|
"isNewDashboard": "true",
|
||||||
|
"PortNumber": "587",
|
||||||
|
"EnableSSL": "YES",
|
||||||
|
"SingleSignOn": "NO",
|
||||||
|
"LDAP": "CEL14"
|
||||||
|
|
||||||
|
},
|
||||||
|
"OpenAI": {
|
||||||
|
"ApiKey": "E71627443D1B3B0F6917242B7A2D213648250712000B17165C0E2D1F7E2F6E21022D24253E5D025E0D53607B5D0C5023007536330C307A73203938316E5D09393F1F3154284411121E7C1A7B08740D193E3B55101D03082F222809170911203F1F1F0F4319081E222B04071A10202F2E152F4724223D223D021F794420062354351C06343A000A31537438203037100C631E1508713637232733345A1C1F224D0323222E2F",
|
||||||
|
"Model": "gpt-5"
|
||||||
|
},
|
||||||
|
"Approver": {
|
||||||
|
"ApproverOneId": "1",
|
||||||
|
"ApproverTwoId": "2",
|
||||||
|
"Balance": "1120000"
|
||||||
|
},
|
||||||
|
"EmployeeApiInfo": {
|
||||||
|
"UserId": "sanofi",
|
||||||
|
"Password": "x"
|
||||||
|
},
|
||||||
|
"AdminPendingJob": {
|
||||||
|
"Profile": "Admin",
|
||||||
|
"MedicalClaim": "x"
|
||||||
|
},
|
||||||
|
"RDLCLocation": "",
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
|
||||||
|
// for Synovia only
|
||||||
|
// the emails has to be comma separated (,) not comma
|
||||||
|
// subordinates of first one and others will be just CC
|
||||||
|
//"SalesEmpEmail": "raq@synoviapharma.com;mtamiz.uddin@synoviapharma.com;ashraful.sharif@synoviapharma.com" // Live
|
||||||
|
"SalesEmpEmail": "", // test
|
||||||
|
|
||||||
|
"BankHead": "22010105",
|
||||||
|
"BergerHead": "11010101",
|
||||||
|
"EPFHead": "21020103",
|
||||||
|
"EPFInterestHead": "21020101",
|
||||||
|
"CPFHead": "21020104",
|
||||||
|
"CPFInterestHead": "21020102",
|
||||||
|
"CPFForfittedHead": "22010102",
|
||||||
|
"EPFPerInterest": "41030101",
|
||||||
|
"CPFPerInterest": "41030102",
|
||||||
|
"EPFFractionYearInterest": "41030103",
|
||||||
|
"LoanHead": "11014101",
|
||||||
|
"LoanInterestHead": "31030102",
|
||||||
|
|
||||||
|
"TrainingSettings": {
|
||||||
|
"InProduction": "NO",
|
||||||
|
"ProjectPath": "\\\\100.100.100.164\\c$\\inetpub\\wwwroot\\SGSRevamp",
|
||||||
|
"ServerIP": "100.100.100.164",
|
||||||
|
"UserID": "EASE\\EaseOne",
|
||||||
|
"Password": "cel1@3$5"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
"SAPSettings": {
|
||||||
|
//"URL": "http://s4dev.bergerbd.com:8001/hrapipossrv/prfbpos?sap-client=900",
|
||||||
|
"URL": "http://bpblecchq.bergerbd.com:8000/hrapipossrvn/prfbpos?sap-client=900",
|
||||||
|
"UserID": "dev_odata",
|
||||||
|
"Password": "Missi@n2020"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
172
SystemAuditHistory_DB_Changes.sql
Normal file
172
SystemAuditHistory_DB_Changes.sql
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
/*
|
||||||
|
System Audit History (Authentication > System Audit Log)
|
||||||
|
========================================================
|
||||||
|
|
||||||
|
The System Audit Log page shows the change history of the Authentication pages, one tab each:
|
||||||
|
Role -> dbo.Z_ROLE (trigger trRole - NEW, below)
|
||||||
|
Role Permission -> dbo.Z_ROLEPERMISSION (trigger trRolePermission - already in the database)
|
||||||
|
User -> dbo.Z_USERS (trigger trUsers - already in the database)
|
||||||
|
User Role -> dbo.Z_USERROLE (trigger truserrole - already in the database)
|
||||||
|
User Access Type -> dbo.Z_USERACCESSTYPE (table + trigger trUserAccessType - NEW, below)
|
||||||
|
|
||||||
|
This script:
|
||||||
|
Part 1 creates dbo.Z_UserAccessType (same shape as dbo.z_users, plus the payroll type).
|
||||||
|
Part 2 creates trigger dbo.trUserAccessType on dbo.UserAccessType (insert, update, delete).
|
||||||
|
Part 3 creates trigger dbo.trRole on dbo.Role (insert, update, delete) writing dbo.Z_ROLE.
|
||||||
|
dbo.Role had no trigger, so dbo.Z_ROLE stayed empty.
|
||||||
|
|
||||||
|
Both new triggers are set-based: User Access Type approves / rejects many rows of a user in
|
||||||
|
one UPDATE / DELETE, and a trigger that reads one value from "inserted" fails on that (Msg 512).
|
||||||
|
|
||||||
|
Who did it (actionby):
|
||||||
|
UserAccessType: the application puts the acting user into SESSION_CONTEXT(N'AuditUserID')
|
||||||
|
(UserAccessTypeService RequestChange / Approve / Reject). Without it the trigger falls back to
|
||||||
|
the row's own ApprovedBy / ModifiedBy / CreatedBy (a delete then has no known user).
|
||||||
|
Role: worked out when reading, from the copied row (ApproveBy / AUTHORIZEDBY / CreatedBy).
|
||||||
|
|
||||||
|
Run order: after UserAccessTypeMakerChecker_DB_Changes.sql (needs UserAccessType.Status,
|
||||||
|
CreatedBy, ModifiedBy, ApprovedBy). Safe to run before or after the code deploys; re-runnable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
-- Part 1: dbo.Z_UserAccessType
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
IF OBJECT_ID('dbo.Z_UserAccessType', 'U') IS NULL
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE dbo.Z_UserAccessType
|
||||||
|
(
|
||||||
|
audittype VARCHAR(100) NULL,
|
||||||
|
auditdate DATETIME NULL,
|
||||||
|
loginid VARCHAR(100) NULL,
|
||||||
|
name VARCHAR(500) NULL,
|
||||||
|
payrolltype VARCHAR(500) NULL,
|
||||||
|
actionby INT NULL,
|
||||||
|
activities VARCHAR(MAX) NULL
|
||||||
|
);
|
||||||
|
PRINT 'Created dbo.Z_UserAccessType';
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
-- Part 2: dbo.trUserAccessType
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
IF OBJECT_ID('dbo.trUserAccessType', 'TR') IS NOT NULL
|
||||||
|
DROP TRIGGER dbo.trUserAccessType;
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE TRIGGER dbo.trUserAccessType
|
||||||
|
ON dbo.UserAccessType
|
||||||
|
FOR INSERT, UPDATE, DELETE
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
DECLARE @auditTime DATETIME = GETDATE();
|
||||||
|
DECLARE @auditUser INT = TRY_CAST(SESSION_CONTEXT(N'AuditUserID') AS INT);
|
||||||
|
|
||||||
|
-- insert: access requested (maker) or given directly
|
||||||
|
INSERT INTO dbo.Z_UserAccessType (audittype, auditdate, loginid, name, payrolltype, actionby, activities)
|
||||||
|
SELECT CASE WHEN i.Status = 2 THEN 'Access type requested' ELSE 'Access type assigned' END,
|
||||||
|
@auditTime, u.LoginID, u.UserName, p.Description,
|
||||||
|
COALESCE(@auditUser, i.CreatedBy, i.ApprovedBy),
|
||||||
|
CASE i.Status
|
||||||
|
WHEN 1 THEN 'Active'
|
||||||
|
WHEN 2 THEN 'New Not Yet Approve'
|
||||||
|
WHEN 5 THEN 'Approved'
|
||||||
|
ELSE 'None'
|
||||||
|
END
|
||||||
|
FROM inserted i
|
||||||
|
LEFT JOIN deleted d ON d.UserAccessTypeID = i.UserAccessTypeID
|
||||||
|
LEFT JOIN dbo.Users u ON u.UserID = i.UserID
|
||||||
|
LEFT JOIN dbo.PayrollType p ON p.PayrollTypeID = i.PayrollTypeID
|
||||||
|
WHERE d.UserAccessTypeID IS NULL;
|
||||||
|
|
||||||
|
-- update: removal requested (maker), request approved, removal rejected, other change
|
||||||
|
INSERT INTO dbo.Z_UserAccessType (audittype, auditdate, loginid, name, payrolltype, actionby, activities)
|
||||||
|
SELECT 'Access type modified',
|
||||||
|
@auditTime, u.LoginID, u.UserName, p.Description,
|
||||||
|
COALESCE(@auditUser,
|
||||||
|
CASE
|
||||||
|
WHEN i.Status = 3 THEN i.ModifiedBy
|
||||||
|
WHEN ISNULL(i.ApprovedBy, 0) <> ISNULL(d.ApprovedBy, 0) THEN i.ApprovedBy
|
||||||
|
ELSE COALESCE(i.ModifiedBy, i.CreatedBy)
|
||||||
|
END),
|
||||||
|
CASE
|
||||||
|
WHEN ISNULL(d.Status, 0) = 2 AND i.Status = 5 THEN 'Approved'
|
||||||
|
WHEN ISNULL(d.Status, 0) = 3 AND i.Status = 5 THEN 'Removal Rejected'
|
||||||
|
WHEN ISNULL(d.Status, 0) <> ISNULL(i.Status, 0) THEN
|
||||||
|
CASE i.Status
|
||||||
|
WHEN 1 THEN 'Active'
|
||||||
|
WHEN 2 THEN 'New Not Yet Approve'
|
||||||
|
WHEN 3 THEN 'Deleted Not Yet Approve'
|
||||||
|
WHEN 4 THEN 'Edited Not Yet Approve'
|
||||||
|
WHEN 5 THEN 'Approved'
|
||||||
|
ELSE 'None'
|
||||||
|
END
|
||||||
|
WHEN ISNULL(d.PayrollTypeID, 0) <> ISNULL(i.PayrollTypeID, 0) THEN 'Access type changed'
|
||||||
|
ELSE ' '
|
||||||
|
END
|
||||||
|
FROM inserted i
|
||||||
|
JOIN deleted d ON d.UserAccessTypeID = i.UserAccessTypeID
|
||||||
|
LEFT JOIN dbo.Users u ON u.UserID = i.UserID
|
||||||
|
LEFT JOIN dbo.PayrollType p ON p.PayrollTypeID = i.PayrollTypeID;
|
||||||
|
|
||||||
|
-- delete: removal approved, request rejected, or access deleted
|
||||||
|
INSERT INTO dbo.Z_UserAccessType (audittype, auditdate, loginid, name, payrolltype, actionby, activities)
|
||||||
|
SELECT 'Access type removed',
|
||||||
|
@auditTime, u.LoginID, u.UserName, p.Description,
|
||||||
|
@auditUser,
|
||||||
|
CASE d.Status
|
||||||
|
WHEN 3 THEN 'Removal Approved'
|
||||||
|
WHEN 2 THEN 'Request Rejected'
|
||||||
|
ELSE 'Deleted'
|
||||||
|
END
|
||||||
|
FROM deleted d
|
||||||
|
LEFT JOIN inserted i ON i.UserAccessTypeID = d.UserAccessTypeID
|
||||||
|
LEFT JOIN dbo.Users u ON u.UserID = d.UserID
|
||||||
|
LEFT JOIN dbo.PayrollType p ON p.PayrollTypeID = d.PayrollTypeID
|
||||||
|
WHERE i.UserAccessTypeID IS NULL;
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
PRINT 'Created trigger dbo.trUserAccessType';
|
||||||
|
GO
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
-- Part 3: dbo.trRole -> dbo.Z_ROLE (copy of the row: Inserted / Update (before) / Update (after) / Deleted)
|
||||||
|
-- ---------------------------------------------------------------------------------------------
|
||||||
|
IF OBJECT_ID('dbo.trRole', 'TR') IS NOT NULL
|
||||||
|
DROP TRIGGER dbo.trRole;
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE TRIGGER dbo.trRole
|
||||||
|
ON dbo.Role
|
||||||
|
FOR INSERT, UPDATE, DELETE
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
DECLARE @auditTime DATETIME = GETDATE();
|
||||||
|
|
||||||
|
-- the row before the change (update) or the removed row (delete)
|
||||||
|
INSERT INTO dbo.Z_ROLE (AUDITTYPE, AUDITDATE, ROLEID, CODE, NAME, CREATEDBY, CREATEDDATE, SEQUENCE, STATUS,
|
||||||
|
ROLETYPE, AUTHORIZEDBY, AUTHORIZEDDATE, DESCRIPTION, APPROVEBY, APPROVEDATE)
|
||||||
|
SELECT CASE WHEN i.RoleID IS NULL THEN 'Deleted' ELSE 'Update (before)' END,
|
||||||
|
@auditTime, d.RoleID, LEFT(d.Code, 20), LEFT(d.Name, 50), d.CreatedBy, d.CreatedDate, d.Sequence, d.Status,
|
||||||
|
d.RoleType, d.AUTHORIZEDBY, d.AUTHORIZEDDATE, LEFT(d.Description, 255), d.ApproveBy, d.ApproveDate
|
||||||
|
FROM deleted d
|
||||||
|
LEFT JOIN inserted i ON i.RoleID = d.RoleID;
|
||||||
|
|
||||||
|
-- the new row (insert) or the row after the change (update)
|
||||||
|
INSERT INTO dbo.Z_ROLE (AUDITTYPE, AUDITDATE, ROLEID, CODE, NAME, CREATEDBY, CREATEDDATE, SEQUENCE, STATUS,
|
||||||
|
ROLETYPE, AUTHORIZEDBY, AUTHORIZEDDATE, DESCRIPTION, APPROVEBY, APPROVEDATE)
|
||||||
|
SELECT CASE WHEN d.RoleID IS NULL THEN 'Inserted' ELSE 'Update (after)' END,
|
||||||
|
@auditTime, i.RoleID, LEFT(i.Code, 20), LEFT(i.Name, 50), i.CreatedBy, i.CreatedDate, i.Sequence, i.Status,
|
||||||
|
i.RoleType, i.AUTHORIZEDBY, i.AUTHORIZEDDATE, LEFT(i.Description, 255), i.ApproveBy, i.ApproveDate
|
||||||
|
FROM inserted i
|
||||||
|
LEFT JOIN deleted d ON d.RoleID = i.RoleID;
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
PRINT 'Created trigger dbo.trRole';
|
||||||
|
GO
|
||||||
38
deploy.ps1
38
deploy.ps1
|
|
@ -11,7 +11,7 @@
|
||||||
# Update these values for each client/environment before running
|
# Update these values for each client/environment before running
|
||||||
|
|
||||||
$baseHref = "/CELHRM_Master/"
|
$baseHref = "/CELHRM_Master/"
|
||||||
$outputFolder = "publish\CELHRM_Master" # relative to this script's folder (repo root)
|
$outputFolder = "publish\CELHRM_Master" # relative to this script's folder (repo root); the version is added: CELHRM_Master_<version>
|
||||||
|
|
||||||
# These never change
|
# These never change
|
||||||
$repoRoot = $PSScriptRoot
|
$repoRoot = $PSScriptRoot
|
||||||
|
|
@ -48,6 +48,10 @@ $newCounter = $lastCounter + 1
|
||||||
$version = "$today-" + $newCounter.ToString("D2") # D2 = always 2 digits (01, 02, 03...)
|
$version = "$today-" + $newCounter.ToString("D2") # D2 = always 2 digits (01, 02, 03...)
|
||||||
$buildTime = (Get-Date).ToUniversalTime().ToString("o")
|
$buildTime = (Get-Date).ToUniversalTime().ToString("o")
|
||||||
|
|
||||||
|
# Output folder carries the version: e.g. publish\CELHRM_Master_20260517-01
|
||||||
|
$destinationPath = Join-Path $repoRoot ($outputFolder + "_" + $version)
|
||||||
|
$wwwrootPath = Join-Path $destinationPath "wwwroot"
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "============================================" -ForegroundColor Cyan
|
Write-Host "============================================" -ForegroundColor Cyan
|
||||||
Write-Host " CEL HRM - Full Build & Deploy Script" -ForegroundColor Cyan
|
Write-Host " CEL HRM - Full Build & Deploy Script" -ForegroundColor Cyan
|
||||||
|
|
@ -132,6 +136,26 @@ Copy-Item -Path $distPath -Destination $wwwrootPath -Recurse -Force
|
||||||
Write-Host "[OK] Angular files copied to: $wwwrootPath" -ForegroundColor Green
|
Write-Host "[OK] Angular files copied to: $wwwrootPath" -ForegroundColor Green
|
||||||
|
|
||||||
|
|
||||||
|
# ---- STEP 5b: Copy everything in HRM.UI\RDLC into the published RDLC folder ---- #
|
||||||
|
# dotnet publish only copies the RDLC files the csproj lists, so a report (or an
|
||||||
|
# image it uses) can be missing on the server. Copy the whole folder as it is in
|
||||||
|
# the repo, overwriting what publish already put there.
|
||||||
|
|
||||||
|
$rdlcSourcePath = Join-Path $repoRoot "HRM.UI\RDLC"
|
||||||
|
$rdlcDestinationPath = Join-Path $destinationPath "RDLC"
|
||||||
|
|
||||||
|
if (Test-Path $rdlcSourcePath) {
|
||||||
|
if (-not (Test-Path $rdlcDestinationPath)) {
|
||||||
|
New-Item -ItemType Directory -Path $rdlcDestinationPath -Force | Out-Null
|
||||||
|
}
|
||||||
|
Copy-Item -Path (Join-Path $rdlcSourcePath "*") -Destination $rdlcDestinationPath -Recurse -Force
|
||||||
|
$rdlcCount = (Get-ChildItem -Path $rdlcDestinationPath -Recurse -File).Count
|
||||||
|
Write-Host "[OK] RDLC folder copied to: $rdlcDestinationPath ($rdlcCount files)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "[WARN] RDLC folder not found: $rdlcSourcePath (skipped)" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ---- STEP 6: Write Angular web.config to wwwroot ---- #
|
# ---- STEP 6: Write Angular web.config to wwwroot ---- #
|
||||||
# This is separate from the backend web.config that dotnet publish
|
# This is separate from the backend web.config that dotnet publish
|
||||||
# already generated at the root of $destinationPath (for the IIS
|
# already generated at the root of $destinationPath (for the IIS
|
||||||
|
|
@ -200,6 +224,18 @@ $angularWebConfig | Out-File -FilePath "$wwwrootPath\web.config" -Encoding utf8
|
||||||
Write-Host "[OK] Angular web.config written to: $wwwrootPath\web.config" -ForegroundColor Green
|
Write-Host "[OK] Angular web.config written to: $wwwrootPath\web.config" -ForegroundColor Green
|
||||||
|
|
||||||
|
|
||||||
|
# ---- STEP 7: Remove the backend web.config from the version folder ---- #
|
||||||
|
# The server keeps its own web.config (hosting settings per client), so the one
|
||||||
|
# dotnet publish generated at the folder root must not overwrite it on deploy.
|
||||||
|
# Only the root file is removed; wwwroot\web.config (Angular, STEP 6) stays.
|
||||||
|
|
||||||
|
$rootWebConfig = Join-Path $destinationPath "web.config"
|
||||||
|
if (Test-Path $rootWebConfig) {
|
||||||
|
Remove-Item -Path $rootWebConfig -Force
|
||||||
|
Write-Host "[OK] Removed web.config from: $destinationPath" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ---- DONE ---- #
|
# ---- DONE ---- #
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "============================================" -ForegroundColor Cyan
|
Write-Host "============================================" -ForegroundColor Cyan
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user