From 13cad28356eb79bdbb514503cfa8a23b2600de9d Mon Sep 17 00:00:00 2001 From: MahanCh Date: Mon, 5 May 2025 14:03:33 +0330 Subject: [PATCH] add WorkshopSettingsPage in client --- .../Company/RollCall/CameraAccounts.cshtml.cs | 216 ----------- .../Index.cshtml} | 10 +- .../RollCall/CameraAccounts/Index.cshtml.cs | 263 +++++++++++++ .../ModalCameraAccountChangePassword.cshtml | 185 ++++++++++ .../ModalCreateAccountSetting.cshtml | 171 +++++++++ .../RollCall/WorkshopSetting/Index.cshtml | 321 ++++++++++++++++ .../RollCall/WorkshopSetting/Index.cshtml.cs | 128 +++++++ .../ModalCreateSettingWorkshop.cshtml | 157 ++++++++ .../_Partials/ModalSettingWorkTime.cshtml | 235 ++++++++++++ .../Client/Pages/Shared/_ClientLayout.cshtml | 10 +- .../Areas/Client/Pages/Shared/_Menu.cshtml | 4 +- ServiceHost/ServiceHost.csproj | 1 - .../css/ModalCreateSettingWorkshop.css | 265 ++++++++++++++ .../css/ModalSettingWorkTime.css | 265 ++++++++++++++ .../js/ModalCreateSettingWorkshop.js | 261 +++++++++++++ .../js/ModalSettingWorkTime.js | 346 ++++++++++++++++++ .../css/ModalCreateAccountSetting.css | 13 +- .../pages/RollCall/js/CameraAccounts.js | 3 +- 18 files changed, 2623 insertions(+), 231 deletions(-) delete mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml.cs rename ServiceHost/Areas/Client/Pages/Company/RollCall/{CameraAccounts.cshtml => CameraAccounts/Index.cshtml} (94%) create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCameraAccountChangePassword.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCreateAccountSetting.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalCreateSettingWorkshop.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalSettingWorkTime.cshtml create mode 100644 ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalCreateSettingWorkshop.css create mode 100644 ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalSettingWorkTime.css create mode 100644 ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalCreateSettingWorkshop.js create mode 100644 ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalSettingWorkTime.js diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml.cs deleted file mode 100644 index dd365849..00000000 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System.Security.Claims; -using _0_Framework.Application; -using _0_Framework.Infrastructure; -using AccountManagement.Application; -using AccountManagement.Application.Contracts.Account; -using AccountManagement.Application.Contracts.CameraAccount; -using AccountManagement.Application.Contracts.SubAccount; -using CompanyManagment.App.Contracts.Workshop; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace ServiceHost.Areas.Client.Pages.Company.RollCall -{ - [Authorize] - [NeedsPermission(SubAccountPermissionHelper.CameraAccountSettingsPermissionCode)] - public class CameraAccountsModel : PageModel - { - public string Mess { get; set; } - private readonly IAuthHelper _authHelper; - private readonly IAccountApplication _accountApplication; - private readonly IWorkshopApplication _workshopApplication; - private readonly IPasswordHasher _passwordHasher; - private readonly ICameraAccountApplication _cameraAccountApplication; - private readonly IHttpContextAccessor _contextAccessor; - private readonly ISubAccountApplication _subAccountApplication; - - private readonly long _workshopId; - public string WorkshopFullName; - - public CameraAccountsModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, ICameraAccountApplication cameraAccountApplication, IAccountApplication accountApplication, IWorkshopApplication workshopApplication, IHttpContextAccessor contextAccessor, ISubAccountApplication subAccountApplication) - { - _authHelper = authHelper; - _passwordHasher = passwordHasher; - _cameraAccountApplication = cameraAccountApplication; - _accountApplication = accountApplication; - _workshopApplication = workshopApplication; - _contextAccessor = contextAccessor; - _subAccountApplication = subAccountApplication; - - var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug"); - _workshopId = _passwordHasher.SlugDecrypt(workshopHash); - - if (_workshopId < 1) - throw new InvalidDataException("اختلال در کارگاه"); - } - - public void OnGet() - { - WorkshopFullName = _workshopApplication.GetDetails(_workshopId).WorkshopFullName; - } - - public IActionResult OnPostSendSms() - { - var accountInfo = _authHelper.CurrentAccountInfo(); - if (accountInfo.SubAccountId == 0) - { - var accountId = accountInfo.Id; - var result = _accountApplication.Search(new AccountSearchModel() { Id = accountId }).FirstOrDefault(); - if (result != null) - { - _accountApplication.SendVerifyCodeToChangingPass(result.Mobile, accountId); - return new JsonResult(new - { - isSuccess = true - }); - } - } - else - { - var result = _subAccountApplication.GetDetails(accountInfo.SubAccountId); - if (result != null && result != default) - { - _subAccountApplication.SendVerifyCodeForPasswordChange(result.PhoneNumber, accountInfo.SubAccountId); - return new JsonResult(new - { - isSuccess = true - }); - } - } - - return new JsonResult(new - { - isSuccess = false - }); - - } - - public IActionResult OnPostCheckCode(string code) - { - var accountInfo = _authHelper.CurrentAccountInfo(); - if (accountInfo.SubAccountId == 0) - { - var accountId = accountInfo.Id; - - var result = _accountApplication.Search(new AccountSearchModel() { Id = accountId }).FirstOrDefault(); - var verfiyResult = _accountApplication.GetByVerifyCode(code, result.Mobile); - if (verfiyResult != null) - { - return new JsonResult(new - { - exist = true, - }); - } - } - else - { - var subAccountId = accountInfo.SubAccountId; - - var result = _subAccountApplication.GetDetails(accountInfo.SubAccountId); - if (result != null && result != default) - { - var verfiyResult = _subAccountApplication.GetByVerifyCodeAndPhoneNumber(code, result.PhoneNumber); - if (verfiyResult != null) - { - return new JsonResult(new - { - exist = true, - }); - } - } - } - return new JsonResult(new - { - exist = false, - }); - } - - #region Camera Account - public IActionResult OnGetCameraAccounts() - { - var authModel = _authHelper.CurrentAccountInfo(); - List<(long Id, string Name)> workshops = authModel.WorkshopList.Select(x => (x.Id, x.Name)).ToList(); - - var result = _cameraAccountApplication.GetAllByWorkshopIdAndAccountId(authModel.Id, workshops); - - return new JsonResult(new - { - success = true, - data = result - }); - } - - public IActionResult OnGetChangeCameraPassword(long id) - { - var camera = _cameraAccountApplication.GetDetails(id); - var command = new CameraAccountViewModel() - { - Id = id, - Username = camera.Username, - WorkshopName = camera.WorkshopName, - }; - return Partial("ModalCameraAccountChangePassword", command); - } - - public IActionResult OnPostChangeCameraPassword(ChangePassword command) - { - var result = _cameraAccountApplication.ChangePass(command); - - return new JsonResult(new - { - success = result.IsSuccedded, - message = result.Message - }); - } - - public IActionResult OnGetCameraValidation(string password, string rePassword) - { - if (string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(rePassword)) - { - return new JsonResult(new - { - success = false, - message = "رمز عبور و تکرار آن نباید خالی باشد" - }); - } - - if (password != rePassword) - { - - return new JsonResult(new - { - success = false, - message = "رمز عبور یکسان نیست", - }); - } - - if (password.Length < 8) - { - return new JsonResult(new - { - success = false, - message = "رمز عبور نمی تواند کمتر از 8 کاراکتر باشد", - }); - } - - return new JsonResult(new - { - success = true, - - }); - } - - public IActionResult OnPostCameraAccountChangeStatus(long id, string type) - { - OperationResult result = type == "active" ? _cameraAccountApplication.Active(id) : _cameraAccountApplication.DeActive(id); - - return new JsonResult(new - { - success = result.IsSuccedded, - message = result.Message - }); - } - #endregion - } -} diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml similarity index 94% rename from ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml rename to ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml index 1f01d100..6eea410d 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml @@ -1,5 +1,5 @@ @page -@model ServiceHost.Areas.Client.Pages.Company.RollCall.CameraAccountsModel +@model ServiceHost.Areas.Client.Pages.Company.RollCall.CameraAccounts.IndexModel @{ string clientVersion = _0_Framework.Application.Version.StyleVersion; @@ -201,12 +201,12 @@ } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml.cs new file mode 100644 index 00000000..5741a8fc --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/Index.cshtml.cs @@ -0,0 +1,263 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.CameraAccount; +using AccountManagement.Application.Contracts.SubAccount; +using CompanyManagment.App.Contracts.Workshop; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Security.Claims; +using _0_Framework.Infrastructure; +using CompanyManagment.App.Contracts.CustomizeWorkshopSettings; +using CompanyManagment.App.Contracts.RollCall; +using CompanyManagment.Application; +using System.Transactions; + +namespace ServiceHost.Areas.Client.Pages.Company.RollCall.CameraAccounts +{ + [Authorize] + [NeedsPermission(SubAccountPermissionHelper.CameraAccountSettingsPermissionCode)] + public class IndexModel : PageModel + { + public string Mess { get; set; } + private readonly IAuthHelper _authHelper; + private readonly IAccountApplication _accountApplication; + private readonly IWorkshopApplication _workshopApplication; + private readonly IPasswordHasher _passwordHasher; + private readonly ICameraAccountApplication _cameraAccountApplication; + private readonly IHttpContextAccessor _contextAccessor; + private readonly ISubAccountApplication _subAccountApplication; + + private readonly long _workshopId; + public string WorkshopFullName; + public bool HasCamera; + + public IndexModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, ICameraAccountApplication cameraAccountApplication, IAccountApplication accountApplication, IWorkshopApplication workshopApplication, IHttpContextAccessor contextAccessor, ISubAccountApplication subAccountApplication) + { + _authHelper = authHelper; + _passwordHasher = passwordHasher; + _cameraAccountApplication = cameraAccountApplication; + _accountApplication = accountApplication; + _workshopApplication = workshopApplication; + _contextAccessor = contextAccessor; + _subAccountApplication = subAccountApplication; + + var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug"); + _workshopId = _passwordHasher.SlugDecrypt(workshopHash); + + if (_workshopId < 1) + throw new InvalidDataException("اختلال در کارگاه"); + } + + public void OnGet() + { + var accountId = _authHelper.CurrentAccountId(); + WorkshopFullName = _workshopApplication.GetDetails(_workshopId).WorkshopFullName; + + HasCamera = _cameraAccountApplication.HasCameraAccount(_workshopId, accountId); + } + + public IActionResult OnPostSendSms() + { + var accountInfo = _authHelper.CurrentAccountInfo(); + if (accountInfo.SubAccountId == 0) + { + var accountId = accountInfo.Id; + var result = _accountApplication.Search(new AccountSearchModel() { Id = accountId }).FirstOrDefault(); + if (result != null) + { + _accountApplication.SendVerifyCodeToChangingPass(result.Mobile, accountId); + return new JsonResult(new + { + isSuccess = true + }); + } + } + else + { + var result = _subAccountApplication.GetDetails(accountInfo.SubAccountId); + if (result != null && result != default) + { + _subAccountApplication.SendVerifyCodeForPasswordChange(result.PhoneNumber, accountInfo.SubAccountId); + return new JsonResult(new + { + isSuccess = true + }); + } + } + + return new JsonResult(new + { + isSuccess = false + }); + + } + + public IActionResult OnPostCheckCode(string code) + { + var accountInfo = _authHelper.CurrentAccountInfo(); + if (accountInfo.SubAccountId == 0) + { + var accountId = accountInfo.Id; + + var result = _accountApplication.Search(new AccountSearchModel() { Id = accountId }).FirstOrDefault(); + var verfiyResult = _accountApplication.GetByVerifyCode(code, result.Mobile); + if (verfiyResult != null) + { + return new JsonResult(new + { + exist = true, + }); + } + } + else + { + var subAccountId = accountInfo.SubAccountId; + + var result = _subAccountApplication.GetDetails(accountInfo.SubAccountId); + if (result != null && result != default) + { + var verfiyResult = _subAccountApplication.GetByVerifyCodeAndPhoneNumber(code, result.PhoneNumber); + if (verfiyResult != null) + { + return new JsonResult(new + { + exist = true, + }); + } + } + } + return new JsonResult(new + { + exist = false, + }); + } + + #region Create Camera + public IActionResult OnGetCreateCameraAccount() + { + var command = new CreateCameraAccount(); + command.WorkshopName = _workshopApplication.GetWorkshopFullname(_workshopId); + return Partial("_Partials/ModalCreateAccountSetting", command); + } + + public IActionResult OnPostCreateCameraAccount(CreateCameraAccount command) + { + var createAccountCommand = new CreateCameraAccount() + { + WorkshopId = _workshopId, + AccountId = _authHelper.CurrentAccountId(), + Username = command.Username, + Password = command.Password, + RePassword = command.RePassword, + WorkshopName = _workshopApplication.GetDetails(_workshopId).WorkshopFullName, + IsActiveString = "true", + }; + var result = _cameraAccountApplication.Create(createAccountCommand); + return new JsonResult(new + { + Success = result.IsSuccedded, + message = result.Message, + }); + } + + #endregion + + #region Camera Account + public IActionResult OnGetCameraAccounts() + { + var authModel = _authHelper.CurrentAccountInfo(); + List<(long Id, string Name)> workshops = authModel.WorkshopList.Select(x => (x.Id, x.Name)).ToList(); + + var result = _cameraAccountApplication.GetAllByWorkshopIdAndAccountId(authModel.Id, workshops); + + return new JsonResult(new + { + success = true, + data = result + }); + } + + public IActionResult OnGetChangeCameraPassword(long id) + { + var camera = _cameraAccountApplication.GetDetails(id); + var command = new CameraAccountViewModel() + { + Id = id, + Username = camera.Username, + WorkshopName = camera.WorkshopName, + }; + return Partial("_Partials/ModalCameraAccountChangePassword", command); + } + + public IActionResult OnPostChangeCameraPassword(ChangePassword command) + { + var result = _cameraAccountApplication.ChangePass(command); + + return new JsonResult(new + { + success = result.IsSuccedded, + message = result.Message + }); + } + + public IActionResult OnGetCameraValidation(string password, string rePassword) + { + if (string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(rePassword)) + { + return new JsonResult(new + { + success = false, + message = "رمز عبور و تکرار آن نباید خالی باشد" + }); + } + + if (password != rePassword) + { + + return new JsonResult(new + { + success = false, + message = "رمز عبور یکسان نیست", + }); + } + + if (password.Length < 8) + { + return new JsonResult(new + { + success = false, + message = "رمز عبور نمی تواند کمتر از 8 کاراکتر باشد", + }); + } + + return new JsonResult(new + { + success = true, + + }); + } + + public IActionResult OnPostCameraAccountChangeStatus(long id, string type) + { + OperationResult result = type == "active" ? _cameraAccountApplication.Active(id) : _cameraAccountApplication.DeActive(id); + + return new JsonResult(new + { + success = result.IsSuccedded, + message = result.Message + }); + } + #endregion + + public IActionResult OnGetCheckAccount(string username) + { + var result = _cameraAccountApplication.CheckUsername(username); + return new JsonResult(new + { + Success = result.IsSuccedded, + message = result.IsSuccedded ? "نام کاربری با مورد تاییداست" : result.Message, + }); + } + } +} diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCameraAccountChangePassword.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCameraAccountChangePassword.cshtml new file mode 100644 index 00000000..0c47cd5f --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCameraAccountChangePassword.cshtml @@ -0,0 +1,185 @@ +@model AccountManagement.Application.Contracts.CameraAccount.CameraAccountViewModel +@{ + string clientVersion = _0_Framework.Application.Version.StyleVersion; + +} + +
+ +
+ + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCreateAccountSetting.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCreateAccountSetting.cshtml new file mode 100644 index 00000000..c12507a3 --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/CameraAccounts/_Partials/ModalCreateAccountSetting.cshtml @@ -0,0 +1,171 @@ +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model AccountManagement.Application.Contracts.CameraAccount.CreateCameraAccount +@{ + string clientVersion = _0_Framework.Application.Version.StyleVersion; + + +} + +
+ + +
+ + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml new file mode 100644 index 00000000..2dbc3868 --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml @@ -0,0 +1,321 @@ +@page +@using _0_Framework.Domain.CustomizeCheckoutShared.Enums +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model ServiceHost.Areas.Client.Pages.Company.RollCall._WorkshopSetting.IndexModel + +@{ + ViewData["Title"] = " - " + "حضور و غیاب"; + string clientVersion = _0_Framework.Application.Version.StyleVersion; + int index = 1; + int i = 0; + + + var isRegularWorkshop = Model.WorkshopSettingsDetails.WorkshopShiftStatus == WorkshopShiftStatus.Regular ? true : false; + + +} + + +
+ +
+
+
+
+ +
+

تنظیم ساعات کاری مجموعه

+
@Model.WorkshopFullName
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + + +
+
+
+
+ +
+ + + + + +
+ + تنظیم ساعات کاری مجموعه + @if (Model.WorkshopSettingsDetails.Id != 0) + { + - @(isRegularWorkshop ? "منقطع" : "مستمر") + } + + +
+ + + @* *@ + +
+ + @if (Model.WorkshopSettingsDetails.Id != 0) + { + + @if (isRegularWorkshop) + { + @foreach (var item in Model.WorkshopSettingsDetails.ShiftsList.OrderBy(x => x.Placement)) + { +
+ + @if (item.Placement == ShiftPlacement.First) + { + @("نوبت اول") + } + else if (item.Placement == ShiftPlacement.Second) + { + @("نوبت دوم") + } + else + { + @("نوبت سوم") + } + +
+ + @if (item.Placement == ShiftPlacement.First) + { + @("نوبت اول") + } + else if (item.Placement == ShiftPlacement.Second) + { + @("نوبت دوم") + } + else + { + @("نوبت سوم") + } + + @item.StartTime + الی + @item.EndTime + +
+
+ } + + } + else + { +
+ مجموعه بدون وقفه و بصورت مستمر فعال می‌باشد +
+ } + } + else + { + +
+ + نوبت اول + +
+ + نوبت اول + + - + الی + - + +
+
+ } + +
+
+ +
+
+
+
+
+ + + + +@section Script { + + + +} \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml.cs new file mode 100644 index 00000000..2fd4e3df --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/Index.cshtml.cs @@ -0,0 +1,128 @@ +using _0_Framework.Application; +using _0_Framework.Infrastructure; +using CompanyManagment.App.Contracts.CustomizeWorkshopSettings; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Configuration.UserSecrets; +using System.Security.Claims; +using CompanyManagment.App.Contracts.Error; +using CompanyManagment.App.Contracts.Workshop; +using _0_Framework.Domain.CustomizeCheckoutShared.Enums; +using AccountManagement.Application.Contracts.CameraAccount; +using CompanyManagment.App.Contracts.RollCall; +using System.Transactions; + +namespace ServiceHost.Areas.Client.Pages.Company.RollCall._WorkshopSetting +{ + [Authorize] + [NeedsPermission(SubAccountPermissionHelper.RollCallOperationsPermissionCode)] + public class IndexModel : PageModel + { + private readonly IWorkshopApplication _workshopApplication; + private readonly ICustomizeWorkshopSettingsApplication _customizeWorkshopSettingsApplication; + private readonly IPasswordHasher _passwordHasher; + private readonly IAuthHelper _authHelper; + private readonly IHttpContextAccessor _contextAccessor; + private readonly long _workshopId; + public EditCustomizeWorkshopSettings WorkshopSettingsDetails; + public string WorkshopFullName; + + public IndexModel(IAuthHelper authHelper, IPasswordHasher passwordHasher, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IHttpContextAccessor contextAccessor, IWorkshopApplication workshopApplication) + { + _authHelper = authHelper; + _passwordHasher = passwordHasher; + _customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication; + _contextAccessor = contextAccessor; + _workshopApplication = workshopApplication; + + var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug"); + _workshopId = _passwordHasher.SlugDecrypt(workshopHash); + + if (_workshopId < 1) + throw new InvalidDataException("اختلال در کارگاه"); + } + + public IActionResult OnGet() + { + WorkshopFullName = _workshopApplication.GetWorkshopInfo(_workshopId).WorkshopFullName; + WorkshopSettingsDetails = _customizeWorkshopSettingsApplication.GetWorkshopSettingsDetails(_workshopId); + return Page(); + } + + + public IActionResult OnGetWorkshopSettingModal() + { + var command = _customizeWorkshopSettingsApplication.GetSimpleWorkshopSettings(_workshopId); + + if (command.Id == 0) + { + var newCommand = new CreateCustomizeWorkshopSettings(); + return Partial("_Partials/ModalCreateSettingWorkshop", newCommand); + } + + return Partial("_Partials/ModalSettingWorkTime", command); + } + + public IActionResult OnPostSaveNewWorkshopSetting(CreateCustomizeWorkshopSettings command) + { + string finalMessage = ""; + using (var transaction = new TransactionScope()) + { + var result = _customizeWorkshopSettingsApplication.CreateWorkshopSettings(command); + finalMessage = result.Message; + if (!result.IsSuccedded) + { + return new JsonResult(new + { + Success = false, + message = finalMessage, + }); + } + + transaction.Complete(); + } + + return new JsonResult(new + { + Success = true, + message = finalMessage, + }); + } + + public IActionResult OnGetGroupListAndEmployeeList(long customizeWorkshopSettingsId) + { + var resultData = _customizeWorkshopSettingsApplication.GetShiftChangesGroupAndEmployees(customizeWorkshopSettingsId); + var success = resultData.Any(); + + return new JsonResult(new + { + success = success, + data = resultData, + }); + } + + public IActionResult OnPostEditSettingWorkTime(List shiftViewModels, + long customizeWorkshopSettingsId, WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork) + { + var workshopHash = User.FindFirstValue("WorkshopSlug"); + var workshopId = _passwordHasher.SlugDecrypt(workshopHash); + if (workshopId < 1) + return new JsonResult(new + { + success = false, + message = "هیچ کارگاهی یافت نشد!", + }); + + var result = _customizeWorkshopSettingsApplication + .EditWorkshopSettingShifts(shiftViewModels, customizeWorkshopSettingsId, workshopShiftStatus, fridayWork, holidayWork); + + return new JsonResult(new + { + success = result.IsSuccedded, + message = result.Message, + }); + } + + } +} diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalCreateSettingWorkshop.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalCreateSettingWorkshop.cshtml new file mode 100644 index 00000000..e408acd7 --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalCreateSettingWorkshop.cshtml @@ -0,0 +1,157 @@ +@using _0_Framework.Domain.CustomizeCheckoutShared.Enums +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model CompanyManagment.App.Contracts.CustomizeWorkshopSettings.CreateCustomizeWorkshopSettings +@{ + string clientVersion = _0_Framework.Application.Version.StyleVersion; + + +} + +
+ +
+ + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalSettingWorkTime.cshtml b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalSettingWorkTime.cshtml new file mode 100644 index 00000000..483e4132 --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/WorkshopSetting/_Partials/ModalSettingWorkTime.cshtml @@ -0,0 +1,235 @@ + +@using _0_Framework.Domain.CustomizeCheckoutShared.Enums +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model CompanyManagment.App.Contracts.CustomizeWorkshopSettings.EditCustomizeWorkshopSettings +@{ + string clientVersion = _0_Framework.Application.Version.StyleVersion; + int i = 0; + + +} + +
+ + + + + @* *@ + +
+ + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml b/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml index 48210f47..5267faa6 100644 --- a/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml +++ b/ServiceHost/Areas/Client/Pages/Shared/_ClientLayout.cshtml @@ -128,11 +128,11 @@ $(id).toggleClass('disable', shouldDisable); }); - if (shouldDisable) { - $('#SetWorkshopWorkingHoursPageUrl a').attr('href', linkCameraAccountAndWorkshopSettingUrl); - } else { - $('#SetWorkshopWorkingHoursPageUrl').removeClass('disable'); - } + // if (shouldDisable) { + // $('#SetWorkshopWorkingHoursPageUrl a').attr('href', linkCameraAccountAndWorkshopSettingUrl); + // } else { + // $('#SetWorkshopWorkingHoursPageUrl').removeClass('disable'); + // } } else { $('#RollCallSubMenu').addClass('disable'); } diff --git a/ServiceHost/Areas/Client/Pages/Shared/_Menu.cshtml b/ServiceHost/Areas/Client/Pages/Shared/_Menu.cshtml index bb014ee4..2e478ddc 100644 --- a/ServiceHost/Areas/Client/Pages/Shared/_Menu.cshtml +++ b/ServiceHost/Areas/Client/Pages/Shared/_Menu.cshtml @@ -187,8 +187,8 @@
  • حضور و غیاب جاری
  • سوابق حضور و غیاب
  • گروه‌بندی
  • -
  • تنظیم ساعت فعالیت مجموعه
  • -
  • تنظیمات حساب کاربری دوربین
  • +
  • تنظیم ساعت فعالیت مجموعه
  • +
  • تنظیمات حساب کاربری دوربین
  • diff --git a/ServiceHost/ServiceHost.csproj b/ServiceHost/ServiceHost.csproj index fc0e7ee5..a341064b 100644 --- a/ServiceHost/ServiceHost.csproj +++ b/ServiceHost/ServiceHost.csproj @@ -305,7 +305,6 @@ - diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalCreateSettingWorkshop.css b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalCreateSettingWorkshop.css new file mode 100644 index 00000000..6fad6ff4 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalCreateSettingWorkshop.css @@ -0,0 +1,265 @@ +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; +} + +.modal-dialog, .modal-content { + height: 460px; + width: 510px; +} + +.timeWorkTitle { + color: #5C5C5C; + font-weight: 600; + font-size: 12px; + margin: auto 0 auto 6px; + white-space: nowrap; +} + +.groupBox { + background-color: #F5F5F5; + border-radius: 10px; + border: 1px solid #E7E7E7; + padding: 6px; + margin: 6px 3px; +} + + .groupBox .form-control { + background-color: #ffffff; + } + + .groupBox .form-control::placeholder { + color: #bfbfbf; + opacity: 1; /* Firefox */ + } + + .groupBox .form-control::-ms-input-placeholder { /* Edge 12-18 */ + color: #bfbfbf; + } + +.btnAddTimeWork { + display: flex; + align-items: center; + justify-content: center; + background-color: #84CC16; + border-radius: 5px; + color: #ffffff; + font-size: 12px; + font-weight: 500; + padding: 4px 8px; +} + +.btnRemoveTimeWork { + display: flex; + align-items: center; + justify-content: center; + background-color: #F87171; + border-radius: 7px; + padding: 3px; + width: 30px; + height: 30px; +} + +.ShowMessage { + position: absolute; + background: #dfdfdf; + width: 100%; + top: 0; + right: 0; + height: 100%; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; +} + + +.btn-workTimeOption-container { + display: flex; +} + +.radio-workTimeOption { + display: none; +} + +.radio-label-workTimeOption { + font-size: 13px; + font-weight: 500; + color: #0F8080; + background-color: #DDF4F4; + text-align: center; + padding: 8px 16px; + border-radius: 4px; + margin: auto 6px; + transition: all 0.3s ease-in-out; + cursor: pointer; +} + + .radio-label-workTimeOption:hover { + color: #FFFFFF; + background-color: #1c7474; + border-color: #23A8A8; + } + +.radio-workTimeOption:checked + .radio-label-workTimeOption { + color: #FFFFFF; + background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%); +} + +.show-disorganized { + height: 81px; + background: #F2FEFF; + border: 1px solid #B0EBF0; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + text-align: center; +} + + .show-disorganized p { + font-weight: 500; + font-size: 14px; + color: #1B929C; + } + + + +.radio-label-workTimeOption { + font-size: 13px; + font-weight: 500; + color: #0F8080; + background-color: #DDF4F4; + text-align: center; + padding: 8px 16px; + border-radius: 9px; + margin: auto 5px; + transition: all 0.3s ease-in-out; + cursor: pointer; +} + + .radio-label-workTimeOption:hover { + color: #FFFFFF; + background-color: #1c7474; + border-color: #23A8A8; + } + +.radio-workTimeOption:checked + .radio-label-workTimeOption { + color: #FFFFFF; + background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%); +} + +.show-disorganized { + height: 81px; + background: #F2FEFF; + border: 1px solid #B0EBF0; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + text-align: center; +} + + .show-disorganized p { + font-weight: 500; + font-size: 14px; + color: #1B929C; + } + +#computeTime span, +.lableCheckBreakTime, +.labelExtraOption { + font-size: 12px; + font-weight: 500; + margin: 0 10px; + color: #101010; + text-align: right; +} + +.breack-time { + border: 1px solid #ddd; + padding: 8px 0; + border-radius: 20px; +} + +.extraOptionBorder { + border: 1px solid #ddd; + padding: 8px 0; + border-radius: 20px; +} + +/************************ Radio Button Input () ************************/ +.form-check-input[type="radio"], +.form-check-input[type="checkbox"] { + width: 15px; + height: 15px; + border-radius: 6px; + padding: 8px; + border: 1px solid #CFD3D4; + background-color: white; + background-position: center; + background-size: contain; + background-repeat: no-repeat; + margin-right: 8px; + appearance: none; +} + + .form-check-input[type="radio"]:checked, + .form-check-input[type="checkbox"]:checked { + background-color: #148989; + border: 1px solid #ffffff !important; + background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="white" stroke-width="3"%3E%3Cpath stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /%3E%3C/svg%3E'); + background-size: 75%; + } + +.form-check-input[type=checkbox]:indeterminate { + background-color: #148989; + border-color: #ffffff; + --bs-form-check-bg-image: url(data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e); +} + +.form-check-input[type="radio"]:focus, +.form-check-input[type="checkbox"]:focus { + outline: none; + box-shadow: none; +} + +.form-check-input[type="radio"] + label, +.form-check-input[type="checkbox"] + label { + color: #83898C; +} + +.form-check-input[type="radio"]:checked + label, +.form-check-input[type="checkbox"]:checked + label { + color: #2B2F32; +} +/************************ Radio Button Input (Like Checkbox appearance) ************************/ + + +@media (max-width: 992px) { + .modal-dialog, .modal-content { + /*height: 622px;*/ + height: 600px; + width: auto; + } + + .radio-label-workTimeOption { + font-size: 10px; + padding: 8px 8px; + font-weight: 800; + } + + #computeTime span, + .lableCheckBreakTime, + .labelExtraOption { + font-size: 11px; + } +} + +@media (min-width: 576px) { + .container, .container-sm { + max-width: none; + } +} \ No newline at end of file diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalSettingWorkTime.css b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalSettingWorkTime.css new file mode 100644 index 00000000..e2a94942 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/css/ModalSettingWorkTime.css @@ -0,0 +1,265 @@ +.errored { + animation: shake 300ms; + color: #eb3434 !important; + background-color: #fef2f2 !important; + border: 1px solid #eb3434 !important; +} + +.modal-dialog, .modal-content { + height: 460px; + width: 510px; +} + +.timeWorkTitle { + color: #5C5C5C; + font-weight: 600; + font-size: 12px; + margin: auto 0 auto 6px; + white-space: nowrap; +} + +.groupBox { + background-color: #F5F5F5; + border-radius: 10px; + border: 1px solid #E7E7E7; + padding: 6px; + margin: 6px 3px; +} + + .groupBox .form-control { + background-color: #ffffff; + } + + .groupBox .form-control::placeholder { + color: #bfbfbf; + opacity: 1; /* Firefox */ + } + + .groupBox .form-control::-ms-input-placeholder { /* Edge 12-18 */ + color: #bfbfbf; + } + +.btnAddTimeWork { + display: flex; + align-items: center; + justify-content: center; + background-color: #84CC16; + border-radius: 5px; + color: #ffffff; + font-size: 12px; + font-weight: 500; + padding: 4px 8px; +} + +.btnRemoveTimeWork { + display: flex; + align-items: center; + justify-content: center; + background-color: #F87171; + border-radius: 7px; + padding: 3px; + width: 30px; + height: 30px; +} + +.ShowMessage { + position: absolute; + background: #dfdfdf; + width: 100%; + top: 0; + right: 0; + height: 100%; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; +} + + +.btn-workTimeOption-container { + display: flex; +} + +.radio-workTimeOption { + display: none; +} + +.radio-label-workTimeOption { + font-size: 13px; + font-weight: 500; + color: #0F8080; + background-color: #DDF4F4; + text-align: center; + padding: 8px 16px; + border-radius: 4px; + margin: auto 6px; + transition: all 0.3s ease-in-out; + cursor: pointer; +} + + .radio-label-workTimeOption:hover { + color: #FFFFFF; + background-color: #1c7474; + border-color: #23A8A8; + } + +.radio-workTimeOption:checked + .radio-label-workTimeOption { + color: #FFFFFF; + background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%); +} + +.show-disorganized { + height: 81px; + background: #F2FEFF; + border: 1px solid #B0EBF0; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + text-align: center; +} + + .show-disorganized p { + font-weight: 500; + font-size: 14px; + color: #1B929C; + } + + + +.radio-label-workTimeOption { + font-size: 13px; + font-weight: 500; + color: #0F8080; + background-color: #DDF4F4; + text-align: center; + padding: 8px 16px; + border-radius: 9px; + margin: auto 5px; + transition: all 0.3s ease-in-out; + cursor: pointer; +} + + .radio-label-workTimeOption:hover { + color: #FFFFFF; + background-color: #1c7474; + border-color: #23A8A8; + } + +.radio-workTimeOption:checked + .radio-label-workTimeOption { + color: #FFFFFF; + background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%); +} + +.show-disorganized { + height: 81px; + background: #F2FEFF; + border: 1px solid #B0EBF0; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + text-align: center; +} + + .show-disorganized p { + font-weight: 500; + font-size: 14px; + color: #1B929C; + } + +#computeTime span, +.lableCheckBreakTime, +.labelExtraOption { + font-size: 12px; + font-weight: 500; + margin: 0 10px; + color: #101010; + text-align: right; +} + +.breack-time { + border: 1px solid #ddd; + padding: 8px 0; + border-radius: 20px; +} + +.extraOptionBorder { + border: 1px solid #ddd; + padding: 8px 0; + border-radius: 20px; +} + +/************************ Radio Button Input () ************************/ +.form-check-input[type="radio"], +.form-check-input[type="checkbox"] { + width: 15px; + height: 15px; + border-radius: 6px; + padding: 8px; + border: 1px solid #CFD3D4; + background-color: white; + background-position: center; + background-size: contain; + background-repeat: no-repeat; + margin-right: 8px; + appearance: none; +} + + .form-check-input[type="radio"]:checked, + .form-check-input[type="checkbox"]:checked { + background-color: #148989; + border: 1px solid #ffffff !important; + background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="white" stroke-width="3"%3E%3Cpath stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /%3E%3C/svg%3E'); + background-size: 75%; + } + +.form-check-input[type=checkbox]:indeterminate { + background-color: #148989; + border-color: #ffffff; + --bs-form-check-bg-image: url(data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e); +} + +.form-check-input[type="radio"]:focus, +.form-check-input[type="checkbox"]:focus { + outline: none; + box-shadow: none; +} + +.form-check-input[type="radio"] + label, +.form-check-input[type="checkbox"] + label { + color: #83898C; +} + +.form-check-input[type="radio"]:checked + label, +.form-check-input[type="checkbox"]:checked + label { + color: #2B2F32; +} +/************************ Radio Button Input (Like Checkbox appearance) ************************/ + + +@media (max-width: 992px) { + .modal-dialog, .modal-content { + /*height: 622px;*/ + height: 600px; + width: auto; + } + + .radio-label-workTimeOption { + font-size: 10px; + padding: 8px 8px; + font-weight: 800; + } + + #computeTime span, + .lableCheckBreakTime, + .labelExtraOption { + font-size: 11px; + } +} + +@media (min-width: 576px) { + .container, .container-sm { + max-width: none; + } +} diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalCreateSettingWorkshop.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalCreateSettingWorkshop.js new file mode 100644 index 00000000..be556ea4 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalCreateSettingWorkshop.js @@ -0,0 +1,261 @@ +$(document).ready(function () { + $(".dateTime").each(function () { + let element = $(this); + + element.on('input', function () { + let value = convertPersianNumbersToEnglish(element.val()); + element.val(value); + }); + + new Cleave(this, { + time: true, + timePattern: ['h', 'm'] + }); + }); + + $("#organized").on("click", function () { + $('#step_workTimeOption').show(); + $('#step_workTimeOptionIrregular').hide(); + + if ($('#step-form2').is(':visible')) { + $('.dateTime').each(function () { + if ($(this).val() === '') { + $('.btn-register').addClass('disable'); + } + }); + } + }); + + $("#disorganized").on("click", function () { + $('#step_workTimeOption').hide(); + $('#step_workTimeOptionIrregular').show(); + $('.btn-register').removeClass('disable'); + }); + + + $(".btnAddTimeWork").on("click", function () { + var currentCount = $('.groupBox').length; + var $inputs = $('.dateTime'); + var allFilled = true; + + $inputs.each(function () { + if ($(this).val() === '') { + allFilled = false; + showAlert('ابتدا ساعت شروع و پایان را وارد نمائید.', $(this)); + } + }); + + //validateAllTimes(); + + if (!allFilled) { + return false; + } + + if (currentCount < 3) { + var namePlacement = ""; + var namePlacementPersian = ""; + + switch (currentCount + 1) { + case 2: + namePlacement = "Second"; + namePlacementPersian = "دوم"; + break; + case 3: + namePlacement = "Third"; + namePlacementPersian = "سوم"; + break; + default: + } + + var timeWorkHtml = ` +
    +
    +
    + +
    نوبت ${namePlacementPersian}
    +
    +
    +
    از
    + +
    +
    +
    الی
    + +
    +
    + +
    +
    +
    `; + + $('#appendChildTimeWorkHtml').append(timeWorkHtml); + + const newStartTimeInput = $(`input[name="ShiftsList[${currentCount}].StartTime"]`); + const newEndTimeInput = $(`input[name="ShiftsList[${currentCount}].EndTime"]`); + + newStartTimeInput.on('input', function () { + const value = convertPersianNumbersToEnglish($(this).val()); + $(this).val(value); + }); + + newEndTimeInput.on('input', function () { + const value = convertPersianNumbersToEnglish($(this).val()); + $(this).val(value); + }); + + new Cleave(newStartTimeInput[0], { + time: true, + timePattern: ['h', 'm'] + }); + + new Cleave(newEndTimeInput[0], { + time: true, + timePattern: ['h', 'm'] + }); + + //new Cleave(`input[name="CreateWorkshopSettings.ShiftsList[${currentCount}].StartTime"]`, { + // time: true, + // timePattern: ['h', 'm'] + //}); + + //new Cleave(`input[name="CreateWorkshopSettings.ShiftsList[${currentCount}].EndTime"]`, { + // time: true, + // timePattern: ['h', 'm'] + //}); + + updateAddButtonText(currentCount + 1); + + if (currentCount + 1 === 3) { + $(".btnAddTimeWork").hide(); + } + + // Update Remove button enable/disable state + updateRemoveButtons(); + } + }); + $(document).on("click", ".btnRemoveTimeWork", function () { + $(this).closest(".groupBox").remove(); + var currentCount = $('.groupBox').length; + + updateAddButtonText(currentCount); + updateRemoveButtons(); + + if (currentCount < 3) { + $(".btnAddTimeWork").show(); + } + }); +}); + +function updateRemoveButtons() { + $(".btnRemoveTimeWork").addClass("disable"); + $(".btnRemoveTimeWork").last().removeClass("disable"); +} + +updateAddButtonText(1); +function updateAddButtonText(currentCount) { + if (currentCount === 1) { + $('.btnAppendChildTimeWork').text('افزودن نوبت دوم'); + } else if (currentCount === 2) { + $('.btnAppendChildTimeWork').text('افزودن نوبت سوم'); + } + + let allFilled = true; + $('.dateTime').each(function () { + const value = $(this).val().trim(); + if (value === "" || !timeValidCheck(value)) { + allFilled = false; + return false; // Break the loop + } + }); + + if (allFilled) { + $('.btn-register').removeClass('disable'); + } else { + $('.btn-register').addClass('disable'); + } +} + +//******************** برای نوشتن تاریخ ******************** + +//$(document).on('input', ".dateTime", function () { +// var value = $(this).val(); +// $(this).val(convertPersianNumbersToEnglish(value)).mask("00:00"); +//}); + +$(document).on('keyup', ".dateTime", function () { + let $input = $(this); + let value = $input.val(); + let lengthValue = value.length; + let currentCount = $('.groupBox').length; + + if (lengthValue >= 5) { + if (!timeValidCheck(value)) { + showAlert('ساعت را به درستی وارد نمائید', $input); + updateAddButtonText(currentCount); + } else { + clearAlert($input); + //validateAllTimes(); + updateAddButtonText(currentCount); + + } + } else { + updateAddButtonText(currentCount); + } +}); + +function showAlert(message, inputElement) { + inputElement.addClass("errored"); + $('.alert-msg').show().find('p').text(message); + setTimeout(function () { + clearAlert(inputElement); + }, 3500); +} + +function clearAlert(inputElement) { + inputElement.removeClass("errored"); + $('.alert-msg').hide().find('p').text(''); +} + +function timeValidCheck(value) { + const timePattern = /^([01]\d|2[0-3]):([0-5]\d)$/; + return timePattern.test(value); +} + +//******************** برای نوشتن تاریخ ******************** + +function saveNewWorkshopSetting() { + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: saveNewWorkshopSettingUrl, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: $('#create-form').serialize(), + success: function (response) { + if (response.success) { + $('.alert-success-msg').show(); + $('.alert-success-msg p').text(response.message); + setTimeout(function () { + $('.alert-success-msg').hide(); + $('.alert-success-msg p').text(''); + }, 3500); + window.location.reload(); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); +} diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalSettingWorkTime.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalSettingWorkTime.js new file mode 100644 index 00000000..577c8457 --- /dev/null +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/WorkshopSetting/js/ModalSettingWorkTime.js @@ -0,0 +1,346 @@ +var isTabPressed = false; +$(document).ready(function () { + updateRemoveButtons(); + + $('.loading').hide(); + + $(".dateTime").on("blur", function () { + var valueCheck = $(this).val().trim(); + if (valueCheck === "" || !timeValidCheck(valueCheck)) { + $(this).addClass("errored"); + } + }); + + //$(".dateTime").on("keydown", function (e) { + // if (e.key === "Tab" && !e.shiftKey) { + // e.preventDefault(); + // isTabPressed = true; + + // if (e.shiftKey) { + // focusPreviousTimeInput(this); + // } else { + // focusNextTimeInput(this); + // } + // } + //}); + + if (IsRegularWorkshop) { + + $("#organized").prop('checked', true); + $("#disorganized").prop('checked', false); + $('#step_workTimeOption').show(); + $('#step_workTimeOptionIrregular').hide(); + + // این مرحله هنگام چک کردن تعداد نوبت هستش + var currentCount = $('.groupBox').length; + updateAddButtonText(currentCount); + } else { + $("#organized").prop('checked', false); + $("#disorganized").prop('checked', true); + $('#step_workTimeOption').hide(); + $('#step_workTimeOptionIrregular').show(); + } + + $("#organized").on("click", function () { + $('#step_workTimeOption').show(); + $('#step_workTimeOptionIrregular').hide(); + + if ($('#step_workTimeOption').is(':visible')) { + $('.dateTime').each(function () { + if ($(this).val() === '') { + var currentCount = $('.groupBox').length; + updateAddButtonText(currentCount); + } + }); + } + }); + + $("#disorganized").on("click", function () { + $('#step_workTimeOption').hide(); + $('#step_workTimeOptionIrregular').show(); + $('.btn-register').removeClass('disable'); + }); + + // ---------------------------------------- + + $(".dateTime").each(function () { + let element = $(this); + + element.on('input', function () { + let value = convertPersianNumbersToEnglish(element.val()); + element.val(value); + }); + + new Cleave(this, { + time: true, + timePattern: ['h', 'm'] + }); + }); + $(".btnAddTimeWork").on("click", function () { + var currentCount = $('.groupBox').length; + var $inputs = $('.dateTime'); + var allFilled = true; + + $inputs.each(function () { + if ($(this).val() === '') { + allFilled = false; + showAlert('ابتدا ساعت شروع و پایان را وارد نمائید.', $(this)); + } + }); + + //validateAllTimes(); + + if (!allFilled) { + return false; + } + + + if (currentCount < 3) { + var namePlacement = ""; + var namePlacementPersian = ""; + + switch (currentCount + 1) { + case 2: + namePlacement = "Second"; + namePlacementPersian = "دوم"; + break; + case 3: + namePlacement = "Third"; + namePlacementPersian = "سوم"; + break; + default: + } + + + var timeWorkHtml = ` +
    +
    +
    + +
    نوبت ${namePlacementPersian}
    +
    +
    +
    از
    + +
    +
    +
    الی
    + +
    +
    + +
    +
    +
    `; + + $('#appendChildTimeWorkHtml').append(timeWorkHtml); + + const newStartTimeInput = $(`input[name="shiftViewModels[${currentCount}].StartTime"]`); + const newEndTimeInput = $(`input[name="shiftViewModels[${currentCount}].EndTime"]`); + + newStartTimeInput.on('input', function () { + const value = convertPersianNumbersToEnglish($(this).val()); + $(this).val(value); + }); + + newEndTimeInput.on('input', function () { + const value = convertPersianNumbersToEnglish($(this).val()); + $(this).val(value); + }); + + new Cleave(newStartTimeInput[0], { + time: true, + timePattern: ['h', 'm'] + }); + + new Cleave(newEndTimeInput[0], { + time: true, + timePattern: ['h', 'm'] + }); + + //new Cleave(`input[name="shiftViewModels[${currentCount}].StartTime"]`, { + // time: true, + // timePattern: ['h', 'm'] + //}); + + //new Cleave(`input[name="shiftViewModels[${currentCount}].EndTime"]`, { + // time: true, + // timePattern: ['h', 'm'] + //}); + + updateAddButtonText(currentCount + 1); + + if (currentCount + 1 === 3) { + $(".btnAddTimeWork").hide(); + } + + // Update Remove button enable/disable state + updateRemoveButtons(); + } + }); + + $(document).on("click", ".btnRemoveTimeWork", function () { + $(this).closest(".groupBox").remove(); + var currentCount = $('.groupBox').length; + + updateAddButtonText(currentCount); + + if (currentCount < 3) { + $(".btnAddTimeWork").show(); + } + + // Update Remove button enable/disable state + updateRemoveButtons(); + }); +}); + +function updateRemoveButtons() { + $(".btnRemoveTimeWork").addClass("disable"); + $(".btnRemoveTimeWork").last().removeClass("disable"); +} + +//updateAddButtonText(1); +function updateAddButtonText(currentCount) { + if (currentCount === 1) { + $('.btnAppendChildTimeWork').text('افزودن نوبت دوم'); + $('.btnAddTimeWork').css('visibility', 'visible'); + } else if (currentCount === 2) { + $('.btnAppendChildTimeWork').text('افزودن نوبت سوم'); + $('.btnAddTimeWork').css('visibility', 'visible'); + } else { + $('.btnAddTimeWork').css('visibility', 'hidden'); + } + + let allFilled = true; + $('.dateTime').each(function () { + const value = $(this).val().trim(); + if (value === "" || !timeValidCheck(value)) { + allFilled = false; + return false; // Break the loop + } + }); + + if (allFilled) { + $('.btn-register').removeClass('disable'); + } else { + $('.btn-register').addClass('disable'); + } +} + +//******************** برای نوشتن تاریخ ******************** + +$(document).on('keyup', ".dateTime", function () { + let $input = $(this); + let value = $input.val(); + let lengthValue = value.length; + let currentCount = $('.groupBox').length; + + if (isTabPressed) { + isTabPressed = false; + return; + } + + if (lengthValue >= 5) { + if (!timeValidCheck(value)) { + showAlert('ساعت را به درستی وارد نمائید', $input); + updateAddButtonText(currentCount); + } else { + clearAlert($input); + updateAddButtonText(currentCount); + } + } else { + updateAddButtonText(currentCount); + } +}); + + +function showAlert(message, inputElement) { + inputElement.addClass("errored"); + $('.alert-msg').show().find('p').text(message); + setTimeout(function () { + clearAlert(inputElement); + }, 3500); +} + +function clearAlert(inputElement) { + inputElement.removeClass("errored"); + $('.alert-msg').hide().find('p').text(''); +} + +function timeValidCheck(value) { + const timePattern = /^([01]\d|2[0-3]):([0-5]\d)$/; + return timePattern.test(value); +} + +function actionForShowModalReplaceChange() { + var htmlEmployeeItem = ''; + $.ajax({ + async: false, + dataType: 'json', + type: 'GET', + url: getGroupListAndEmployeeListAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: { 'customizeWorkshopSettingsId': $('#customizeWorkshopSettingsId').val() }, + success: function (response) { + if (response.success) { + $('#ConfirmEmployeeModal').show(); + + response.data.forEach(function (itemEmployee) { + htmlEmployeeItem += `
  • ${itemEmployee.groupName}
  • `; + if (itemEmployee.employeeName.length > 0) { + htmlEmployeeItem += `
      `; + itemEmployee.employeeName.forEach(function (itemEmployeeName) { + htmlEmployeeItem += `
    • ${itemEmployeeName}
    • `; + }); + htmlEmployeeItem += `
    `; + } + }); + + $('#loadEmployeeItem').html(htmlEmployeeItem); + } else { + saveEditSettingWorkTime(); + } + }, + error: function (err) { + console.log(err); + } + }); +} + +function saveEditSettingWorkTime() { + $.ajax({ + async: false, + dataType: 'json', + type: 'POST', + url: saveEditSettingWorkTimeAjax, + headers: { "RequestVerificationToken": antiForgeryToken }, + data: $('#create-form').serialize(), + success: function (response) { + if (response.success) { + $('.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(); + }, 1500); + $('#MainModal').modal('hide'); + } else { + $('.alert-msg').show(); + $('.alert-msg p').text(response.message); + setTimeout(function () { + $('.alert-msg').hide(); + $('.alert-msg p').text(''); + }, 3500); + } + }, + error: function (err) { + console.log(err); + } + }); +} diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/css/ModalCreateAccountSetting.css b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/css/ModalCreateAccountSetting.css index 99b44390..9aaa4300 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/css/ModalCreateAccountSetting.css +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/css/ModalCreateAccountSetting.css @@ -121,4 +121,15 @@ font-weight: 500; font-size: 14px; color: #1B929C; -} \ No newline at end of file +} + +.profilePasswordModal .modal-header h5 { + font-size: 20px; +} + +.modal-title { + font-size: 16px; + color: #1F2937; + font-weight: 600; +} + diff --git a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CameraAccounts.js b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CameraAccounts.js index 5f2802ac..fa8d9519 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CameraAccounts.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/CameraAccounts.js @@ -8,7 +8,8 @@ $(document).ready(function () { if (response.hasRollCallService) { if (!response.hasCameraAccount || !response.hasRollCallWorkshopSetting) { //window.location.href = saveCameraAccountUrl; - AjaxUrlContentModal(saveCameraAccountUrl); + //AjaxUrlContentModal(saveCameraAccountUrl); + AjaxUrlContentModal(modalCreateCameraAccountUrl); } } });