950 lines
26 KiB
C#
950 lines
26 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Globalization;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.CheckoutAgg;
|
|
using Company.Domain.ContractAgg;
|
|
using CompanyManagment.App.Contracts.Contract;
|
|
using CompanyManagment.App.Contracts.Employee;
|
|
using CompanyManagment.App.Contracts.Employer;
|
|
using CompanyManagment.App.Contracts.Job;
|
|
using CompanyManagment.App.Contracts.Leave;
|
|
using CompanyManagment.App.Contracts.LeftWork;
|
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
|
using CompanyManagment.App.Contracts.WorkingHours;
|
|
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
|
using CompanyManagment.App.Contracts.Workshop;
|
|
using CompanyManagment.App.Contracts.YearlySalary;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace ServiceHost.Areas.Admin.Pages.Company.Contracts;
|
|
|
|
[Authorize]
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IAuthHelper _authHelper;
|
|
private readonly ICheckoutRepository _checkoutRepository;
|
|
private readonly IContractApplication _contractApplication;
|
|
private readonly IContractRepository _contractRepository;
|
|
private readonly IEmployeeApplication _employeeApplication;
|
|
private readonly IEmployerApplication _employerApplication;
|
|
private readonly IJobApplication _jobApplication;
|
|
private readonly ILeaveApplication _leaveApplication;
|
|
private readonly ILeftWorkApplication _leftWorkApplication;
|
|
private readonly IPersonalContractingPartyApp _personalContractingPartyApp;
|
|
private readonly IWorkingHoursApplication _workingHoursApplication;
|
|
private readonly IWorkingHoursItemsApplication _workingHoursItemsApplication;
|
|
private readonly IWorkshopApplication _workshopApplication;
|
|
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
|
public List<ComputingViewModel> ComputingView;
|
|
|
|
public List<ContractViweModel> Contracts;
|
|
public List<ContractViweModel> Contracts2;
|
|
public string DeleteCheck = "false";
|
|
public string employeeFullName;
|
|
public List<EmployeeViewModel> EmployeeList;
|
|
public SelectList Employees;
|
|
public List<EmployerViewModel> EmployerList;
|
|
public SelectList Employers;
|
|
|
|
|
|
public List<JobViewModel> JobList;
|
|
public SelectList Jobs;
|
|
public List<EmployeeSelectListViewModel> PersonnelList;
|
|
|
|
public ContractSearchModel SearchModel;
|
|
public string SignCheck = "false";
|
|
public List<WorkshopEmployerViewModel> WorkshopEmployer;
|
|
public List<WorkshopViewModel> WorkshopList;
|
|
|
|
public SelectList Workshops;
|
|
public SelectList WorkshopsCode;
|
|
public string WorkshopSearch = "false";
|
|
public List<string> YearlyList;
|
|
public bool IsSysManager = false;
|
|
|
|
public IndexModel(IContractApplication contractApplication, IWorkshopApplication workshopApplication,
|
|
IEmployeeApplication employeeApplication,
|
|
IEmployerApplication employerApplication,
|
|
IYearlySalaryApplication yearlySalaryApplication,
|
|
IJobApplication jobApplication, IContractRepository contractRepository,
|
|
IWorkingHoursApplication workingHoursApplication,
|
|
IWorkingHoursItemsApplication workingHoursItemsApplication,
|
|
IAuthHelper authHelper, ILeftWorkApplication leftWorkApplication, ILeaveApplication leaveApplication,
|
|
ICheckoutRepository checkoutRepository, IPersonalContractingPartyApp personalContractingPartyApp)
|
|
{
|
|
_contractApplication = contractApplication;
|
|
_workshopApplication = workshopApplication;
|
|
_employeeApplication = employeeApplication;
|
|
_employerApplication = employerApplication;
|
|
_yearlySalaryApplication = yearlySalaryApplication;
|
|
_jobApplication = jobApplication;
|
|
_contractRepository = contractRepository;
|
|
_workingHoursApplication = workingHoursApplication;
|
|
_workingHoursItemsApplication = workingHoursItemsApplication;
|
|
_authHelper = authHelper;
|
|
_leftWorkApplication = leftWorkApplication;
|
|
_leaveApplication = leaveApplication;
|
|
_checkoutRepository = checkoutRepository;
|
|
_personalContractingPartyApp = personalContractingPartyApp;
|
|
}
|
|
|
|
public string Message { get; set; }
|
|
public bool falseCheck { get; set; }
|
|
|
|
|
|
[SuppressMessage("ReSharper.DPA", "DPA0009: High execution time of DB command", MessageId = "time: 619ms")]
|
|
public void OnGet(ContractSearchModel searchModel)
|
|
{
|
|
var accountId = _authHelper.CurrentAccountId();
|
|
IsSysManager = accountId is 2 or 3;
|
|
//EmployerList = _employerApplication.GetEmployers();
|
|
//EmployeeList = _employeeApplication.GetEmployee();
|
|
//WorkshopList = _workshopApplication.GetWorkshop();
|
|
Jobs =
|
|
new SelectList(_jobApplication.GetJob(), "Id", "JobName");
|
|
|
|
Workshops =
|
|
new SelectList(_workshopApplication.GetWorkshopAccount(), "Id", "WorkshopFullName");
|
|
|
|
WorkshopsCode =
|
|
new SelectList(_workshopApplication.GetWorkshopAccount(), "Id", "ArchiveCode");
|
|
|
|
//Employees =
|
|
// new SelectList(_employeeApplication.GetEmployee(), "Id", "EmployeeFullName");
|
|
|
|
Employers =
|
|
new SelectList(_employerApplication.GetEmployers(), "Id", "FullName");
|
|
YearlyList =
|
|
_yearlySalaryApplication.GetYears();
|
|
|
|
Contracts = _contractApplication.SearchForMainContract(searchModel);
|
|
if (Contracts != null)
|
|
{
|
|
if (searchModel.WorkshopIds != 0 || searchModel.EmployeeId != 0) WorkshopSearch = "true";
|
|
if (searchModel.WorkshopIds != 0 && !string.IsNullOrEmpty(searchModel.Year)) DeleteCheck = "true";
|
|
if (searchModel.WorkshopIds != 0 && !string.IsNullOrEmpty(searchModel.Year) &&
|
|
!string.IsNullOrEmpty(searchModel.Month)) SignCheck = "true";
|
|
}
|
|
|
|
if (searchModel.EmployeeId > 0)
|
|
employeeFullName = Contracts.Select(x => x.EmployeeName).FirstOrDefault();
|
|
else
|
|
employeeFullName = searchModel.EmployeeName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// نحوه محاسبه پایه سنوات و ارتقاء مزد رو نمایش میده
|
|
/// </summary>
|
|
/// <param name="contractId"></param>
|
|
/// <returns></returns>
|
|
public async Task<IActionResult> OnGetDailyWageAndBaseYearReport(long contractId)
|
|
{
|
|
var res = new ContractDailyWageAndBaseYearReport();
|
|
var contract = _contractApplication.GetDetails(contractId);
|
|
var employeeName = _employeeApplication.GetDetails(contract.EmployeeId).EmployeeFullName;
|
|
var workshopName = _workshopApplication.GetWorkshopInfo(contract.WorkshopIds).WorkshopFullName;
|
|
var baseYearResult =await _yearlySalaryApplication.BaseYearComputeByContractId(contractId);
|
|
|
|
if (contract.DailySalaryUnAffected == 0 || string.IsNullOrWhiteSpace(contract.DailyWageType))
|
|
{
|
|
res = new ContractDailyWageAndBaseYearReport()
|
|
{
|
|
|
|
EmployeeName = employeeName,
|
|
WorkshopName = workshopName,
|
|
Contradiction = false,
|
|
OldComputeMethod = true,
|
|
|
|
|
|
};
|
|
|
|
return Partial("DailyWageAndBaseYearReport", res);
|
|
}
|
|
|
|
var dailyWageListResult = new List<UpgradeManualDailyWageList>();
|
|
bool contradiction = false;
|
|
if (contract.DailyWageType == "UpgradedDailyWage")
|
|
{
|
|
var upgradeDailyWageResult = _contractRepository.GetManualDailWageList(contract.WorkshopIds,
|
|
contract.EmployeeId, contract.ContractStartGr).GetAwaiter().GetResult();
|
|
dailyWageListResult = upgradeDailyWageResult.UpgradeManualDailyWageLists;
|
|
|
|
//اگر مغایرت داشت
|
|
if (contract.DailySalaryUnAffected.ToMoney().MoneyToDouble() != upgradeDailyWageResult.DailyWage.ToMoney().MoneyToDouble()
|
|
|| baseYearResult.BaseYearResult.ToMoney().MoneyToDouble() != contract.BaseYearUnAffected.ToMoney().MoneyToDouble())
|
|
contradiction = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
res = new ContractDailyWageAndBaseYearReport()
|
|
{
|
|
BaseYearDataViewModel = baseYearResult,
|
|
BaseYearAffected = contract.BaseYearAffected > 0 ? contract.BaseYearAffected.ToMoney() : "0",
|
|
DailySalaryAffected = contract.DailySalaryAffected > 0 ? contract.DailySalaryAffected.ToMoney() : "0",
|
|
DailySalaryUnAffected = contract.DailySalaryUnAffected > 0 ? contract.DailySalaryUnAffected.ToMoney() : "0",
|
|
DailyWage = contract.DayliWage,
|
|
ContractDate = $"تا تاریخ {contract.ContarctStart.FindeEndOfMonth()}",
|
|
DailyWageType = contract.DailyWageType,
|
|
UpgradeManualDailyWageLists = dailyWageListResult,
|
|
EmployeeName = employeeName,
|
|
WorkshopName = workshopName,
|
|
Contradiction = contradiction,
|
|
|
|
};
|
|
return Partial("DailyWageAndBaseYearReport", res);
|
|
}
|
|
|
|
public async Task<IActionResult> OnGetPersonelMainList(string searchEmployee)
|
|
{
|
|
PersonnelList = await _employeeApplication.GetEmployeeToList();
|
|
var person = PersonnelList.Where(x => x.EmployeeFullName.Contains(searchEmployee)).Take(200).ToList();
|
|
person = person.OrderBy(x => x.EmployeeFullName.Length).ToList();
|
|
|
|
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
mylist = person
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostCheckPsCode(long id, long workshopId, string code)
|
|
{
|
|
var psCode = Convert.ToInt64(code);
|
|
var cheker = _contractRepository.Exists(x =>
|
|
x.PersonnelCode == psCode && x.WorkshopIds == workshopId && x.EmployeeId != id &&
|
|
x.IsActiveString == "true");
|
|
if (cheker)
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
psCodeExist = true
|
|
});
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
psCodeExist = false
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostLoadPersonel(long id, long workshopId)
|
|
{
|
|
var leftWorkStartdate = "";
|
|
var result = _employeeApplication.GetDetails(id);
|
|
var serachModel = new LeftWorkSearchModel
|
|
{
|
|
EmployeeId = id,
|
|
WorkshopId = workshopId
|
|
};
|
|
var leftWoekSerchResult = _leftWorkApplication.search(serachModel);
|
|
if (leftWoekSerchResult.Count > 0)
|
|
//var leftWorkLast = leftWoekSerchResult.OrderByDescending(x => x.StartWorkDateGr).FirstOrDefault();
|
|
//if (leftWorkLast.LeftWorkDate == "1500/01/01")
|
|
//{
|
|
// leftWorkStartdate = leftWoekSerchResult.Select(x => x.StartWorkDate).FirstOrDefault();
|
|
//}
|
|
leftWorkStartdate = leftWoekSerchResult.OrderBy(x => x.StartWorkDateGr).FirstOrDefault()?.StartWorkDate;
|
|
|
|
//var psCode = _contractRepository.FindPersonnelCode(workshopId, id);
|
|
//var contractExistBythisPsCode = _contractRepository.Exists(x => x.PersonnelCode == psCode && x.WorkshopIds == workshopId && x.EmployeeId == id && x.IsActiveString =="true");
|
|
//var chekoutExistByThisPerson = _checkoutRepository.Exists(x => x.EmployeeId == id && x.WorkshopId == workshopId);
|
|
//var exsitContractAndCheckout = false;
|
|
//if(contractExistBythisPsCode || chekoutExistByThisPerson)
|
|
//{
|
|
// exsitContractAndCheckout = true;
|
|
//}
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
result.FatherName,
|
|
result.NationalCode,
|
|
result.IdNumber,
|
|
result.DateOfBirth,
|
|
result.State,
|
|
result.City,
|
|
result.Address,
|
|
LeftWorkStartDate = leftWorkStartdate
|
|
//personnelCode = psCode,
|
|
//contractExist = exsitContractAndCheckout
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostLoadWorkshops(long id)
|
|
{
|
|
var result = _workshopApplication.GetWorkshopInfo(id);
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true,
|
|
InsurancCode = result.InsuranceCode,
|
|
archiveCode = result.ArchiveCode,
|
|
state = result.State,
|
|
city = result.City,
|
|
address = result.Address,
|
|
adres = result.State + "-" + result.City + "-" + result.Address,
|
|
empList = result.EmpList,
|
|
employeeList = result.EmployeeList
|
|
});
|
|
}
|
|
|
|
// پرینت تکی
|
|
|
|
#region PrintOne
|
|
|
|
public IActionResult OnGetDetails(long id)
|
|
{
|
|
var res = _contractApplication.GetDetails(id);
|
|
var weeklyDouble = 0.0;
|
|
var weekly = res.WorkingHoursWeekly;
|
|
if (!string.IsNullOrWhiteSpace(weekly) &&
|
|
weekly != "24 - 12" && weekly != "24 - 24" && weekly != "36 - 12" && weekly != "48 - 24")
|
|
{
|
|
if (weekly.Contains("/"))
|
|
{
|
|
weeklyDouble = double.Parse(weekly);
|
|
var minute = (int)(weeklyDouble % 1 * 60);
|
|
var hour = (int)weeklyDouble;
|
|
res.WorkingHoursWeekly = hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
|
|
}
|
|
else if (weekly.Contains("."))
|
|
{
|
|
weeklyDouble = double.Parse(weekly, CultureInfo.InvariantCulture);
|
|
var minute = (int)(weeklyDouble % 1 * 60);
|
|
var hour = (int)weeklyDouble;
|
|
res.WorkingHoursWeekly = hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
|
|
}
|
|
else
|
|
{
|
|
res.WorkingHoursWeekly = res.WorkingHoursWeekly + " " + "ساعت";
|
|
}
|
|
}
|
|
|
|
|
|
//res.WorkshopEmployerList = _contractRepository.GetWorkshopEmployer();
|
|
//res.Employers = _employerApplication.GetEmployers();
|
|
//res.Employees = _employeeApplication.GetEmployee();
|
|
//res.Workshops = _workshopApplication.GetWorkshop();
|
|
return Partial("Details", res);
|
|
}
|
|
|
|
#endregion
|
|
|
|
// پرینت گروهی
|
|
|
|
#region PrintAll
|
|
|
|
public IActionResult OnGetPrintAllB(List<long> ids)
|
|
{
|
|
var result = _contractApplication.PrintAll(ids);
|
|
var finalresult = result.OrderByDescending(x => x.ContractEndGr).ToList();
|
|
var res = new GroupPrintViewModel
|
|
{
|
|
ContractList = finalresult
|
|
};
|
|
//var res = _contractApplication.PrintAll(ids);
|
|
|
|
return Partial("PrintAllTest", res);
|
|
}
|
|
|
|
#endregion
|
|
|
|
public IActionResult OnGetDeActive(long id)
|
|
{
|
|
var result = _contractApplication.DeActive(id);
|
|
|
|
if (result.IsSuccedded)
|
|
return RedirectToPage("./Index");
|
|
Message = result.Message;
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
public IActionResult OnGetIsActive(long id)
|
|
{
|
|
var result = _contractApplication.Active(id);
|
|
if (result.IsSuccedded)
|
|
return RedirectToPage("./Index");
|
|
Message = result.Message;
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
//public IActionResult OnGetSign(long id)
|
|
//{
|
|
|
|
|
|
// var result = _contractApplication.Sign(id);
|
|
// return RedirectToPage("./Index");
|
|
|
|
|
|
//}
|
|
//public IActionResult OnGetUnSign(long id)
|
|
//{
|
|
|
|
|
|
// var result = _contractApplication.UnSign(id);
|
|
// return RedirectToPage("./Index");
|
|
|
|
//}
|
|
public IActionResult OnGetSign(string Id)
|
|
{
|
|
var id = Convert.ToInt64(Id);
|
|
var result = _contractApplication.Sign(id);
|
|
if (result.IsSuccedded)
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true
|
|
});
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = false
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetUnSign(string Id)
|
|
{
|
|
var permissions = _authHelper.GetPermissions();
|
|
var checkHasPermission = permissions.Any(n => n.Equals(20122));
|
|
if (checkHasPermission)
|
|
{
|
|
var id = Convert.ToInt64(Id);
|
|
var result = _contractApplication.UnSign(id);
|
|
if (result.IsSuccedded)
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = true
|
|
});
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = false
|
|
});
|
|
}
|
|
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = false
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetGroupDeActive(List<long> ids)
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
var result = _contractApplication.DeActive(item);
|
|
}
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
|
|
public IActionResult OnGetGroupReActive(List<long> ids)
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
var result = _contractApplication.Active(item);
|
|
}
|
|
|
|
|
|
//if (result.IsSuccedded)
|
|
// return RedirectToPage("./Index");
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
|
|
public IActionResult OnGetGroupSign(List<long> ids)
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
var result = _contractApplication.Sign(item);
|
|
}
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
public IActionResult OnGetGroupUnSign(List<long> ids)
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
var result = _contractApplication.UnSign(item);
|
|
}
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
|
|
|
|
// مرخصی
|
|
|
|
#region PaidLeaveSickLeav
|
|
|
|
#region SickLeave
|
|
|
|
public IActionResult OnGetCreateSickLeave(long employeeId, long workshopId, long hd)
|
|
{
|
|
var workshopName = _workshopApplication.GetDetails(workshopId);
|
|
var employeeName = _employeeApplication.GetDetails(employeeId);
|
|
var search = new LeaveSearchModel
|
|
{
|
|
EmployeeId = employeeId,
|
|
WorkshopId = workshopId,
|
|
LeaveType = "استعلاجی"
|
|
};
|
|
var serachResult = _leaveApplication.search(search);
|
|
|
|
var command = new CreateLeave
|
|
{
|
|
EmployeeId = employeeId,
|
|
WorkshopId = workshopId,
|
|
LeaveSearch = serachResult,
|
|
WorkshopName = workshopName.WorkshopFullName,
|
|
EmployeeFullName = employeeName.EmployeeFullName
|
|
};
|
|
return Partial("./SickLeave", command);
|
|
}
|
|
|
|
public IActionResult OnPostCreateSickLeave(CreateLeave command)
|
|
{
|
|
command.LeaveType = "استعلاجی";
|
|
|
|
var result = _leaveApplication.Create(command);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
command.EmployeeId,
|
|
command.WorkshopId
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostRemoveSickLeave(long id, long EmployeeId, long WorkshopId)
|
|
{
|
|
var result = _leaveApplication.RemoveLeave(id);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = EmployeeId,
|
|
workshopId = WorkshopId,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetEditSickLeave(long id)
|
|
{
|
|
var res = _leaveApplication.GetDetails(id);
|
|
|
|
|
|
return Partial("EditSick", res);
|
|
}
|
|
|
|
public IActionResult OnPostEditSickLeave(EditLeave command)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
}
|
|
|
|
command.LeaveType = "استعلاجی";
|
|
var result = _leaveApplication.Edit(command);
|
|
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = command.EmployeeId,
|
|
workshopId = command.WorkshopId,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PaidLeave
|
|
|
|
public IActionResult OnGetCreatePaidLeave(long employeeId, long workshopId, long hd)
|
|
{
|
|
var workshopName = _workshopApplication.GetDetails(workshopId);
|
|
var employeeName = _employeeApplication.GetDetails(employeeId);
|
|
var search = new LeaveSearchModel
|
|
{
|
|
EmployeeId = employeeId,
|
|
WorkshopId = workshopId,
|
|
LeaveType = "استحقاقی"
|
|
};
|
|
var serachResult = _leaveApplication.search(search);
|
|
|
|
var command = new CreateLeave
|
|
{
|
|
EmployeeId = employeeId,
|
|
WorkshopId = workshopId,
|
|
LeaveSearch = serachResult,
|
|
WorkshopName = workshopName.WorkshopFullName,
|
|
EmployeeFullName = employeeName.EmployeeFullName
|
|
};
|
|
return Partial("./PaidLeave", command);
|
|
}
|
|
|
|
public IActionResult OnPostCreatePaidLeave(CreateLeave command)
|
|
{
|
|
command.LeaveType = "استحقاقی";
|
|
|
|
var result = _leaveApplication.Create(command);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
command.EmployeeId,
|
|
command.WorkshopId
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetCheckIfValidToEdit(long id)
|
|
{
|
|
var check = _leaveApplication.CheckIfValidToEdit(id);
|
|
if (check)
|
|
return new JsonResult(new
|
|
{
|
|
validToEdit = true
|
|
});
|
|
return new JsonResult(new
|
|
{
|
|
validToEdit = false
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetEditPaidLeave(long id)
|
|
{
|
|
var res = _leaveApplication.GetDetails(id);
|
|
return Partial("EditPaidLeave", res);
|
|
}
|
|
|
|
public IActionResult OnPostEditPaidLeave(EditLeave command)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
}
|
|
|
|
command.LeaveType = "استحقاقی";
|
|
var result = _leaveApplication.Edit(command);
|
|
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = command.EmployeeId,
|
|
workshopId = command.WorkshopId,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetComputeLeavHourse(string startHours, string endHourse)
|
|
{
|
|
var start = Convert.ToDateTime(startHours);
|
|
var end = Convert.ToDateTime(endHourse);
|
|
if (start > end || start == end) end = end.AddDays(1);
|
|
|
|
var hoursesSpan = end - start;
|
|
var hours = (int)hoursesSpan.TotalHours;
|
|
var minuts = hoursesSpan.TotalMinutes % 60;
|
|
|
|
|
|
if (hours > 0 && minuts > 0)
|
|
return new JsonResult(new
|
|
{
|
|
res = hours + " " + "ساعت و" + " " + minuts + " " + "دقیقه"
|
|
});
|
|
if (hours > 0 && minuts == 0)
|
|
return new JsonResult(new
|
|
{
|
|
res = hours + " " + "ساعت "
|
|
});
|
|
if (hours == 0 && minuts > 0)
|
|
return new JsonResult(new
|
|
{
|
|
res = minuts + " " + "دقیقه"
|
|
});
|
|
|
|
return new JsonResult(new
|
|
{
|
|
totalHours = $"{hours}"
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetComputeLeavdays(string startDay, string endDay)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(startDay) && !string.IsNullOrWhiteSpace(endDay))
|
|
{
|
|
var start = startDay.ToGeorgianDateTime();
|
|
var end = endDay.ToGeorgianDateTime();
|
|
if (end >= start)
|
|
{
|
|
var daysSpan = (end - start).TotalDays + 1;
|
|
return new JsonResult(new
|
|
{
|
|
res = $"{(int)daysSpan} روز"
|
|
});
|
|
}
|
|
|
|
return new JsonResult(new
|
|
{
|
|
res = "تاریخ پایان از تاریخ شروع کوچکتر است"
|
|
});
|
|
}
|
|
|
|
return new JsonResult(new
|
|
{
|
|
res = ""
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostRemovePaidLeave(long id, long EmployeeId, long WorkshopId)
|
|
{
|
|
var result = _leaveApplication.RemoveLeave(id);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = EmployeeId,
|
|
workshopId = WorkshopId,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
//ترک کار
|
|
|
|
#region LeftWorks
|
|
|
|
public IActionResult OnPostRemoveLeftWork(long id, long EmployeeId, string employeeName)
|
|
{
|
|
var result = _leftWorkApplication.RemoveLeftWork(id);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = EmployeeId,
|
|
employeeName,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetCreateLeftWork(long employeeId, string employeeName)
|
|
{
|
|
var search = new LeftWorkSearchModel
|
|
{
|
|
EmployeeId = employeeId
|
|
};
|
|
var serachResult = _leftWorkApplication.search(search);
|
|
var workShops = _workshopApplication.GetWorkshop();
|
|
var command = new CreateLeftWork
|
|
{
|
|
EmployeeId = employeeId,
|
|
EmployeeFullName = employeeName,
|
|
LeftWorkSearch = serachResult,
|
|
Workshops = workShops
|
|
};
|
|
return Partial("./LeftWork", command);
|
|
}
|
|
|
|
public IActionResult OnPostCreateLetWork(CreateLeftWork command)
|
|
{
|
|
//var workshopName = _workshopApplication.GetDetails(command.WorkshopId);
|
|
//var start = _leftWorkApplication.StartWork(command.EmployeeId, command.WorkshopId, command.LeftWorkDate);
|
|
command.LeftWorkDate = "1500/01/01";
|
|
//command.WorkshopName = workshopName.WorkshopFullName;
|
|
|
|
var result = _leftWorkApplication.Create(command);
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
command.EmployeeId,
|
|
employeeName = command.EmployeeFullName
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetEditLeftWork(long id)
|
|
{
|
|
var res = _leftWorkApplication.GetDetails(id);
|
|
|
|
|
|
return Partial("EditLeftWork", res);
|
|
}
|
|
|
|
public IActionResult OnPostEditLeftWork(EditLeftWork command)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
}
|
|
|
|
|
|
var result = _leftWorkApplication.Edit(command);
|
|
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = command.EmployeeId,
|
|
employeeName = command.EmployeeFullName,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
public IActionResult OnGetEnterLeftWork(long id, string employeeName)
|
|
{
|
|
var res = _leftWorkApplication.GetDetails(id);
|
|
res.LeftWorkDate = "";
|
|
res.EmployeeFullName = employeeName;
|
|
|
|
return Partial("EnterLeftWorkDate", res);
|
|
}
|
|
|
|
public IActionResult OnPostEnterLeftWork(EditLeftWork command)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
}
|
|
|
|
|
|
var result = _leftWorkApplication.Edit(command);
|
|
|
|
var res = result.IsSuccedded;
|
|
return new JsonResult(new
|
|
{
|
|
IsSuccedded = res,
|
|
message = result.Message,
|
|
employeeId = command.EmployeeId,
|
|
workshopId = command.WorkshopId,
|
|
hd = 1
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NewChangeByHeydari
|
|
|
|
public IActionResult OnPostDeleteAllContarcts(List<long> ids, long workshopId)
|
|
{
|
|
var op = new OperationResult();
|
|
var workshop = _workshopApplication.GetDetails(workshopId);
|
|
var empId = workshop.EmployerIdList.FirstOrDefault();
|
|
var isBlock = _personalContractingPartyApp.IsBlockByEmployerId(empId);
|
|
if (isBlock == "true")
|
|
return new JsonResult(new
|
|
{
|
|
successDelete = false
|
|
});
|
|
|
|
var checkoutList = _contractApplication.CheckHasCheckout(ids);
|
|
var hasSignatureIds = new List<long>();
|
|
if (checkoutList == null || (checkoutList != null && checkoutList.Count == 0)) //تصفیه حساب نداشته باشد
|
|
{
|
|
hasSignatureIds = _contractApplication.CheckHasSignature(ids);
|
|
if (hasSignatureIds == null || (hasSignatureIds != null && hasSignatureIds.Count == 0)) //امضا نداشته باشد
|
|
op = _contractApplication.DeleteAllContarcts(ids);
|
|
}
|
|
|
|
return new JsonResult(new
|
|
{
|
|
hasCheckout = checkoutList != null && checkoutList.Count() > 0 ? true : false,
|
|
checkoutList,
|
|
hasSignature = hasSignatureIds != null && hasSignatureIds.Count() > 0 ? true : false,
|
|
signatureList = hasSignatureIds,
|
|
successDelete = op.IsSuccedded
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostDeleteContarcts(long id)
|
|
{
|
|
var ids = new List<long>();
|
|
ids.Add(id);
|
|
var op = new OperationResult();
|
|
var checkoutList = _contractApplication.CheckHasCheckout(ids);
|
|
var hasSignatureIds = new List<long>();
|
|
if (checkoutList == null || (checkoutList != null && checkoutList.Count == 0)) //تصفیه حساب نداشته باشد
|
|
{
|
|
hasSignatureIds = _contractApplication.CheckHasSignature(ids);
|
|
if (hasSignatureIds == null ||
|
|
(hasSignatureIds != null && hasSignatureIds.Count == 0)) //امضا نداشته باشد
|
|
op = _contractApplication.DeleteContarcts(id);
|
|
}
|
|
|
|
return new JsonResult(new
|
|
{
|
|
hasCheckout = checkoutList != null && checkoutList.Count() > 0 ? true : false,
|
|
checkoutList,
|
|
hasSignature = hasSignatureIds != null && hasSignatureIds.Count() > 0 ? true : false,
|
|
signatureList = hasSignatureIds,
|
|
successDelete = op.IsSuccedded
|
|
});
|
|
}
|
|
|
|
public IActionResult OnPostSignatureAll(List<long> ids, long workshopId)
|
|
{
|
|
var result = new OperationResult();
|
|
var workshop = _workshopApplication.GetDetails(workshopId);
|
|
var empId = workshop.EmployerIdList.FirstOrDefault();
|
|
var isBlock = _personalContractingPartyApp.IsBlockByEmployerId(empId);
|
|
if (isBlock == "true")
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = false
|
|
});
|
|
|
|
foreach (var item in ids)
|
|
{
|
|
result = _contractApplication.Sign(item);
|
|
if (!result.IsSuccedded)
|
|
break;
|
|
}
|
|
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
public IActionResult OnPostDeleteAllSignature(List<long> ids, long workshopId)
|
|
{
|
|
var permissions = _authHelper.GetPermissions();
|
|
var checkHasPermission = permissions.Any(n => n.Equals(20122));
|
|
|
|
var result = new OperationResult();
|
|
var workshop = _workshopApplication.GetDetails(workshopId);
|
|
var empId = workshop.EmployerIdList.FirstOrDefault();
|
|
var isBlock = _personalContractingPartyApp.IsBlockByEmployerId(empId);
|
|
if (isBlock == "true" || !checkHasPermission)
|
|
return new JsonResult(new
|
|
{
|
|
isSuccedded = false
|
|
});
|
|
|
|
foreach (var item in ids)
|
|
{
|
|
result = _contractApplication.UnSign(item);
|
|
if (!result.IsSuccedded)
|
|
break;
|
|
}
|
|
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
public class Person
|
|
{
|
|
public string FirstName { get; set; }
|
|
public string LastName { get; set; }
|
|
public int Age { get; set; }
|
|
} |