4385 lines
166 KiB
C#
4385 lines
166 KiB
C#
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
using HRM.BO.Configuration;
|
|
using HRM.DA;
|
|
using HRM.UI.MODELS;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using Microsoft.Extensions.Options;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using static iTextSharp.text.pdf.AcroFields;
|
|
using System.Text;
|
|
|
|
|
|
namespace HRM.UI.Controllers.Attendance
|
|
{
|
|
[Route("api/Attendance")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class AttendanceController : ControllerBase
|
|
{
|
|
private readonly IShiftService _shiftService;
|
|
private readonly IHolidayCalendarService _holidayCalendarService;
|
|
private readonly IAttnNationalHolidayService _attnNationalHolidayService;
|
|
private readonly IWorkPlanGroupService _workPlanGroupService;
|
|
private readonly IEmployeeWorkPlanSetupService _employeeWorkPlanSetupService;
|
|
private readonly IShiftRotationService _shiftRotationService;
|
|
private readonly IDailyAttnProcessService _dailyAttnProcessService;
|
|
private readonly IActingResponsibilitySetupService _actingResponsibilitySetupService;
|
|
private readonly IEmployeeOutsideDutyService _employeeOutsideDutyService;
|
|
private readonly IMonthlyWorkPlanService _monthyWorkPlan;
|
|
private readonly IActingResponsibilitySetupService _actingResponsiblity;
|
|
private readonly IAttnRawDataService _attnRawDataService;
|
|
private readonly IEmployeeService _employeeService;
|
|
private readonly IPayrollComponentListService _payrollComponentListService;
|
|
private readonly IAllowanceDeductionService _allowanceDeductionService;
|
|
private readonly ITermService _termService;
|
|
private readonly IOutsideDutyService _outsideDutyService;
|
|
private readonly IOptions<EmailSettings> _emailSettings;
|
|
private readonly ILeaveYearService _leaveYearService;
|
|
private readonly ICacheManager _cashManager;
|
|
private readonly IAccessCardService _accessCardService;
|
|
private readonly ICardOperationService _cCardOperationService;
|
|
|
|
public AttendanceController(IShiftService shiftService,
|
|
IHolidayCalendarService holidayCalendarService,
|
|
IAttnNationalHolidayService attnNationalHolidayService,
|
|
IWorkPlanGroupService workPlanGroupService,
|
|
IEmployeeWorkPlanSetupService employeeWorkPlanSetupService,
|
|
IShiftRotationService shiftRotationService,
|
|
IDailyAttnProcessService dailyAttnProcessService,
|
|
IEmployeeOutsideDutyService employeeOutsideDutyService,
|
|
IMonthlyWorkPlanService monthyworkplan,
|
|
IActingResponsibilitySetupService actingResponsiblity,
|
|
IEmployeeService employeeService,
|
|
IAttnRawDataService attnRawDataService,
|
|
IActingResponsibilitySetupService actingResponsibilitySetupService,
|
|
IPayrollComponentListService payrollComponentListService,
|
|
IAllowanceDeductionService allowanceDeductionService,
|
|
ITermService termService,
|
|
IOutsideDutyService outsideDutyService,
|
|
IOptions<EmailSettings> emailSettings,
|
|
ILeaveYearService leaveYearService,
|
|
IAccessCardService oaccessCardService,
|
|
ICardOperationService ocCardOperationService,
|
|
ICacheManager cashManager)
|
|
{
|
|
this._shiftService = shiftService;
|
|
this._holidayCalendarService = holidayCalendarService;
|
|
this._attnNationalHolidayService = attnNationalHolidayService;
|
|
this._workPlanGroupService = workPlanGroupService;
|
|
this._employeeWorkPlanSetupService = employeeWorkPlanSetupService;
|
|
this._shiftRotationService = shiftRotationService;
|
|
this._dailyAttnProcessService = dailyAttnProcessService;
|
|
this._employeeOutsideDutyService = employeeOutsideDutyService;
|
|
this._monthyWorkPlan = monthyworkplan;
|
|
this._actingResponsiblity = actingResponsiblity;
|
|
this._attnRawDataService = attnRawDataService;
|
|
this._employeeService = employeeService;
|
|
this._actingResponsibilitySetupService = actingResponsibilitySetupService;
|
|
this._payrollComponentListService = payrollComponentListService;
|
|
this._allowanceDeductionService = allowanceDeductionService;
|
|
this._termService = termService;
|
|
this._outsideDutyService = outsideDutyService;
|
|
this._emailSettings = emailSettings;
|
|
this._leaveYearService = leaveYearService;
|
|
this._accessCardService = oaccessCardService;
|
|
this._cCardOperationService = ocCardOperationService;
|
|
this._cashManager = cashManager;
|
|
}
|
|
|
|
// SHIFT
|
|
|
|
[HttpGet("getShifts/{code}/{name}/{status}")]
|
|
public ActionResult GetShifts(string code, string name, EnumStatus status)
|
|
{
|
|
code = GlobalFunctions.GetApiDefaultData(code);
|
|
name = GlobalFunctions.GetApiDefaultData(name);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
List<Shift> items = new List<Shift>();
|
|
try
|
|
{
|
|
items = _shiftService.Get(code, name, status, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getShiftById/{id}")]
|
|
public ActionResult GetShiftById(int id)
|
|
{
|
|
Shift item = new Shift();
|
|
try
|
|
{
|
|
item = _shiftService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getShiftByName/{name}")]
|
|
public ActionResult GetShiftByName(string name)
|
|
{
|
|
Shift item = new Shift();
|
|
try
|
|
{
|
|
item = _shiftService.Get(name);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getOutSideDutyTypes")]
|
|
public ActionResult GetOutSideDutyTypes()
|
|
{
|
|
List<OutsideDuty> oOutsideDuty = new List<OutsideDuty>();
|
|
try
|
|
{
|
|
oOutsideDuty = _outsideDutyService.Get(EnumStatus.Active);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(oOutsideDuty);
|
|
}
|
|
|
|
[HttpGet("getAttendanceAllowancePrev")]
|
|
public ActionResult GetAttendanceAllowancePrev()
|
|
{
|
|
List<PayrollComponentList> componenentList = new List<PayrollComponentList>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
|
|
try
|
|
{
|
|
List<enumPayrollComponentType> ptipes = new List<enumPayrollComponentType>();
|
|
ptipes.Add(enumPayrollComponentType.Over_Time);
|
|
ptipes.Add(enumPayrollComponentType.Allowance);
|
|
componenentList = _payrollComponentListService.Get(ptipes, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(componenentList);
|
|
}
|
|
|
|
[HttpGet("getAttendanceAllowance")]
|
|
public ActionResult GetAttendanceAllowance()
|
|
{
|
|
List<AllowanceDeduction> oAllowanceDeduction = new List<AllowanceDeduction>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
|
|
try
|
|
{
|
|
oAllowanceDeduction = _allowanceDeductionService.Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(oAllowanceDeduction);
|
|
}
|
|
|
|
[HttpGet("getAttendanceOverTimeAllowance")]
|
|
public ActionResult GetAttendanceOverTimeAllowance()
|
|
{
|
|
List<Term> oTerm = new List<Term>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
|
|
try
|
|
{
|
|
oTerm = _termService.Get(EnumStatus.Active, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(oTerm);
|
|
}
|
|
|
|
[HttpGet("getShiftByCounterClock/{isCounterClock}")]
|
|
public ActionResult GetShiftByCounterClock(bool isCounterClock)
|
|
{
|
|
List<Shift> items = new List<Shift>();
|
|
try
|
|
{
|
|
items = _shiftService.Get(isCounterClock);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("isShiftExist/{shiftCode}/{shortName}/{shiftId}")]
|
|
public ActionResult IsShiftExist(string shiftCode, string shortName, int shiftId)
|
|
{
|
|
bool ans;
|
|
try
|
|
{
|
|
ans = _shiftService.IsExist(shiftCode, shortName, shiftId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteShiftById")]
|
|
public ActionResult DeleteShiftById(Shift oshift)
|
|
{
|
|
try
|
|
{
|
|
_shiftService.Delete(oshift.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveTemporaryShift")]
|
|
public ActionResult SaveTemporaryShift(UpdateRosterModel oUpdateRosterModel)
|
|
{
|
|
try
|
|
{
|
|
_actingResponsibilitySetupService.SaveTemporaryShift(oUpdateRosterModel);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveShift")]
|
|
public ActionResult SaveShift(Shift item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
if (item.IsNew == true)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
item.Status = EnumStatus.Active;
|
|
item.payrollTypeID = (int)currentUser.PayrollTypeID;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
_shiftService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// Holiday Calendar
|
|
[HttpGet("getHolidaysByLocId/{locId}")]
|
|
public ActionResult GetHolidaysByLocId(int locId)
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetHoliDays(locId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpPost("ProcessHoliday")]
|
|
public ActionResult ProcessHoliday(HolidayCalendar Item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
_holidayCalendarService.Process((int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
|
|
[HttpGet("getNationalHolidays")]
|
|
public ActionResult GetNationalHolidays()
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetNationalHolidays();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getHolidayById/{id}")]
|
|
public ActionResult GetHolidayById(int id)
|
|
{
|
|
HolidayCalendar item = new HolidayCalendar();
|
|
try
|
|
{
|
|
item = _holidayCalendarService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getTotalMonthlyHolidays/{locationNumber}/{firstDateOfMonth}/{lastDateOfMonth}")]
|
|
public ActionResult GetTotalMonthlyHolidays(int locationNumber, DateTime firstDateOfMonth,
|
|
DateTime lastDateOfMonth)
|
|
{
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _holidayCalendarService.GetTotalMonthlyHolidays(locationNumber, firstDateOfMonth,
|
|
lastDateOfMonth);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
|
|
[HttpGet("getAllHolidays")]
|
|
public ActionResult GetAllHolidays()
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getWeeklyHolidays")]
|
|
public ActionResult GetWeeklyHolidays()
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetWeeklyHoliDay();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getWeeklyAndLocHoliday/{locId}")]
|
|
public ActionResult GetWeeklyAndLocHoliday(int locId)
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetWeeklyAndLocHoliday(locId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getNoOfHoliday")]
|
|
public ActionResult GetNoOfHoliday()
|
|
{
|
|
double ans;
|
|
try
|
|
{
|
|
ans = _holidayCalendarService.GetNoofHoliday();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getHolidaysByMonthRange/{locationId}/{startDate}/{endDate}")]
|
|
public ActionResult GetHolidaysByMonthRange(int locationId, DateTime startDate, DateTime endDate)
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetbyMonthRange(locationId, startDate, endDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getHolidaysByDateRange/{startDate}/{endDate}")]
|
|
public ActionResult GetHolidaysByDateRange(DateTime startDate, DateTime endDate)
|
|
{
|
|
List<HolidayCalendar> items = new List<HolidayCalendar>();
|
|
try
|
|
{
|
|
items = _holidayCalendarService.GetbyDateRange(startDate, endDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveHoliday")]
|
|
public ActionResult SaveHoliday(HolidayCalendar item)
|
|
{
|
|
try
|
|
{
|
|
_holidayCalendarService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteHolidayById")]
|
|
public ActionResult DeleteHolidayById(int id)
|
|
{
|
|
try
|
|
{
|
|
_holidayCalendarService.Delete(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteAllHolidayByYear")]
|
|
public ActionResult DeleteAllHolidayByYear(int year)
|
|
{
|
|
try
|
|
{
|
|
_holidayCalendarService.DeleteAll(year);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
// AttnNationalHoliday
|
|
|
|
[HttpGet("getAttnNationalHolidayById/{id}")]
|
|
public ActionResult GetAttnNationalHolidayById(int id)
|
|
{
|
|
AttnNationalHoliday item = new AttnNationalHoliday();
|
|
try
|
|
{
|
|
item = _attnNationalHolidayService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
|
|
[HttpGet("getupcommingNationalHoliday/{fromDate}")]
|
|
public ActionResult getupcommingNationalHoliday(string fromDate)
|
|
{
|
|
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
try
|
|
{
|
|
items = this._cashManager.Get<List<AttnNationalHoliday>>(enumMemoryCashType.Holiday, enumMemoryCashNature.Global);
|
|
if (items == null)
|
|
{
|
|
items = _attnNationalHolidayService.GetupcommintHolidayByUserId(fdate, (int)currentUser.PayrollTypeID);
|
|
this._cashManager.Set(items, enumMemoryCashType.Holiday, enumMemoryCashNature.Global);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnNationalHolidayListByDateRange/{fromDate}/{toDate}")]
|
|
public ActionResult GetAttnNationalHolidayListByDateRange(DateTime fromDate, DateTime toDate)
|
|
{
|
|
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _attnNationalHolidayService.Get(fromDate, toDate, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnNationalHolidayListByStatus/{status}")]
|
|
public ActionResult GetAttnNationalHolidayListByStatus(EnumStatus status)
|
|
{
|
|
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
LeaveYear oLeaveyear = _leaveYearService.GetCurrentYear((int)currentUser.PayrollTypeID);
|
|
if (oLeaveyear != null)
|
|
{
|
|
items = _attnNationalHolidayService.GetByMonthAndPayrollTypeWithDetails(oLeaveyear.StartDate, oLeaveyear.EndDate, payrollTypeId);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnNationalHolidayLocationList/{id}")]
|
|
public ActionResult getAttnNationalHolidayLocationList(int id)
|
|
{
|
|
List<AttnNationalHolidayLocation> items = new List<AttnNationalHolidayLocation>();
|
|
try
|
|
{
|
|
items = _attnNationalHolidayService.GetAttnNationalHolidayLocation(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnNationalHolidayShiftList/{id}")]
|
|
public ActionResult GetAttnNationalHolidayShiftList(int id)
|
|
{
|
|
List<AttnShiftWiseNationalHoliday> items = new List<AttnShiftWiseNationalHoliday>();
|
|
try
|
|
{
|
|
items = _attnNationalHolidayService.GetAttnNationalHolidayShift(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnNationalHolidayListByMonthAndPayrollType/{fromDate}/{toDate}")]
|
|
public ActionResult GetAttnNationalHolidayListByMonthAndPayrollType(DateTime fromDate, DateTime toDate)
|
|
{
|
|
List<AttnNationalHoliday> items = new List<AttnNationalHoliday>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _attnNationalHolidayService.GetByMonthAndPayrollType(fromDate, toDate, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteAttnNationalHolidayById")]
|
|
public ActionResult DeleteAttnNationalHolidayById(AttnNationalHoliday nationalHoliday)
|
|
{
|
|
try
|
|
{
|
|
_attnNationalHolidayService.Delete(nationalHoliday.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveAttnNationalHoliday")]
|
|
public ActionResult SaveAttnNationalHoliday(AttnNationalHoliday item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _attnNationalHolidayService.Save(item, payrollTypeId);
|
|
this._cashManager.Remove(enumMemoryCashType.Holiday, enumMemoryCashNature.Global);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
|
|
// WorkPlanGroup
|
|
|
|
[HttpGet("getWorkPlanGroupById/{id}")]
|
|
public ActionResult GetWorkPlanGroupById(int id)
|
|
{
|
|
WorkPlanGroup item = new WorkPlanGroup();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
item = _workPlanGroupService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
|
|
[HttpGet("GetWorkPlanGroups/{status}/{Name}/{Type}")]
|
|
public ActionResult GetWorkPlanGroups(EnumStatus status, string name, string groupType)
|
|
{
|
|
EnumWorkPlanGroup? gType = null;
|
|
if (GlobalFunctions.GetApiDefaultIntData(groupType) != null)
|
|
gType = (EnumWorkPlanGroup)GlobalFunctions.GetApiDefaultIntData(groupType);
|
|
name = GlobalFunctions.GetApiDefaultData(name);
|
|
List<WorkPlanGroup> items = new List<WorkPlanGroup>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _workPlanGroupService.Get(status, (int)currentUser.PayrollTypeID, name, gType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
//[HttpGet("getWorkPlanGroupListByName/{name}")]
|
|
//public ActionResult GetWorkPlanGroupListByName(string name)
|
|
//{
|
|
// List<WorkPlanGroup> items = new List<WorkPlanGroup>();
|
|
// CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
// int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
// try
|
|
// {
|
|
// items = _workPlanGroupService.GetByName(name, payrollTypeId);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok(items);
|
|
//}
|
|
|
|
[HttpGet("getAllWorkPlanGroupList")]
|
|
public ActionResult GetAllWorkPlanGroupList()
|
|
{
|
|
List<WorkPlanGroup> items = new List<WorkPlanGroup>();
|
|
try
|
|
{
|
|
items = _workPlanGroupService.GetAll();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveWorkPlanGroup")]
|
|
public ActionResult SaveWorkPlanGroup(WorkPlanGroup item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
if (item.IsNew == true)
|
|
{
|
|
item.CreatedDate = DateTime.Today;
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.PayrollTypeID = item.PayrollTypeID;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedDate = DateTime.Today;
|
|
item.CreatedBy = currentUser.UserID;
|
|
}
|
|
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _workPlanGroupService.Save(item, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteWorkPlanGroupById")]
|
|
public ActionResult DeleteWorkPlanGroupById(WorkPlanGroup item)
|
|
{
|
|
try
|
|
{
|
|
_workPlanGroupService.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// EmployeeWorkPlanSetup
|
|
[HttpGet("getEmployeeWorkPlanSetupById/{id}")]
|
|
public ActionResult GetEmployeeWorkPlanSetupById(int id)
|
|
{
|
|
EmployeeWorkPlanSetup item = new EmployeeWorkPlanSetup();
|
|
try
|
|
{
|
|
item = _employeeWorkPlanSetupService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupByEmpId/{empId}")]
|
|
public ActionResult GetEmployeeWorkPlanSetupByEmpId(int empId)
|
|
{
|
|
EmployeeWorkPlanSetup item = new EmployeeWorkPlanSetup();
|
|
try
|
|
{
|
|
item = _employeeWorkPlanSetupService.Get(empId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupList")]
|
|
public ActionResult GetEmployeeWorkPlanSetupList(int empId)
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost("IsEmpExistInWorkplan")]
|
|
public ActionResult IsEmpExistInWorkplan(List<SearchEmployee> empworkPlans)
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.IsEmpExistInWorkplan(empworkPlans,
|
|
(int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupByWorkPlanGroup/{type}")]
|
|
public ActionResult GetEmployeeWorkPlanSetupByWorkPlanGroup(EnumWorkPlanGroup type)
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.Get(type);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupForFixedWP/{groupId}/{holiday}")]
|
|
public ActionResult GetEmployeeWorkPlanSetupForFixedWP(int groupId, DayOfWeek holiday)
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.GetForFixedWP(groupId, holiday);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getNotYetAssiged")]
|
|
public ActionResult getNotYetAssiged()
|
|
{
|
|
//List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
List<Employee> items = new List<Employee>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
try
|
|
{
|
|
//items = _employeeWorkPlanSetupService.NotYetAssigned((int)currentUser.PayrollTypeID);
|
|
items = _employeeService.NotYetAssigned((int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupByWPGroupID/{groupId}")]
|
|
public ActionResult GetEmployeeWorkPlanSetupByWPGroupID(int groupId)
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.GetByWPGroupID(groupId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("isEmployeeExistInWorkPlan/{empId}")]
|
|
public ActionResult isEmployeeExistInWorkPlan(int empId)
|
|
{
|
|
bool ans;
|
|
try
|
|
{
|
|
ans = _employeeWorkPlanSetupService.IsEmployeeExistInWorkplan(empId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("isEmployeeWorkPlanSetupExist/{groupId}/{weekendOn}")]
|
|
public ActionResult IsEmployeeWorkPlanSetupExist(int groupId, DayOfWeek weekendOn)
|
|
{
|
|
bool ans;
|
|
try
|
|
{
|
|
ans = _employeeWorkPlanSetupService.IsExist(groupId, weekendOn);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
|
|
[HttpGet("getEmployeeWorkPlanSetupByPayrollTypeID")]
|
|
public ActionResult GetEmployeeWorkPlanSetupByWPGroupID()
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.GetByPayrollTypeID(payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAllEmployeeWorkPlanSetup")]
|
|
public ActionResult GetAllEmployeeWorkPlanSetup()
|
|
{
|
|
List<EmployeeWorkPlanSetup> items = new List<EmployeeWorkPlanSetup>();
|
|
try
|
|
{
|
|
items = _employeeWorkPlanSetupService.GetAll();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveEmployeeWorkPlanSetup")]
|
|
public ActionResult SaveEmployeeWorkPlanSetup(EmployeeWorkPlanSetup item)
|
|
{
|
|
int ans;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
ans = _employeeWorkPlanSetupService.Save(item, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveEmployeeWorkPlanSetupList")]
|
|
public ActionResult SaveEmployeeWorkPlanSetupList(List<EmployeeWorkPlanSetup> EmployeeWorkPlanSetups)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
int loggedInId = currentUser.UserID;
|
|
try
|
|
{
|
|
foreach (EmployeeWorkPlanSetup employeeWorkPlanSetup in EmployeeWorkPlanSetups)
|
|
{
|
|
if (employeeWorkPlanSetup.WorkPlanGroupType != EnumWorkPlanGroup.Fixed)
|
|
{
|
|
DateTime targetDate = employeeWorkPlanSetup.StartDate.AddDays(6);
|
|
int nShiftInterval = 7;
|
|
TimeSpan st = targetDate - employeeWorkPlanSetup.StartDate;
|
|
int dayCount = st.Days;
|
|
int nCircleDay = (dayCount % nShiftInterval);
|
|
int dayCycle = nShiftInterval - nCircleDay - 1;
|
|
if (dayCycle == 0)
|
|
employeeWorkPlanSetup.WeekEndOn = employeeWorkPlanSetup.StartDate.DayOfWeek;
|
|
else
|
|
employeeWorkPlanSetup.WeekEndOn = null;
|
|
|
|
}
|
|
}
|
|
|
|
EmployeeWorkPlanSetups.ForEach(x => x.CreatedBy = loggedInId);
|
|
_employeeWorkPlanSetupService.Save(EmployeeWorkPlanSetups, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveFixedWPlansList")]
|
|
public ActionResult SaveFixedWPlansList(List<EmployeeWorkPlanSetup> items)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
_employeeWorkPlanSetupService.SaveFixedWPlans(items, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteEmployeeWorkPlanSetupById")]
|
|
public ActionResult DleteEmployeeWorkPlanSetupById(EmployeeWorkPlanSetup item)
|
|
{
|
|
try
|
|
{
|
|
_employeeWorkPlanSetupService.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("deleteEmployeeWorkPlanSetupByGroupId")]
|
|
public ActionResult DeleteEmployeeWorkPlanSetupByGroupId(EmployeeWorkPlanSetup item)
|
|
{
|
|
try
|
|
{
|
|
_employeeWorkPlanSetupService.Delete(item.WorkPlanGroupID, DayOfWeek.Saturday);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
// ShiftRotation
|
|
[HttpGet("getShiftRotationById/{id}")]
|
|
public ActionResult GetShiftRotationById(int id)
|
|
{
|
|
ShiftRotation item = new ShiftRotation();
|
|
try
|
|
{
|
|
item = _shiftRotationService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getShiftRotationByWorkPlanGroupType/{workPlanGroupType}")]
|
|
public ActionResult GetShiftRotationByWorkPlanGroupType(EnumWorkPlanGroup workPlanGroupType)
|
|
{
|
|
List<ShiftRotation> items = new List<ShiftRotation>();
|
|
try
|
|
{
|
|
items = _shiftRotationService.Get(workPlanGroupType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getShiftRotationByWorkPlanGroup/{workPlanGroup}")]
|
|
public ActionResult GetShiftRotationByWorkPlanGroup(EnumWorkPlanGroup workPlanGroup)
|
|
{
|
|
List<ShiftRotation> items = new List<ShiftRotation>();
|
|
try
|
|
{
|
|
items = _shiftRotationService.Get(workPlanGroup);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getShiftRotationByStatus/{status}")]
|
|
public ActionResult GetShiftRotationByStatus(EnumStatus status)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
List<ShiftRotation> items = new List<ShiftRotation>();
|
|
try
|
|
{
|
|
items = _shiftRotationService.Get(status, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getShiftRotationByWorkGroupType/{workPlanGroupType}/{sequence}")]
|
|
public ActionResult GetShiftRotationByWorkGroupType(EnumWorkPlanGroup workPlanGroup, int sequence)
|
|
{
|
|
ShiftRotation item = new ShiftRotation();
|
|
try
|
|
{
|
|
item = _shiftRotationService.Get(workPlanGroup, sequence);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveShiftRotation")]
|
|
public ActionResult SaveShiftRotation(ShiftRotation item)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
|
|
try
|
|
{
|
|
_shiftRotationService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteShiftRotationById")]
|
|
public ActionResult DeleteShiftRotationById(ShiftRotation item)
|
|
{
|
|
try
|
|
{
|
|
_shiftRotationService.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost("getDailyAttnProcessByEmp")]
|
|
public ActionResult getDailyAttnProcessByEmp(dynamic data)
|
|
{
|
|
List<DailyAttnProcess> attnProcesses = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string empids = "";
|
|
DateTime attnDate = DateTime.Today;
|
|
foreach (var item in items)
|
|
{
|
|
int empID = (int)item["employeeid"].ToObject<int>();
|
|
empids = empids + empID.ToString() + ",";
|
|
attnDate = (DateTime)item["attnDate"].ToObject<DateTime>();
|
|
}
|
|
|
|
if (empids.Length > 0)
|
|
{
|
|
empids = empids.Substring(0, empids.Length - 1);
|
|
}
|
|
|
|
attnDate = new DateTime(attnDate.Year, attnDate.Month, attnDate.Day);
|
|
attnProcesses = this._dailyAttnProcessService.Get(empids, attnDate, attnDate);
|
|
// removed by shamim, please talk to him if needed this
|
|
//foreach(DailyAttnProcess process in attnProcesses)
|
|
//{
|
|
// process.ActualInOutTime = (process.ActualInTime == null ? (process.InTime == null ? "" : process.InTime.Value.ToString("hh:mm tt")) : process.ActualInTime.Value.ToString("hh:mm tt") )+ " - " + (process.ActualOutTime == null ? (process.OutTime == null ? "" : process.OutTime.Value.ToString("hh:mm tt")) : process.ActualOutTime.Value.ToString("hh:mm tt"));
|
|
//}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(attnProcesses);
|
|
}
|
|
|
|
// DailyAttnProcess
|
|
[HttpGet("getDailyAttnProcessByEmployeeId/{employeeId}")]
|
|
public ActionResult GetDailyAttnProcessByEmployeeId(int employeeId)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetByEmployeeID(employeeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getMonthJobCardByEmployeeId/{employeeId}/{attnMonth}")]
|
|
public ActionResult GetMonthJobCardByEmployeeId(int employeeId, string attnMonth)
|
|
{
|
|
JobCardReport jobCardReport = null;
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
DateTime dateTime = Convert.ToDateTime(attnMonth);
|
|
jobCardReport = _dailyAttnProcessService.GetMonthJobCardByEmployeeId(employeeId,
|
|
dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(), payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(jobCardReport);
|
|
}
|
|
|
|
|
|
[HttpGet("getMonthJobCardNewByEmployeeId/{employeeId}/{attnMonth}")]
|
|
public ActionResult GetMonthJobCardNewByEmployeeId(int employeeId, string attnMonth)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
DateTime dateTime = Convert.ToDateTime(attnMonth);
|
|
//jobCardReport = _dailyAttnProcessService.GetMonthJobCardNewByEmployeeId(employeeId,
|
|
//dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(), payrollTypeId);
|
|
bytes = new HRM.Report.AttendanceReport().ShowDateRangeJobCardMultiple(dateTime.FirstDateOfMonth(), dateTime.LastDateOfMonth(),
|
|
employeeId.ToString(), payrollTypeId, "EXCEL");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(bytes);
|
|
}
|
|
|
|
//[HttpGet("getDailyDataByStatusReport/{attnDate}/{sStatus}/{sEmpID}")]
|
|
//public ActionResult GetDailyDataByStatusReport(DateTime attnDate, string sStatus, string sEmpID)
|
|
//{
|
|
// List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
// try
|
|
// {
|
|
// DateTime dateTime = Convert.ToDateTime(attnDate);
|
|
// dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyDataByStatusReport(attnDate,
|
|
// sStatus, sEmpID);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok(dailyAttnByStatusReports);
|
|
//}
|
|
[HttpPost("getDateRangeWiseDataByStatusReport")]
|
|
public ActionResult GetDateRangeWiseDataByStatusReport(dynamic data)
|
|
{
|
|
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|
string sStatus = (string)items["status"].ToObject<string>();
|
|
try
|
|
{
|
|
dailyAttnByStatusReports = _dailyAttnProcessService.GetDateRangeWiseDataByStatusReport(fromDate, toDate,
|
|
sStatus, sEmpID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnByStatusReports);
|
|
}
|
|
|
|
[HttpPost("getDailyDataByStatusReport")]
|
|
public ActionResult GetDailyDataByStatusReport(dynamic data)
|
|
{
|
|
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
|
|
string sStatus = (string)items["status"].ToObject<string>();
|
|
try
|
|
{
|
|
dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyDataByStatusReport(attnDate,
|
|
sStatus, sEmpID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnByStatusReports);
|
|
}
|
|
|
|
[HttpPost("getDataByStatusReport")]
|
|
public ActionResult GetDataByStatusReport(dynamic data)
|
|
{
|
|
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|
string sStatus = (string)items["status"].ToObject<string>();
|
|
try
|
|
{
|
|
dailyAttnByStatusReports = _dailyAttnProcessService.GetDataByStatusReport(fromDate, toDate,
|
|
sStatus, sEmpID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnByStatusReports);
|
|
}
|
|
|
|
[HttpPost("getDailyOddDataByStatusReport")]
|
|
public ActionResult GetDailyOddDataByStatusReport(dynamic data)
|
|
{
|
|
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
|
|
try
|
|
{
|
|
dailyAttnByStatusReports = _dailyAttnProcessService.GetDailyOddDataByStatusReport(attnDate,
|
|
sEmpID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnByStatusReports);
|
|
}
|
|
|
|
[HttpPost("getDateWiseAttnRecords")]
|
|
public ActionResult GetDateWiseAttnRecords(dynamic data)
|
|
{
|
|
List<DailyAttnByStatusReport> dailyAttnByStatusReports = new List<DailyAttnByStatusReport>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime attnDate = (DateTime)items["attnDate"].ToObject<DateTime>();
|
|
try
|
|
{
|
|
dailyAttnByStatusReports = _dailyAttnProcessService.GetDateWiseAttnRecords(attnDate,
|
|
sEmpID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnByStatusReports);
|
|
}
|
|
|
|
[HttpPost("getDailyAttnProcessByWFStatus")]
|
|
public ActionResult GetDailyAttnProcessByWFStatus(dynamic data)
|
|
{
|
|
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
|
|
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|
EnumWFAttnStatus status = (EnumWFAttnStatus)Convert.ToInt16(items["status"].ToObject<string>());
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if (string.IsNullOrEmpty(sEmpID) || sEmpID == "0")
|
|
{
|
|
sEmpID = currentUser.EmployeeID.ToString();
|
|
}
|
|
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
dailyAttnProcess = _dailyAttnProcessService.GetAttnDataByWFStatus(fromDate, toDate, sEmpID, status);
|
|
attendanceRegularizationDTOs =
|
|
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcess, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(attendanceRegularizationDTOs);
|
|
}
|
|
|
|
[HttpGet("getMyNotSubmittedAbsentList")]
|
|
public ActionResult getMyNotSubmittedAbsentList()
|
|
{
|
|
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
dailyAttnProcess = _dailyAttnProcessService.getMyNotSubmittedAbsentList((int)currentUser.EmployeeID);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnProcess);
|
|
}
|
|
|
|
|
|
[HttpGet("getMyTeamNotApprovedList")]
|
|
public ActionResult getMyTeamNotApprovedList()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
DataTable olist = null;
|
|
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
olist = _dailyAttnProcessService.getMyTeamNotApprovedList((int)currentUser.EmployeeID);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(olist);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Team Summary grid + Absent-vs-Late trend for the logged-in line
|
|
/// manager. Both come back from one execution of
|
|
/// usp_EmployeeAttendanceLeaveSummaryLM.
|
|
/// </summary>
|
|
[HttpGet("getTeamAttendanceLeaveSummary/{fromDate}/{toDate}/{trendMonths}")]
|
|
public ActionResult GetTeamAttendanceLeaveSummary(string fromDate, string toDate, int trendMonths)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
TeamAttendanceSummaryResult item = null;
|
|
|
|
try
|
|
{
|
|
DateTime dFromDate = Convert.ToDateTime(fromDate);
|
|
DateTime dToDate = Convert.ToDateTime(toDate);
|
|
|
|
item = _dailyAttnProcessService.GetTeamAttendanceLeaveSummary((int)currentUser.EmployeeID,dFromDate, dToDate, trendMonths);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
|
|
[HttpGet("getMyTeamAbsentAndLeaveList/{frommonth}/{tomonth}")]
|
|
public ActionResult getMyTeamAbsentAndLeaveList(string frommonth, string tomonth)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
DataTable olist = null;
|
|
DateTime ddate = GlobalFunctions.FirstDateOfMonth(Convert.ToDateTime(frommonth));
|
|
DateTime dtomonth = GlobalFunctions.LastDateOfMonth(Convert.ToDateTime(tomonth));
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
|
|
try
|
|
{
|
|
olist = _dailyAttnProcessService.getMyTeamAbsentAndLeaveList((int)currentUser.EmployeeID
|
|
, GlobalFunctions.FirstDateOfMonth(ddate), GlobalFunctions.LastDateOfMonth(dtomonth));
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(olist);
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("getDailyAttnProcessByEmpIdandWFStatus")]
|
|
public ActionResult GetDailyAttnProcessByEmpIdandWFStatus(dynamic data)
|
|
{
|
|
List<DailyAttnProcess> dailyAttnProcess = new List<DailyAttnProcess>();
|
|
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string sEmpID = (string)items["empIds"].ToObject<string>();
|
|
EnumWFAttnStatus status = (EnumWFAttnStatus)Convert.ToInt16(items["status"].ToObject<string>());
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
if (string.IsNullOrEmpty(sEmpID) || sEmpID == "0")
|
|
{
|
|
sEmpID = currentUser.EmployeeID.ToString();
|
|
}
|
|
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
dailyAttnProcess = _dailyAttnProcessService.GetAttnDataByWFStatus(sEmpID, status);
|
|
attendanceRegularizationDTOs =
|
|
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcess, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(attendanceRegularizationDTOs);
|
|
}
|
|
|
|
[HttpPost("updateAttendanceRegularization")]
|
|
public ActionResult UpdateAttendanceRegularization(DailyAttnProcess pDailyAttnProcess)
|
|
{
|
|
List<DailyAttnProcess> regularizableAttnData = new List<DailyAttnProcess>();
|
|
regularizableAttnData.Add(pDailyAttnProcess);
|
|
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Save(regularizableAttnData, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
Thread CheckOutFixedPositionThread = new Thread(() =>
|
|
_dailyAttnProcessService.SendRegularizationApplicationMail(currentUser.UserID, pDailyAttnProcess, _emailSettings.Value));
|
|
CheckOutFixedPositionThread.Start();
|
|
|
|
//try
|
|
//{
|
|
// // send mail to LM
|
|
// _dailyAttnProcessService.SendRegularizationApplicationMail(pDailyAttnProcess, _emailSettings.Value);
|
|
//}
|
|
//catch (Exception e)
|
|
//{
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
|
|
//}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
[HttpPost("updateAttendanceRegularizationForApprove")]
|
|
public ActionResult UpdateAttendanceRegularizationForApprove(DailyAttnProcess item)
|
|
{
|
|
|
|
if (item == null)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "No Data Found to save");
|
|
}
|
|
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
item.LineManagerID = (int)currentUser.EmployeeID;
|
|
item.LMApproveDate = DateTime.Today;
|
|
if (item.ShiftID != null)
|
|
{
|
|
Shift oshift = new ShiftService().Get((int)item.ShiftID);
|
|
if (oshift != null)
|
|
{
|
|
new AttendanceProcess().CalculateLateAndDelay(item, oshift);
|
|
new AttendanceProcess().CalculateOverTime(item, oshift);
|
|
|
|
}
|
|
}
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
items.Add(item);
|
|
|
|
try
|
|
{
|
|
this._dailyAttnProcessService.ApproveAttnByLM(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
try
|
|
{
|
|
// send mail to Applier
|
|
_dailyAttnProcessService.SendRegularizationApprovalMail(currentUser.UserID, item, _emailSettings.Value);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("updateActingResponsibilitySetupForApprove")]
|
|
public ActionResult UpdateActingResponsibilitySetupForApprove(
|
|
ActingResponsibilitySetup actingResponsibilitySetup)
|
|
{
|
|
if (actingResponsibilitySetup == null)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "No Data Found to save");
|
|
}
|
|
|
|
ActingResponsibilitySetup dailyAttnProcess =
|
|
_actingResponsibilitySetupService.Get(actingResponsibilitySetup.ID);
|
|
if (dailyAttnProcess == null)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "No Previous Data Found to save");
|
|
}
|
|
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
actingResponsibilitySetup.ModifiedBy = currentUser.EmployeeID;
|
|
actingResponsibilitySetup.ModifiedDate = DateTime.Today;
|
|
_actingResponsibilitySetupService.Save(actingResponsibilitySetup);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpGet("getLastProcessDateByEmpId/{empId}")]
|
|
public ActionResult GetLastProcessDateByEmpId(int empId)
|
|
{
|
|
DateTime item;
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.GetLastProcessDateByEmpId(empId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getAttnSubmittedDataByDateRange/{empId}/{fromDate}/{toDate}")]
|
|
public ActionResult GetAttnSubmittedDataByDateRange(string empId, DateTime fromDate, DateTime toDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetAttnSubmittedData(empId, fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnSubmittedData/{empId}/{isCurrentMonth}")]
|
|
public ActionResult GetAttnSubmittedData(string empId, bool isCurrentMonth)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetAttnSubmittedData(empId, isCurrentMonth);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnDataByWFStatus/{empId}/{status}")]
|
|
public ActionResult GetAttnDataByWFStatus(string empId, EnumWFAttnStatus status)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetAttnDataByWFStatus(empId, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnDataByWFStatusCount/{empId}/{status}")]
|
|
public ActionResult GetAttnDataByWFStatusCount(string empId, EnumWFAttnStatus status)
|
|
{
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _dailyAttnProcessService.GetAttnDataByWFStatusCount(empId, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessById/{id}")]
|
|
public ActionResult GetDailyAttnProcessById(int id)
|
|
{
|
|
DailyAttnProcess item = new DailyAttnProcess();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByEmpId/{empId}/{attnDate}")]
|
|
public ActionResult GetDailyAttnProcessByEmpId(int empId, DateTime attnDate)
|
|
{
|
|
DailyAttnProcess item = new DailyAttnProcess();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.Get(empId, attnDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
|
|
[HttpGet("getDailyAttnProcessByWPG/{wpg}/{attnDate}")]
|
|
public ActionResult GetDailyAttnProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetProcessByWPG(wpg, attnDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByAttnDate/{attnDate}")]
|
|
public ActionResult GetDailyAttnProcessByAttnDate(DateTime attnDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(attnDate, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("getDailyAttnManualProcess/{attnDate}")]
|
|
public ActionResult GetDailyAttnManualProcess(DateTime attnDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetManualProcess(attnDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
//internal static IDataReader GetTeamForAttenReguApprove(TransactionContext tc, int employeeid, EnumStatus enumStatus)
|
|
//{
|
|
// return tc.ExecuteReader(@"SELECT DISTINCT e.EmployeeID, EmployeeNo, e.Name, e.categoryID, e.GradeID,
|
|
// LocationID, d.name as DesignationName, g.DESCRIPTION GradeName, dept.DESCRIPTION DepartmentName From Employee e
|
|
// left join designation d on d.DESIGNATIONID = e.DESIGNATIONID
|
|
// LEFT JOIN DEPARTMENT dept ON dept.DEPARTMENTID = e.DEPARTMENTID
|
|
// LEFT JOIN GRADES g ON g.GRADEID = e.GRADEID
|
|
// LEFT JOIN DAILYATTNPROCESS dap ON dap.EMPLOYEEID = e.EMPLOYEEID
|
|
// WHERE dap.WFStatus = 1 AND e.linemanagerid =%n and e.status = %n", employeeid, (int)enumStatus);
|
|
//}
|
|
|
|
[HttpGet("getDailyAttnProcessByEmpIdAndDateRange/{empId}/{sFromDate}/{sToDate}")]
|
|
public ActionResult GetDailyAttnProcessByEmpIdAndDateRange(int empId, string sFromDate, string sToDate)
|
|
{
|
|
List<AttendanceRegularizationDTO> attendanceRegularizationDTOs = new List<AttendanceRegularizationDTO>();
|
|
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
if (empId == 0)
|
|
{
|
|
empId = (int)currentUser.EmployeeID;
|
|
}
|
|
|
|
try
|
|
{
|
|
DateTime fromDate = Convert.ToDateTime(sFromDate);
|
|
DateTime toDate = Convert.ToDateTime(sToDate);
|
|
dailyAttnProcesses = _dailyAttnProcessService.Get(empId, fromDate, toDate);
|
|
attendanceRegularizationDTOs =
|
|
AttendanceProcess.GetNotSubmittedAttnData(dailyAttnProcesses, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(attendanceRegularizationDTOs);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByDateRangeEss/{empId}/{sFromDate}/{sToDate}")]
|
|
public ActionResult GetDailyAttnProcessByDateRangeEss(int empId, string sFromDate, string sToDate)
|
|
{
|
|
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
if (empId == 0)
|
|
{
|
|
empId = (int)currentUser.EmployeeID;
|
|
}
|
|
|
|
try
|
|
{
|
|
DateTime fromDate = Convert.ToDateTime(sFromDate);
|
|
DateTime toDate = Convert.ToDateTime(sToDate);
|
|
dailyAttnProcesses = _dailyAttnProcessService.Get(empId, fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnProcesses);
|
|
}
|
|
|
|
|
|
[HttpGet("getRegularizableAttendance/{empId}/{sFromDate}/{sToDate}")]
|
|
public ActionResult getRegularizableAttendance(int empId, string sFromDate, string sToDate)
|
|
{
|
|
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
if (empId == 0)
|
|
{
|
|
empId = (int)currentUser.EmployeeID;
|
|
}
|
|
|
|
try
|
|
{
|
|
DateTime fromDate = Convert.ToDateTime(sFromDate);
|
|
DateTime toDate = Convert.ToDateTime(sToDate);
|
|
dailyAttnProcesses = _dailyAttnProcessService.GetRegularizableAttn(empId, fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dailyAttnProcesses);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessBysEmpIdAndDateRange/{empId}/{fromDate}/{toDate}")]
|
|
public ActionResult GetDailyAttnProcessBysEmpIdAndDateRange(string empId, string fromDate, string toDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
DateTime dfromDate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime dtoDate = GlobalFunctions.GetApiDefaultDateData(toDate);
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(Convert.ToInt32(empId), dfromDate, dtoDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByDateRange/{fromDate}/{toDate}")]
|
|
public ActionResult GetDailyAttnProcessByDateRange(DateTime fromDate, DateTime toDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByAttnDateAndShiftId/{attnDate}/{shiftId}/{attnType}")]
|
|
public ActionResult GetDailyAttnProcessByAttnDateAndShiftId(DateTime attnDate, int shiftId,
|
|
EnumAttendanceType attnType)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(attnDate, shiftId, attnType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyEmployeeAbsentById/{id}/{date}")]
|
|
public ActionResult GetDailyEmployeeAbsentById(int id, DateTime date)
|
|
{
|
|
DailyAttnProcess item = new DailyAttnProcess();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.GetDailyEmployeeAbsent(id, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnWhereOutTimeIsNull/{attnDate}/{shiftId}")]
|
|
public ActionResult GetDailyAttnWhereOutTimeIsNull(DateTime attnDate, int shiftId)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetWhrOutTimeIsNull(attnDate, shiftId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getEmployeesFirstAttendances/{employeeIds}")]
|
|
public ActionResult getEmployeesFirstAttendances(string employeeIds)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetEmployeesFirstAttendances(employeeIds);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getLastProcessDate")]
|
|
public ActionResult GetLastProcessDate()
|
|
{
|
|
DateTime item = new DateTime();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.GetLastProcessDate();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet(
|
|
"getDailyAttnProcessByEmpIdAndShiftIdAndDateRange/{empId}/{shiftId}/{fromDate}/{toDate}/{attendanceType}")]
|
|
public ActionResult GetDailyAttnProcessByEmpIdAndShiftIdAndDateRange(int empId, int shiftId, DateTime fromDate,
|
|
DateTime toDate, EnumAttendanceType attendanceType)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(empId, shiftId, fromDate, toDate, attendanceType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnProcessByAttnDateAndEmpIds/{attnDate}/{empIds}")]
|
|
public ActionResult GetDailyAttnProcessByAttnDateAndEmpIds(DateTime attnDate, string empIds)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(attnDate, empIds, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnDataByWFStatusCountByDateRange/{fromDate}/{toDate}/{status}")]
|
|
public ActionResult GetAttnDataByWFStatusCountByDateRange(DateTime fromDate, DateTime toDate,
|
|
EnumWFAttnStatus status)
|
|
{
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _dailyAttnProcessService.GetAttnDataByWFStatusCount(fromDate, toDate, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnBySalaryMonth/{salaryMonth}")]
|
|
public ActionResult GetDailyAttnBySalaryMonth(DateTime salaryMonth)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetBySalaryMonth(salaryMonth, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnByStatusAndDateRange/{empId}/{fromDate}/{toDate}/{status}")]
|
|
public ActionResult GetDailyAttnByStatusAndDateRange(int empId, DateTime fromDate, DateTime toDate,
|
|
string status)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetByStatus(empId, fromDate, toDate, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnByStatusAndDateRangeAndsEmpId/{empId}/{fromDate}/{toDate}/{status}")]
|
|
public ActionResult getDailyAttnByStatusAndDateRangeAndsEmpId(string empId, DateTime fromDate, DateTime toDate,
|
|
EnumClaimWFStatus status)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.Get(empId, fromDate, toDate, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnLastProcessDate")]
|
|
public ActionResult GetDailyAttnLastProcessDate()
|
|
{
|
|
DateTime item = new DateTime();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.GetLastProcessDate();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpGet("getDailyAttnManualProcessByAttnDate/{attnDate}")]
|
|
public ActionResult GetDailyAttnManualProcessByAttnDate(DateTime attnDate)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetManualProcess(attnDate, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAttnDataByWFStatusByProcessId/{dailyAttnProcessId}/{status}")]
|
|
public ActionResult GetAttnDataByWFStatusByProcessId(int dailyAttnProcessId, EnumWFAttnStatus status)
|
|
{
|
|
DailyAttnProcess item = new DailyAttnProcess();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|
try
|
|
{
|
|
item = _dailyAttnProcessService.GetAttnDataByWFStatus(dailyAttnProcessId, status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveDailyAttnProcess")]
|
|
public ActionResult SaveDailyAttnProcess(DailyAttnProcess item)
|
|
{
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Save(new List<DailyAttnProcess>() { item }, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("RejectAttnStatusByLM")]
|
|
public ActionResult RejectAttnStatusByLM(DailyAttnProcess process)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
_dailyAttnProcessService.RejectAttnStatusByLM(process.EmployeeID, process.AttnDate, (int)currentUser.EmployeeID, process.LMRemarks, process.Comments);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
try
|
|
{
|
|
// send mail to Applier
|
|
_dailyAttnProcessService.SendRegularizationApprovalMail(currentUser.UserID, process, _emailSettings.Value);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "Successfully Regularized. But could not send mail.");
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[Route("save")]
|
|
public ActionResult Save(List<DailyAttnProcess> item)
|
|
{
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Save(item, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saverawdata")]
|
|
public ActionResult SaveRawData(List<AttnRawData> items)
|
|
{
|
|
try
|
|
{
|
|
//List<AttnRawData> items = new List<AttnRawData>();
|
|
//items = JsonConvert.DeserializeObject<List<AttnRawData>>(data.dataList.ToString());
|
|
_attnRawDataService.SaveAuto(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpGet("getrawdata/{fromDate}/{toDate}/{empIDs}")]
|
|
public ActionResult GetHolidaysByDateRange(DateTime fromDate, DateTime toDate, string empIDs)
|
|
{
|
|
empIDs = (empIDs == "null" || empIDs == "undefined") ? null : empIDs;
|
|
DateTime end = toDate.AddDays(1).AddSeconds(-1);
|
|
List<Employee> employees = new EmployeeService().GetAllEmps();
|
|
List<AttnRawData> items = new List<AttnRawData>();
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
items = _attnRawDataService.Get(fromDate, end, empIDs, (int)currentUser.PayrollTypeID);
|
|
foreach (var temp in items)
|
|
{
|
|
temp.EmployeeName = employees?.Where(x => x.ID == temp.EmployeeID)?.FirstOrDefault()?.Name;
|
|
temp.EmployeeNo = employees?.Where(x => x.ID == temp.EmployeeID)?.FirstOrDefault()?.EmployeeNo;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
//[HttpPost]
|
|
//[Route("saveDailyAttnProcessListWithCounterClock")]
|
|
//public ActionResult SaveDailyAttnProcessListWithCounterClock(List<DailyAttnProcess> items)
|
|
//{
|
|
// try
|
|
// {
|
|
// _dailyAttnProcessService.Save(items, true);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("UpdateManualEntry")]
|
|
public ActionResult UpdateManualEntry(List<DailyAttnProcess> items)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<Shift> oshifts = new ShiftService().Get(string.Empty, string.Empty,
|
|
EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
|
|
foreach (DailyAttnProcess item in items)
|
|
{
|
|
item.AttnDate = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day);
|
|
if (item.InTime != null)
|
|
item.InTime = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day,
|
|
((DateTime)item.InTime).Hour, ((DateTime)item.InTime).Minute, 0);
|
|
|
|
if (item.OutTime != null)
|
|
{
|
|
item.OutTime = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day,
|
|
((DateTime)item.OutTime).Hour, ((DateTime)item.OutTime).Minute, 0);
|
|
|
|
}
|
|
|
|
if (item.InTime != null && item.OutTime != null)
|
|
{
|
|
if (((DateTime)item.OutTime).Hour < ((DateTime)item.InTime).Hour)
|
|
{
|
|
DateTime tempDate = (DateTime)item.AttnDate.AddDays(1);
|
|
item.OutTime = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day,
|
|
((DateTime)item.OutTime).Hour, ((DateTime)item.OutTime).Minute, 0);
|
|
|
|
}
|
|
}
|
|
|
|
if (item.IsNew == true)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
new AttendanceProcess().CalculateLateAndDelay(item, oshifts);
|
|
|
|
//if(item.ShiftID !=null)
|
|
//{ var sft = oshifts.FirstOrDefault(x => x.ID == item.ShiftID);
|
|
// if(sft!=null)
|
|
// {
|
|
// new AttendanceProcess().CalulateOverTimeForMobileAttendance(item, sft);
|
|
|
|
// }
|
|
//}
|
|
}
|
|
|
|
try
|
|
{
|
|
_dailyAttnProcessService.ManualEditSave(items, (int)currentUser.PayrollTypeID, currentUser.UserID, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[Route("saveDailyAttnProcessList")]
|
|
public ActionResult SaveDailyAttnProcessList(List<DailyAttnProcess> items)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<Shift> oshifts = new ShiftService().Get(string.Empty, string.Empty,
|
|
EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
|
|
|
foreach (DailyAttnProcess item in items)
|
|
{
|
|
item.AttnDate = new DateTime(item.AttnDate.Year, item.AttnDate.Month, item.AttnDate.Day);
|
|
if (item.IsNew == true)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
new AttendanceProcess().CalculateLateAndDelay(item, oshifts);
|
|
}
|
|
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Save(items, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveDailyAttnProcessListAndAttnMonthlyBenefits")]
|
|
public ActionResult SaveDailyAttnProcessListAndAttnMonthlyBenefits(List<DailyAttnProcess> items)
|
|
{
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Save(items, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("deleteDailyAttnProcessById")]
|
|
public ActionResult DeleteDailyAttnProcessById(DailyAttnProcess item)
|
|
{
|
|
List<AttnMonthlyBenefit> attnMonthlyBenefits = new List<AttnMonthlyBenefit>();
|
|
bool IscounterClock = true;
|
|
try
|
|
{
|
|
_dailyAttnProcessService.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
//[HttpPost]
|
|
//[Route("updateLeave")]
|
|
//public ActionResult UpdateLeave(DailyAttnProcess item)
|
|
//{
|
|
// try
|
|
// {
|
|
// _dailyAttnProcessService.UpdateLeave(item.EmployeeID, 1, DateTime.Now, 1);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
//[HttpPost]
|
|
//[Route("saveForBridgeHoliday")]
|
|
//public ActionResult SaveForBridgeHoliday(List<DailyAttnProcess> items)
|
|
//{
|
|
// List<LeaveEntry> oLeaveEntrys = new List<LeaveEntry>();
|
|
// try
|
|
// {
|
|
// _dailyAttnProcessService.SaveForBridgeHoliday(items, oLeaveEntrys);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
//[HttpPost]
|
|
//[Route("saveAutoForLmApproved")]
|
|
//public ActionResult SaveAutoForLmApproved(List<DailyAttnProcess> items)
|
|
//{
|
|
// List<AttnMonthlyBenefit> oAtnMonthlyBenifits = new List<AttnMonthlyBenefit>();
|
|
// AttnProcessRunSummary oAttnRunSummary = new AttnProcessRunSummary();
|
|
// try
|
|
// {
|
|
// _dailyAttnProcessService.SaveAutoForLmApproved(items, oAtnMonthlyBenifits, oAttnRunSummary);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
[HttpPost]
|
|
//[Route("saveAutoDailyAttnProcess")]
|
|
//public ActionResult SaveAutoDailyAttnProcess(List<DailyAttnProcess> items)
|
|
//{
|
|
// List<AttnMonthlyBenefit> oAtnMonthlyBenifits = new List<AttnMonthlyBenefit>();
|
|
// AttnProcessRunSummary oAttnRunSummary = new AttnProcessRunSummary();
|
|
// try
|
|
// {
|
|
// _dailyAttnProcessService.SaveAuto(items, oAtnMonthlyBenifits, oAttnRunSummary);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
// }
|
|
|
|
// return Ok();
|
|
//}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("dailyAttnProcessManual")]
|
|
public ActionResult dailyAttnProcessManual(dynamic processItems)
|
|
{
|
|
DateTime fromDate = DateTime.Today;
|
|
DateTime toDate = DateTime.Today;
|
|
bool withoutEmployee = true;
|
|
List<SearchEmployee> emps = null;
|
|
List<Employee> employees = null;
|
|
int empid;
|
|
int count = 0;
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(processItems));
|
|
foreach (var item in items)
|
|
{
|
|
fromDate = (DateTime)item["fromDate"].ToObject<DateTime>();
|
|
toDate = (DateTime)item["toDate"].ToObject<DateTime>();
|
|
withoutEmployee = (bool)item["isWithEmployee"].ToObject<bool>();
|
|
if (withoutEmployee == true) break;
|
|
if (withoutEmployee == false && emps == null)
|
|
emps = new List<SearchEmployee>();
|
|
empid = (int)item["employeeID"].ToObject<int>();
|
|
SearchEmployee emp = new SearchEmployee();
|
|
emp.EmployeeID = empid;
|
|
emps.Add(emp);
|
|
}
|
|
if (withoutEmployee == false)
|
|
{
|
|
employees = new EmployeeService().GetByEmpIDs(SearchEmployee.getEmpID(emps),
|
|
(int)currentUser.PayrollTypeID);
|
|
count++;
|
|
}
|
|
|
|
for (DateTime attDate = fromDate; attDate <= toDate; attDate = attDate.AddDays(1))
|
|
{
|
|
new AttendanceProcess().Process(new DateTime(attDate.Year, attDate.Month, attDate.Day),
|
|
EnumProcessMode.Manual, (int)currentUser.PayrollTypeID, currentUser.UserID, employees);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("BenifitProcess")]
|
|
public ActionResult BenifitProcess(dynamic processItems)
|
|
{
|
|
List<SalaryProcessStatus> items = new List<SalaryProcessStatus>();
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
items = new AttendanceProcess().BenifitProcess(currentUser.UserID, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
// EmployeeOutsideDuty
|
|
[HttpGet("getAllEmployeeOutsideDuties")]
|
|
public ActionResult GetAllEmployeeOutsideDuties()
|
|
{
|
|
List<EmployeeOutsideDuty> items = new List<EmployeeOutsideDuty>();
|
|
try
|
|
{
|
|
items = _employeeOutsideDutyService.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getOutsideDutiesByEmployeeId/{empId}")]
|
|
public ActionResult getOutsideDutiesByEmployeeId(int empId)
|
|
{
|
|
List<EmployeeOutsideDutyDetails> items = new List<EmployeeOutsideDutyDetails>();
|
|
try
|
|
{
|
|
items = _employeeOutsideDutyService.GetByEmpIdDetails(empId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveEmployeeOutsideDuty")]
|
|
public ActionResult SaveEmployeeOutsideDuty(EmployeeOutsideDuty item)
|
|
{
|
|
int ans = 0;
|
|
try
|
|
{
|
|
ans = _employeeOutsideDutyService.Save(item);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("SaveMontlhyWorkPlan")]
|
|
public ActionResult SaveMontlhyWorkPlan(List<MonthlyWorkPlan> items)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
items.ForEach(x =>
|
|
{
|
|
x.payrollTypeID = (int)currentUser.PayrollTypeID;
|
|
x.CreatedBy = currentUser.UserID;
|
|
x.CreatedDate = DateTime.Today;
|
|
});
|
|
|
|
try
|
|
{
|
|
this._monthyWorkPlan.Save(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("DeleteMontlhyWorkPlan/{FromDate}/{ToDate}")]
|
|
public ActionResult DeleteMontlhyWorkPlan(DateTime fromDate, DateTime toDate)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
this._monthyWorkPlan.Delete(fromDate, toDate, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("DeleteOnwardMonthyworkPlan/{fromMonth}")]
|
|
public ActionResult DeleteOnwardMonthyworkPlan(DateTime fromMonth)
|
|
{
|
|
fromMonth = GlobalFunctions.FirstDateOfMonth(fromMonth);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
this._monthyWorkPlan.DeleteOnward(fromMonth, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("GetWorkPlan/{MonthDate}")]
|
|
public ActionResult GetWorkPlan(DateTime MonthDate)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<MonthlyWorkPlan> items = null;
|
|
try
|
|
{
|
|
items = this._monthyWorkPlan.Get(MonthDate, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("GetWorkPlanByDate/{FromDate}/{toDate}")]
|
|
public ActionResult GetWorkPlanByDate(DateTime MonthDate, DateTime toDate)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<MonthlyWorkPlan> items = null;
|
|
try
|
|
{
|
|
items = this._monthyWorkPlan.Get(MonthDate, toDate, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("RefreshMonthlyWorkplan/{monthDate}")]
|
|
public ActionResult RefreshMonthlyWorkplan(string monthDate)
|
|
{
|
|
DateTime fdate = GlobalFunctions.FirstDateOfMonth(GlobalFunctions.GetApiDefaultDateData(monthDate));
|
|
DateTime tdate = GlobalFunctions.LastDateOfMonth(fdate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<MonthlyWorkPlan> items = null;
|
|
try
|
|
{
|
|
items = this._monthyWorkPlan.RefreshMonthlyWorkplan(fdate, tdate, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("UpdateMonthlyWorkplan")]
|
|
public ActionResult UpdateMonthlyWorkplan(MonthlyWorkPlan mworkPlan)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
mworkPlan.payrollTypeID = (int)currentUser.PayrollTypeID;
|
|
List<MonthlyWorkPlan> items = null;
|
|
try
|
|
{
|
|
this._monthyWorkPlan.UpdateShiftAndRoster(mworkPlan);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("GetRosterTable")]
|
|
public ActionResult GetRosterTable(List<MonthlyWorkPlan> monthyPlans)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<WorkPlanGroup> groups = this._workPlanGroupService.Get(EnumStatus.Regardless,
|
|
(int)currentUser.PayrollTypeID, string.Empty, null);
|
|
List<Shift> oshifts = this._shiftService.Get(string.Empty, string.Empty, EnumStatus.Regardless,
|
|
(int)currentUser.PayrollTypeID);
|
|
DataTable table = new DataTable("RosterCanlender");
|
|
table.Columns.Add("Date");
|
|
groups.ForEach(x => { table.Columns.Add(new DataColumn(x.Name)); });
|
|
try
|
|
{
|
|
DateTime fromDAte = monthyPlans[0].WorkDate;
|
|
DateTime toDAte = monthyPlans[monthyPlans.Count - 1].WorkDate;
|
|
for (DateTime dDate = fromDAte; dDate <= toDAte; dDate = dDate.AddDays(1))
|
|
{
|
|
DataRow row = table.NewRow();
|
|
row["Date"] = dDate.ToString("dd MMM");
|
|
table.Rows.Add(row);
|
|
}
|
|
|
|
int nindex = -1;
|
|
for (DateTime dDate = fromDAte; dDate <= toDAte; dDate = dDate.AddDays(1))
|
|
{
|
|
nindex = nindex + 1;
|
|
foreach (WorkPlanGroup wg in groups)
|
|
{
|
|
MonthlyWorkPlan oplan = monthyPlans.FirstOrDefault(x => x.WorkDate == dDate
|
|
&& x.WorkPlanGroupID == wg.ID);
|
|
if (oplan != null)
|
|
{
|
|
if (oplan.Type == EnumWorkPlanDayType.WorkingDay)
|
|
{
|
|
Shift oshift = oshifts.FirstOrDefault(x => x.ID == oplan.ShiftID);
|
|
if (oshift != null)
|
|
{
|
|
table.Rows[nindex][wg.Name] = oshift.ShortName;
|
|
}
|
|
}
|
|
else if (oplan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|
{
|
|
table.Rows[nindex][wg.Name] = "WH";
|
|
}
|
|
else
|
|
{
|
|
table.Rows[nindex][wg.Name] = "NH";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(table);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("GetLastSavedWorkDate")]
|
|
public ActionResult GetLastSavedWorkDate()
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
DateTime ddate;
|
|
try
|
|
{
|
|
ddate = this._monthyWorkPlan.GetLastSavedWorkDate((int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
string sdata = "";
|
|
if (ddate != DateTime.MinValue)
|
|
sdata = ddate.ToString("dd MMM yyyy");
|
|
return Ok(sdata);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("deleteEmployeeOutsideDuty")]
|
|
public ActionResult DeleteEmployeeOutsideDuty(EmployeeOutsideDuty item)
|
|
{
|
|
try
|
|
{
|
|
_employeeOutsideDutyService.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("getActingResponsiblityByEmpID/{fromDate}/{ToDate}/{empid}")]
|
|
public ActionResult getActingResponsiblityByEmpID(string fromDate, string ToDate, int empid)
|
|
{
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<ActingResponsibilitySetup> items = null;
|
|
try
|
|
{
|
|
items = this._actingResponsiblity.GetByEmpID(fdate, tdate, empid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getActingResponsiblityByEmpIDAndStatus/{fromDate}/{ToDate}/{empid}/{wfStatus}")]
|
|
public ActionResult GetActingResponsiblityByEmpIDAndStatus(string fromDate, string ToDate, int empid,
|
|
int wfStatus)
|
|
{
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<ActingResponsibilitySetup> items = null;
|
|
try
|
|
{
|
|
items = this._actingResponsiblity.Get(fdate, tdate, empid, (EnumClaimWFStatus)wfStatus);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getActingResponsiblityForApprove/{fromDate}/{ToDate}/{wfStatus}")]
|
|
public ActionResult GetActingResponsiblityForApprove(string fromDate, string ToDate, int wfStatus)
|
|
{
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<ActingResponsibilitySetup> items = null;
|
|
try
|
|
{
|
|
items = this._actingResponsiblity.GetForApprove(fdate, tdate, (int)currentUser.EmployeeID,
|
|
(EnumClaimWFStatus)wfStatus);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getActingResponsiblity/{fromDate}/{ToDate}")]
|
|
public ActionResult getActingResponsiblityByEmpID(string fromDate, string ToDate)
|
|
{
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(fromDate);
|
|
DateTime tdate = GlobalFunctions.GetApiDefaultDateData(ToDate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<ActingResponsibilitySetup> items = null;
|
|
try
|
|
{
|
|
items = this._actingResponsiblity.Get(fdate, tdate, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getOnWardActingResponsiblity/{fromDate}/{empid}")]
|
|
public ActionResult getOnWardActingResponsiblity(string monthFromDate, int empid)
|
|
{
|
|
DateTime fdate = GlobalFunctions.GetApiDefaultDateData(monthFromDate);
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
List<ActingResponsibilitySetup> items = null;
|
|
try
|
|
{
|
|
items = this._actingResponsiblity.GetOnwardByEmpID(fdate, empid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("SaveActingResponsiblities")]
|
|
public ActionResult SaveActingResponsiblities(List<ActingResponsibilitySetup> items)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
items.ForEach(item =>
|
|
{
|
|
if (item.IsNew == true)
|
|
{
|
|
item.CreatedBy = currentUser.UserID;
|
|
item.CreatedDate = DateTime.Today;
|
|
item.payrollTypeID = (int)currentUser.PayrollTypeID;
|
|
item.SalaryMonth = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
item.ModifiedBy = currentUser.UserID;
|
|
item.ModifiedDate = DateTime.Today;
|
|
}
|
|
});
|
|
try
|
|
{
|
|
this._actingResponsiblity.Save(items);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(true);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("DeleteActingResponsiblity")]
|
|
public ActionResult DeleteActingResponsiblity(ActingResponsibilitySetup item)
|
|
{
|
|
try
|
|
{
|
|
this._actingResponsiblity.Delete(item.ID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[Route("GetEmployeeRoster")]
|
|
public dynamic GetEmployeeRoster(dynamic paramData)
|
|
{
|
|
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(paramData));
|
|
string empids = "";
|
|
DateTime fromDate = DateTime.Today;
|
|
DateTime toDate = DateTime.Today;
|
|
bool isteam = false;
|
|
foreach (var item in items)
|
|
{
|
|
int empID = (int)item["employeeID"].ToObject<int>();
|
|
if (empID != 0)
|
|
empids = empids + empID.ToString() + ",";
|
|
fromDate = (DateTime)item["fromDate"].ToObject<DateTime>();
|
|
toDate = (DateTime)item["toDate"].ToObject<DateTime>();
|
|
|
|
isteam = (bool)item["isTeam"].ToObject<bool>();
|
|
|
|
}
|
|
|
|
if (empids.Length > 0)
|
|
{
|
|
empids = empids.Substring(0, empids.Length - 1);
|
|
}
|
|
|
|
|
|
DateTime DFromDate = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day);
|
|
DateTime DToDate = new DateTime(toDate.Year, toDate.Month, toDate.Day); ;
|
|
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
List<SearchEmployee> team = new List<SearchEmployee>();
|
|
if (isteam == true)
|
|
team = new SearchEmployeeService().GetTeam((int)currentUser.EmployeeID, EnumStatus.Active);
|
|
|
|
|
|
List<MonthlyWorkPlan> mWorkPlans =
|
|
this._monthyWorkPlan.Get(DFromDate, DToDate, (int)currentUser.PayrollTypeID);
|
|
|
|
if (mWorkPlans == null || mWorkPlans.Count == 0)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "There is no roster calender, please contact admin user for create roster calender.");
|
|
// throw new Exception("There is no roster calender, please contact admin user for create roster calender.");
|
|
}
|
|
List<WorkPlanGroup> groups = this._workPlanGroupService.Get(EnumStatus.Active,
|
|
(int)currentUser.PayrollTypeID, string.Empty, null);
|
|
string temp = SearchEmployee.getEmpID(team);
|
|
if (empids.Length == 0) empids = temp;
|
|
else
|
|
{
|
|
team.InsertRange(team.Count == 0 ? 0 : team.Count - 1, new SearchEmployeeService().GetByEmpIDIn(empids));
|
|
}
|
|
if (temp.Length > 0) empids = empids + "," + temp;
|
|
if (empids.Length == 0)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, "employee not found for the roster creation.");
|
|
}
|
|
List<EmployeeWorkPlanSetup> empworkPlans = this._employeeWorkPlanSetupService.getEmployeeWorkPlan(empids);
|
|
List<ActingResponsibilitySetup> actingSetup = this._actingResponsiblity.GetByStatus(DFromDate, DToDate,
|
|
(int)currentUser.PayrollTypeID, EnumClaimWFStatus.LMApproved);
|
|
List<Shift> oshifts = this._shiftService.Get(string.Empty, string.Empty, EnumStatus.Regardless,
|
|
(int)currentUser.PayrollTypeID);
|
|
DataTable table = new DataTable("RosterCanlender");
|
|
table.Columns.Add("EmployeeID");
|
|
table.Columns.Add("Name");
|
|
|
|
for (DateTime i = DFromDate; i <= DToDate; i = i.AddDays(1))
|
|
{
|
|
table.Columns.Add(new DataColumn(i.ToString("dd-MMM")));
|
|
}
|
|
|
|
try
|
|
{
|
|
foreach (SearchEmployee item in team)
|
|
{
|
|
DataRow row = table.NewRow();
|
|
row["EmployeeID"] = item.EmployeeNo;
|
|
row["Name"] = item.Name;
|
|
table.Rows.Add(row);
|
|
for (DateTime i = DFromDate; i <= DToDate; i = i.AddDays(1))
|
|
{
|
|
EmployeeWorkPlanSetup empworkPlan =
|
|
empworkPlans.FirstOrDefault(x => x.EmployeeID == item.EmployeeID);
|
|
if (empworkPlan != null)
|
|
{
|
|
MonthlyWorkPlan mplan = mWorkPlans.FirstOrDefault(x =>
|
|
x.WorkDate == i && x.WorkPlanGroupID == empworkPlan.WorkPlanGroupID);
|
|
if (mplan != null)
|
|
{
|
|
var exception = actingSetup.FirstOrDefault(x =>
|
|
x.EmployeeID == item.EmployeeID && x.FromDate <= i && i <= x.ToDate);
|
|
if (exception != null)
|
|
{
|
|
if (exception.IsHoliday)
|
|
{
|
|
row[i.ToString("dd-MMM")] = "WH";
|
|
}
|
|
else if (exception.ShiftID != null)
|
|
{
|
|
Shift shift = oshifts.FirstOrDefault(x => x.ID == exception.ShiftID);
|
|
if (shift != null) row[i.ToString("dd-MMM")] = "EX-" + shift.ShortName;
|
|
}
|
|
else
|
|
{
|
|
MonthlyWorkPlan emplan = mWorkPlans.FirstOrDefault(x =>
|
|
x.WorkDate == i && x.WorkPlanGroupID == exception.WorkPlanGroupID);
|
|
Shift shift = oshifts.FirstOrDefault(x => x.ID == emplan.ShiftID);
|
|
if (shift != null) row[i.ToString("dd-MMM")] = shift.ShortName;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (mplan.Type == EnumWorkPlanDayType.WorkingDay)
|
|
{
|
|
Shift oshift = oshifts.FirstOrDefault(x => x.ID == mplan.ShiftID);
|
|
if (oshift != null)
|
|
{
|
|
row[i.ToString("dd-MMM")] = oshift.ShortName;
|
|
}
|
|
}
|
|
else if (mplan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|
{
|
|
row[i.ToString("dd-MMM")] = "WH";
|
|
}
|
|
else
|
|
{
|
|
row[i.ToString("dd-MMM")] = "NH";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(table);
|
|
}
|
|
|
|
#region My Team
|
|
|
|
[HttpGet]
|
|
[Route("getAttendanceDashboard")]
|
|
public ActionResult GetAttendanceDashboard()
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int id = currentUser.EmployeeID.GetValueOrDefault();
|
|
Employee oEmp = _employeeService.Get(id);
|
|
try
|
|
{
|
|
dt = _dailyAttnProcessService.GetAttendanceDashboard(oEmp);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("getTopEmpAbsentData")]
|
|
public ActionResult getTopEmpAbsentData()
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int id = currentUser.EmployeeID.GetValueOrDefault();
|
|
Employee oEmp = _employeeService.Get(id);
|
|
try
|
|
{
|
|
dt = _dailyAttnProcessService.getTopEmpAbsentData(oEmp, EnumAttendanceType.Absent);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet]
|
|
[Route("getcorehrAbsentData")]
|
|
public ActionResult getcorehrAbsentData()
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int id = currentUser.EmployeeID.GetValueOrDefault();
|
|
Employee oEmp = _employeeService.Get(id);
|
|
try
|
|
{
|
|
dt = _dailyAttnProcessService.getcorehrAbsentData(oEmp, EnumAttendanceType.Absent);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
#endregion
|
|
|
|
[HttpGet("getAccessCard/{id}")]
|
|
public ActionResult getAccessCard(int id)
|
|
{
|
|
AccessCard item = new AccessCard();
|
|
try
|
|
{
|
|
item = this._accessCardService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("assignCard")]
|
|
public ActionResult assignCard(List<CardOperation> cardOperations)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
AccessCard item = new AccessCard();
|
|
cardOperations.ForEach(x =>
|
|
{
|
|
x.CreatedBy = currentUser.UserID;
|
|
x.CreatedDate = DateTime.Today;
|
|
});
|
|
try
|
|
{
|
|
this._cCardOperationService.Save(cardOperations, (int)currentUser.PayrollTypeID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
[HttpPost]
|
|
[Route("lostCardFromEmployee")]
|
|
public ActionResult lostCardFromEmployee(CardOperation cardOperations)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
AccessCard item = new AccessCard();
|
|
|
|
try
|
|
{
|
|
item = new AccessCardService().Get(cardOperations.CardNumber);
|
|
cardOperations.CardID = item.ID;
|
|
this._cCardOperationService.Save(cardOperations);
|
|
new CardOperationService().DetachCardFromEmployee(cardOperations.EmployeeID, cardOperations.CardNumber, cardOperations.AssignDate, EnumCardStatus.Lost);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
[HttpGet]
|
|
[Route("getCardInformation/{enumCardStatus}")]
|
|
public ActionResult getCardInformation(int enumCardStatus)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
DataTable table = null;
|
|
|
|
|
|
try
|
|
{
|
|
table = new AccessCardService().getCardInformation(enumCardStatus);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
return Ok(table);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("foundCard")]
|
|
public ActionResult foundCard(dynamic data)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
CardOperation item = new CardOperation();
|
|
var ac = new AccessCardService();
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
string cardNumber = (string)items["cardNumber"].ToObject<string>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
item = new CardOperationService().Get(cardNumber);
|
|
if (item.EmployeeID != 0)
|
|
{
|
|
throw new Exception("Card is already astteched to another employee");
|
|
}
|
|
else
|
|
{
|
|
item.Status = EnumCardStatus.Free;
|
|
tc = TransactionContext.Begin(true);
|
|
ac.UpdateStatus(tc, item.CardID, item.Status, (int)currentUser.PayrollTypeID);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("detachCardInfoFromEmployee")]
|
|
public ActionResult detachCardInfoFromEmployee(CardOperation cardOperations)
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
TransactionContext tc = null;
|
|
|
|
var ac = new AccessCardService();
|
|
|
|
cardOperations.CreatedBy = currentUser.UserID;
|
|
cardOperations.CreatedDate = DateTime.Today;
|
|
|
|
try
|
|
{
|
|
AccessCard accessCard = new AccessCardService().Get(cardOperations.CardNumber);
|
|
cardOperations.CardID = accessCard.ID;
|
|
if (cardOperations.CardID != 0)
|
|
cardOperations.AccessCard = new AccessCardService().Get(cardOperations.CardID);
|
|
|
|
tc = TransactionContext.Begin(true);
|
|
new CardOperationService().DetachCardFromEmployee(cardOperations.EmployeeID, cardOperations.CardNumber, cardOperations.AssignDate, EnumCardStatus.Detached);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("getAttandanceDashboardData")]
|
|
public ActionResult getAttandanceDashboardData(dynamic param)
|
|
{
|
|
DateTime fromDate = DateTime.Today;
|
|
DateTime toDate = DateTime.Today;
|
|
int shiftId = 0;
|
|
bool isLate = false;
|
|
bool isEarly = false;
|
|
string departmentIds = string.Empty;
|
|
string employeeIds = string.Empty;
|
|
bool appliedForRegularize = false;
|
|
int status = 0;
|
|
string otHourType = string.Empty;
|
|
int otHour = 0;
|
|
bool isCalledFromEss = false;
|
|
string lineManager = string.Empty;
|
|
string statusText = string.Empty;
|
|
DataTable dt = new DataTable();
|
|
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
int CurrentUserId = (int)currentUser.EmployeeID;
|
|
int payrollTypeId = (int)currentUser.PayrollTypeID;
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(param));
|
|
fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|
toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|
shiftId = (int)items["shiftId"].ToObject<int>();
|
|
departmentIds = (string)items["departmentIds"].ToObject<string>();
|
|
lineManager = (string)items["lineManager"].ToObject<string>();
|
|
employeeIds = (string)items["employeeIds"].ToObject<string>();
|
|
statusText = (string)items["statusText"].ToObject<string>();
|
|
appliedForRegularize = (bool)items["appliedForRegularize"].ToObject<bool>();
|
|
status = (int)items["status"].ToObject<int>();
|
|
otHourType = (string)items["otHourType"].ToObject<string>();
|
|
otHour = (int)items["otHour"].ToObject<int>();
|
|
isCalledFromEss = (bool)items["isCalledFromEss"].ToObject<bool>();
|
|
|
|
dt = new DailyAttnProcessService().GetAttandanceDashboardData(fromDate, toDate, shiftId, departmentIds, employeeIds, appliedForRegularize,
|
|
status, otHourType, otHour, CurrentUserId, isCalledFromEss, lineManager, statusText, payrollTypeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet]
|
|
[Route("GetAbsentAndLeaveCountYearlyByEmployee/{employeeID}/{date}")]
|
|
public ActionResult GetAbsentAndLeaveCountYearlyByEmployee(int employeeID, DateTime date)
|
|
{
|
|
DateTime fromDate = PayrollGlobalFunctions.FirstDateOfYear(date);
|
|
DateTime toDate = PayrollGlobalFunctions.LastDateOfYear(date);
|
|
DataTable dt = new DataTable();
|
|
try
|
|
{
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
dt = new DailyAttnProcessService().GetAbsentAndLeaveCountYearlyByEmployee(employeeID, fromDate, toDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
|
|
|
|
#region Late Workhour Effect
|
|
|
|
[HttpGet]
|
|
[Route("getWorkHourViewRawDataDT/{attnFromDate}/{attnToDate}/{empIds}")]
|
|
public ActionResult getDailyAttnProcessByAttnDateDT(string attnFromDate, string attnToDate, string empIds)
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
DateTime fromDate = DateTime.Parse(attnFromDate);
|
|
DateTime toDate = DateTime.Parse(attnToDate);
|
|
dt = _attnRawDataService.GetWorkHourData(fromDate, toDate, empIds);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet]
|
|
[Route("getDailyAttnProcessByAttnDateDT/{attnDate}")]
|
|
public ActionResult getDailyAttnProcessByAttnDateDT(string attnDate)
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
dt = _attnRawDataService.GetAttnProcessWorkHourData(attnDate);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet]
|
|
[Route("getWorkHourSummeryByDateRangeDT/{fromDate}/{toDate}")]
|
|
public ActionResult getWorkHourSummeryByDateRangeDT(string fromDate, string toDate)
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
dt = _attnRawDataService.GetWorkHourSummeryByDateRangeData(fromDate, toDate);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet("getDailyAttnByAttnTypeAndDateRange/{fromDate}/{toDate}/{enumAttendanceType}")]
|
|
public ActionResult getDailyAttnByAttnTypeAndDateRange(string fromDate, string toDate, EnumAttendanceType enumAttendanceType)
|
|
{
|
|
List<DailyAttnProcess> items = new List<DailyAttnProcess>();
|
|
try
|
|
{
|
|
items = _dailyAttnProcessService.GetDailyAttnByAttnTypeAndDateRange(Convert.ToDateTime(fromDate), Convert.ToDateTime(toDate), enumAttendanceType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
[HttpPost("workhourEffectProcess")]
|
|
public IActionResult WorkhourEffectProcess(dynamic data)
|
|
{
|
|
try
|
|
{
|
|
var fileitems = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
JArray jsonArray = data.effectDatalist;
|
|
DataTable employeeLeaveDeductionDT = JsonConvert.DeserializeObject<DataTable>(jsonArray.ToString());
|
|
DateTime effectMonth = fileitems["effectmonth"].ToObject<DateTime>().Date;
|
|
var currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
List<object> processResults = new List<object>();
|
|
|
|
LeaveYear currentLeaveYear = _leaveYearService.Get()
|
|
.FirstOrDefault(x => x.StartDate.Year == effectMonth.Year);
|
|
|
|
List<Employee> employeeList =
|
|
_employeeService.Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID);
|
|
|
|
EmailSettings emailSettings = _emailSettings.Value;
|
|
|
|
foreach (DataRow row in employeeLeaveDeductionDT.Rows)
|
|
{
|
|
int empId = Convert.ToInt32(row["EmployeeID"]);
|
|
double lateDays = Convert.ToDouble(row["lateDays"]);
|
|
double deductDays = Convert.ToDouble(row["LeaveDeducts"]);
|
|
|
|
string leaveSaveStatus = "NOT PROCESSED";
|
|
string mailStatus = "NOT SENT";
|
|
string errorMessage = null;
|
|
string employeeNo = null;
|
|
string employeeName = null;
|
|
|
|
try
|
|
{
|
|
if (deductDays <= 0)
|
|
{
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus = "SKIPPED",
|
|
mailStatus = "NOT SENT",
|
|
errorMessage = "Deduction days <= 0"
|
|
});
|
|
continue;
|
|
}
|
|
|
|
Employee employee =
|
|
employeeList.FirstOrDefault(x => (int)x.ID == empId);
|
|
|
|
if (employee == null)
|
|
{
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus = "FAILED",
|
|
mailStatus = "NOT SENT",
|
|
errorMessage = "Employee not found"
|
|
});
|
|
continue;
|
|
}
|
|
|
|
employeeNo = employee.EmployeeNo;
|
|
employeeName = employee.Name;
|
|
|
|
#region SAVE LEAVE ENTRY
|
|
|
|
LeaveEntry oLeaveEntry = new LeaveEntry
|
|
{
|
|
LeaveID = 7,
|
|
EntryDate = DateTime.Now,
|
|
IsDrafted = 0,
|
|
IsAvailed = 0,
|
|
LeaveStatus = EnumLeaveStatus.Approved,
|
|
|
|
EmpID = empId,
|
|
EmpGradeId = (int)employee.GradeID,
|
|
|
|
AppliedLeaveID = 7,
|
|
AppliedLeaveDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedFromDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedToDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedTotalDays = deductDays,
|
|
LeaveYearId = currentLeaveYear.ID,
|
|
|
|
ApprovedLeaveDate = DateTime.Now,
|
|
ApprovedFromDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
ApprovedToDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
ApprovedTotalDays = deductDays,
|
|
ApprovedBy = currentUser.UserID,
|
|
|
|
CreatedBy = currentUser.UserID,
|
|
WorkingDate = DateTime.Now,
|
|
Remarks = "Workhour Leave Deduction (Effect Processed)",
|
|
SalaryMonth = effectMonth
|
|
};
|
|
|
|
LeaveEntryService leaveEntryService = new LeaveEntryService();
|
|
leaveEntryService.SaveLeaveEntry(new List<LeaveEntry> { oLeaveEntry });
|
|
|
|
leaveSaveStatus = "SUCCESS";
|
|
|
|
#endregion
|
|
|
|
|
|
#region SEND MAIL
|
|
|
|
string mailSubject =
|
|
$"Annual Leave Deduction for {effectMonth:MMMM yy} Due to Absence";
|
|
|
|
string custombody = $@"
|
|
<p>Dear {employee.Name},</p>
|
|
<p>This is to inform you that as per the HR system records,
|
|
{lateDays} half-days marked against your attendance were not regularized within the given timeframe.</p>
|
|
<p>Accordingly, {deductDays} day(s) have been deducted from your annual leave balance for the month of {effectMonth:MMMM yy}.</p>
|
|
<p>Please review your leave balance in the system for confirmation.</p>
|
|
<p>If you believe this deduction has been made in error, kindly contact the HR Department.</p>
|
|
<p>Best regards,<br/>HR Department</p>";
|
|
|
|
MailSender mailSender = new MailSender();
|
|
mailSender.AddTo(employee.EmailAddress.ToString());
|
|
mailSender.Subject = mailSubject;
|
|
mailSender.Body = custombody;
|
|
|
|
var isSent = mailSender.SendMail(emailSettings, "");
|
|
|
|
mailStatus = isSent ? "SUCCESS" : "FAILED";
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region MAIL LOG
|
|
|
|
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
string folderPath = Path.Combine(rootPath, "MailLogs");
|
|
string filePath = Path.Combine(folderPath, "DeductLeaveLog.txt");
|
|
|
|
if (!Directory.Exists(folderPath))
|
|
Directory.CreateDirectory(folderPath);
|
|
|
|
string logLine = string.Format(
|
|
"{0} | {1} | {2} | LateDays: {3} | DeductDays: {4} | LeaveSave: {5} | MailStatus: {6} | MailType: {7}",
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
employeeName,
|
|
employeeNo,
|
|
lateDays,
|
|
deductDays,
|
|
leaveSaveStatus,
|
|
mailStatus,
|
|
"Effect"
|
|
);
|
|
|
|
System.IO.File.AppendAllText(filePath, logLine + Environment.NewLine);
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
leaveSaveStatus = "FAILED";
|
|
mailStatus = "FAILED";
|
|
errorMessage = ex.Message;
|
|
}
|
|
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus,
|
|
mailStatus,
|
|
errorMessage
|
|
});
|
|
|
|
System.Threading.Thread.Sleep(300);
|
|
}
|
|
|
|
return Ok(new
|
|
{
|
|
message = "Work hour effect process completed.",
|
|
totalEmployees = processResults.Count,
|
|
successCount = processResults.Count(x =>
|
|
x.GetType().GetProperty("leaveSaveStatus")
|
|
.GetValue(x).ToString() == "SUCCESS"),
|
|
failedCount = processResults.Count(x =>
|
|
x.GetType().GetProperty("leaveSaveStatus")
|
|
.GetValue(x).ToString() == "FAILED"),
|
|
data = processResults
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
[HttpPost]
|
|
[Route("sendEffectProcessMailForMultiple")]
|
|
public ActionResult sendEffectProcessMailForMultiple(dynamic data)
|
|
{
|
|
try
|
|
{
|
|
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
JArray jsonArray = data.effectDatalist;
|
|
DataTable effectDatalistDto = JsonConvert.DeserializeObject<DataTable>(jsonArray.ToString());
|
|
DateTime effectMonth = ((DateTime)data["effectMonth"].ToObject<DateTime>()).Date.AddMonths(0);
|
|
|
|
StringBuilder salaryNotProcessedForEmps = new StringBuilder();
|
|
|
|
EmailSettings emailSettings = _emailSettings.Value;
|
|
//string subject = item["emailSubject"]?.ToObject<string>() ?? "";
|
|
//string body = item["emailBody"]?.ToObject<string>() ?? "";
|
|
|
|
List<Employee> employeeList = _employeeService.Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID);
|
|
|
|
foreach (DataRow row in effectDatalistDto.Rows)
|
|
{
|
|
double lateDays = Convert.ToDouble(row["lateDays"]);
|
|
double deductDays = Convert.ToDouble(row["leaveDeducts"]);
|
|
Employee employee = employeeList.FirstOrDefault(x => (int)x.ID == Convert.ToInt32(row["EmployeeID"]));
|
|
if (employee == null) continue;
|
|
|
|
string mailSubject = $@"Deduct annual leave for the month of {effectMonth.ToString("MMMM yy")} for Absent at office.";
|
|
string custombody = $@"
|
|
<p>Dear {employee.Name},</p>
|
|
<p>As per the HR system records, there are {lateDays} half-days currently marked against your attendance. These have not yet been regularized from System.</p>
|
|
<p>Kindly apply for leave or regularize your attendance in the system within the next two working days.</p>
|
|
<p>Please note that if no action is taken within this timeframe, the system will automatically deduct {deductDays} days of the annual leave from your available leave balance.</p>
|
|
<p>Best regards,<br/>HR Department</p>
|
|
<p>Please click the link below to access the HR system:<a href='{emailSettings.WebAddress}'>HERE</a></p>";
|
|
|
|
|
|
MailSender mailSender = new MailSender();
|
|
mailSender.AddTo(employee.EmailAddress.ToString());
|
|
mailSender.Subject = mailSubject;
|
|
mailSender.Body = custombody;
|
|
//mailSender.SendMail(emailSettings, "");
|
|
|
|
var isSent = mailSender.ThreadSendMail(emailSettings, "");
|
|
string mailStatus = isSent ? "SUCCESS" : "FAILED";
|
|
|
|
#region mail status logging
|
|
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
string folderPath = Path.Combine(rootPath, "MailLogs");
|
|
string filePath = Path.Combine(folderPath, "DeductLeaveLog.txt");
|
|
|
|
// Create folder if not exists
|
|
if (!Directory.Exists(folderPath))
|
|
{
|
|
Directory.CreateDirectory(folderPath);
|
|
}
|
|
|
|
// Prepare log line
|
|
string logLine = string.Format(
|
|
"{0} | {1} | {2} | LateDays: {3} | DeductDays: {4} | LeaveSave: {5} | MailStatus: {6} | MailType: {7}",
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
employee.Name,
|
|
employee.EmployeeNo, // make sure EmployeeNo property exists
|
|
lateDays,
|
|
deductDays,
|
|
"Not Initiated",
|
|
mailStatus,
|
|
"Notify"
|
|
);
|
|
|
|
// Append to file
|
|
System.IO.File.AppendAllText(filePath, logLine + Environment.NewLine);
|
|
#endregion
|
|
|
|
// Optional delay between emails
|
|
System.Threading.Thread.Sleep(500);
|
|
}
|
|
|
|
return Ok(new
|
|
{
|
|
message = "The email sending process is running in the background and may take several minutes. You may continue with your other tasks. To check the result, please review the mail log."
|
|
});
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
[HttpPost("getWorkhourEffectMaillog")]
|
|
public IActionResult GetWorkHourLog(dynamic data)
|
|
{
|
|
var fileitems = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
DateTime effectMonth = fileitems["effectMonth"].ToObject<DateTime>().Date;
|
|
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
string folderPath = Path.Combine(rootPath, "MailLogs");
|
|
string filePath = Path.Combine(folderPath, "DeductLeaveLog.txt");
|
|
|
|
if (!System.IO.File.Exists(filePath))
|
|
return Ok(new List<object>());
|
|
|
|
var lines = System.IO.File.ReadAllLines(filePath);
|
|
|
|
var result = new List<object>();
|
|
|
|
foreach (var line in lines)
|
|
{
|
|
var parts = line.Split('|');
|
|
if (parts.Length >= 8)
|
|
{
|
|
var parsedDate = DateTime.Parse(parts[0].Trim());
|
|
|
|
if (parsedDate.Year == effectMonth.Year &&
|
|
parsedDate.Month == effectMonth.Month + 1)
|
|
{
|
|
result.Add(new
|
|
{
|
|
dateTime = parsedDate,
|
|
name = parts[1].Trim(),
|
|
empId = parts[2].Trim(),
|
|
lateDays = int.Parse(parts[3].Split(':')[1].Trim()),
|
|
deductDays = decimal.Parse(parts[4].Split(':')[1].Trim()),
|
|
leaveStatus = parts[5].Split(':')[1].Trim(),
|
|
mailStatus = parts[6].Split(':')[1].Trim(),
|
|
mailType = parts[7].Split(':')[1].Trim()
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
result = result
|
|
.OrderByDescending(x => ((dynamic)x).dateTime)
|
|
.ToList();
|
|
|
|
return Ok(result);
|
|
}
|
|
[HttpGet]
|
|
[Route("getMonthlyLateAttnSummaryDT/{fromDate}/{toDate}")]
|
|
public ActionResult GetMonthlyLateAttnSummaryDT(string fromDate, string toDate)
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
dt = _dailyAttnProcessService.GetMonthlyLateAttnSummaryDT(fromDate, toDate);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpGet]
|
|
[Route("getMonthlyLateAttnDetailsDT/{fromDate}/{toDate}")]
|
|
public ActionResult GetMonthlyLateAttnDetailsDT(string fromDate, string toDate)
|
|
{
|
|
DataTable dt = null;
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
try
|
|
{
|
|
dt = _dailyAttnProcessService.GetMonthlyLateAttnDetailsDT(fromDate, toDate);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(dt);
|
|
}
|
|
[HttpPost]
|
|
[Route("sendMailMonthlyLateAttnSummaryForMultiple")]
|
|
public ActionResult sendMailMonthlyLateAttnSummaryForMultiple(dynamic data)
|
|
{
|
|
try
|
|
{
|
|
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
JArray jsonArray = data.effectDatalist;
|
|
DataTable effectDatalistDto = JsonConvert.DeserializeObject<DataTable>(jsonArray.ToString());
|
|
DateTime effectMonth = ((DateTime)data["effectMonth"].ToObject<DateTime>()).Date.AddMonths(0);
|
|
|
|
StringBuilder salaryNotProcessedForEmps = new StringBuilder();
|
|
|
|
EmailSettings emailSettings = _emailSettings.Value;
|
|
//string subject = item["emailSubject"]?.ToObject<string>() ?? "";
|
|
//string body = item["emailBody"]?.ToObject<string>() ?? "";
|
|
|
|
List<Employee> employeeList = _employeeService.Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID);
|
|
|
|
foreach (DataRow row in effectDatalistDto.Rows)
|
|
{
|
|
double lateDays = Convert.ToDouble(row["lateDays"]);
|
|
double deductDays = Convert.ToDouble(row["leaveDeducts"]);
|
|
Employee employee = employeeList.FirstOrDefault(x => (int)x.ID == Convert.ToInt32(row["EmployeeID"]));
|
|
if (employee == null) continue;
|
|
|
|
string mailSubject = $@"Deduct annual leave for the month of {effectMonth.ToString("MMMM yy")} for Absent at office.";
|
|
//string custombody = $@"
|
|
//<p>Dear {employee.Name},</p>
|
|
//<p>As per the HR system records, there are {lateDays} late-attendance-days currently marked against your attendance. These have not yet been regularized from System.</p>
|
|
//<p>Kindly apply for leave or regularize your attendance in the system within the next two working days.</p>
|
|
//<p>Please note that if no action is taken within this timeframe, the system will automatically deduct {deductDays} days of the annual leave from your available leave balance.</p>
|
|
//<p>Best regards,<br/>HR Department</p>
|
|
//<p>Please click the link below to access the HR system:<a href='{emailSettings.WebAddress}'>HERE</a></p>";
|
|
|
|
string custombody = $@"
|
|
<p>Dear {employee.Name},</p>
|
|
<p>As per the HR system records, there are {lateDays} late-attendance-days currently marked against your attendance for the month of {effectMonth.ToString("MMMM yy")}.</p>
|
|
<pSo we are enforced to deduct your annual leave for {deductDays} day(s).</p>
|
|
<p>Please improve your office attendance.</p>
|
|
<p>Best regards,<br/>HR Department</p>
|
|
<p>Please click the link below to access the HR system:<a href='{emailSettings.WebAddress}'>HERE</a></p>";
|
|
|
|
|
|
|
|
MailSender mailSender = new MailSender();
|
|
mailSender.AddTo(employee.EmailAddress.ToString());
|
|
mailSender.Subject = mailSubject;
|
|
mailSender.Body = custombody;
|
|
//mailSender.SendMail(emailSettings, "");
|
|
|
|
var isSent = mailSender.ThreadSendMail(emailSettings, "");
|
|
string mailStatus = isSent ? "SUCCESS" : "FAILED";
|
|
|
|
#region mail status logging
|
|
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
string folderPath = Path.Combine(rootPath, "MailLogs");
|
|
string filePath = Path.Combine(folderPath, "DeductLeaveLog.txt");
|
|
|
|
// Create folder if not exists
|
|
if (!Directory.Exists(folderPath))
|
|
{
|
|
Directory.CreateDirectory(folderPath);
|
|
}
|
|
|
|
/// Prepare log line
|
|
string logLine = string.Format(
|
|
"{0} | {1} | {2} | LateDays: {3} | DeductDays: {4} | LeaveSave: {5} | MailStatus: {6} | MailType: {7}",
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
employee.Name,
|
|
employee.EmployeeNo, // make sure EmployeeNo property exists
|
|
lateDays,
|
|
deductDays,
|
|
"Not Initiated",
|
|
mailStatus,
|
|
"Notify"
|
|
);
|
|
|
|
// Append to file
|
|
System.IO.File.AppendAllText(filePath, logLine + Environment.NewLine);
|
|
#endregion
|
|
|
|
// Optional delay between emails
|
|
System.Threading.Thread.Sleep(500);
|
|
}
|
|
|
|
return Ok(new
|
|
{
|
|
message = "The email sending process is running in the background and may take several minutes. You may continue with your other tasks. To check the result, please review the mail log."
|
|
});
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
[HttpPost("monthlyLateAttenEffectProcess")]
|
|
public IActionResult MonthlyLateAttenEffectProcess(dynamic data)
|
|
{
|
|
try
|
|
{
|
|
var fileitems = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|
JArray jsonArray = data.effectDatalist;
|
|
DataTable employeeLeaveDeductionDT = JsonConvert.DeserializeObject<DataTable>(jsonArray.ToString());
|
|
DateTime effectMonth = fileitems["effectmonth"].ToObject<DateTime>().Date;
|
|
var currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|
|
|
List<object> processResults = new List<object>();
|
|
|
|
LeaveYear currentLeaveYear = _leaveYearService.Get()
|
|
.FirstOrDefault(x => x.StartDate.Year == effectMonth.Year);
|
|
|
|
List<Employee> employeeList =
|
|
_employeeService.Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID);
|
|
|
|
EmailSettings emailSettings = _emailSettings.Value;
|
|
|
|
|
|
|
|
#region UPDATE ATTN REGULARIZE DailyAttnProcess ENTRY - AS REJECT
|
|
|
|
var service = new DailyAttnProcessService();
|
|
|
|
// Safely extract employee IDs
|
|
var empIdList = employeeLeaveDeductionDT.AsEnumerable()
|
|
.Select(row => row["EmployeeID"])
|
|
.Where(val => val != DBNull.Value && val != null)
|
|
.Select(val =>
|
|
{
|
|
int.TryParse(val.ToString(), out int id);
|
|
return id;
|
|
})
|
|
.Where(id => id > 0)
|
|
.Distinct()
|
|
.ToList();
|
|
|
|
if (empIdList.Count > 0)
|
|
{
|
|
var fromDate = effectMonth.FirstDateOfMonth();
|
|
var toDate = effectMonth.LastDateOfMonth();
|
|
|
|
var existingPendingData = service
|
|
.GetDateRange(fromDate, toDate, 1)
|
|
.Where(x =>
|
|
x.IsLate &&
|
|
x.WFStatus == EnumWFAttnStatus.EmpSubmitted &&
|
|
empIdList.Contains(x.EmployeeID))
|
|
.ToList();
|
|
|
|
foreach (var item in existingPendingData)
|
|
{
|
|
string dailyAttnProcessIDs = string.Join(",", existingPendingData.Select(x => x.ID));
|
|
var status = EnumWFAttnStatus.Reject;
|
|
var reason = "Late Attendance Leave Deduction(Effect Process)";
|
|
|
|
service.RejectAttnStatusMonthlyByLateAttnEffect(dailyAttnProcessIDs, status, reason);
|
|
|
|
//service.RejectAttnStatusByLateAttnEffect(
|
|
// item.ID,
|
|
// EnumWFAttnStatus.Reject,
|
|
// item.Reason = "Late Attendance Leave Deduction(Effect Process)"
|
|
//);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
foreach (DataRow row in employeeLeaveDeductionDT.Rows)
|
|
{
|
|
int empId = Convert.ToInt32(row["EmployeeID"]);
|
|
double lateDays = Convert.ToDouble(row["lateDays"]);
|
|
double deductDays = Convert.ToDouble(row["LeaveDeducts"]);
|
|
|
|
string leaveSaveStatus = "NOT PROCESSED";
|
|
string mailStatus = "NOT SENT";
|
|
string errorMessage = null;
|
|
string employeeNo = null;
|
|
string employeeName = null;
|
|
|
|
try
|
|
{
|
|
if (deductDays <= 0)
|
|
{
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus = "SKIPPED",
|
|
mailStatus = "NOT SENT",
|
|
errorMessage = "Deduction days <= 0"
|
|
});
|
|
continue;
|
|
}
|
|
|
|
Employee employee =
|
|
employeeList.FirstOrDefault(x => (int)x.ID == empId);
|
|
|
|
if (employee == null)
|
|
{
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus = "FAILED",
|
|
mailStatus = "NOT SENT",
|
|
errorMessage = "Employee not found"
|
|
});
|
|
continue;
|
|
}
|
|
|
|
employeeNo = employee.EmployeeNo;
|
|
employeeName = employee.Name;
|
|
|
|
|
|
#region SAVE LEAVE ENTRY
|
|
|
|
LeaveEntry oLeaveEntry = new LeaveEntry
|
|
{
|
|
LeaveID = 7,
|
|
EntryDate = DateTime.Now,
|
|
IsDrafted = 0,
|
|
IsAvailed = 0,
|
|
LeaveStatus = EnumLeaveStatus.Approved,
|
|
|
|
EmpID = empId,
|
|
EmpGradeId = (int)employee.GradeID,
|
|
|
|
AppliedLeaveID = 7,
|
|
AppliedLeaveDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedFromDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedToDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
AppliedTotalDays = deductDays,
|
|
LeaveYearId = currentLeaveYear.ID,
|
|
|
|
ApprovedLeaveDate = DateTime.Now,
|
|
ApprovedFromDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
ApprovedToDate = effectMonth.AddMonths(1).FirstDateOfMonth(),
|
|
ApprovedTotalDays = deductDays,
|
|
ApprovedBy = currentUser.UserID,
|
|
|
|
CreatedBy = currentUser.UserID,
|
|
WorkingDate = DateTime.Now,
|
|
Remarks = "Late Attendance Leave Deduction (Effect Processed)",
|
|
SalaryMonth = effectMonth
|
|
};
|
|
|
|
LeaveEntryService leaveEntryService = new LeaveEntryService();
|
|
leaveEntryService.SaveLeaveEntry(new List<LeaveEntry> { oLeaveEntry });
|
|
|
|
leaveSaveStatus = "SUCCESS";
|
|
|
|
#endregion
|
|
|
|
#region SAVE WORKHOUR EFFECT STATUS
|
|
|
|
WorkhourEffectStatus oWorkhourEffectStatus = new WorkhourEffectStatus
|
|
{
|
|
EffectMonth = effectMonth.LastDateOfMonth(),
|
|
EmployeeID = empId,
|
|
|
|
NotifyStatus = true,
|
|
NotifyDate = DateTime.Now,
|
|
|
|
EffectType = "Late Deduction",
|
|
EffectValue = (decimal)deductDays,
|
|
|
|
EffectStatus = true,
|
|
|
|
LeaveEntryID = oLeaveEntry.ID,
|
|
|
|
EffectAppliedDate = DateTime.Now,
|
|
EffectAppliedBy = currentUser.UserID
|
|
};
|
|
|
|
DailyAttnProcessService workhourEffectStatusService = new DailyAttnProcessService();
|
|
workhourEffectStatusService.SaveWorkhourEffectStatus(oWorkhourEffectStatus);
|
|
|
|
#endregion
|
|
|
|
#region SEND MAIL
|
|
|
|
string mailSubject =
|
|
$"Annual Leave Deduction for {effectMonth:MMMM yy} Due to Absence";
|
|
|
|
string custombody = $@"
|
|
<p>Dear {employee.Name},</p>
|
|
<p>This is to inform you that as per the HR system records,
|
|
{lateDays} late-attendance-days marked against your attendance were not regularized within the given timeframe.</p>
|
|
<p>Accordingly, {deductDays} day(s) have been deducted from your annual leave balance for the month of {effectMonth:MMMM yy}.</p>
|
|
<p>Please review your leave balance in the system for confirmation.</p>
|
|
<p>If you believe this deduction has been made in error, kindly contact the HR Department.</p>
|
|
<p>Best regards,<br/>HR Department</p>
|
|
<p>Please click the link below to access the HR system:<a href='{emailSettings.WebAddress}'>HERE</a></p>";
|
|
|
|
MailSender mailSender = new MailSender();
|
|
mailSender.AddTo(employee.EmailAddress.ToString());
|
|
mailSender.Subject = mailSubject;
|
|
mailSender.Body = custombody;
|
|
|
|
var isSent = mailSender.SendMail(emailSettings, "");
|
|
|
|
mailStatus = isSent ? "SUCCESS" : "FAILED";
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region MAIL LOG
|
|
|
|
string rootPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
string folderPath = Path.Combine(rootPath, "MailLogs");
|
|
string filePath = Path.Combine(folderPath, "DeductLeaveLog.txt");
|
|
|
|
if (!Directory.Exists(folderPath))
|
|
Directory.CreateDirectory(folderPath);
|
|
|
|
string logLine = string.Format(
|
|
"{0} | {1} | {2} | LateDays: {3} | DeductDays: {4} | LeaveSave: {5} | MailStatus: {6} | MailType: {7}",
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
employeeName,
|
|
employeeNo,
|
|
lateDays,
|
|
deductDays,
|
|
leaveSaveStatus,
|
|
mailStatus,
|
|
"Effect"
|
|
);
|
|
|
|
System.IO.File.AppendAllText(filePath, logLine + Environment.NewLine);
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
leaveSaveStatus = "FAILED";
|
|
mailStatus = "FAILED";
|
|
errorMessage = ex.Message;
|
|
}
|
|
|
|
processResults.Add(new
|
|
{
|
|
employeeID = empId,
|
|
employeeNo,
|
|
employeeName,
|
|
deductDays,
|
|
leaveSaveStatus,
|
|
mailStatus,
|
|
errorMessage
|
|
});
|
|
|
|
System.Threading.Thread.Sleep(300);
|
|
}
|
|
|
|
return Ok(new
|
|
{
|
|
message = "Late attendance leave deduction effect process completed.",
|
|
totalEmployees = processResults.Count,
|
|
successCount = processResults.Count(x =>
|
|
x.GetType().GetProperty("leaveSaveStatus")
|
|
.GetValue(x).ToString() == "SUCCESS"),
|
|
failedCount = processResults.Count(x =>
|
|
x.GetType().GetProperty("leaveSaveStatus")
|
|
.GetValue(x).ToString() == "FAILED"),
|
|
data = processResults
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |