camera changes - add admin rollcall reports

This commit is contained in:
SamSys
2024-12-22 02:47:29 +03:30
parent 8277ab5c7b
commit 9c54102596
18 changed files with 403 additions and 284 deletions

View File

@@ -32,23 +32,24 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
public List<TicketViewModel> GetAll(TicketSearchModel searchModel)
{
var query = _accountContext.Tickets.OrderByDescending(x => x.CreationDate).Select(x => new TicketViewModel()
{
Description = x.Description,
SenderId = x.SenderId,
ContractingPartyName = x.ContractingPartyName,
Id = x.id,
Title = x.Title,
TicketType = x.TicketType,
Status = x.Status,
CreationDateTimeGr = x.CreationDate,
CreationDateTime = x.CreationDate.ToFarsiFull(),
TicketNumber = $"TKC_{x.TicketNumber}",
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName,
HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)),
WorkshopId = x.WorkshopId,
RawTicketNumber = x.TicketNumber
});
var query = _accountContext.Tickets.OrderBy(x => x.Status == "بسته شده").ThenBy(x => x.Status == "پاسخ داده شده")
.ThenBy(x => x.Status == "درحال بررسی").ThenBy(x => "باز").Select(x => new TicketViewModel()
{
Description = x.Description,
SenderId = x.SenderId,
ContractingPartyName = x.ContractingPartyName,
Id = x.id,
Title = x.Title,
TicketType = x.TicketType,
Status = x.Status,
CreationDateTimeGr = x.CreationDate,
CreationDateTime = x.CreationDate.ToFarsiFull(),
TicketNumber = $"TKC_{x.TicketNumber}",
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName,
HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)),
WorkshopId = x.WorkshopId,
RawTicketNumber = x.TicketNumber
});
#region Search

View File

@@ -60,8 +60,10 @@ namespace Company.Domain.RollCallAgg
RollCallViewModel GetDetails(long rollCallId);
#endregion
long Flag(long employeeId, long workshopId);
TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, DateTime start, DateTime end);
#endregion
long Flag(long employeeId, long workshopId);
/// <summary>
/// چک می کند که اگر کارگر به تازگی خروج یا ورود زده است اجازه ثبت مجدد ندهد

View File

@@ -34,10 +34,19 @@ namespace CompanyManagment.App.Contracts.RollCall
#region Pooya
OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa);
/// <summary>
/// برای صدور فیش حقوقی
/// برای محسابه ساعت کارکرد هنگام جستجوی پرسنل در بازه زمانی در صفحه سوابق
/// </summary>
List<CheckoutDailyRollCallViewModel> GetActiveEmployeeRollCallsForDuration(long employeeId, long workshopId,
TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, string startFa, string endFa);
/// <summary>
/// برای صدور فیش حقوقی
/// </summary>
List<CheckoutDailyRollCallViewModel> GetActiveEmployeeRollCallsForDuration(long employeeId, long workshopId,
string startDate, string endDate);

View File

@@ -565,8 +565,8 @@ public class InsuranceListApplication: IInsuranceListApplication
case 6219://ثابت
countWorkingDays = 15;
break;
case 7897://ثابت
countWorkingDays = 15;
//case 7897://ثابت
// countWorkingDays = 15;
break;
}
#endregion
@@ -1509,9 +1509,9 @@ public class InsuranceListApplication: IInsuranceListApplication
case 6219://ثابت
countWorkingDays = 15;
break;
case 7897://ثابت
countWorkingDays = 15;
break;
//case 7897://ثابت
// countWorkingDays = 15;
// break;
}
;
#endregion

View File

@@ -76,8 +76,21 @@ public class RollCallApplication : IRollCallApplication
}
#region Pooya
public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa)
#region Pooya
public TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, string startFa,
string endFa)
{
if (startFa.TryToGeorgianDateTime(out DateTime startDateTime) == false)
return TimeSpan.Zero;
if (endFa.TryToGeorgianDateTime(out DateTime endDateTime) == false)
return TimeSpan.Zero;
if(startDateTime > endDateTime)
return TimeSpan.Zero;
return _rollCallRepository.GetEmployeeRollCallTimeSpanForDuration(employeeId, workshopId, startDateTime, endDateTime);
}
public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa)
{
OperationResult op = new();
var date = dateFa.ToGeorgianDateTime();
@@ -125,7 +138,7 @@ public class RollCallApplication : IRollCallApplication
{
startDateTimeGr = startDateTime.ToGeorgianDateTime();
endDateTimeGr = endDateTime.ToGeorgianDateTime();
if (endDateTimeGr <= startDateTimeGr)
if (endDateTimeGr < startDateTimeGr)
{
return new();
}

View File

@@ -62,8 +62,8 @@ namespace CompanyManagment.Application
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
//موقت
//یکتا تجارت گیل
if(workshopId == 108)
//یکتا تجارت گیل 108 - کهن سرویس وارنا 215
if(workshopId == 108 || workshopId == 215)
return false;
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);

View File

@@ -19,6 +19,7 @@ using System.Linq;
using CompanyManagment.App.Contracts.Fine;
using System.Globalization;
using System.IO;
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using Microsoft.EntityFrameworkCore;
@@ -59,10 +60,18 @@ CreateWorkingHoursTemp command, long leavId)
string shiftOver22Minuts = "0";
double ShiftPayResult = 0;
int numberOfFridays = 0;
#endregion
#endregion
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
//گرفتن ساعت استراحت پرسنل از تنظیمات
#region breakTime
BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
#endregion
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel()
{
@@ -76,18 +85,20 @@ CreateWorkingHoursTemp command, long leavId)
CreationDate = x.Key,
ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(),
HasFriday = x.Any(s => s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value.DayOfWeek == DayOfWeek.Friday),
SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)),
}).ToList();
SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - CalculateBreakTime(breakTime,
new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
}).ToList();
numberOfFridays = groupedRollCall.Count(x => x.HasFriday);
//*****کسر ساعاعت استراحت پرسنل از ساعت کار
List<GroupedRollCalls> rollCallSubtractSpan = groupedRollCall.Select(x => new GroupedRollCalls()
{
CreationDate = x.CreationDate,
AfterSubtractRestSpan = AfterSubtract(command, x.SumOneDaySpan, x.CreationDate),
}).ToList();
TimeSpan sumSpans = new TimeSpan(rollCallSubtractSpan.Sum(x => x.AfterSubtractRestSpan.Ticks));
////*****کسر ساعاعت استراحت پرسنل از ساعت کار
//List<GroupedRollCalls> rollCallSubtractSpan = groupedRollCall.Select(x => new GroupedRollCalls()
//{
// CreationDate = x.CreationDate,
// AfterSubtractRestSpan = AfterSubtract(command, x.SumOneDaySpan, x.CreationDate),
//}).ToList();
TimeSpan sumSpans = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks));
//****افزودن مرخصی پرسنل به مجموع ساعات کار***
@@ -130,7 +141,7 @@ CreateWorkingHoursTemp command, long leavId)
}).ToList();
leavingDayCout += afterCheckout.Sum(x => x.DayCounter);
Console.WriteLine(leavingDayCout);
TimeSpan workingPerDayAve = sumSpans / rollCallSubtractSpan.Count;//میانگین ساعت کار در روز
TimeSpan workingPerDayAve = sumSpans / groupedRollCall.Count;//میانگین ساعت کار در روز
TimeSpan sumLeave = new TimeSpan();
if (workingPerDayAve <= new TimeSpan(7, 20, 0))
{
@@ -493,7 +504,20 @@ CreateWorkingHoursTemp command, long leavId)
return res;
}
public TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate)
private TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan)
{
if (breakTime.BreakTimeType != BreakTimeType.WithTime)
return TimeSpan.Zero;
var breakTimeSpan = breakTime.BreakTimeValue.ToTimeSpan();
if (breakTimeSpan * 2 >= sumOneDaySpan)
return TimeSpan.Zero;
return breakTimeSpan; ;
}
public TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate)
{
#region RestTimes

View File

@@ -161,7 +161,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
RollCallDateFa = x.Key.Date.ToFarsi(),
DateTimeGr = x.Key.Date,
IsSliced = x.Count() > 1
IsSliced = x.Count() > 2
};
});
@@ -184,6 +184,8 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
}
public List<RollCallViewModel> GetEmployeeRollCallsHistoryAll(long workshopId, long employeeId, DateTime start, DateTime end)
{
return _context.RollCalls.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.EndDate.Value >= start &&
@@ -198,9 +200,19 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
}
public TimeSpan GetEmployeeRollCallTimeSpanForDuration(long employeeId, long workshopId, DateTime start, DateTime end)
{
//جستجوی سوابق حضور غیاب بر اساس کارمند
public EmployeeRollCallsByMonthViewModel GetEmployeeRollCallsHistory(long employeeId, long workshopId,
var rollCalls = _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate != null && x.EndDate != null && x.RollCallModifyType != RollCallModifyType.Undefined &&
x.StartDate.Value.Date >= start && x.StartDate.Value.Date <= end).ToList();
return new TimeSpan(rollCalls.Sum(x => (x.EndDate - x.StartDate).Value.Ticks));
}
//جستجوی سوابق حضور غیاب بر اساس کارمند
public EmployeeRollCallsByMonthViewModel GetEmployeeRollCallsHistory(long employeeId, long workshopId,
DateTime? startDateTime, DateTime? endDateTime, DateTime? exactDateTime, DateTime? dateIndex)
{
@@ -716,7 +728,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
#endregion
public long Flag(long employeeId, long workshopId)
{
var checkDate = DateTime.Now.AddDays(-3);
var checkDate = DateTime.Now.AddDays(-5);
var query = _context.RollCalls
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.CreationDate >= checkDate);
if (query.Any())

View File

@@ -29,7 +29,7 @@ namespace Query.AdminReports.Handlers
//workshop filter by parameters
var rollCallServiceQuery = _companyContext.RollCallServices
.Where(x => x.StartService.Date <= DateTime.Now.Date && x.EndService.Date >= DateTime.Now.Date);
.Where(x => x.StartService <= DateTime.Now && x.EndService >= DateTime.Now);
var allWorkshops = _companyContext.Workshops.Select(x => new { x.id, x.WorkshopFullName });
if (!string.IsNullOrWhiteSpace(parameters.WorkshopName))

View File

@@ -445,12 +445,12 @@ public class IndexModel : PageModel
else
{
mandatoryCompute = MandatoryHours(workingHours, workshop.WorkshopHolidayWorking, 0);
var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr,
separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds);
if (hasLeave != null)
{
//var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id);
}
//var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr,
// separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds);
//if (hasLeave != null)
//{
// //var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id);
//}
}

View File

@@ -52,7 +52,7 @@
<div id="loader" class="loader-container">
<div class="loader">
<svg version="1.1" class="logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 621.6 721.91" x="0px" y="0px" style="enable-background:new 0 0 97.4 71.4;" xml:space="preserve">
@* <svg version="1.1" class="logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 621.6 721.91" x="0px" y="0px" style="enable-background:new 0 0 97.4 71.4;" xml:space="preserve">
<defs>
<linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#30c1c1;stop-opacity:1" />
@@ -62,8 +62,16 @@
<polygon class="cls-3 letter letter--gradient" points="0 328.82 129.91 244.95 129.91 453.87 310.8 562.4 488.4 453.87 488.4 355.2 310.8 355.2 488.4 241.73 621.6 241.73 621.6 541.02 310.8 721.91 0 541.02 0 328.82" />
<polygon class="cls-1 letter letter--gradient" points="217.07 309.16 217.07 192.4 426.8 65.78 523.83 123.33 217.07 309.16" />
<polyline class="cls-2 letter letter--gradient" points="308.61 0 395.56 47.69 1.3 293.19 1.3 184.66 308.61 0" />
</svg>
</div>
</svg> *@
<img src="~/assetsclient/images/gozareshgir-gr.svg" />
<div style="color:white;font-size: 12px;margin-top:15px;display: flex;align-items: center;gap: 2px;white-space: nowrap;">
<i class="ion-loading-a" > </i> در حال آماده سازی...
</div>
</div>
</div>
<div id="content" style="display: none">
@@ -356,6 +364,6 @@
</script>
@* <script src="~/assetscamera/js/index.js"></script> *@
<script src="~/assetscamera/js/Index.min.js"></script>
<script src="~/assetscamera/js/Index.js?ver=@adminVersion"></script>
}

View File

@@ -14,6 +14,7 @@
<link rel="stylesheet" href="~/AssetsClient/css/bootstrap.rtl.css">
<link href="~/AssetsClient/css/validation-style.css" rel="stylesheet" />
<link href="~/AssetsClient/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<link href="~/AdminTheme/assets/ionicon/css/ionicons.min.css" rel="stylesheet" />
<style>
.alert-msg, .alert-success-msg {

View File

@@ -137,63 +137,63 @@
</div>
</button>
<div class="container-fluid">
<div class="row px-2">
<div class="col-12 p-0 mb-2 d-none d-md-block">
<div class="search-box card border-0">
<div class="d-flex align-items-center gap-2">
<div class="container-fluid">
<div class="row px-2">
<div class="col-12 p-0 mb-2 d-none d-md-block">
<div class="search-box card border-0">
<div class="d-flex align-items-center gap-2">
<div class="col-3 col-xl-2">
<div class="wrapper-dropdown-normal btn-dropdown">
<span class="selected-display">تاریخ براساس یک روز</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 dropdown-days boxes">
<li class="item active" value-data-normal="OneDay">تاریخ براساس یک روز</li>
<li class="item" value-data-normal="RangeDays">تاریخ براساس بازه ی زمانی</li>
</ul>
</div>
</div>
<div class="">
<div class="d-flex align-items-center gap-2">
<div>
<input type="text" class="form-control date start-date text-center" id="StartDate" placeholder="تاریخ">
</div>
<div class="col-3 col-xl-2">
<div class="wrapper-dropdown-normal btn-dropdown">
<span class="selected-display">تاریخ براساس یک روز</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 dropdown-days boxes">
<li class="item active" value-data-normal="OneDay">تاریخ براساس یک روز</li>
<li class="item" value-data-normal="RangeDays">تاریخ براساس بازه ی زمانی</li>
</ul>
</div>
</div>
<div class="">
<div class="d-flex align-items-center gap-2">
<div>
<input type="text" class="form-control date start-date text-center" id="StartDate" placeholder="تاریخ">
</div>
<div class="d-flex align-items-center d-none" id="endDateRollcall">
<div class="me-2 elay">الی</div>
<input type="text" class="form-control date end-date text-center" id="EndDate" placeholder="تاریخ پایان">
</div>
</div>
</div>
<div class="d-flex align-items-center d-none" id="endDateRollcall">
<div class="me-2 elay">الی</div>
<input type="text" class="form-control date end-date text-center" id="EndDate" placeholder="تاریخ پایان">
</div>
</div>
</div>
<div class="col-3 col-xl-2">
<select class="form-select select2Option" aria-label="انتخاب پرسنل ..." id="employeeSelect">
<option value="0">انتخاب پرسنل ...</option>
@foreach (var itemEmployee in Model.RollCallEmployeeList)
{
<option value="@itemEmployee.EmployeeId">@itemEmployee.EmployeeFullName</option>
}
</select>
</div>
<div class="col-3 col-xl-2">
<select class="form-select select2Option" aria-label="انتخاب پرسنل ..." id="employeeSelect">
<option value="0">انتخاب پرسنل ...</option>
@foreach (var itemEmployee in Model.RollCallEmployeeList)
{
<option value="@itemEmployee.EmployeeId">@itemEmployee.EmployeeFullName</option>
}
</select>
</div>
<button class="btn-search btn-w-size btn-search-click text-nowrap d-flex align-items-center justify-content-center" id="searchBtn" type="submit">
<span>جستجو</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<circle cx="11" cy="11" r="6" stroke="white" />
<path d="M20 20L17 17" stroke="white" stroke-linecap="round" />
</svg>
</button>
<a asp-page="/Company/RollCall/CaseHistory" class="btn-clear-filter btn-w-size text-nowrap d-flex align-items-center justify-content-center disable" id="filterRemove" style="padding: 7px 10px;">
<span>حذف جستجو</span>
</a>
</div>
</div>
</div>
<button class="btn-search btn-w-size btn-search-click text-nowrap d-flex align-items-center justify-content-center" id="searchBtn" type="submit">
<span>جستجو</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<circle cx="11" cy="11" r="6" stroke="white"/>
<path d="M20 20L17 17" stroke="white" stroke-linecap="round"/>
</svg>
</button>
<a asp-page="/Company/RollCall/CaseHistory" class="btn-clear-filter btn-w-size text-nowrap d-flex align-items-center justify-content-center disable" id="filterRemove" style="padding: 7px 10px;">
<span>حذف جستجو</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- List Items -->
<div class="container-fluid" id="containerHeight">
@@ -243,7 +243,8 @@
<span class="textListTitle">لیست سوابق حضور و غیاب</span>
</div>
<div class="col-4 d-none d-md-block">
<div class="col-4 d-none d-md-block text-end">
<div class="textListTitle" id="sumTimeWork"></div>
</div>
</div>
@@ -383,6 +384,7 @@
<script>
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
var caseHistoryAjaxLoadData = `@Url.Page("./CaseHistory", "CaseHistoryRollCallAjax")`;
var loadEmployeeRollCallTimeSpanUrl = `@Url.Page("./CaseHistory", "EmployeeRollCallTimeSpan")`;
var itemsYearList = @Html.Raw(Json.Serialize(Model.YearlyList.OrderBy(x => x)));
// var dateIndex = 0;

View File

@@ -26,7 +26,10 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
private readonly IYearlySalaryApplication _yearlySalaryApplication;
private readonly ILeaveApplication _leaveApplication;
private readonly ICustomizeWorkshopSettingsApplication _customizeWorkshopSettingsApplication;
public RollCallsByDateViewModel RollCallViewModels { get; set; }
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly long _workshopId;
public RollCallsByDateViewModel RollCallViewModels { get; set; }
public EmployeeRollCallsByMonthViewModel RollCallEmployeeViewModels { get; set; }
public string WorkshopFullName { get; set; }
public List<RollCallEmployeeViewModel> RollCallEmployeeList;
@@ -34,7 +37,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
public RollCallSearchModel SearchModel { get; set; } = new();
public List<string> YearlyList { get; set; }
public CaseHistoryModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, IRollCallEmployeeApplication rollCallEmployeeApplication, IWorkshopApplication workshopApplication, IRollCallApplication rollCallApplication, IYearlySalaryApplication yearlySalaryApplication, ILeaveApplication leaveApplication, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication)
public CaseHistoryModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, IRollCallEmployeeApplication rollCallEmployeeApplication, IWorkshopApplication workshopApplication, IRollCallApplication rollCallApplication, IYearlySalaryApplication yearlySalaryApplication, ILeaveApplication leaveApplication, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IHttpContextAccessor httpContextAccessor)
{
_authHelper = authHelper;
_passwordHasher = passwordHasher;
@@ -44,122 +47,111 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
_yearlySalaryApplication = yearlySalaryApplication;
_leaveApplication = leaveApplication;
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
}
public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
{
_httpContextAccessor = httpContextAccessor;
var auth = _authHelper.CurrentAccountInfo();
var workshopId = _passwordHasher.SlugDecrypt(auth.WorkshopSlug);
if (IrregularWorkshopHaveGroupedAllPersonnelValidation(workshopId) == false)
context.HttpContext.Response.Redirect("./grouping");
var workshopHash = _httpContextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug");
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
base.OnPageHandlerExecuting(context);
}
if (_workshopId < 1)
throw new InvalidDataException("اختلال در کارگاه");
}
//public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
//{
// if (IrregularWorkshopHaveGroupedAllPersonnelValidation(_workshopId) == false)
// context.HttpContext.Response.Redirect("./grouping");
public bool IrregularWorkshopHaveGroupedAllPersonnelValidation(long customizeWorkshopSettingsId)
{
var isWorkshopIrregular = _customizeWorkshopSettingsApplication
.GetWorkshopSettingsDetails(customizeWorkshopSettingsId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular;
// base.OnPageHandlerExecuting(context);
//}
if (isWorkshopIrregular == false)
return true;
//public bool IrregularWorkshopHaveGroupedAllPersonnelValidation(long workshopId)
//{
// var isWorkshopIrregular = _customizeWorkshopSettingsApplication
// .GetWorkshopSettingsDetails(workshopId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular;
if (_customizeWorkshopSettingsApplication.GetEmployeesWithoutGroup(customizeWorkshopSettingsId).Any())
return false;
return true;
}
// if (isWorkshopIrregular == false)
// return true;
// var employeesWithoutGroup = _customizeWorkshopSettingsApplication.GetEmployeesWithoutGroupByWorkshopId(workshopId);
// if (employeesWithoutGroup.Any())
// return false;
// return true;
//}
public IActionResult OnGet()
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId > 0)
if (_rollCallEmployeeApplication.GetByWorkshopId(_workshopId).Any())
{
if (_rollCallEmployeeApplication.GetByWorkshopId(workshopId).Any())
RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(_workshopId);
WorkshopFullName = _workshopApplication.GetDetails(_workshopId).WorkshopFullName;
var searchModel = new RollCallSearchModel()
{
RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(workshopId);
WorkshopFullName = _workshopApplication.GetDetails(workshopId).WorkshopFullName;
WorkshopId = _workshopId
};
var searchModel = new RollCallSearchModel()
{
WorkshopId = workshopId
};
RollCallViewModels = _rollCallApplication.GetWorkshopRollCallHistory(searchModel);
YearlyList = _yearlySalaryApplication.GetYears();
RollCallViewModels = _rollCallApplication.GetWorkshopRollCallHistory(searchModel);
YearlyList = _yearlySalaryApplication.GetYears();
return Page();
}
else
{
return Redirect("/Client/Company/RollCall");
}
return Page();
}
else
{
return NotFound();
return Redirect("/Client/Company/RollCall");
}
}
public IActionResult OnGetCaseHistoryRollCallAjax(int dateIndex, string exactDateFa, string startDate, string endDate, long employeeId, string dateEmployeeIndex)
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId > 0)
if (employeeId > 0)
{
if (employeeId > 0)
{
RollCallEmployeeViewModels = _rollCallApplication.GetEmployeeRollCallsHistory(employeeId, workshopId, startDate, endDate, exactDateFa, dateEmployeeIndex);
if (RollCallEmployeeViewModels == null)
return new JsonResult(new
{
IsSuccedded = false,
message = "داده ای یافت نشد!",
});
}
else
{
var searchModel = new RollCallSearchModel()
RollCallEmployeeViewModels = _rollCallApplication.GetEmployeeRollCallsHistory(employeeId, _workshopId, startDate, endDate, exactDateFa, dateEmployeeIndex);
if (RollCallEmployeeViewModels == null || RollCallEmployeeViewModels.DateGr == new DateTime())
return new JsonResult(new
{
WorkshopId = workshopId,
DateIndex = dateIndex,
ExactDateFa = exactDateFa,
StarDateFa = startDate,
EndDateFa = endDate,
EmployeeId = employeeId
};
RollCallViewModels = _rollCallApplication.GetWorkshopRollCallHistory(searchModel);
}
return new JsonResult(new
{
IsSuccedded = true,
data = RollCallViewModels,
dataEmployee = RollCallEmployeeViewModels,
});
IsSuccedded = false,
message = "داده ای یافت نشد!",
});
}
else
{
return new JsonResult(new
var searchModel = new RollCallSearchModel()
{
IsSuccedded = false,
message = "داده ای یافت نشد!",
});
WorkshopId = _workshopId,
DateIndex = dateIndex,
ExactDateFa = exactDateFa,
StarDateFa = startDate,
EndDateFa = endDate,
EmployeeId = employeeId
};
RollCallViewModels = _rollCallApplication.GetWorkshopRollCallHistory(searchModel);
}
return new JsonResult(new
{
IsSuccedded = true,
data = RollCallViewModels,
dataEmployee = RollCallEmployeeViewModels,
});
}
public IActionResult OnGetEmployeeRollCallTimeSpan(long employeeId, string start, string end)
{
var resultData = _rollCallApplication.GetEmployeeRollCallTimeSpanForDuration(employeeId, _workshopId, start, end);
var hours = (int)resultData.TotalHours;
var minutes = resultData.Minutes;
var timeString = $"{hours}:{minutes}";
return new JsonResult(new
{
success = true,
data = timeString
});
}
public IActionResult OnGetEmployeeList()
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId <= 0)
return new JsonResult(new
{
success = false,
message = "کارگاه ای یافت نشد",
});
var resultData = _rollCallEmployeeApplication.GetRollCallEmployeesByWorkshopId(workshopId);
var resultData = _rollCallEmployeeApplication.GetRollCallEmployeesByWorkshopId(_workshopId);
return new JsonResult(new
{
@@ -168,7 +160,6 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
});
}
public IActionResult OnGetCreate()
{
var command = new CreateOrEditEmployeeRollCall();
@@ -179,25 +170,15 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
{
bool isSuccess = false;
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId < 1)
return new JsonResult(new
{
success = false,
message = "کارگاهی یافت نشد!",
});
List<RollCallViewModel> resultData = new List<RollCallViewModel>();
if (!string.IsNullOrWhiteSpace(date))
{
resultData = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(workshopId, employeeId, date);
resultData = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
isSuccess = resultData.Any();
}
var result = _leaveApplication.HasDailyLeave(workshopId, employeeId, date);
var result = _leaveApplication.HasDailyLeave(_workshopId, employeeId, date);
var isLeave = result.IsSuccedded ? result.Data : false;
var isNullEndDate = resultData.Any(x => x.EndDate == null);
@@ -212,30 +193,17 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
});
}
public IActionResult OnGetEdit(long employeeId, string date)
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId < 1)
{
var resultError = new ErrorViewModel()
{
Message = "کارگاه شما یافت نشده است."
};
return Partial("../Error/_ErrorModal", resultError);
}
var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(workshopId, employeeId, date);
var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
//var dates = _rollCallApplication.GetEditableDatesForManualEdit(DateTime.Parse(date));
var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
var command = new EmployeeRollCallsViewModel()
{
EmployeeFullName = name.EmployeeFullName,
EmployeeId = employeeId,
DateFa = date,
RollCalls = result
RollCalls = result,
};
return Partial("ModalEditRollCall", command);
@@ -243,16 +211,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
public IActionResult OnPostManualCreateOrEdit(CreateOrEditEmployeeRollCall command)
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId < 1)
return new JsonResult(new
{
success = false,
message = "هیچ کارگاهی یافت نشده است!",
});
command.WorkshopId = workshopId;
command.WorkshopId = _workshopId;
var result = _rollCallApplication.ManualEdit(command);
return new JsonResult(new
@@ -264,23 +223,13 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
public IActionResult OnPostRemoveEmployeeRollCallsInDate(long employeeId, string date)
{
var workshopHash = User.FindFirstValue("WorkshopSlug");
var workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId < 1)
return new JsonResult(new
{
success = false,
message = "هیچ کارگاهی یافت نشده است!",
});
var result = _rollCallApplication.RemoveEmployeeRollCallsInDate(workshopId, employeeId, date);
var result = _rollCallApplication.RemoveEmployeeRollCallsInDate(_workshopId, employeeId, date);
return new JsonResult(new
{
success = result.IsSuccedded,
message = result.Message,
});
}
}
}

View File

@@ -19,8 +19,8 @@
"sqlDebugging": true,
"dotnetRunMessages": "true",
"nativeDebugging": true,
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
//"applicationUrl": "https://localhost:5004;http://localhost:5003;http://192.168.0.118:82;https://192.168.0.118:83;",
//"applicationUrl": "https://localhost:5004;http://localhost:5003;",
"applicationUrl": "https://localhost:5004;http://localhost:5003;http://192.168.0.117:82;https://192.168.0.117:83;",
"jsWebView2Debugging": false,
"hotReloadEnabled": true
},

View File

@@ -22,21 +22,26 @@ resetTimer();
// ------------------------------------------------------------- end camera standby
window.onload = function () {
setTimeout(function () {
const loader = document.getElementById("loader");
loader.classList.add("hidden");
}, 3000);
//setTimeout(function () {
/* const loader = document.getElementById("loader");*/
/* loader.classList.add("hidden");*/
//}, 3000);
setTimeout(function () {
loader.style.display = "none";
}, 3500);
//setTimeout(function () {
/* loader.style.display = "none";*/
//}, 3500);
document.getElementById("content").style.display = "block";
setTimeout(function () {
const loader = document.getElementById("loader");
loader.style.display = "none";
document.getElementById("content").style.opacity = 1;
}, 100);
}, 6000);
};
// ------------------------------------------------------------- start camera
@@ -74,6 +79,7 @@ $(document).ready(function () {
}
run();
startWebcam();
//sendPersonelCodeToGetEmployeeId(23);
@@ -674,4 +680,12 @@ function enterPersonnelCode() {
function openPersonnelModal() {
var goTo = `#showmodal=/Camera/Index?handler=PersonnelWorkshopAjax`;
window.location.href = goTo;
}
}
//setTimeout(function () {
/* loader.classList.add("hidden");*/
//}, 3000);

View File

@@ -59,4 +59,28 @@
display: flex;
align-items: center;
justify-content: center;
}
}
.operations-btns-main {
padding: 5px;
width: 98%;
margin: 0 auto 10px;
display: none;
border-radius: 0px 0px 8px 8px;
background: #F1F5F9;
box-shadow: 0px 4px 5px 0px rgba(0, 0, 0, 0.03) inset;
}
.toggleRollCall {
cursor: pointer;
font-size: 12px;
}
.toggleRollCall svg {
stroke: #ffffff;
transition: transform 0.3s ease;
}
.toggleRollCall.open svg {
transform: rotate(-90deg);
}

View File

@@ -22,11 +22,6 @@ $(document).ready(function () {
loadingDiv.show();
});
$(document).on('click', ".openAction", function () {
$(this).next().find(".operations-btns").slideToggle(500);
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
});
var filterEmployeeId = $('#employeeSelect').val();
var filterStart = $('#StartDate').val().trim();
@@ -200,7 +195,6 @@ $(document).ready(function () {
} else {
$('.btn-clear-filter').addClass('disable');
}
console.log(filterEmployeeId);
hasData = true;
dateIndex = 0;
@@ -208,6 +202,7 @@ $(document).ready(function () {
$('#caseHistoryLoadData').html('');
caseHistoryLoadAjax();
loadUntilHeightExceeds();
loadEmployeeRollCallTimeSpanForDuration();
if ($('#searchBtnMobile').is(':visible')) {
$('#searchModal').modal('hide');
@@ -318,25 +313,30 @@ function caseHistoryLoadAjax() {
$('#dateFaEmployee').show();
html += `<div class="Rtable-row Rtable-row--head align-items-center d-none d-md-flex sticky" style="background: #58B3B3;border: none !important;">
html += `<div class="Rtable-row Rtable-row--head align-items-center d-none d-md-flex sticky openActionMain" style="background: #58B3B3;border: none !important;cursor: pointer">
<div class="col-4"></div>
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">${caseHistoryEmployeeData.persianMonthName + ` ` + caseHistoryEmployeeData.persianYear}</div>
</div>
<div class="col-4"></div>
<div class="col-4 text-end">
</div>
</div>
<div class="Rtable-row Rtable-row--head align-items-center d-flex d-md-none sticky" style="background: #58B3B3;border: none !important;">
<div class="col-6">
<div class="Rtable-row Rtable-row--head align-items-center d-flex d-md-none sticky openActionMain" style="background: #58B3B3;border: none !important;cursor: pointer">
<div class="col-4">
<div class="Rtable-cell column-heading text-center justify-content-start">${caseHistoryEmployeeData.rollCalls.length > 0 ? caseHistoryEmployeeData.rollCalls[0].employeeFullName : `-`}
</div>
</div>
<div class="col-6 text-center">
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center">${caseHistoryEmployeeData.persianMonthName + ` ` + caseHistoryEmployeeData.persianYear}</div>
</div>
<div class="col-4 text-end">
</div>
</div>`;
//html += `<div class="operations-btns-main"><div></div>`;
$.each(caseHistoryEmployeeData.rollCalls, function (i, item) {
html += `
@@ -557,11 +557,13 @@ function caseHistoryLoadAjax() {
</div>
</div>
</div>
</div>
</div>
</div>`;
}
});
});
//html += `</div>`;
//dateIndex++;
dateEmployeeIndex = caseHistoryEmployeeData.dateIndex;
@@ -578,7 +580,7 @@ function caseHistoryLoadAjax() {
$('#dateFaEmployee').hide();
html += `
<div class="Rtable-row Rtable-row--head align-items-center d-flex sticky" style="background: #58B3B3;border: none !important;">
<div class="Rtable-row Rtable-row--head align-items-center d-flex sticky openActionMain" style="background: #58B3B3;border: none !important;cursor: pointer">
<div class="col-4 text-start">
<div class="Rtable-cell column-heading justify-content-center">
${caseHistoryData.dayOfWeekFa}
@@ -588,10 +590,12 @@ function caseHistoryLoadAjax() {
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">${caseHistoryData.dateFa}</div>
</div>
<div class="col-4"></div>
<div class="col-4 text-end">
</div>
</div>
`;
//html += `<div class="operations-btns-main"><div></div>`;
$.each(caseHistoryData.activeEmployees, function (i, item) {
html += `
@@ -646,7 +650,7 @@ function caseHistoryLoadAjax() {
html += `</div>
<div class="Rtable-cell width6 position-relative bg-filter text-center d-none d-md-block h-100">`;
<div class="Rtable-cell width6 position-relative bg-filter text-center d-none d-md-block h-100">`;
if (item.rollCallTimesList.length > 0) {
item.rollCallTimesList.forEach(function (itemTime) {
@@ -736,8 +740,7 @@ function caseHistoryLoadAjax() {
}
html += `</div>`;
html +=
`<div class="width3 d-block d-md-none" style="width:1% !important;padding: 0 0 0 20px;">-</div>`;
html += `<div class="width3 d-block d-md-none" style="width:1% !important;padding: 0 0 0 20px;">-</div>`;
html += `</div>`;
@@ -781,13 +784,12 @@ function caseHistoryLoadAjax() {
</button>
</div>
</div>
</div>
</div>
</div>`;
}
});
//html += `</div>`;
dateIndex++;
$('#caseHistoryLoadData').append(html);
@@ -1745,4 +1747,62 @@ function removeAction(removeEmployeeId, removeDate) {
console.log(err);
}
});
}
}
function loadEmployeeRollCallTimeSpanForDuration() {
if ($('#StartDate').val().trim() !== '' && $('#StartDate').val().length === 10) {
if ($('#EndDate').is(":visible")) {
if ($('#EndDate').val().trim() !== '' && $('#EndDate').val().length === 10) {
filterEmployeeId = $('#employeeSelect').val();
if (filterEmployeeId !== "0") {
var data = {
"employeeId": Number(filterEmployeeId),
"start": $('#StartDate').val(),
"end": $('#EndDate').val()
}
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadEmployeeRollCallTimeSpanUrl,
data: data,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
if (response.success) {
$('#sumTimeWork').text('مجموع ساعت کارکرد ' + response.data);
}
},
failure: function (response) {
console.log(response);
hasData = false;
}
});
}
}
}
}
}
//$(document).on('click', ".openActionMain", function () {
// $('.toggleRollCall').not($(this).find('.toggleRollCall')).removeClass('open');
// $(".operations-btns-main")
// .not($(this).next(".operations-btns-main"))
// .slideUp(500);
// $(this).next(".operations-btns-main").slideToggle(500);
// $(this).find('.toggleRollCall').toggleClass('open');
//});
$(document).on('click', ".openAction", function () {
if (window.matchMedia('(max-width: 768px)').matches) {
$(this).next().find(".operations-btns").slideToggle(500);
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
}
});