diff --git a/0_Framework/Application/Version.cs b/0_Framework/Application/Version.cs index 3c1d2c51..a3bd952a 100644 --- a/0_Framework/Application/Version.cs +++ b/0_Framework/Application/Version.cs @@ -10,9 +10,9 @@ public static class Version { static Version() { - StyleVersion = "2.12.10"; - AdminVersion = "2.5.30"; - CameraVersion = "1.0.6"; + StyleVersion = "2.12.12"; + AdminVersion = "2.5.32"; + CameraVersion = "1.0.7"; } public static string StyleVersion { get; set; } diff --git a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs index 9e1edbbf..781a5126 100644 --- a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs +++ b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs @@ -9,7 +9,7 @@ public interface IRollCallEmployeeRepository : IRepository GetByWorkshopId(long workshopId); EditRollCallEmployee GetDetails(long id); RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId); - List GetPersonnelRollCallList(long workshopId); + List GetPersonnelRollCallListPaginate(long workshopId, int pageIndex); //rollcallEmployeeIncludeStatus RollCallEmployee GetWithRollCallStatus(long id); int activedPerson(long workshopId); @@ -18,5 +18,8 @@ public interface IRollCallEmployeeRepository : IRepository GetByEmployeeIdWithStatuses(long employeeId); List GetActivePersonnelByWorkshopId(long workshopId); + List GetEmployeeRollCalls(long workshopId); + + List GetPersonnelRollCallListAll(long workshopId); #endregion } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/RollCallEmployee/IRollCallEmployeeApplication.cs b/CompanyManagment.App.Contracts/RollCallEmployee/IRollCallEmployeeApplication.cs index 3e204ea0..3a7086a0 100644 --- a/CompanyManagment.App.Contracts/RollCallEmployee/IRollCallEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/RollCallEmployee/IRollCallEmployeeApplication.cs @@ -12,8 +12,16 @@ public interface IRollCallEmployeeApplication List GetByWorkshopId(long workshopId); EditRollCallEmployee GetDetails(long id); RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId); - List GetPersonnelRollCallList(long workshopId); + List GetPersonnelRollCallListPaginate(long workshopId, int pageIndex); List GetActivePersonnelByWorkshopId(long workshopId); bool IsEmployeeRollCallActive(long employeeId, long workshopId); int activedPerson(long workshopId); + #region pooya + + List GetEmployeeRollCalls(long workshopId); + + List GetPersonnelRollCallListAll(long workshopId); + + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs b/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs index 0488d25d..58a9f016 100644 --- a/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs +++ b/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs @@ -34,4 +34,5 @@ public class RollCallEmployeeViewModel : EditRollCallEmployee public string EmployeeLName { get; set; } public string EmployeeFName { get; set; } + public long RollCallEmployeeId { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/RollCallEmployeeApplication.cs b/CompanyManagment.Application/RollCallEmployeeApplication.cs index f3bdb303..255df1c1 100644 --- a/CompanyManagment.Application/RollCallEmployeeApplication.cs +++ b/CompanyManagment.Application/RollCallEmployeeApplication.cs @@ -113,9 +113,9 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication return _rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId); } - public List GetPersonnelRollCallList(long workshopId) + public List GetPersonnelRollCallListPaginate(long workshopId, int pageIndex) { - return _rollCallEmployeeRepository.GetPersonnelRollCallList(workshopId); + return _rollCallEmployeeRepository.GetPersonnelRollCallListPaginate(workshopId, pageIndex); } public int activedPerson(long workshopId) @@ -143,5 +143,15 @@ public class RollCallEmployeeApplication : IRollCallEmployeeApplication } + public List GetEmployeeRollCalls(long workshopId) + { + return _rollCallEmployeeRepository.GetEmployeeRollCalls(workshopId); + } + + public List GetPersonnelRollCallListAll(long workshopId) + { + return _rollCallEmployeeRepository.GetPersonnelRollCallListAll(workshopId); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs index ce1c9a09..861a65de 100644 --- a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs @@ -66,136 +66,35 @@ public class RollCallEmployeeRepository : RepositoryBase }).FirstOrDefault(); } - public List GetPersonnelRollCallList(long workshopId) + public List GetPersonnelRollCallListPaginate(long workshopId, int pageIndex) { - //var nowFa = DateTime.Now; - //var employee = _context.Employees.Include(x => x.LeftWorks).Where(l => l.LeftWorks.Any(c => c.StartWorkDate <= nowFa && c.LeftWorkDate > nowFa && c.WorkshopId == workshopId)); + var dateNow = DateTime.Now; + var f = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances) + .Where(x => x.LeftWorks.Any(y => y.WorkshopId == workshopId && y.StartWorkDate <= dateNow && y.LeftWorkDate > dateNow) || + x.LeftWorkInsurances.Any(y => y.WorkshopId == workshopId && y.StartWorkDate <= dateNow && + (y.LeftWorkDate > dateNow || y.LeftWorkDate == null))).ToList(); - //return employee.Select(x => new RollCallEmployeeViewModel - //{ - // WorkshopId = workshopId, - // EmployeeId = x.id, - // EmployeeFullName= x.FName + ' ' + x.LName, - // NationalCode = x.NationalCode, - // IsActiveString = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.IsActiveString == "true") ? "true" : "false", - // HasUploadedImage = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.HasUploadedImage == "true") ? "true" : "false", - //}).ToList(); - - var leftDate = new DateTime(2121, 3, 21); - var join = new List(); - var contractLeftWork = _context.LeftWorkList.Select(x => new RollCallEmployeeViewModel() - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - PersonName = x.EmployeeFullName, - PersonelCode = 0, - ContractPerson = true, - ContractLeft = x.LeftWorkDate != leftDate, - StartWork = x.StartWorkDate - }).Where(x => x.WorkshopId == workshopId).OrderByDescending(x => x.StartWork).ToList(); - - contractLeftWork = contractLeftWork.Select(x => new RollCallEmployeeViewModel() - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - PersonName = x.PersonName, - PersonelCode = _context.PersonnelCodeSet.Any(p => p.EmployeeId == x.EmployeeId && p.WorkshopId == x.WorkshopId) ? - _context.PersonnelCodeSet.FirstOrDefault(p => p.EmployeeId == x.EmployeeId && p.WorkshopId == x.WorkshopId)!.PersonnelCode : 0, - ContractPerson = true, - ContractLeft = x.ContractLeft, - StartWork = x.StartWork - }).ToList(); - - var insuranceLeftWork = _context.LeftWorkInsuranceList.Select(x => new RollCallEmployeeViewModel() - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - PersonName = x.EmployeeFullName, - PersonelCode = 0, - InsurancePerson = true, - InsurancetLeft = x.LeftWorkDate != null, - StartWork = x.StartWorkDate - }).Where(x => x.WorkshopId == workshopId).OrderByDescending(x => x.StartWork).ToList(); - insuranceLeftWork = insuranceLeftWork.Select(x => new RollCallEmployeeViewModel() - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - PersonName = x.PersonName, - PersonelCode = _context.PersonnelCodeSet.Any(p => p.EmployeeId == x.EmployeeId && p.WorkshopId == x.WorkshopId) ? - _context.PersonnelCodeSet.FirstOrDefault(p => p.EmployeeId == x.EmployeeId && p.WorkshopId == x.WorkshopId)!.PersonnelCode : 0, - InsurancePerson = true, - InsurancetLeft = x.InsurancetLeft, - StartWork = x.StartWork - }).ToList(); - - - var joinEqualList = contractLeftWork.Join(insuranceLeftWork, x => x.EmployeeId, c => c.EmployeeId, - (first, second) => new RollCallEmployeeViewModel - { - EmployeeId = first.EmployeeId, - ContractPerson = first.ContractPerson, - ContractLeft = first.ContractLeft, - InsurancePerson = second.InsurancePerson, - InsurancetLeft = second.InsurancetLeft - }).ToList(); - - if (contractLeftWork.Any() && !insuranceLeftWork.Any()) - { - join = contractLeftWork.ToList(); - } - else if (!contractLeftWork.Any() && insuranceLeftWork.Any()) - { - join = insuranceLeftWork.ToList(); - } - else if (contractLeftWork.Any() && insuranceLeftWork.Any()) - { - join = contractLeftWork.Concat(insuranceLeftWork).ToList(); - } - - //if (joinEqualList.Count == 0) - // return join; - - join = join.GroupBy(x => x.EmployeeId).Select(d => d.First()).ToList(); - - var finalList = join.Select(x => new RollCallEmployeeViewModel() - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - PersonName = x.PersonName, - PersonelCode = x.PersonelCode, - ContractPerson = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.ContractPerson : x.ContractPerson, - InsurancePerson = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.InsurancePerson : x.InsurancePerson, - ContractLeft = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.ContractLeft : x.ContractLeft, - InsurancetLeft = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.InsurancetLeft : x.InsurancetLeft, - Black = false, - }).ToList(); - - var f = finalList.GroupBy(x => x.EmployeeId).Select(x => x.First()).ToList(); var res = f.Select(x => new RollCallEmployeeViewModel - { - WorkshopId = x.WorkshopId, - EmployeeId = x.EmployeeId, - Id = _context.RollCallEmployees.FirstOrDefault(r => r.EmployeeId == x.EmployeeId && r.WorkshopId == workshopId) == null ? 0 : - _context.RollCallEmployees.FirstOrDefault(r => r.EmployeeId == x.EmployeeId && r.WorkshopId == workshopId).id, - EmployeeFullName = x.PersonName, - EmployeeSlug = _passwordHasher.SlugHasher(x.EmployeeId), - NationalCode = _context.Employees.FirstOrDefault(e => e.id == x.EmployeeId)?.NationalCode, - PersonName = x.PersonName, - IsActiveString = _context.RollCallEmployees.Any(r => r.EmployeeId == x.EmployeeId && r.WorkshopId == workshopId && r.IsActiveString == "true") ? "true" : "false", - HasUploadedImage = _context.RollCallEmployees.Any(r => r.EmployeeId == x.EmployeeId && r.WorkshopId == workshopId && r.HasUploadedImage == "true") ? "true" : "false", - ImagePath = (System.IO.File.Exists(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", x.WorkshopId.ToString(), x.EmployeeId.ToString(), "1.jpg"))) - ? Tools.ResizeImage(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", x.WorkshopId.ToString(), x.EmployeeId.ToString(), "1.jpg"), 150, 150) - : "", - // ImagePath = x.HasUploadedImage == "true" ? Convert.ToBase64String(System.IO.File.ReadAllBytes($"{_webHostEnvironment.ContentRootPath}\\Faces\\{x.WorkshopId}\\{x.EmployeeId}\\1.jpg")) : "", - ContractPerson = x.ContractPerson, - InsurancePerson = x.InsurancePerson, - ContractLeft = x.ContractLeft, - InsurancetLeft = x.InsurancetLeft, - Black = ((x.ContractPerson && x.InsurancePerson && x.InsurancetLeft && x.ContractLeft) || (x.ContractPerson && !x.InsurancePerson && x.ContractLeft) || (x.InsurancePerson && !x.ContractPerson && x.InsurancetLeft)) ? true : false - }).ToList(); + { + WorkshopId = workshopId, + EmployeeId = x.id, + Id = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId) ? + _context.RollCallEmployees.FirstOrDefault(r => r.EmployeeId == x.id && r.WorkshopId == workshopId)!.id : 0, + EmployeeFullName = $"{x.FName} {x.LName}", + EmployeeSlug = _passwordHasher.SlugHasher(x.id), + NationalCode = _context.Employees.FirstOrDefault(e => e.id == x.id).NationalCode, + IsActiveString = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.IsActiveString == "true") ? "true" : "false", + HasUploadedImage = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.HasUploadedImage == "true") ? "true" : "false", + ImagePath = (System.IO.File.Exists(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", workshopId.ToString(), x.id.ToString(), "1.jpg"))) + ? Tools.ResizeImage(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", workshopId.ToString(), x.id.ToString(), "1.jpg"), 150, 150) + : "", + }).OrderBy(x => x.PersonelCode) + .Skip(pageIndex) + .Take(30) + .ToList(); - return res.Where(x => !x.Black).ToList(); + return res; } public RollCallEmployee GetWithRollCallStatus(long id) @@ -250,5 +149,50 @@ public class RollCallEmployeeRepository : RepositoryBase } + public List GetEmployeeRollCalls(long workshopId) + { + var dateNow = DateTime.Now; + var f = _context.RollCallEmployees.Where(x => x.WorkshopId == workshopId); + + var res = f.Select(x => new RollCallEmployeeViewModel + { + RollCallEmployeeId = x.id, + EmployeeId = x.EmployeeId, + EmployeeFullName = x.EmployeeFullName + }) + .ToList(); + + return res; + } + + public List GetPersonnelRollCallListAll(long workshopId) + { + var dateNow = DateTime.Now; + var f = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances) + .Where(x => x.LeftWorks.Any(y => y.WorkshopId == workshopId && y.StartWorkDate <= dateNow && y.LeftWorkDate > dateNow) || + x.LeftWorkInsurances.Any(y => y.WorkshopId == workshopId && y.StartWorkDate <= dateNow && + (y.LeftWorkDate > dateNow || y.LeftWorkDate == null))).ToList(); + + + var res = f.Select(x => new RollCallEmployeeViewModel + { + WorkshopId = workshopId, + EmployeeId = x.id, + Id = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId) ? + _context.RollCallEmployees.FirstOrDefault(r => r.EmployeeId == x.id && r.WorkshopId == workshopId)!.id : 0, + EmployeeFullName = $"{x.FName} {x.LName}", + EmployeeSlug = _passwordHasher.SlugHasher(x.id), + NationalCode = _context.Employees.FirstOrDefault(e => e.id == x.id).NationalCode, + IsActiveString = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.IsActiveString == "true") ? "true" : "false", + HasUploadedImage = _context.RollCallEmployees.Any(r => r.EmployeeId == x.id && r.WorkshopId == workshopId && r.HasUploadedImage == "true") ? "true" : "false", + ImagePath = (System.IO.File.Exists(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", workshopId.ToString(), x.id.ToString(), "1.jpg"))) + ? Tools.ResizeImage(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", workshopId.ToString(), x.id.ToString(), "1.jpg"), 150, 150) + : "", + }).OrderBy(x => x.PersonelCode) + .ToList(); + + return res; + } + #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml index af3d1ca0..948283b0 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml @@ -147,7 +147,7 @@ @foreach (var itemEmployee in Model.RollCallEmployeeList) { - + } @@ -267,11 +267,11 @@ - @foreach (var itemEmployee in Model.RollCallEmployeeList) { - + } @@ -318,5 +318,5 @@ var itemsYearList = @Html.Raw(Json.Serialize(Model.YearlyList.OrderBy(x => x))); // var dateIndex = 0; - + } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs index 81096169..0bf265db 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs @@ -47,7 +47,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall { if (_rollCallEmployeeApplication.GetByWorkshopId(workshopId).Any()) { - RollCallEmployeeList = _rollCallEmployeeApplication.GetPersonnelRollCallList(workshopId); + RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(workshopId); WorkshopFullName = _workshopApplication.GetDetails(workshopId).WorkshopFullName; var searchModel = new RollCallSearchModel() diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml deleted file mode 100644 index 04c5542a..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml +++ /dev/null @@ -1,272 +0,0 @@ -@page "{slug}" -@using Version = _0_Framework.Application.Version -@model EmployeeUploadPicModel - -@{ - Layout = "Shared/_ClientLayout"; - ViewData["title"] = " - آپلود عکس پرسنل"; - var index = 1; -} - -@section Styles { - - - - - - -} - -
-
-
-
-
- -
-

آپلود عکس پرسنل

-
@Model.WorkshopFullName
-
-
- -
-
-
- - @* *@ - -
- -
-
-
-
- - - - - -

تعداد پرسنل سرویس خریداری شده: @Model.MaxPersonValid

-
-
-
-

تعداد افراد فعال: @Model.MaxPersonValid

-
-
-

تعداد افراد غیرفعال: @Model.Employees.Count()

-
-
-
- -
-
- @if (Model.HasEmployees) - { -
-
-
ردیف
-
نام و نام خانوادگی
-
کد ملی
-
وضعیت عکس
-
عملیات
-
- - @foreach (var item in Model.Employees) - { -
- -
-
- ردیف -
-
- - @index - -
-
-
-
نام و نام خانوادگی
-
- - @item.EmployeeFullName -
-
-
-
کد ملی
-
@item.NationalCode
-
-
-
وضعیت عکس
-
- @if (item.HasUploadedImage == "true") - { -

عکس پرسنل آپلود شده است

- } - else - { -

عکس پرسنل آپلود نشده است

- } -
-
-
-
- @if (item.IsActiveString == "true") - { - - } - else - { - - } - -
-
- - -
-
-
- - @index - -
-
- - - -
-
-
@item.EmployeeFullName
-
عکس پرسنل آپلود شده است.
-
-
-
-
-
- -
-
-
- @{ - index++; - } -
-
- } -
- } - else - { -
-
- -
اطلاعاتی وجود ندارد.
-
-
- } -
-
-
-
- - - - - - - -@section Script { - - -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml.cs deleted file mode 100644 index cf9de42c..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPic.cshtml.cs +++ /dev/null @@ -1,100 +0,0 @@ -using _0_Framework.Application; -using CompanyManagment.App.Contracts.RollCallEmployee; -using CompanyManagment.App.Contracts.RollCallService; -using CompanyManagment.App.Contracts.Workshop; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace ServiceHost.Areas.Client.Pages.Company.RollCall; - -public class EmployeeUploadPicModel : PageModel -{ - private readonly IPasswordHasher _passwordHasher; - private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication; - private readonly IRollCallServiceApplication _rollCallServiceApplication; - - private readonly IWorkshopApplication _workshopApplication; - public List Employees; - public bool HasEmployees; - public int MaxPersonValid; - public string WorkshopFullName; - public long WorkshopId; - - - public EmployeeUploadPicModel(IWorkshopApplication workshopApplication, IPasswordHasher passwordHasher, - IRollCallEmployeeApplication rollCallEmployeeApplication, - IRollCallServiceApplication rollCallServiceApplication) - { - _workshopApplication = workshopApplication; - _passwordHasher = passwordHasher; - _rollCallEmployeeApplication = rollCallEmployeeApplication; - _rollCallServiceApplication = rollCallServiceApplication; - } - - public void OnGet(string slug) - { - if (slug != "") - { - var workshopId = _passwordHasher.SlugDecrypt(slug); - if (workshopId != 0) - { - var workshop = _workshopApplication.GetWorkshopInfo(workshopId); - WorkshopFullName = workshop.WorkshopFullName; - - MaxPersonValid = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId).MaxPersonValid; - - WorkshopId = workshop.Id; - Employees = _rollCallEmployeeApplication.GetPersonnelRollCallList(workshopId); - HasEmployees = Employees.Count > 0 ? true : false; - } - else - { - Response.Redirect("/error/404"); - } - } - else - { - Response.Redirect("/error/404"); - } - } - - public IActionResult OnGetCheckModalTakeImage(long workshopId, long employeeId) - { - var plan = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId); - var mess = ""; - if (plan != null) - { - if (plan.IsActiveString == "true") - { - var maxValid = plan.MaxPersonValid; - var activedPerson = _rollCallEmployeeApplication.activedPerson(workshopId); - if (activedPerson < maxValid) - return new JsonResult(new - { - isSuccedded = true, - url = Url.Page("/Company/RollCall/EmployeeUploadPic", "ModalTakeImages") - }); - mess = "محدودیت افزودن پرسنل"; - } - else - { - mess = "سرویس شما فعال نیست"; - } - } - else - { - mess = "شما سرویس خریداری شده ندارید"; - } - - return new JsonResult(new - { - isSuccedded = false, - message = mess - }); - } - - public IActionResult OnGetModalTakeImages() - { - return Partial("ModalTakeImages"); - } -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml index 8eac9a81..314fe386 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml @@ -101,7 +101,7 @@ @foreach (var item in @Model.Employees.PersonnelInfoViewModels) { -
+
@@ -118,11 +118,11 @@
@if (item.HasUploadedImage == "true") { - + } else { - + } @item.EmployeeFullName
@@ -136,10 +136,11 @@
@if (item.HasUploadedImage == "true") { -

عکس پرسنل آپلود شده است

+

عکس پرسنل آپلود شده است

} - else { -

عکس پرسنل آپلود نشده است

+ else + { +

عکس پرسنل آپلود نشده است

}
@@ -157,7 +158,7 @@
-
@@ -175,11 +176,11 @@ @if (item.HasUploadedImage == "true") { - + } else { - + }
@@ -188,10 +189,10 @@
@if (item.HasUploadedImage == "true") { -

عکس پرسنل آپلود شده است

+

عکس پرسنل آپلود شده است

} else { -

عکس پرسنل آپلود نشده است

+

عکس پرسنل آپلود نشده است

}
@@ -199,7 +200,7 @@
- @@ -259,5 +260,5 @@ var deActivePersonnelAjax = `@Url.Page("./EmployeeUploadPicture", "DeActivePersonnel")`; var activePersonnelAjax = `@Url.Page("./EmployeeUploadPicture", "ActivePersonnel")`; - + } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs index e387da13..fcd9b3a3 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs @@ -56,15 +56,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall MaxPersonValid = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId).MaxPersonValid; - var distinctEmployees = _rollCallEmployeeApplication - .GetPersonnelRollCallList(workshopId) - .GroupBy(x => x.EmployeeId) - .Select(g => g.First()) - .OrderBy(x => x.Black ? 1 : 0) - .ThenBy(x => x.PersonelCode) - .Skip(0) - .Take(30) - .ToList(); + var distinctEmployees = _rollCallEmployeeApplication.GetPersonnelRollCallListPaginate(workshopId, 0); Employees = new RollCallEmployeeViewModel { @@ -88,15 +80,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall if (workshopId > 0) { MaxPersonValid = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId).MaxPersonValid; - var distinctEmployees = _rollCallEmployeeApplication - .GetPersonnelRollCallList(workshopId) - .GroupBy(x => x.EmployeeId) - .Select(g => g.First()) - .OrderBy(x => x.Black ? 1 : 0) - .ThenBy(x => x.PersonelCode) - .Skip(pageIndex) - .Take(30) - .ToList(); + + var distinctEmployees = _rollCallEmployeeApplication.GetPersonnelRollCallListPaginate(workshopId, pageIndex); Employees = new RollCallEmployeeViewModel { @@ -136,13 +121,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall var activeService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId); var maxPersonValid = activeService.MaxPersonValid; - var employees = _rollCallEmployeeApplication - .GetPersonnelRollCallList(workshopId) - .GroupBy(e => e.EmployeeId) - .Select(g => g.First()) - .OrderBy(e => e.Black ? 1 : 0) - .ThenBy(e => e.PersonelCode) - .ToList(); + var employees = _rollCallEmployeeApplication.GetPersonnelRollCallListAll(workshopId); var activeCount = employees.Count(e => e.IsActiveString == "true"); var inactiveCount = employees.Count(e => e.IsActiveString == "false"); @@ -307,6 +286,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall { IsSuccedded = result.IsSuccedded, Message = result.Message, + src = Tools.ResizeImage(Path.Combine(_webHostEnvironment.ContentRootPath, "Faces", workshopId.ToString(), employeeId.ToString(), "1.jpg"), 150, 150) }); } else diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml deleted file mode 100644 index ce6ca267..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@page "{slug}" -@model HistoryModel -@{ -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml.cs deleted file mode 100644 index 5130e95e..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/History.cshtml.cs +++ /dev/null @@ -1,24 +0,0 @@ -using _0_Framework.Application; -using CompanyManagment.App.Contracts.RollCallEmployee; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace ServiceHost.Areas.Client.Pages.Company.RollCall; - -public class HistoryModel : PageModel -{ - private readonly IAuthHelper _authHelper; - private readonly IPasswordHasher _passwordHasher; - private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication; - - public HistoryModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, - IRollCallEmployeeApplication rollCallEmployeeApplication) - { - _authHelper = authHelper; - _passwordHasher = passwordHasher; - _rollCallEmployeeApplication = rollCallEmployeeApplication; - } - - public void OnGet(string slug) - { - } -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml deleted file mode 100644 index c902dca1..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@page "{slug}" -@model ListModel -@{ -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml.cs deleted file mode 100644 index d61d574a..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/List.cshtml.cs +++ /dev/null @@ -1,46 +0,0 @@ -using _0_Framework.Application; -using CompanyManagment.App.Contracts.RollCallEmployee; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace ServiceHost.Areas.Client.Pages.Company.RollCall; - -public class ListModel : PageModel -{ - private readonly IAuthHelper _authHelper; - private readonly IPasswordHasher _passwordHasher; - private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication; - - public ListModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, - IRollCallEmployeeApplication rollCallEmployeeApplication) - { - _authHelper = authHelper; - _passwordHasher = passwordHasher; - _rollCallEmployeeApplication = rollCallEmployeeApplication; - } - - public void OnGet(string slug) - { - if (slug != "") - { - var workshopId = _passwordHasher.SlugDecrypt(slug); - if (workshopId != 0) - { - if (_rollCallEmployeeApplication.GetByWorkshopId(workshopId).Count() > 0) - { - } - else - { - Response.Redirect("/error/403"); - } - } - else - { - Response.Redirect("/error/403"); - } - } - else - { - Response.Redirect("/error/403"); - } - } -} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/ModalTakeImages.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/ModalTakeImages.cshtml index e1c06cd2..29915924 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/ModalTakeImages.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/ModalTakeImages.cshtml @@ -215,7 +215,10 @@ \ No newline at end of file diff --git a/ServiceHost/Faces/367/3825/1.jpg b/ServiceHost/Faces/367/3825/1.jpg new file mode 100644 index 00000000..55eaa669 Binary files /dev/null and b/ServiceHost/Faces/367/3825/1.jpg differ diff --git a/ServiceHost/Faces/367/3825/2.jpg b/ServiceHost/Faces/367/3825/2.jpg new file mode 100644 index 00000000..c7d1e8c4 Binary files /dev/null and b/ServiceHost/Faces/367/3825/2.jpg differ diff --git a/ServiceHost/Faces/367/3826/1.jpg b/ServiceHost/Faces/367/3826/1.jpg new file mode 100644 index 00000000..7f1b26c8 Binary files /dev/null and b/ServiceHost/Faces/367/3826/1.jpg differ diff --git a/ServiceHost/Faces/367/3826/2.jpg b/ServiceHost/Faces/367/3826/2.jpg new file mode 100644 index 00000000..e1d45954 Binary files /dev/null and b/ServiceHost/Faces/367/3826/2.jpg differ diff --git a/ServiceHost/Faces/367/3828/1.jpg b/ServiceHost/Faces/367/3828/1.jpg new file mode 100644 index 00000000..c253c6f7 Binary files /dev/null and b/ServiceHost/Faces/367/3828/1.jpg differ diff --git a/ServiceHost/Faces/367/3828/2.jpg b/ServiceHost/Faces/367/3828/2.jpg new file mode 100644 index 00000000..a1e94191 Binary files /dev/null and b/ServiceHost/Faces/367/3828/2.jpg differ diff --git a/ServiceHost/Faces/367/3831/1.jpg b/ServiceHost/Faces/367/3831/1.jpg new file mode 100644 index 00000000..1cff8b49 Binary files /dev/null and b/ServiceHost/Faces/367/3831/1.jpg differ diff --git a/ServiceHost/Faces/367/3831/2.jpg b/ServiceHost/Faces/367/3831/2.jpg new file mode 100644 index 00000000..3497090d Binary files /dev/null and b/ServiceHost/Faces/367/3831/2.jpg differ diff --git a/ServiceHost/Faces/367/3832/1.jpg b/ServiceHost/Faces/367/3832/1.jpg new file mode 100644 index 00000000..dc670c2e Binary files /dev/null and b/ServiceHost/Faces/367/3832/1.jpg differ diff --git a/ServiceHost/Faces/367/3832/2.jpg b/ServiceHost/Faces/367/3832/2.jpg new file mode 100644 index 00000000..e03f73b9 Binary files /dev/null and b/ServiceHost/Faces/367/3832/2.jpg differ diff --git a/ServiceHost/Faces/367/3833/1.jpg b/ServiceHost/Faces/367/3833/1.jpg new file mode 100644 index 00000000..69ffe4c3 Binary files /dev/null and b/ServiceHost/Faces/367/3833/1.jpg differ diff --git a/ServiceHost/Faces/367/3833/2.jpg b/ServiceHost/Faces/367/3833/2.jpg new file mode 100644 index 00000000..a87c2b4e Binary files /dev/null and b/ServiceHost/Faces/367/3833/2.jpg differ diff --git a/ServiceHost/Faces/50/230/1.jpg b/ServiceHost/Faces/50/230/1.jpg new file mode 100644 index 00000000..29ab2ea4 Binary files /dev/null and b/ServiceHost/Faces/50/230/1.jpg differ diff --git a/ServiceHost/Faces/50/230/2.jpg b/ServiceHost/Faces/50/230/2.jpg new file mode 100644 index 00000000..6d0a860f Binary files /dev/null and b/ServiceHost/Faces/50/230/2.jpg differ diff --git a/ServiceHost/ServiceHost.csproj b/ServiceHost/ServiceHost.csproj index 72b92ee6..b5770179 100644 --- a/ServiceHost/ServiceHost.csproj +++ b/ServiceHost/ServiceHost.csproj @@ -198,11 +198,8 @@ - - - diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CaseHistory.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CaseHistory.js index 8ad81584..cbe14ad4 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CaseHistory.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CaseHistory.js @@ -10,6 +10,12 @@ $(document).ready(function () { dir: "rtl" }); + $(".select2OptionMobile").select2({ + language: "fa", + dir: "rtl", + dropdownParent: $('#searchModal'), + }); + $('.loadingButton').on('click', function () { var button = $(this); var loadingDiv = button.find('.loading'); @@ -125,6 +131,7 @@ $(document).ready(function () { } else { $('.btn-clear-filter').addClass('disable'); } + console.log(filterEmployeeId); hasData = true; dateIndex = 0; @@ -246,12 +253,22 @@ function caseHistoryLoadAjax() { $('#dateFaEmployee').show(); - html += `
+ html += `
-
${caseHistoryEmployeeData.persianMonthName + ` ` + caseHistoryEmployeeData.persianYear}
+
${caseHistoryEmployeeData.persianMonthName + ` ` + caseHistoryEmployeeData.persianYear}
+
+ +
+
+
${caseHistoryEmployeeData.rollCalls[0].employeeFullName} +
+
+
+
${caseHistoryEmployeeData.persianMonthName + ` ` + caseHistoryEmployeeData.persianYear}
+
`; $.each(caseHistoryEmployeeData.rollCalls, function (i, item) { @@ -269,13 +286,20 @@ function caseHistoryLoadAjax() {
-
+
نام پرسنل
${item.employeeFullName}
+
+
تاریخ
+
+ ${item.dateFa} +
+
+
شماره پرسنلی:
@@ -440,13 +464,13 @@ function caseHistoryLoadAjax() { html += `
-
+
${caseHistoryData.dayOfWeekFa} ${caseHistoryData.isHoliday ? `(تعطیل)` : ``}
-
${caseHistoryData.dateFa}
+
${caseHistoryData.dateFa}
diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/EmployeeUploadPicture.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/EmployeeUploadPicture.js index a7976ea5..8f3790d3 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/EmployeeUploadPicture.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/EmployeeUploadPicture.js @@ -40,9 +40,8 @@ function loadDataAjax() { dataLoad.forEach(function(item) { html += ` -
+
@@ -59,11 +58,11 @@ function loadDataAjax() {
`; if (item.hasUploadedImage === "true") { - html += ``; + html += ``; } else { - html += ``; + html += ``; } html += `${item.employeeFullName}
@@ -76,10 +75,10 @@ function loadDataAjax() {
وضعیت عکس
`; if (item.hasUploadedImage === "true") { - html += `

عکس پرسنل آپلود شده است

`; + html += `

عکس پرسنل آپلود شده است

`; } else { - html += `

عکس پرسنل آپلود نشده است

`; + html += `

عکس پرسنل آپلود نشده است

`; } html += `
@@ -99,7 +98,7 @@ function loadDataAjax() {
-
@@ -116,21 +115,21 @@ function loadDataAjax() {
`; if (item.hasUploadedImage === "true") { - html += ``; + html += ``; } else { - html += ``; + html += ``; } html += `
-
@item.EmployeeFullName
+
${item.employeeFullName}
`; if (item.hasUploadedImage === "true") { - html += `

عکس پرسنل آپلود شده است

`; + html += `

عکس پرسنل آپلود شده است

`; } else { - html += `

عکس پرسنل آپلود نشده است

`; + html += `

عکس پرسنل آپلود نشده است

`; } html += `
@@ -138,7 +137,7 @@ function loadDataAjax() {
- diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/ModalTakeImages.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/ModalTakeImages.js index 7eb765f2..b07bfd11 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/ModalTakeImages.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/ModalTakeImages.js @@ -1,126 +1,14 @@ - // if ($(window).width() < 992) { - // Webcam.set({ - - // width: 1800, - // height: 1800, - - // // final cropped size - // // crop_width: 296, - // // crop_height: 396, - // dest_width: 1800, - // dest_height: 1800, - - // crop_width: 1800, - // crop_height: 1800, - // image_format: 'jpeg', - // jpeg_quality: 90, - // // facingMode: "environment", - // constraints: { - // facingMode: "user" // This sets the camera to front-facing - // } - // }); - // Webcam.attach('#my_camera'); - // Webcam.attach('#video'); - // var demo = $('#video'); - // let demoVideo = $('#video').find('video[playsinline="playsinline"]'); - // demo.css({ - // width: "100%", - // height: "100%", - // }); - // demoVideo.css({ - // width: "100%", - // height: "100%", - // }); - // } else { - - // Webcam.set({ - // width: 600, - // height: 600, - // image_format: 'jpeg', - // jpeg_quality: 100 - // }); - // Webcam.attach('#my_camera'); - // Webcam.attach('#video'); - // var demo = $('#video'); - // let demoVideo = $('#video').find('video[playsinline="playsinline"]'); - // demo.css({ - // width: "100%", - // height: "100%", - // }); - // demoVideo.css({ - // width: "100%", - // height: "100%", - // }); - // } - - // function take_snapshot1() { - // Webcam.snap(function (data_uri) { - // // ایجاد یک عنصر تصویر از داده‌های تصویر - // var img = new Image(); - // img.src = data_uri; - // img.onload = function() { - // let canvas = document.createElement('canvas'); - // let ctx = canvas.getContext('2d'); - - // // پیدا کردن اندازه مربع برای کراپ - // let sideLength = Math.min(img.width, img.height); - // let startX = (img.width - sideLength) / 2; - // let startY = (img.height - sideLength) / 2; - - // let newWidth = 1800; - // let newHeight = 1800; - - // // تنظیم اندازه کانواس به اندازه جدید - // canvas.width = newWidth; - // canvas.height = newHeight; - - // // رسم تصویر کراپ شده و تغییر اندازه داده شده - // ctx.drawImage(img, startX, startY, sideLength, sideLength, 0, 0, newWidth, newHeight); - // // resolve(canvas.toDataURL('image/jpeg')); - - - // // // ایجاد یک بوم برای برش دادن تصویر - // // var canvas = document.createElement('canvas'); - // // var context = canvas.getContext('2d'); - // // var size = Math.min(img.width, img.height); - - // // canvas.width = size; - // // canvas.height = size; - - // // // محاسبه محل برش تصویر - // // var sx = (img.width - size) / 2; - // // var sy = (img.height - size) / 2; - - // // context.drawImage(img, sx, sy, size, size, 0, 0, size, size); - - // // تبدیل بوم به داده‌های URI - // var croppedDataUri = canvas.toDataURL('image/jpeg'); - - // // نمایش تصویر برش داده شده - // document.getElementById('result1').innerHTML = ''; - // document.getElementById('demoResult1').innerHTML = ''; - // }; - // }); - // $('.md-modal').removeClass('md-show'); - // } - - // function take_snapshot1() { - // Webcam.snap(function(data_uri) { - // document.getElementById('result1').innerHTML = ''; - // document.getElementById('demoResult1').innerHTML = ''; - // }); - // $('.md-modal').removeClass('md-show'); - // } - // function take_snapshot2() { - // Webcam.snap(function (data_uri) { - // document.getElementById('result2').innerHTML = ''; - // document.getElementById('demoResult2').innerHTML = ''; - // }); - // $('.md-modal').removeClass('md-show'); - // } - +var loadModels = async () => { + await Promise.all([ + faceapi.nets.ssdMobilenetv1.loadFromUri("\\weights\\"), + faceapi.nets.faceRecognitionNet.loadFromUri("\\weights\\"), + faceapi.nets.faceLandmark68Net.loadFromUri("\\weights\\") + ]); +}; +loadModels(); $(document).ready(function () { + if ($(window).width() > 992) { $('#desktopDisplay').show(); $('#mobileDisplay').hide(); @@ -155,29 +43,23 @@ $(document).ready(function () { updateSaveButton(); }); -window.onload = async () => { - await loadModels(); - modelsLoaded = true; -}; +//window.onload = async () => { +// await loadModels(); +// modelsLoaded = true; +//}; + -var loadModels = async () => { - await Promise.all([ - faceapi.nets.ssdMobilenetv1.loadFromUri("\\weights\\"), - faceapi.nets.faceRecognitionNet.loadFromUri("\\weights\\"), - faceapi.nets.faceLandmark68Net.loadFromUri("\\weights\\") - ]); -}; var modelsLoaded = false; -var ensureModelsLoaded = async () => { - if (!modelsLoaded) { - await loadModels(); - modelsLoaded = true; - } -}; +//var ensureModelsLoaded = async () => { +// if (!modelsLoaded) { +// await loadModels(); +// modelsLoaded = true; +// } +//}; var updateSaveButton = () => { - if (checkFace === 2) { + if (!hasErrorPic1 && checkFace1 && !hasErrorPic2 && checkFace2) { $('#SaveImageEmployee').removeClass('disable'); } else { $('#SaveImageEmployee').addClass('disable'); @@ -185,78 +67,89 @@ var updateSaveButton = () => { }; var runCheckFace1 = async () => { - await ensureModelsLoaded(); const img1 = document.getElementById('pic1'); - const detectionPromise1 = faceapi.detectSingleFace(img1).withFaceLandmarks().withFaceDescriptor(); - const delayPromise1 = new Promise(resolve => setTimeout(resolve, 2000)); + const detectionPromise1 = await faceapi.detectAllFaces(img1).withFaceLandmarks().withFaceDescriptors(); + + if (detectionPromise1.length === 1) { + console.log('یک چهره در تصویر اول شناسایی شد'); - const [detection1] = await Promise.all([detectionPromise1, delayPromise1]); - - //const detection1 = await faceapi.detectSingleFace(img1).withFaceLandmarks().withFaceDescriptor(); - if (detection1) { - console.log('چهره در تصویر اول شناسایی شد'); - - if (checkFace < 2) { - checkFace = checkFace + 1; - } + checkFace1 = true; + hasErrorPic1 = false; $('#demoResult1').css('border', '2px dashed #148b8b'); - } else { + } else if (detectionPromise1.length > 1) { $('.alert-msg').show(); - $('.alert-msg p').text('چهره‌ای در تصویر اول شناسایی نشد'); + $('.alert-msg p').text('بیش از یک چهره در تصویر اول شناسایی شد'); setTimeout(function () { $('.alert-msg').hide(); $('.alert-msg p').text(''); }, 2000); - if (checkFace > 0) { - checkFace = checkFace - 1; - } - + hasErrorPic1 = true; + $('#SaveImageEmployee').addClass('disable'); $('.upload-image1').css('background', '#ff090940'); $('#demoResult1').css('border', '2px dashed #ff5c5c'); - } - updateSaveButton(); - $('#loadingImage1').hide(); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text('چهره‌ای در تصویر اول شناسایی نشد'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 2000); + + hasErrorPic1 = true; + + $('#SaveImageEmployee').addClass('disable'); + $('.upload-image1').css('background', '#ff090940'); + $('#demoResult1').css('border', '2px dashed #ff5c5c'); + } + updateSaveButton(); + $('#loadingImage1').hide(); }; var runCheckFace2 = async () => { - await ensureModelsLoaded(); + const img2 = document.getElementById('pic2'); - const detectionPromise2 = faceapi.detectSingleFace(img2).withFaceLandmarks().withFaceDescriptor(); - const delayPromise2 = new Promise(resolve => setTimeout(resolve, 2000)); + const detectionPromise2 = await faceapi.detectAllFaces(img2).withFaceLandmarks().withFaceDescriptors(); - const [detection2] = await Promise.all([detectionPromise2, delayPromise2]); - - //const detection2 = await faceapi.detectSingleFace(img2).withFaceLandmarks().withFaceDescriptor(); - if (detection2) { - console.log('چهره در تصویر دوم شناسایی شد'); - - if (checkFace < 2) { - checkFace = checkFace + 1; - } + if (detectionPromise2.length === 1) { + console.log('یک چهره در تصویر دوم شناسایی شد'); + checkFace2 = true; + hasErrorPic2 = false; + $('#demoResult2').css('border', '2px dashed #148b8b'); - } else { + } else if (detectionPromise2.length > 1) { $('.alert-msg').show(); - $('.alert-msg p').text('چهره‌ای در تصویر دوم شناسایی نشد'); + $('.alert-msg p').text('بیش از یک چهره در تصویر دوم شناسایی شد'); setTimeout(function () { $('.alert-msg').hide(); $('.alert-msg p').text(''); }, 2000); - if (checkFace > 0) { - checkFace = checkFace - 1; - } + hasErrorPic2 = true; $('#SaveImageEmployee').addClass('disable'); $('.upload-image2').css('background', '#ff090940'); $('#demoResult2').css('border', '2px dashed #ff5c5c'); - } + } else { + $('.alert-msg').show(); + $('.alert-msg p').text('چهره‌ای در تصویر دوم شناسایی نشد'); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 2000); + + hasErrorPic2 = true; + + $('#SaveImageEmployee').addClass('disable'); + $('.upload-image2').css('background', '#ff090940'); + $('#demoResult2').css('border', '2px dashed #ff5c5c'); + } updateSaveButton(); - $('#loadingImage2').hide(); + $('#loadingImage2').hide(); }; @@ -359,8 +252,6 @@ function take_snapshot2() { $('.md-modal').removeClass('md-show'); stopCamera(); - loadModels(); - runCheckFace2(); } @@ -370,7 +261,7 @@ function set() { let workshopId = Number($('#workshopId').val()); let employeeId = Number($('#employeeId').val()); - if (checkFace) { + if (!hasErrorPic1 && checkFace1 && !hasErrorPic2 && checkFace2) { if (pic1 != null && pic2 != null) { const loading = $('.spinner-loading-progress').show(); const loadingBtn = $('.spinner-loading').show(); @@ -378,7 +269,6 @@ function set() { $('#SaveImageEmployee').addClass('disable'); - $.ajax({ type: 'POST', url: takePictureAjax, @@ -406,9 +296,9 @@ function set() { success: function (response) { let elapsedTime = Date.now() - startTime; let delay = Math.max(1000 - elapsedTime, 0); + console.log(response); setTimeout(function () { - if (response.isSuccedded) { $('.alert-success-msg').show(); $('.alert-success-msg p').text(response.message); @@ -416,10 +306,19 @@ function set() { $('.alert-success-msg').hide(); $('.alert-success-msg p').text(''); + $(`#ImageEmployee_${employeeId}`).attr("src", `data:image/jpeg;base64,${response.src}`); + $(`#ImageEmployeeMobile_${employeeId}`).attr("src", `data:image/jpeg;base64,${response.src}`); + + $(`#TextUpload_${employeeId}`).text("عکس پرسنل آپلود شده است").removeClass('text-danger'); + $(`#TextUploadMobile_${employeeId}`).text("عکس پرسنل آپلود شده است").removeClass('text-danger'); + + $(`#uploadMobileBTN_${employeeId}`).text("ویرایش عکس"); + $(`#uploadMobileBTNMobile_${employeeId}`).text("ویرایش عکس"); + + $(`#Section_${employeeId}`).removeClass("deactive"); + $('#SaveImageEmployee').removeClass('disable'); - //loading.hide(); $('#MainModal').modal('hide'); - //window.location.reload(); }, 1000); } else { $('#SaveImageEmployee').removeClass('disable'); @@ -452,62 +351,4 @@ function set() { $('.alert-msg p').text(''); }, 3500); } -} - - - -//function set() { -// let pic1 = $("#pic1").attr('src'); -// let pic2 = $("#pic2").attr('src'); -// let workshopId = Number($('#workshopId').val()); -// let employeeId = Number($('#employeeId').val()); - -// if (checkFace) { -// if (pic1 != null && pic2 != null) { -// $.ajax({ -// type: 'POST', -// url: takePictureAjax, -// data: { "base64pic1": pic1, "base64pic2": pic2, "workshopId": workshopId, "employeeId": employeeId }, -// headers: { "RequestVerificationToken": antiForgeryToken }, -// success: function(response) { -// if (response.isSuccedded) { -// $('.alert-success-msg').show(); -// $('.alert-success-msg p').text(response.message); -// setTimeout(function() { -// $('.alert-success-msg').hide(); -// $('.alert-success-msg p').text(''); -// window.location.reload(); -// }, -// 2000); -// } else { -// $('.alert-msg').show(); -// $('.alert-msg p').text(response.message); -// setTimeout(function() { -// $('.alert-msg').hide(); -// $('.alert-msg p').text(''); -// }, -// 3500); -// } -// }, -// failure: function(response) { -// console.log(5, response); -// } -// }); -// } else { -// $('.alert-msg').show(); -// $('.alert-msg p').text('گرفتن دو عکس الزامیست'); -// setTimeout(function() { -// $('.alert-msg').hide(); -// $('.alert-msg p').text(''); -// }, -// 3500); -// } -// } else { -// $('.alert-msg').show(); -// $('.alert-msg p').text('گرفتن دو عکس الزامیست'); -// setTimeout(function () { -// $('.alert-msg').hide(); -// $('.alert-msg p').text(''); -// }, 3500); -// } -//} \ No newline at end of file +} \ No newline at end of file