Merge branch 'master' into WorskhopClassifiedPlan

This commit is contained in:
SamSys
2025-10-07 17:36:14 +03:30
24 changed files with 11174 additions and 554 deletions

View File

@@ -22,7 +22,7 @@ public interface ILeaveRepository : IRepository<long, Leave>
bool CheckContractExist(DateTime myDate,long employeeId, long workshopId);
LeavErrorViewModel CheckErrors(DateTime startLeav, DateTime endLeav, long employeeId, long workshopId);
LeavErrorViewModel CheckErrors(DateTime startLeav, DateTime endLeav, long employeeId, long workshopId,bool isInvalid);
LeaveViewModel LeavOnChekout(DateTime starContract, DateTime endContract, long employeeId, long workshopId);
List<LeaveMainViewModel> searchClient(LeaveSearchModel searchModel);
LeavePrintViewModel PrintOne(long id);

View File

@@ -8,7 +8,9 @@ public class Leave: EntityBase
{
public Leave(DateTime startLeave, DateTime endLeave,
string leaveHourses, long workshopId, long employeeId,
string paidLeaveType, string leaveType, string employeeFullName, string workshopName, bool isAccepted, string decription, int year, int month, TimeSpan shiftDuration, bool hasShiftDuration)
string paidLeaveType, string leaveType, string employeeFullName, string workshopName,
bool isAccepted, string decription, int year, int month, TimeSpan shiftDuration,
bool hasShiftDuration,bool isInvalid)
{
StartLeave = startLeave;
EndLeave = endLeave;
@@ -25,6 +27,7 @@ public class Leave: EntityBase
Month = month;
ShiftDuration = shiftDuration;
HasShiftDuration = hasShiftDuration;
IsInvalid = isInvalid;
}
public DateTime StartLeave { get; private set; }
@@ -43,6 +46,10 @@ public class Leave: EntityBase
public TimeSpan ShiftDuration { get; private set; }
public bool HasShiftDuration { get; private set; }
/// <summary>
///آیا فاقد اعتبار است. فاقد اعتبار ها فقط برای فیش های غیررسمی مورد استفاده قرار میگیرند
/// </summary>
public bool IsInvalid { get; private set; }
public void Edit(DateTime startLeave, DateTime endLeave,
string leaveHourses, long workshopId, long employeeId,

View File

@@ -37,4 +37,5 @@ public class CreateLeave
public List<CustomizeRotatingShiftsViewModel> RotatingShifts { get; set; }
public bool HasRollCall { get; set; }
public CustomizeRotatingShiftsViewModel SelectedShift { get; set; }
public bool IsInvallid { get; set; }
}

View File

@@ -27,4 +27,5 @@ public class LeavePrintViewModel
public string MonthGr { get; set; }
public int PrintCounter { get; set; }
public List<EmprViewModel> EmployerList { get; set; }
public bool IsInvalid { get; set; }
}

View File

@@ -20,4 +20,5 @@ public class LeaveSearchModel
public int Year { get; set; }
public int Month { get; set; }
public int PageIndex { get; set; }
public bool IsInvalid { get; set; }
}

View File

@@ -27,4 +27,5 @@ public class LeaveViewModel
public TimeSpan ShiftDuration { get; set; }
public bool HasShiftDuration { get; set; }
public bool IsInvalid { get; set; }
}

View File

@@ -179,8 +179,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
else
{
nationalCodValid = false;
return opration.Failed("کد ملی وارد شده نا معتبر است");
nationalCodValid = false;
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
}
catch (Exception)
@@ -313,8 +318,15 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
else
{
nationalCodValid = false;
return opration.Failed("کد ملی وارد شده نا معتبر است");
if (command.Nationality == "ایرانی")
{
nationalCodValid = false;
return opration.Failed("کد ملی وارد شده نا معتبر است");
}
else
{
nationalCodValid = true;
}
}
}
catch (Exception)

View File

@@ -84,7 +84,7 @@ public class LeaveApplication : ILeaveApplication
var end = command.PaidLeaveType == "ساعتی" ? start : command.EndLeave.ToGeorgianDateTime();
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId);
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId,command.IsInvallid);
// start = new DateTime(start.Year, start.Month, start.Day, startH.Hours, startH.Minutes, startH.Seconds);
//end = new DateTime(end.Year, end.Month, end.Day, endH.Hours, endH.Minutes, endH.Seconds);
@@ -96,10 +96,10 @@ public class LeaveApplication : ILeaveApplication
return op.Failed(checkErr.ContractErrMessage);
if (checkErr.HasLeftWork)
return op.Failed(checkErr.LeftWorlErrMessage);
if (checkErr.HasHolidayError)
return op.Failed(checkErr.HolidayErrorMessage);
//if (checkErr.HasHolidayError)
// return op.Failed(checkErr.HolidayErrorMessage);
if (start > end)
if (start > end)
return op.Failed("تارخ شروع از پایان بزرگتر است");
@@ -238,7 +238,8 @@ public class LeaveApplication : ILeaveApplication
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
var leave = new Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
, command.PaidLeaveType, command.LeaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription, year, month, shiftDuration, hasShiftDuration);
, command.PaidLeaveType, command.LeaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription,
year, month, shiftDuration, hasShiftDuration,command.IsInvallid);
_leaveRepository.Create(leave);
_leaveRepository.SaveChanges();
@@ -300,7 +301,7 @@ public class LeaveApplication : ILeaveApplication
return op.Failed("لطفا تاریخ پایان را وارد کنید");
var start = command.StartLeave.ToGeorgianDateTime();
var end = command.PaidLeaveType == "ساعتی" ? start : command.EndLeave.ToGeorgianDateTime();
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId);
var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId,command.IsInvallid);
if (checkErr.HasChekout)

View File

@@ -20,6 +20,7 @@ public class LeaveMapping : IEntityTypeConfiguration<Leave>
builder.Property(x => x.IsAccepted);
builder.Property(x => x.Decription).HasMaxLength(255);
builder.Property(x => x.ShiftDuration).HasTimeSpanConversion();
builder.HasQueryFilter(x => !x.IsInvalid);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addisInvalidtoleave : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsInvalid",
table: "Leave",
type: "bit",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsInvalid",
table: "Leave");
}
}
}

View File

@@ -3948,6 +3948,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<bool>("IsAccepted")
.HasColumnType("bit");
b.Property<bool>("IsInvalid")
.HasColumnType("bit");
b.Property<string>("LeaveHourses")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");

View File

@@ -6,12 +6,14 @@ using _0_Framework.InfraStructure;
using Company.Domain.LeaveAgg;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Leave;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
{
private readonly CompanyContext _context;
public LeaveRepository(CompanyContext context) : base(context)
{
_context = context;
@@ -20,24 +22,24 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
public EditLeave GetDetails(long id)
{
return _context.LeaveList.Select(x => new EditLeave()
{
Id = x.id,
StartLeave = x.StartLeave.ToFarsi(),
EndLeave = x.EndLeave.ToFarsi(),
StartLeaveGr = x.StartLeave,
EndLeaveGr = x.EndLeave,
WorkshopId = x.WorkshopId,
EmployeeId = x.EmployeeId,
LeaveHourses = x.LeaveHourses,
PaidLeaveType = x.PaidLeaveType,
LeaveType = x.LeaveType,
EmployeeFullName = x.EmployeeFullName,
WorkshopName = x.WorkshopName,
IsAccepted = x.IsAccepted,
Decription = x.Decription,
Year = x.Year,
Month = x.Month,
HasRollCall = x.HasShiftDuration,
{
Id = x.id,
StartLeave = x.StartLeave.ToFarsi(),
EndLeave = x.EndLeave.ToFarsi(),
StartLeaveGr = x.StartLeave,
EndLeaveGr = x.EndLeave,
WorkshopId = x.WorkshopId,
EmployeeId = x.EmployeeId,
LeaveHourses = x.LeaveHourses,
PaidLeaveType = x.PaidLeaveType,
LeaveType = x.LeaveType,
EmployeeFullName = x.EmployeeFullName,
WorkshopName = x.WorkshopName,
IsAccepted = x.IsAccepted,
Decription = x.Decription,
Year = x.Year,
Month = x.Month,
HasRollCall = x.HasShiftDuration,
}).FirstOrDefault(x => x.Id == id);
}
@@ -63,16 +65,20 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
Month = x.Month,
HasShiftDuration = x.HasShiftDuration,
ShiftDuration = x.ShiftDuration,
IsInvalid = x.IsInvalid
});
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
if (searchModel.IsInvalid)
{
query = query.IgnoreQueryFilters().Where(x => x.IsInvalid);
}
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
if (!string.IsNullOrWhiteSpace(searchModel.LeaveType))
query = query.Where(x => x.LeaveType == searchModel.LeaveType);
query = query.Where(x => x.LeaveType == searchModel.LeaveType);
if (!string.IsNullOrWhiteSpace(searchModel.PaidLeaveType))
query = query.Where(x => x.PaidLeaveType == searchModel.PaidLeaveType);
query = query.Where(x => x.PaidLeaveType == searchModel.PaidLeaveType);
if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave))
{
DateTime startSearch = searchModel.StartLeave.ToGeorgianDateTime();
@@ -81,21 +87,29 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
(startSearch <= x.EndLeaveGr.Date && endSearch >= x.EndLeaveGr.Date) ||
(startSearch >= x.StartLeaveGr.Date && startSearch <= x.EndLeaveGr.Date) ||
(endSearch >= x.StartLeaveGr.Date && endSearch <= x.EndLeaveGr.Date));
}else if (searchModel.StartLeaveGr != null && searchModel.EndLeaveGr != null)
}
else if (searchModel.StartLeaveGr != null && searchModel.EndLeaveGr != null)
{
query = query.Where(x => (searchModel.StartLeaveGr <= x.StartLeaveGr.Date && searchModel.EndLeaveGr >= x.StartLeaveGr.Date) ||
(searchModel.StartLeaveGr <= x.EndLeaveGr.Date && searchModel.EndLeaveGr >= x.EndLeaveGr.Date) ||
(searchModel.StartLeaveGr >= x.StartLeaveGr.Date && searchModel.StartLeaveGr <= x.EndLeaveGr.Date) ||
(searchModel.EndLeaveGr >= x.StartLeaveGr.Date && searchModel.EndLeaveGr <= x.EndLeaveGr.Date));
}
if(searchModel.IsAccepted)
query = query.Where(x => x.IsAccepted == true);
return query.OrderByDescending(x => x.Id).ToList();
query = query.Where(x =>
(searchModel.StartLeaveGr <= x.StartLeaveGr.Date && searchModel.EndLeaveGr >= x.StartLeaveGr.Date) ||
(searchModel.StartLeaveGr <= x.EndLeaveGr.Date && searchModel.EndLeaveGr >= x.EndLeaveGr.Date) ||
(searchModel.StartLeaveGr >= x.StartLeaveGr.Date && searchModel.StartLeaveGr <= x.EndLeaveGr.Date) ||
(searchModel.EndLeaveGr >= x.StartLeaveGr.Date && searchModel.EndLeaveGr <= x.EndLeaveGr.Date));
}
if (searchModel.IsAccepted)
query = query.Where(x => x.IsAccepted == true);
return query.OrderByDescending(x => x.Id).ToList();
}
public List<LeaveMainViewModel> searchClient(LeaveSearchModel searchModel)
{
var leaveMainList = _context.LeaveList.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
var leaveMainList = _context.LeaveList.Where(x =>
x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
if (searchModel.IsInvalid)
{
leaveMainList = leaveMainList.IgnoreQueryFilters().Where(x => x.IsInvalid);
}
if (searchModel.LeaveType == "paidLeave")
leaveMainList = leaveMainList.Where(x => x.LeaveType == "استحقاقی");
@@ -135,7 +149,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
EndLeaveGr = item.EndLeave,
WorkshopId = item.WorkshopId,
EmployeeId = item.EmployeeId,
LeaveHourses = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType,item.LeaveHourses),
LeaveHourses = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
PaidLeaveType = item.PaidLeaveType,
LeaveType = item.LeaveType,
IsAccepted = item.IsAccepted,
@@ -169,17 +183,21 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
IsAccepted = x.IsAccepted,
Decription = x.Decription,
EmployerList = new List<EmprViewModel>(),
IsInvalid = x.IsInvalid
}).SingleOrDefault(x => x.Id == id);
//leave.ContractNo = _context.Contracts.FirstOrDefault(x => x.ContarctStart <= leave.StartLeaveGr && x.ContractEnd > leave.StartLeaveGr
// && x.ContarctStart < leave.EndLeaveGr && x.ContractEnd > leave.EndLeaveGr
// && x.WorkshopIds == leave.WorkshopId && x.EmployeeId == leave.EmployeeId).ContractNo;
leave.ContractNo = _context.Contracts.FirstOrDefault(x=>x.ContarctStart <= leave.StartLeaveGr && x.ContractEnd >= leave.StartLeaveGr && x.EmployeeId == leave.EmployeeId && x.WorkshopIds == leave.WorkshopId)?.ContractNo;
leave.ContractNo = _context.Contracts.FirstOrDefault(x =>
x.ContarctStart <= leave.StartLeaveGr && x.ContractEnd >= leave.StartLeaveGr &&
x.EmployeeId == leave.EmployeeId && x.WorkshopIds == leave.WorkshopId)?.ContractNo;
var Employee = _context.Employees.SingleOrDefault(x => x.id == leave.EmployeeId);
leave.NationalCode = Employee.NationalCode;
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == leave.WorkshopId).Select(x => x.EmployerId).ToList();
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == leave.WorkshopId).Select(x => x.EmployerId)
.ToList();
var employerlist = _context.Employers.Select(x => new EmprViewModel()
{
Id = x.id,
@@ -225,21 +243,24 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
Year = x.Year,
Month = x.Month,
MonthGr = Tools.ToFarsiMonthByIntNumber(x.Month),
EmployerList = new List<EmprViewModel>()
EmployerList = new List<EmprViewModel>(),
IsInvalid = x.IsInvalid
}).SingleOrDefault(x => x.Id == item);
//leave.ContractNo = _context.Contracts.FirstOrDefault(x => x.ContarctStart <= leave.StartLeaveGr && x.ContractEnd > leave.StartLeaveGr
// && x.ContarctStart < leave.EndLeaveGr && x.ContractEnd > leave.EndLeaveGr
// && x.WorkshopIds == leave.WorkshopId && x.EmployeeId == leave.EmployeeId).ContractNo;
leave.ContractNo = _context.Contracts.FirstOrDefault(x => x.ContarctStart <= leave.StartLeaveGr
&& x.ContractEnd >= leave.StartLeaveGr && x.EmployeeId == leave.EmployeeId
leave.ContractNo = _context.Contracts.FirstOrDefault(x => x.ContarctStart <= leave.StartLeaveGr
&& x.ContractEnd >= leave.StartLeaveGr &&
x.EmployeeId == leave.EmployeeId
&& x.WorkshopIds == leave.WorkshopId)?.ContractNo;
var Employee = _context.Employees.SingleOrDefault(x => x.id == leave.EmployeeId);
leave.NationalCode = Employee.NationalCode;
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == leave.WorkshopId).Select(x => x.EmployerId).ToList();
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == leave.WorkshopId).Select(x => x.EmployerId)
.ToList();
var employerlist = _context.Employers.Select(x => new EmprViewModel()
{
Id = x.id,
@@ -254,8 +275,10 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
{
leave.EmployerList = new List<EmprViewModel>();
}
query.Add(leave);
}
query = query.OrderBy(x => x.Year).ThenBy(x => x.Month).ToList();
int printNumer = 0;
foreach (var rec in query)
@@ -263,6 +286,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
printNumer += 1;
rec.PrintCounter = printNumer;
}
return query;
}
@@ -281,6 +305,11 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
if (searchModel.LeaveType == "sickLeave")
leaveMainList = leaveMainList.Where(x => x.LeaveType == "استعلاجی");
if (searchModel.IsInvalid)
{
leaveMainList = leaveMainList.IgnoreQueryFilters().Where(x => x.IsInvalid);
}
if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave))
{
var start = searchModel.StartLeave.ToGeorgianDateTime();
@@ -297,41 +326,43 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
}
var leaveList = leaveMainList.Where(x => x.WorkshopId == searchModel.WorkshopId).Select(item => new LeaveViewModel()
{
Id = item.id,
StartLeave = item.StartLeave.ToFarsi(),
EndLeave = item.EndLeave.ToFarsi(),
StartLeaveGr = item.StartLeave,
EndLeaveGr = item.EndLeave,
WorkshopId = item.WorkshopId,
EmployeeId = item.EmployeeId,
EmployeeFullName = item.EmployeeFullName,
LeaveHourses = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
PaidLeaveType = item.PaidLeaveType,
LeaveType = item.LeaveType,
IsAccepted = item.IsAccepted,
Decription = item.Decription,
Year = item.Year,
Month = item.Month,
MonthStr = item.Month.ToFarsiMonthByIntNumber(),
CreationDate = item.CreationDate,
}).OrderByDescending(x => x.CreationDate).Skip(searchModel.PageIndex).Take(30).ToList();
var leaveList = leaveMainList.Where(x => x.WorkshopId == searchModel.WorkshopId).Select(item =>
new LeaveViewModel()
{
Id = item.id,
StartLeave = item.StartLeave.ToFarsi(),
EndLeave = item.EndLeave.ToFarsi(),
StartLeaveGr = item.StartLeave,
EndLeaveGr = item.EndLeave,
WorkshopId = item.WorkshopId,
EmployeeId = item.EmployeeId,
EmployeeFullName = item.EmployeeFullName,
LeaveHourses = Tools.CalculateLeaveHoursAndDays(item.PaidLeaveType, item.LeaveHourses),
PaidLeaveType = item.PaidLeaveType,
LeaveType = item.LeaveType,
IsAccepted = item.IsAccepted,
Decription = item.Decription,
Year = item.Year,
Month = item.Month,
MonthStr = item.Month.ToFarsiMonthByIntNumber(),
CreationDate = item.CreationDate,
IsInvalid = item.IsInvalid
}).OrderByDescending(x => x.CreationDate).Skip(searchModel.PageIndex).Take(30).ToList();
return leaveList;
}
#endregion
public bool CheckIfValidToEdit(long id)
{
var leave = _context.LeaveList.FirstOrDefault(x => x.id == id);
var checkoutExist = _context.CheckoutSet.Where(x => x.WorkshopId == leave.WorkshopId && x.EmployeeId == leave.EmployeeId)
var checkoutExist = _context.CheckoutSet
.Where(x => x.WorkshopId == leave.WorkshopId && x.EmployeeId == leave.EmployeeId)
.Where(x => leave.StartLeave <= x.ContractEnd).ToList();
if (checkoutExist.Count > 0)
{
return false;
}
else
@@ -346,37 +377,38 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
var item = _context.LeaveList.FirstOrDefault(x => x.id == id);
if (item != null)
{
var checkoutExist = _context.CheckoutSet.Where(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId)
var checkoutExist = _context.CheckoutSet
.Where(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId)
.Where(x => item.StartLeave <= x.ContractEnd).ToList();
if (checkoutExist.Count > 0)
{
return op.Failed("در بازه زمانی این مرخصی و یا بعد از آن فیش حقوقی وجود دارد");
}
else
{
_context.LeaveList.Remove(item);
_context.SaveChanges();
return op.Succcedded();
}
}
return op.Failed("موردی یافت نشد");
}
#region Pooya
public bool HasDailyLeave(long employeeId, long workshopId, DateTime date)
{
return _context.LeaveList
.Where(x => (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه") ||
x.LeaveType == "استعلاجی")
.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
x.StartLeave.Date <= date.Date && x.EndLeave.Date >= date.Date) != null;
.Where(x => (x.LeaveType == "استحقاقی" && x.PaidLeaveType == "روزانه") ||
x.LeaveType == "استعلاجی")
.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
x.StartLeave.Date <= date.Date && x.EndLeave.Date >= date.Date) != null;
}
public List<LeaveViewModel> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end)
public List<LeaveViewModel> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start,
DateTime end)
{
return _context.LeaveList.Where(x => x.EmployeeId == employeeId && x.EndLeave >= start && x.StartLeave <= end)
.Select(x => new LeaveViewModel
@@ -389,28 +421,32 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
EndLeaveGr = x.EndLeave,
LeaveHourses = x.LeaveHourses
}).ToList();
}
}
#endregion
public bool CheckContractExist(DateTime myDate, long employeeId, long workshopId)
{
var result = _context.Contracts.Any(x => x.ContarctStart <= myDate
&& x.ContractEnd >= myDate && x.EmployeeId == employeeId &&
x.WorkshopIds == workshopId && x.IsActiveString=="true");
x.WorkshopIds == workshopId && x.IsActiveString == "true");
return result;
}
public LeavErrorViewModel CheckErrors(DateTime startLeav, DateTime endLeav, long employeeId, long workshopId)
public LeavErrorViewModel CheckErrors(DateTime startLeav, DateTime endLeav, long employeeId, long workshopId,
bool invalidCheckout)
{
var res = new LeavErrorViewModel();
#region Check iF Has Checkout
//var checkoutExist = _context.CheckoutSet.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
// .Where(x => (startLeav >= x.ContractStart && startLeav <= x.ContractEnd && endLeav > x.ContractEnd) ||
// (startLeav >= x.ContractStart && endLeav <= x.ContractEnd) ||
// (startLeav < x.ContractStart && endLeav <= x.ContractEnd && endLeav >= x.ContractStart) ||
// (startLeav < x.ContractStart && endLeav > x.ContractEnd)).ToList();
var checkoutExist = _context.CheckoutSet.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId && startLeav <= x.ContractEnd).ToList();
var checkoutExist = _context.CheckoutSet.Where(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId && startLeav <= x.ContractEnd).ToList();
if (checkoutExist.Count > 0)
{
res.HasChekout = true;
@@ -433,6 +469,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
res.ContractErrMessage = "در بازه تاریخ مرخصی وارد شده قراردادی وجود ندارد";
return res;
}
#endregion
#region Check LeftWork
@@ -445,22 +482,32 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
if (leftCheck.Count < 1)
{
res.HasLeftWork = true;
res.LeftWorlErrMessage = " پرسنل در بازه تاریخ وارد شده شروع بکار ندارد";
return res;
res.HasLeftWork = true;
res.LeftWorlErrMessage = " پرسنل در بازه تاریخ وارد شده شروع بکار ندارد";
return res;
}
#endregion
#region HolidayError
var hasCustomizeCheckout =
_context.RollCallServices.FirstOrDefault(x => x.WorkshopId == workshopId && x.IsActiveString == "true")
?.HasCustomizeCheckoutService == "true";
if (_context.HolidayItems.Any(x => startLeav.Date == x.Holidaydate.Date) ||
startLeav.DayOfWeek == DayOfWeek.Friday)
{
res.HasHolidayError = true;
res.HolidayErrorMessage = "شما نمیتوانید در روز های تعطیل مرخصی ثبت کنید";
if (!hasCustomizeCheckout)
{
res.HasHolidayError = true;
res.HolidayErrorMessage = "شما نمیتوانید در روز های تعطیل مرخصی ثبت کنید";
}
else if (!invalidCheckout)
{
res.HasHolidayError = true;
res.HolidayErrorMessage = "شما نمیتوانید در روز های مرخصی دارای اعتبار ثبت کنید";
}
}
#endregion
@@ -470,7 +517,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
public LeaveViewModel LeavOnChekout(DateTime starContract, DateTime endContract, long employeeId, long workshopId)
{
return _context.LeaveList.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x =>
return _context.LeaveList.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x =>
new LeaveViewModel()
{
Id = x.id,
@@ -483,10 +530,9 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
LeaveType = x.LeaveType,
IsAccepted = x.IsAccepted,
Decription = x.Decription
}).FirstOrDefault(x =>
(starContract <= x.StartLeaveGr && endContract >= x.StartLeaveGr) ||
(starContract <= x.EndLeaveGr && endContract >= x.EndLeaveGr) ||
(starContract <= x.EndLeaveGr && endContract >= x.EndLeaveGr) ||
(starContract >= x.StartLeaveGr && starContract <= x.EndLeaveGr) ||
(endContract >= x.StartLeaveGr && endContract <= x.EndLeaveGr));
}

View File

@@ -3547,6 +3547,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
StartLeaveGr = contractStart,
EndLeaveGr = contractEnd,
IsAccepted = true,
};
List<LeaveViewModel> leaveList = _leaveRepository.search(leaveHourseSearch);

View File

@@ -31,6 +31,7 @@
data-action="ReloadLeave">
<input type="hidden" asp-for="@Model.WorkshopId" />
<input type="hidden" asp-for="@Model.IsInvallid" id="isInvalid" />
<div class="modal-content">
<div class="modal-header d-block text-center position-relative">
@@ -208,6 +209,8 @@
var computeLeaveDailyAjax = `@Url.Page("/Company/Employees/Leave", "ComputeLeaveDaily")`;
var employeeListAjax = `@Url.Page("Index", "EmployeeList")`;
var hasRotatingShiftAjax = `@Url.Page("/Company/Employees/Leave", "HasRotatingShift")`;
var checkCanCreateInvalidUrl = `@Url.Page("/Company/Employees/Leave","CheckIsInvalidLeave")`;
</script>
<script src="~/assetsclient/pages/employees/js/createleave.js?ver=@clientVersion"></script>

View File

@@ -252,6 +252,8 @@
<input type="hidden" name="leaveType" id="leaveType" asp-for="SearchModel.LeaveType" />
<input type="hidden" name="start" id="start" asp-for="SearchModel.StartLeave" />
<input type="hidden" name="end" id="end" asp-for="SearchModel.EndLeave" />
<input type="hidden" name="isInvalid" id="isInvalid" asp-for="SearchModel.IsInvalid" />
<div class="container-fluid d-none d-lg-block">
<div class="row px-2">
@@ -260,64 +262,80 @@
<div class="col-12">
<div class="d-grid search-section gap-2">
<div class="d-grid grid-cols-3 gap-2 col-span-4">
@{
var gridCols = Model.HasCustomizeCheckout ? "4" : "3";
}
<div class="d-grid grid-cols-@gridCols gap-2 col-span-4">
<div class="wrapper-dropdown-normal btn-dropdown" id="dropdown-normal">
<span class="selected-display" id="destination-normal">هر دو</span>
<svg id="drp-arrow" class="arrow transition-all ml-auto rotate-180" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-normal boxes">
<li class="item" value-data-normal="both">هر دو</li>
<li class="item" value-data-normal="paidLeave">استحقاقی</li>
<li class="item" value-data-normal="sickLeave">استعلاجی</li>
</ul>
<input type="hidden" id="sendSorting" asp-for="SearchModel.LeaveType"/>
</div>
<div class="wrapper-dropdown-year btn-dropdown" id="dropdown-year">
<span class="selected-display" id="destination-year">سال</span>
<svg class="arrow" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="transition-all ml-auto rotate-180">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-year boxes" id="my-scrollbar">
<li class="item" value-data-year="0">سال</li>
@foreach (string year in @Model.YearlyList)
{
<li class="item" value-data-year="@year">@year</li>
}
</ul>
<input type="hidden" id="sendDropdownYear" asp-for="SearchModel.Year"/>
</div>
<div class="wrapper-dropdown-month btn-dropdown" id="dropdown-month">
<span class="selected-display" id="destination-month">ماه</span>
<svg class="arrow" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="transition-all ml-auto rotate-180">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-month boxes">
<li class="item" value-data-month="0">ماه</li>
<li class="item" value-data-month="01">فروردین</li>
<li class="item" value-data-month="02">اردیبهشت</li>
<li class="item" value-data-month="03">خرداد</li>
<li class="item" value-data-month="04">تیر</li>
<li class="item" value-data-month="05">مرداد</li>
<li class="item" value-data-month="06">شهریور</li>
<li class="item" value-data-month="07">مهر</li>
<li class="item" value-data-month="08">آبان</li>
<li class="item" value-data-month="09">آذر</li>
<li class="item" value-data-month="10">دی</li>
<li class="item" value-data-month="11">بهمن</li>
<li class="item" value-data-month="12">اسفند</li>
</ul>
<input type="hidden" id="sendDropdownMonth" asp-for="SearchModel.Month"/>
<span class="selected-display" id="destination-normal">هر دو</span>
<svg id="drp-arrow" class="arrow transition-all ml-auto rotate-180" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-normal boxes">
<li class="item" value-data-normal="both">هر دو</li>
<li class="item" value-data-normal="paidLeave">استحقاقی</li>
<li class="item" value-data-normal="sickLeave">استعلاجی</li>
</ul>
<input type="hidden" id="sendSorting" asp-for="SearchModel.LeaveType"/>
</div>
</div>
<div class="col-span-2 md-col-span-2"><input type="text" class="form-control date start-date" asp-for="SearchModel.StartLeave" placeholder="تاریخ شروع"></div>
<div class="wrapper-dropdown-year btn-dropdown" id="dropdown-year">
<span class="selected-display" id="destination-year">سال</span>
<svg class="arrow transition-all ml-auto rotate-180" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-year boxes" id="my-scrollbar">
<li class="item" value-data-year="0">سال</li>
@foreach (string year in @Model.YearlyList)
{
<li class="item" value-data-year="@year">@year</li>
}
</ul>
<input type="hidden" id="sendDropdownYear" asp-for="SearchModel.Year"/>
</div>
<div class="wrapper-dropdown-month btn-dropdown" id="dropdown-month">
<span class="selected-display" id="destination-month">ماه</span>
<svg class="arrow transition-all ml-auto rotate-180" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-month boxes">
<li class="item" value-data-month="0">ماه</li>
<li class="item" value-data-month="01">فروردین</li>
<li class="item" value-data-month="02">اردیبهشت</li>
<li class="item" value-data-month="03">خرداد</li>
<li class="item" value-data-month="04">تیر</li>
<li class="item" value-data-month="05">مرداد</li>
<li class="item" value-data-month="06">شهریور</li>
<li class="item" value-data-month="07">مهر</li>
<li class="item" value-data-month="08">آبان</li>
<li class="item" value-data-month="09">آذر</li>
<li class="item" value-data-month="10">دی</li>
<li class="item" value-data-month="11">بهمن</li>
<li class="item" value-data-month="12">اسفند</li>
</ul>
<input type="hidden" id="sendDropdownMonth" asp-for="SearchModel.Month"/>
</div>
@if (Model.HasCustomizeCheckout)
{
<div class="wrapper-dropdown-invalid btn-dropdown" id="dropdown-invalid">
<span class="selected-display" id="destination-invalid">دارای اعتبار</span>
<svg class="arrow transition-all ml-auto rotate-180" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 14.5l5-5 5 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
<ul class="dropdown-invalid boxes">
<li class="item" value-data-invalid="false">دارای اعتبار</li>
<li class="item" value-data-invalid="true">فاقد اعتبار</li>
</ul>
<input type="hidden" id="sendDropdownInvalid" asp-for="SearchModel.IsInvalid"/>
</div>
}
</div>
<div class="col-span-1 md-col-span-2"><input type="text" class="form-control date start-date" asp-for="SearchModel.StartLeave" placeholder="تاریخ شروع"></div>
<div class="col-span-2 md-col-span-2"><input type="text" class="form-control date end-date" asp-for="SearchModel.EndLeave" placeholder="تاریخ پایان"></div>
<div class="col-span-2 md-col-span-3">
<div class="employeeSelect">
<select class="form-select select2Option" aria-label="انتخاب پرسنل ..." asp-for="SearchModel.EmployeeId" id="employeeSelect">
@@ -888,13 +906,20 @@
</select>
</div>
<div class="mb-2">
<select class="form-select" asp-for="SearchModel.LeaveType">
<option value="both" selected>هر دو</option>
<option value="paidLeave">استحقاقی</option>
<option value="sickLeave">استعلاجی</option>
</select>
</div>
<div class="mb-2">
<select class="form-select" asp-for="SearchModel.LeaveType">
<option value="both" selected>هر دو</option>
<option value="paidLeave">استحقاقی</option>
<option value="sickLeave">استعلاجی</option>
</select>
</div>
<div class="mb-2">
<select class="form-select" asp-for="SearchModel.IsInvalid">
<option value="false">دارای اعتبار</option>
<option value="true">فاقد اعتبار</option>
</select>
</div>
<div>
<span class="form-control text-center persianDateInputStartDate" id="start-date">تاریخ شروع</span>
@@ -1219,6 +1244,12 @@
$('#sendDropdownMonth').val(dataVal);
});
$('.dropdown-invalid .item').on("click", function () {
let dataVal = $(this).attr("value-data-invalid");
$('#sendDropdownInvalid').val(dataVal === 'both' ? '' : dataVal);
$('#isInvalid').val(dataVal === 'both' ? '' : dataVal)
});
var sendDropdownNormal = $("#sendSorting").val();
if (sendDropdownNormal) {
let itemDropdownNormal = $(".dropdown-normal").find(".item[value-data-normal='" + sendDropdownNormal + "']");
@@ -1243,6 +1274,21 @@
selectedMonthDisplay.text(itemDropdownMonth.text());
}
// Initialize invalid dropdown display
var sendDropdownInvalid = $("#sendDropdownInvalid").val();
if (!sendDropdownInvalid) {
let itemInvalidBoth = $(".dropdown-invalid").find(".item[value-data-invalid='both']");
itemInvalidBoth.addClass("active");
var selectedInvalidDisplay = $(".wrapper-dropdown-invalid").find(".selected-display");
selectedInvalidDisplay.text(itemInvalidBoth.text());
} else {
let invalidVal = sendDropdownInvalid.toString().toLowerCase();
let itemInvalid = $(".dropdown-invalid").find(".item[value-data-invalid='" + invalidVal + "']");
itemInvalid.addClass("active");
var selectedInvalidDisplay = $(".wrapper-dropdown-invalid").find(".selected-display");
selectedInvalidDisplay.text(itemInvalid.text());
}
// check if anything else ofther than the dropdown is clicked
window.addEventListener("click", function (e) {
if (e.target.closest(".wrapper-dropdown") === null) {
@@ -2752,7 +2798,8 @@
'searchModel.LeaveType': $('#leaveType').val(),
'searchModel.StartLeave': $('#start').val(),
'searchModel.EndLeave': $('#end').val(),
'searchModel.PageIndex': $('#pageIndex').val()
'searchModel.PageIndex': $('#pageIndex').val(),
'searchModel.IsInvalid': $('#isInvalid').val(),
};

View File

@@ -15,7 +15,9 @@ using System.Text.RegularExpressions;
using _0_Framework.Infrastructure;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
using CompanyManagment.App.Contracts.HolidayItem;
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
using CompanyManagment.App.Contracts.RollCallService;
namespace ServiceHost.Areas.Client.Pages.Company.Employees
{
@@ -49,10 +51,13 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IHttpContextAccessor _contextAccessor;
private readonly long _workshopId;
private readonly IHolidayItemApplication _holidayItemApplication;
private readonly IRollCallServiceApplication _rollCallServiceApplication;
public int PageIndex;
public bool HasCustomizeCheckout { get; set; }
#region Initial Data
public LeaveModel(IWorkshopApplication workshopApplication, IEmployeeApplication employeeApplication, IAuthHelper authHelper, ILeaveApplication leaveApplication, IYearlySalaryApplication yearlySalaryApplication, IPasswordHasher passwordHasher, IHttpContextAccessor contextAccessor, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication)
#region Initial Data
public LeaveModel(IWorkshopApplication workshopApplication, IEmployeeApplication employeeApplication, IAuthHelper authHelper, ILeaveApplication leaveApplication, IYearlySalaryApplication yearlySalaryApplication, IPasswordHasher passwordHasher, IHttpContextAccessor contextAccessor, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IHolidayItemApplication holidayItemApplication, IRollCallServiceApplication rollCallServiceApplication)
{
_workshopApplication = workshopApplication;
_employeeApplication = employeeApplication;
@@ -62,6 +67,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
_contextAccessor = contextAccessor;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
_holidayItemApplication = holidayItemApplication;
_rollCallServiceApplication = rollCallServiceApplication;
_authHelper = authHelper;
@@ -80,6 +87,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
{
//long employeeId = _passwordHasher.SlugDecrypt(employeeHash);
long employeeId = searchModel.EmployeeId;
var rollCallServiceViewModel = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId);
HasCustomizeCheckout = rollCallServiceViewModel is { HasCustomizeCheckoutService: "true" };
if (employeeId >= 0)
{
var workshop = _workshopApplication.GetDetails(_workshopId);
@@ -91,7 +100,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
Year = searchModel.Year,
Month = searchModel.Month,
StartLeave = searchModel.StartLeave,
EndLeave = searchModel.EndLeave
EndLeave = searchModel.EndLeave,
IsInvalid = searchModel.IsInvalid
};
Year = searchModel.Year;
Month = searchModel.Month;
@@ -166,6 +176,35 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees
PrintID = result.SendId
});
}
public IActionResult OnPostCheckIsInvalidLeave(string startDate)
{
bool isInHoliday = false;
bool canCreateInvalid = false;
var dateTimeGr = startDate.ToGeorgianDateTime();
if (dateTimeGr.DayOfWeek == DayOfWeek.Friday)
{
isInHoliday = true;
}else if (_holidayItemApplication.IsHoliday(dateTimeGr))
{
isInHoliday = true;
};
if (isInHoliday)
{
var rollCallService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId);
if (rollCallService != null)
{
canCreateInvalid =rollCallService.HasCustomizeCheckoutService == "true";
}
}
return new JsonResult(new
{
isInHoliday,
canCreateInvalid
});
}
#endregion
#region Check If Valide To Edit

View File

@@ -329,7 +329,8 @@
}
</div>
<div class="col-6 d-inline-block text-center">
<p style="font-size: 15px; font-weight: bold">برگ مرخصی</p>
<p class="m-0" style="font-size: 15px; font-weight: bold">برگ مرخصی @(item.IsInvalid?"(فاقداعتبار)":"")</p>
</div>
<div class="col-3 d-inline-block" style="text-align: left;">
@if (item.PaidLeaveType == "روزانه")

View File

@@ -222,7 +222,7 @@
<div class="row">
<div class="col-3 d-inline-block"><fieldset style="border: 1px solid black; border-radius: 15px; padding: 1px 15px 1px 15px; width: 60%; font-size: 12px; text-align: center;"> @item.ContractNo</fieldset></div>
<div class="col-6 d-inline-block text-center">
<p style="font-size: 15px; font-weight: bold">برگ مرخصی</p>
<p class="m-0" style="font-size: 15px; font-weight: bold">برگ مرخصی @(item.IsInvalid?"(فاقداعتبار)":"")</p>
</div>
<div class="col-3 d-inline-block" style="text-align: left;">
@if (item.PaidLeaveType == "روزانه")

View File

@@ -298,7 +298,7 @@
}
</div>
<div class="col-6 d-inline-block text-center">
<p class="m-0" style="font-size: 15px; font-weight: bold">برگ مرخصی</p>
<p class="m-0" style="font-size: 15px; font-weight: bold">برگ مرخصی @(Model.IsInvalid?"(فاقداعتبار)":"")</p>
</div>
<div class="col-3 d-inline-block" style="text-align: left;">
@if (Model.PaidLeaveType == "روزانه")

View File

@@ -230,7 +230,7 @@
<div class="row">
<div class="col-3 d-inline-block"><fieldset style="border: 1px solid black; border-radius: 15px; padding: 1px 15px 1px 15px; width: 60%; font-size: 12px; text-align: center;"> @Model.ContractNo</fieldset></div>
<div class="col-6 d-inline-block text-center">
<p style="font-size: 15px; font-weight: bold">برگ مرخصی</p>
<p class="m-0" style="font-size: 15px; font-weight: bold">برگ مرخصی @(Model.IsInvalid?"(فاقداعتبار)":"")</p>
</div>
<div class="col-3 d-inline-block" style="text-align: left;">
@if (Model.PaidLeaveType == "روزانه")

View File

@@ -548,6 +548,7 @@ svg {
overflow: hidden;
}
.dropdown-global-item {
padding: 4px 10px;
cursor: pointer;
@@ -567,4 +568,101 @@ svg {
.dropdown-global.active .dropdown-global-content {
display: flex;
}
}
/* --------------------------------------------------------------------------------Invalid-------------------------------------------------------------------------------------- */
/* the code below is for the dropdown menu */
.wrapper-dropdown-invalid {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 3px 7px;
border-radius: 7px;
background: #ffffff;
color: #575a5d;
border: 1px solid #DADADA;
font-size: 12px;
font-weight: 400;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.wrapper-dropdown-invalid::before {
position: absolute;
top: 50%;
right: 16px;
margin-top: -2px;
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: #fff transparent;
}
.wrapper-dropdown-invalid .dropdown-invalid {
transition: 0.3s;
position: absolute;
top: 120%;
right: 0;
left: 0;
margin: 0;
padding: 0;
list-style: none;
z-index: 99;
border-radius: 15px;
background: inherit;
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
opacity: 0;
visibility: hidden;
height: auto;
overflow: auto;
scrollbar-width: none;
scrollbar-color: #dfe3ea #fff;
border: 1px solid #DADADA;
}
.wrapper-dropdown-invalid .dropdown-invalid li {
padding: 0 10px;
line-height: 36px;
overflow: hidden;
transition: all .1s ease;
margin: 2px 0;
white-space: nowrap;
}
.wrapper-dropdown-invalid .dropdown-invalid li:last-child {
border-bottom: none;
}
.dropdown-invalid {
padding: 0.5rem !important;
}
.wrapper-dropdown-invalid .dropdown-invalid li:hover {
background-color: #3ad1d1;
color: #fff;
border-radius: 10px;
}
.wrapper-dropdown-invalid .dropdown-invalid .active {
background-color: #3ad1d1;
color: #fff;
border-radius: 10px;
}
.wrapper-dropdown-invalid.active .dropdown-invalid {
opacity: 1;
visibility: visible;
border-radius: 15px;
}

View File

@@ -215,6 +215,58 @@ $(document).ready(function () {
});
}
/* --------------------------------------------------------------------------------Invalid-------------------------------------------------------------------------------------- */
// dropdown invalid
const selectedAllInvalid = document.querySelectorAll(".wrapper-dropdown-invalid");
selectedAllInvalid.forEach((selected) => {
const optionsContainer = selected.children[2];
const optionsList = selected.querySelectorAll("div.wrapper-dropdown-invalid li");
selected.addEventListener("click", () => {
let arrow = selected.children[1];
let currentActive = document.querySelector(".wrapper-dropdown-invalid.active");
if (currentActive) {
let anotherArrow = currentActive.children[1];
handleDropdown(currentActive, anotherArrow, false);
}
handleDropdown(selected, arrow, true);
});
// update the display of the dropdown invalid
for (let o of optionsList) {
o.addEventListener("click", () => {
selected.querySelector(".selected-display").innerHTML = o.innerHTML;
});
}
$(document).on("click", '.dropdown-invalid .item', function (e) {
$('.dropdown-invalid .item').removeClass("active");
$(this).addClass("active");
closeAllDropdownsInvalid();
});
});
// check if anything else other than the dropdown invalid is clicked
window.addEventListener("click", function (e) {
if (e.target.closest(".wrapper-dropdown-invalid") === null) {
closeAllDropdownsInvalid();
}
});
// close all the dropdowns invalid
function closeAllDropdownsInvalid() {
const selectedInvalid = document.querySelectorAll(".wrapper-dropdown-invalid");
selectedInvalid.forEach((selected) => {
const optionsContainer = selected.children[2];
let arrow = selected.children[1];
handleDropdown(selected, arrow, false);
});
}
// open all the dropdowns
function handleDropdown(dropdown, arrow, open) {

View File

@@ -14,7 +14,7 @@ $(document).ready(function () {
return data.text;
}
});
$(".select2OptionShift").select2({
language: "fa",
dir: "rtl",
@@ -27,12 +27,12 @@ $(document).ready(function () {
}
});
ajaxPersonals();
ajaxPersonals();
$("#cardSectionLeave div *").prop('disabled', true);
document.getElementById("MainModal").style.visibility = "visible";
document.getElementById("MainModal").style.visibility = "visible";
$('#employeeSelectList').on('change', function () {
$('#employeeSelectList').on('change', function () {
$('#rotatingShiftSection').addClass('disable');
$('#HasRollCall').val(false);
previousStartDate = "";
@@ -65,7 +65,7 @@ $(document).ready(function () {
$('#SelectedShift_EndTime').val(endTime || '');
});
$('#employeeSelectList').change(function () {
$('#employeeSelectList').change(function () {
var selectValue = $('#employeeSelectList').val();
if (selectValue === '') {
@@ -78,64 +78,64 @@ $(document).ready(function () {
}
});
//******************** شرط استحقاقی و استعلاجی ********************
$(document).on("change", ".LeaveType", function () {
if ($('#paid').is(':checked')) {
$('#dailyType').css('visibility', 'visible');
rotatingShift();
}
if ($('#sick').is(':checked')) {
$('#dailyType').css('visibility', 'hidden');
$('#daily').prop('checked', true);
if ($('#daily').is(':checked')) {
$('#end_date_estehghaghi').show();
$('.time_paid').hide();
}
//******************** شرط استحقاقی و استعلاجی ********************
$(document).on("change", ".LeaveType", function () {
if ($('#paid').is(':checked')) {
$('#dailyType').css('visibility', 'visible');
rotatingShift();
}
});
}
// شرط ساعتی و روزانه
$(document).on("change", ".LeaveTime", function () {
if ($('#daily').is(':checked')) {
$('#end_date_estehghaghi').show();
$('.time_paid').hide();
if ($('#sick').is(':checked')) {
$('#dailyType').css('visibility', 'hidden');
$('#daily').prop('checked', true);
if ($('#daily').is(':checked')) {
$('#end_date_estehghaghi').show();
$('.time_paid').hide();
}
rotatingShift();
}
}
});
if ($('#hourly').is(':checked')) {
$('#end_date_estehghaghi').hide();
$('.time_paid').show();
// شرط ساعتی و روزانه
$(document).on("change", ".LeaveTime", function () {
if ($('#daily').is(':checked')) {
$('#end_date_estehghaghi').show();
$('.time_paid').hide();
rotatingShift();
}
});
//******************** شرط استحقاقی و استعلاجی ********************
}
if ($('#hourly').is(':checked')) {
$('#end_date_estehghaghi').hide();
$('.time_paid').show();
rotatingShift();
}
});
//******************** شرط استحقاقی و استعلاجی ********************
//******************** بلور کردن باکس ********************
$('#IsAccepted').on('change', function () {
if ($(this).is(':checked')) {
$('#blur-div').addClass('blur');
$('#textArea').text('');
$('#textArea').attr('disabled', true);
//******************** بلور کردن باکس ********************
$('#IsAccepted').on('change', function () {
if ($(this).is(':checked')) {
$('#blur-div').addClass('blur');
$('#textArea').text('');
$('#textArea').attr('disabled', true);
} else {
$('#blur-div').removeClass('blur');
$('#textArea').attr('disabled', false);
}
});
} else {
$('#blur-div').removeClass('blur');
$('#textArea').attr('disabled', false);
}
});
if ($('#IsAccepted').is(':checked')) {
$('#blur-div').addClass('blur');
$('#textArea').text('');
$('#textArea').attr('disabled', true);
} else {
$('#blur-div').removeClass('blur');
$('#textArea').attr('disabled', false);
}
//******************** بلور کردن باکس ********************
if ($('#IsAccepted').is(':checked')) {
$('#blur-div').addClass('blur');
$('#textArea').text('');
$('#textArea').attr('disabled', true);
} else {
$('#blur-div').removeClass('blur');
$('#textArea').attr('disabled', false);
}
//******************** بلور کردن باکس ********************
$(document).on("change", "#IsAccepted", function () {
var IsAcceptedCheck = $('#IsAccepted').is(':checked');
@@ -149,7 +149,7 @@ $(document).ready(function () {
}
});
$('#save').on('click', function () {
$('#save').on('click', function () {
var hasRollCallInput = $("#HasRollCall").val();
var rotatingShiftInput = $("#rotatingShift").val();
@@ -166,91 +166,128 @@ $(document).ready(function () {
}
}
$("#descriptionAcceptedCheck").on("change", function () {
$('#descriptionAcceptedCheck').removeClass('errored');
});
$("#descriptionAcceptedCheck").on("change", function () {
$('#descriptionAcceptedCheck').removeClass('errored');
});
var IsAcceptedCheck = $('#IsAccepted').is(':checked');
var descriptionAcceptedCheck = $('#descriptionAcceptedCheck').val();
var IsAcceptedCheck = $('#IsAccepted').is(':checked');
var descriptionAcceptedCheck = $('#descriptionAcceptedCheck').val();
if (!IsAcceptedCheck && descriptionAcceptedCheck.length === 0) {
$('#descriptionAcceptedCheck').addClass('errored');
$('.alert-msg').show();
$('.alert-msg p').text('لطفا توضیحات در صورت عدم موافقت را پر کنید.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
return false;
}
if (!IsAcceptedCheck && descriptionAcceptedCheck.length === 0) {
$('#descriptionAcceptedCheck').addClass('errored');
$('.alert-msg').show();
$('.alert-msg p').text('لطفا توضیحات در صورت عدم موافقت را پر کنید.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
return false;
}
if ($('.errored').length < 1) {
$('#saveFinaly').click();
} else {
$('.alert-msg').show();
$('.alert-msg p').text('لطفا خطاها را برطرف کنید.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
}
});
if ($('.errored').length < 1) {
$.ajax({
/* contentType: 'charset=utf-8',*/
async: false,
dataType: 'json',
type: 'POST',
url: checkCanCreateInvalidUrl,
headers: {"RequestVerificationToken": antiForgeryToken},
data: {"startDate": $('#StartLeave').val()},
success: function (response) {
debugger;
if (response.isInHoliday) {
if (response.canCreateInvalid) {
swal({
title: "در قانون کار کشور ایجاد مرخصی در روز های تعطیل فاقد اعتبار میباشد، و فقط در فیش های حقوقی غیر رسمی قابل استفاده میباشند. آیا میخواهید ادامه دهید؟",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: true
},
function (isConfirm) {
if (isConfirm) {
$('#isInvalid').val("true");
$('#saveFinaly').click();
}
});
}
} else if (response.isInHoliday === false) {
$('#saveFinaly').click();
}
},
failure: function (response) {
console.log(5, response);
}
});
//$('#saveFinaly').click();
} else {
$('.alert-msg').show();
$('.alert-msg p').text('لطفا خطاها را برطرف کنید.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
}
});
$(".date").on('input', function () {
var value = $(this).val();
$(this).val(convertPersianNumbersToEnglish(value));
}).mask("0000/00/00");
$('.date').on('input', function () {
let startDate = this.value;
if (startDate.length === 10) {
let submitcheck = dateValidcheck(this);
if (submitcheck) {
$(".date").on('input', function () {
var value = $(this).val();
$(this).val(convertPersianNumbersToEnglish(value));
}).mask("0000/00/00");
$('.date').on('input', function () {
let startDate = this.value;
if (startDate.length === 10) {
let submitcheck = dateValidcheck(this);
if (submitcheck) {
$(this).removeClass('errored');
if ($('#StartLeave').val() != '' && $('#EndLeave').val() != '') {
computeDays();
}
$(this).removeClass('errored');
if ($('#StartLeave').val() != '' && $('#EndLeave').val() != '') {
computeDays();
}
} else {
$(this).addClass('errored');
} else {
$(this).addClass('errored');
}
}
} else {
$(this).addClass('errored');
}
});
} else {
$(this).addClass('errored');
}
});
$('input:radio[name="PaidLeaveType"]').change(function () {
if ($(this).is(':checked') && $(this).val() == 'روزانه') {
$("#hours").val('');
$("#hours").attr("disabled", "disabled");
$("#endLeave").removeAttr("disabled");
$('.endLeaveLabal').show();
$('#StartHoures').removeClass("invalidTime");
$('#StartHoures').val('');
$('#EndHours').removeClass("invalidTime");
$('#EndHours').val('');
$("#endLeave").show();
$('.res').remove();
$('.validTime').removeClass("validTime");
$('.sumHourseDiv').hide();
$('.sumDaysDiv').show();
} else if ($(this).is(':checked') && $(this).val() == 'ساعتی') {
$("#endLeave").val('');
$("#endLeave").attr("disabled", "disabled");
$("#endLeave").hide();
$('.endLeaveLabal').hide();
$("#hours").removeAttr("disabled");
$('.sumHourseDiv').show();
$('.sumDaysDiv').hide();
}
});
/////////////////Time Input Validatet/////////////////
$('input:radio[name="PaidLeaveType"]').change(function () {
if ($(this).is(':checked') && $(this).val() == 'روزانه') {
$("#hours").val('');
$("#hours").attr("disabled", "disabled");
$("#endLeave").removeAttr("disabled");
$('.endLeaveLabal').show();
$('#StartHoures').removeClass("invalidTime");
$('#StartHoures').val('');
$('#EndHours').removeClass("invalidTime");
$('#EndHours').val('');
$("#endLeave").show();
$('.res').remove();
$('.validTime').removeClass("validTime");
$('.sumHourseDiv').hide();
$('.sumDaysDiv').show();
} else if ($(this).is(':checked') && $(this).val() == 'ساعتی') {
$("#endLeave").val('');
$("#endLeave").attr("disabled", "disabled");
$("#endLeave").hide();
$('.endLeaveLabal').hide();
$("#hours").removeAttr("disabled");
$('.sumHourseDiv').show();
$('.sumDaysDiv').hide();
}
});
/////////////////Time Input Validatet/////////////////
$(".dateTime").each(function () {
$(".dateTime").each(function () {
let element = $(this);
element.on('input', function () {
let value = convertPersianNumbersToEnglish(element.val());
@@ -264,6 +301,7 @@ $(document).ready(function () {
});
$("#StartHoures, #EndHours").on("keyup", validateTimeOrder);
function parseTimeToMinutes(time) {
const [hours, minutes] = time.split(':').map(Number);
return hours * 60 + minutes;
@@ -301,121 +339,122 @@ $(document).ready(function () {
return true;
}
//$('#StartHoures').on("keyup", function () {
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
// if (isValid) {
// $(this).addClass("validTime");
// $(this).removeClass("invalidTime");
// if ($('#EndHours').hasClass('validTime') && $('#EndHours').val() != null) {
// computeHourse();
// }
// } else {
// $(this).removeClass("validTime");
// $(this).addClass("invalidTime");
// }
// });
//$('#EndHours').on("keyup", function () {
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
// if (isValid) {
// $(this).addClass("validTime");
// $(this).removeClass("invalidTime");
// if ($('#StartHoures').hasClass('validTime') && $('#StartHoures').val() != null) {
// computeHourse();
// }
// } else {
// $(this).removeClass("validTime");
// $(this).addClass("invalidTime");
// }
// });
//$('#StartHoures').on("keyup", function () {
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
// if (isValid) {
// $(this).addClass("validTime");
// $(this).removeClass("invalidTime");
// if ($('#EndHours').hasClass('validTime') && $('#EndHours').val() != null) {
// computeHourse();
// }
// } else {
// $(this).removeClass("validTime");
// $(this).addClass("invalidTime");
// }
// });
//$('#EndHours').on("keyup", function () {
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
// if (isValid) {
// $(this).addClass("validTime");
// $(this).removeClass("invalidTime");
// if ($('#StartHoures').hasClass('validTime') && $('#StartHoures').val() != null) {
// computeHourse();
// }
// } else {
// $(this).removeClass("validTime");
// $(this).addClass("invalidTime");
// }
// });
//$('#employeeSelect').change(function () {
// var selectValue = $('#employeeSelect').val();
//
// if (selectValue == '') {
// $('#cardSectionLeave').addClass('blur');
// $("#cardSectionLeave div *").prop('disabled', true);
// } else {
// $('#cardSectionLeave').removeClass('blur');
// $("#cardSectionLeave div *").prop('disabled', false);
// $('#descriptionAcceptedCheck').attr('disabled', true);
// }
//});
//$('#employeeSelect').change(function () {
// var selectValue = $('#employeeSelect').val();
//
// if (selectValue == '') {
// $('#cardSectionLeave').addClass('blur');
// $("#cardSectionLeave div *").prop('disabled', true);
// } else {
// $('#cardSectionLeave').removeClass('blur');
// $("#cardSectionLeave div *").prop('disabled', false);
// $('#descriptionAcceptedCheck').attr('disabled', true);
// }
//});
});
function dateValidcheck(inputField1) {
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === 'string') {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
let getdate = inputField1.value;
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === 'string') {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
let getdate = inputField1.value;
let m1, m2;
let y1, y2, y3, y4;
let d1, d2;
let s1, s2;
for (var i = 0; i < getdate.length; i++) {
if (i === 0) {
y1 = fixNumbers(getdate[i]);
}
if (i === 1) {
y2 = fixNumbers(getdate[i]);
}
if (i === 2) {
y3 = fixNumbers(getdate[i]);
}
if (i === 3) {
y4 = fixNumbers(getdate[i]);
}
if (i === 4) {
s1 = fixNumbers(getdate[i]);
}
if (i === 5) {
m1 = fixNumbers(getdate[i]);
}
if (i === 6) {
m2 = fixNumbers(getdate[i]);
}
if (i === 7) {
s2 = fixNumbers(getdate[i]);
}
if (i === 8) {
d1 = fixNumbers(getdate[i]);
}
if (i === 9) {
d2 = fixNumbers(getdate[i]);
}
let m1, m2;
let y1, y2, y3, y4;
let d1, d2;
let s1, s2;
for (var i = 0; i < getdate.length; i++) {
if (i === 0) {
y1 = fixNumbers(getdate[i]);
}
if (i === 1) {
y2 = fixNumbers(getdate[i]);
}
if (i === 2) {
y3 = fixNumbers(getdate[i]);
}
if (i === 3) {
y4 = fixNumbers(getdate[i]);
}
if (i === 4) {
s1 = fixNumbers(getdate[i]);
}
if (i === 5) {
m1 = fixNumbers(getdate[i]);
}
if (i === 6) {
m2 = fixNumbers(getdate[i]);
}
if (i === 7) {
s2 = fixNumbers(getdate[i]);
}
if (i === 8) {
d1 = fixNumbers(getdate[i]);
}
if (i === 9) {
d2 = fixNumbers(getdate[i]);
}
}
let yRes = y1 + y2 + y3 + y4;
let year = parseInt(yRes);
let mRes = m1 + m2;
let month = parseInt(mRes);
let dRes = d1 + d2;
let day = parseInt(dRes);
let fixResult = yRes + s1 + mRes + s2 + dRes;
let test1 = checkEnValid(inputField1.value);
}
let yRes = y1 + y2 + y3 + y4;
let year = parseInt(yRes);
let mRes = m1 + m2;
let month = parseInt(mRes);
let dRes = d1 + d2;
let day = parseInt(dRes);
let fixResult = yRes + s1 + mRes + s2 + dRes;
let test1 = checkEnValid(inputField1.value);
let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult);
let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult);
if (isValid && test1) {
// inputField1.style.backgroundColor = '#a6e9a6';
start1valid = true;
if (isValid && test1) {
// inputField1.style.backgroundColor = '#a6e9a6';
start1valid = true;
} else {
} else {
if (inputField1.value != "") {
// inputField1.style.backgroundColor = '#f94c4c';
//$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید");
if (inputField1.value != "") {
// inputField1.style.backgroundColor = '#f94c4c';
//$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید");
$('#StartLeave').addClass('errored');
$('.alert-msg').show();
$('.alert-msg p').text('لطفا تاریخ را بصورت صحیح وارد کنید');
@@ -424,161 +463,161 @@ function dateValidcheck(inputField1) {
$('.alert-msg p').text("");
$('#StartLeave').removeClass("errored");
}, 3500);
start1valid = false;
}
start1valid = false;
}
}
return start1valid;
}
return start1valid;
}
function checkEnValid(fixDate1) {
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === 'string') {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
let getdate = fixDate1;
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === 'string') {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
let getdate = fixDate1;
let m1, m2;
let y1, y2, y3, y4;
let d1, d2;
for (let i = 0; i < getdate.length; i++) {
if (i === 0) {
y1 = fixNumbers(getdate[i]);
}
if (i === 1) {
y2 = fixNumbers(getdate[i]);
}
if (i === 2) {
y3 = fixNumbers(getdate[i]);
}
if (i === 3) {
y4 = fixNumbers(getdate[i]);
}
if (i === 5) {
m1 = fixNumbers(getdate[i]);
}
if (i === 6) {
m2 = fixNumbers(getdate[i]);
}
if (i === 8) {
d1 = fixNumbers(getdate[i]);
}
if (i === 9) {
d2 = fixNumbers(getdate[i]);
}
}
let yRes = y1 + y2 + y3 + y4;
let year = parseInt(yRes);
let mRes = m1 + m2;
let month = parseInt(mRes);
let dRes = d1 + d2;
let day = parseInt(dRes);
let kabiseh = false;
if (month <= 6 && day > 31) {
return false;
} else if (month > 6 && month < 12 && day > 30) {
return false;
} else if (month === 12) {
let m1, m2;
let y1, y2, y3, y4;
let d1, d2;
for (let i = 0; i < getdate.length; i++) {
if (i === 0) {
y1 = fixNumbers(getdate[i]);
}
if (i === 1) {
y2 = fixNumbers(getdate[i]);
}
if (i === 2) {
y3 = fixNumbers(getdate[i]);
}
if (i === 3) {
y4 = fixNumbers(getdate[i]);
}
if (i === 5) {
m1 = fixNumbers(getdate[i]);
}
if (i === 6) {
m2 = fixNumbers(getdate[i]);
}
if (i === 8) {
d1 = fixNumbers(getdate[i]);
}
if (i === 9) {
d2 = fixNumbers(getdate[i]);
}
}
let yRes = y1 + y2 + y3 + y4;
let year = parseInt(yRes);
let mRes = m1 + m2;
let month = parseInt(mRes);
let dRes = d1 + d2;
let day = parseInt(dRes);
let kabiseh = false;
if (month <= 6 && day > 31) {
return false;
} else if (month > 6 && month < 12 && day > 30) {
return false;
} else if (month === 12) {
switch (year) {
case 1346:
kabiseh = true;
break;
case 1350:
kabiseh = true;
break;
case 1354:
kabiseh = true;
break;
case 1358:
kabiseh = true;
break;
case 1362:
kabiseh = true;
break;
case 1366:
kabiseh = true;
break;
case 1370:
kabiseh = true;
break;
case 1375:
kabiseh = true;
break;
case 1379:
kabiseh = true;
break;
case 1383:
kabiseh = true;
break;
case 1387:
kabiseh = true;
break;
case 1391:
kabiseh = true;
break;
case 1395:
kabiseh = true;
break;
case 1399:
kabiseh = true;
break;
case 1403:
kabiseh = true;
break;
case 1408:
kabiseh = true;
break;
case 1412:
kabiseh = true;
break;
case 1416:
kabiseh = true;
break;
case 1420:
kabiseh = true;
break;
case 1424:
kabiseh = true;
break;
case 1428:
kabiseh = true;
break;
case 1432:
kabiseh = true;
break;
case 1436:
kabiseh = true;
break;
case 1441:
kabiseh = true;
break;
case 1445:
kabiseh = true;
break;
default:
kabiseh = false;
switch (year) {
case 1346:
kabiseh = true;
break;
case 1350:
kabiseh = true;
break;
case 1354:
kabiseh = true;
break;
case 1358:
kabiseh = true;
break;
case 1362:
kabiseh = true;
break;
case 1366:
kabiseh = true;
break;
case 1370:
kabiseh = true;
break;
case 1375:
kabiseh = true;
break;
case 1379:
kabiseh = true;
break;
case 1383:
kabiseh = true;
break;
case 1387:
kabiseh = true;
break;
case 1391:
kabiseh = true;
break;
case 1395:
kabiseh = true;
break;
case 1399:
kabiseh = true;
break;
case 1403:
kabiseh = true;
break;
case 1408:
kabiseh = true;
break;
case 1412:
kabiseh = true;
break;
case 1416:
kabiseh = true;
break;
case 1420:
kabiseh = true;
break;
case 1424:
kabiseh = true;
break;
case 1428:
kabiseh = true;
break;
case 1432:
kabiseh = true;
break;
case 1436:
kabiseh = true;
break;
case 1441:
kabiseh = true;
break;
case 1445:
kabiseh = true;
break;
default:
kabiseh = false;
}
if (kabiseh == true && day > 30) {
return false;
} else if (kabiseh == false && day > 29) {
return false;
} else {
return true;
}
} else {
return true;
}
}
if (kabiseh == true && day > 30) {
return false;
} else if (kabiseh == false && day > 29) {
return false;
} else {
return true;
}
} else {
return true;
}
}
function computeHourse() {
@@ -588,9 +627,9 @@ function computeHourse() {
async: false,
dataType: 'json',
type: 'GET',
url: computeLeaveHourlyAjax,
headers: { "RequestVerificationToken": antiForgeryToken },
data: { "startHours": $('#StartHoures').val(), "endHours": $('#EndHours').val() },
url: computeLeaveHourlyAjax,
headers: {"RequestVerificationToken": antiForgeryToken},
data: {"startHours": $('#StartHoures').val(), "endHours": $('#EndHours').val()},
success: function (response) {
let res = `<span class="res">${response.res}</span>`;
$('.sumHours').append(res);
@@ -608,9 +647,9 @@ function computeDays() {
async: false,
dataType: 'json',
type: 'GET',
url: computeLeaveDailyAjax,
headers: { "RequestVerificationToken": antiForgeryToken },
data: { "startDay": $('#StartLeave').val(), "endDay": $('#EndLeave').val() },
url: computeLeaveDailyAjax,
headers: {"RequestVerificationToken": antiForgeryToken},
data: {"startDay": $('#StartLeave').val(), "endDay": $('#EndLeave').val()},
success: function (response) {
if (response.status == false) {
$('.sumDays').addClass("note");
@@ -635,11 +674,11 @@ function ajaxPersonals() {
$("#cardSectionLeave div *").prop('disabled', true);
var employees = response.data;
var employeeOptionsHtml = '<option value="">انتخاب پرسنل ...</option>';
employees.forEach(function (employee) {
var black = employee.black ? "blackSelect" : "";
employees.forEach(function (employee) {
var black = employee.black ? "blackSelect" : "";
employeeOptionsHtml += `<option class="${black}" value="${employee.id}">${employee.employeeFullName}</option>`;
});
$('#employeeSelectList').html(employeeOptionsHtml);
$('#employeeSelectList').html(employeeOptionsHtml);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
@@ -648,15 +687,13 @@ function ajaxPersonals() {
}
function rotatingShift() {
var startDateValue = $('#StartLeave').val();
$('#rotatingShiftSection').addClass('disable');
if ($('#paid').is(':checked') && $('#daily').is(':checked') && startDateValue.length === 10) {
ajaxService.get(hasRotatingShiftAjax, { employeeId: currentEmployeeId, startDateTime: startDateValue })
ajaxService.get(hasRotatingShiftAjax, {employeeId: currentEmployeeId, startDateTime: startDateValue})
.then(response => {
$('#HasRollCall').val(response.hasRollCall);