diff --git a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs index 2f1b692d..396047da 100644 --- a/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs +++ b/CompanyManagment.App.Contracts/Employee/IEmployeeApplication.cs @@ -60,7 +60,7 @@ public interface IEmployeeApplication /// Task> ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, - string birthDate, long workshopId); + string birthDate,bool authorizedCanceled, long workshopId); /// /// پرسنل هایی که در کارگاهی از سمت ادمین شروع به کار کرده اند diff --git a/CompanyManagment.Application/EmployeeAplication.cs b/CompanyManagment.Application/EmployeeAplication.cs index 7ac810f6..0452f369 100644 --- a/CompanyManagment.Application/EmployeeAplication.cs +++ b/CompanyManagment.Application/EmployeeAplication.cs @@ -1263,7 +1263,7 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli System.IO.File.WriteAllBytes(filePath, bytes); } public async Task> - ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate, long workshopId) + ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate,bool authorizedCanceled, long workshopId) { var op = new OperationResult(); @@ -1279,65 +1279,25 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli var employee = _EmployeeRepository.GetByNationalCodeIgnoreQueryFilter(nationalCode); - if (employee == null) + if (employee == null && !authorizedCanceled) { var personalInfo = await _uidService.GetPersonalInfo(nationalCode, birthDate); - - if (personalInfo.ResponseContext.Status.Code == 14) + if (personalInfo != null) { - return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeByNationalCodeInWorkshopViewModel() { AuthorizedCanceled = true }); - } - if (personalInfo.ResponseContext.Status.Code != 0) - { - return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); - } + if (personalInfo.ResponseContext.Status.Code == 14) + { + return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeByNationalCodeInWorkshopViewModel() { AuthorizedCanceled = true }); + } + if (personalInfo.ResponseContext.Status.Code != 0) + { + return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند"); + } - var basicInfo = personalInfo.BasicInformation; - var identityInfo = personalInfo.IdentificationInformation; - DateTime apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime(); + var basicInfo = personalInfo.BasicInformation; + var identityInfo = personalInfo.IdentificationInformation; + DateTime apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime(); - var dateOfIssue = new DateTime(1922, 1, 1); - - var gender = basicInfo.GenderEnum switch - { - Gender.Female => "زن", - Gender.Male => "مرد", - _ => throw new AggregateException() - }; - - var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber; - - var newEmployee = new Employee(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate, - dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی", identityInfo.ShenasnameSerial, identityInfo.ShenasnameSeri); - newEmployee.Authorized(); - await _EmployeeRepository.CreateAsync(newEmployee); - await _EmployeeRepository.SaveChangesAsync(); - - return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel() - { - EmployeeId = newEmployee.id, - EmployeeFName = newEmployee.FName, - Gender = newEmployee.Gender, - Nationality = newEmployee.Nationality, - EmployeeLName = newEmployee.LName - }); - } - - if (_leftWorkTempRepository.ExistsIgnoreQueryFilter(x => - x.EmployeeId == employee.id && x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.StartWork)) - { - return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد"); - } - - if (employee.IsAuthorized == false) - { - var personalInfoResponse = await _uidService.GetPersonalInfo(nationalCode, birthDate); - - if (personalInfoResponse.ResponseContext.Status.Code == 0) - { - var basicInfo = personalInfoResponse.BasicInformation; - var identityInfo = personalInfoResponse.IdentificationInformation; - var apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime(); + var dateOfIssue = new DateTime(1922, 1, 1); var gender = basicInfo.GenderEnum switch { @@ -1348,31 +1308,86 @@ public class EmployeeAplication : RepositoryBase, IEmployeeAppli var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber; - - employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate, - employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber, - gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City, - employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation, - employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode, employee.InsuranceHistoryByYear, - employee.InsuranceHistoryByMonth, employee.NumberOfChildren, - employee.OfficePhone, employee.MclsUserName, employee.MclsPassword, - employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName, - employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword); - - employee.Authorized(); - + var newEmployee = new Employee(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate, + dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی", identityInfo.ShenasnameSerial, identityInfo.ShenasnameSeri); + newEmployee.Authorized(); + await _EmployeeRepository.CreateAsync(newEmployee); await _EmployeeRepository.SaveChangesAsync(); + return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel() + { + EmployeeId = newEmployee.id, + EmployeeFName = newEmployee.FName, + Gender = newEmployee.Gender, + Nationality = newEmployee.Nationality, + EmployeeLName = newEmployee.LName + }); } - else + + + + + } + else if (employee == null && authorizedCanceled) + { + return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()); + } + + if (_leftWorkTempRepository.ExistsIgnoreQueryFilter(x => + x.EmployeeId == employee.id && x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.StartWork)) + { + return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد"); + } + + var personalInfoResponse = await _uidService.GetPersonalInfo(nationalCode, birthDate); + if (personalInfoResponse != null) + { + if (employee.IsAuthorized == false) + { + + + if (personalInfoResponse.ResponseContext.Status.Code == 0) + { + var basicInfo = personalInfoResponse.BasicInformation; + var identityInfo = personalInfoResponse.IdentificationInformation; + var apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime(); + + var gender = basicInfo.GenderEnum switch + { + Gender.Female => "زن", + Gender.Male => "مرد", + _ => throw new AggregateException() + }; + + var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber; + + + employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate, + employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber, + gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City, + employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation, + employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode, employee.InsuranceHistoryByYear, + employee.InsuranceHistoryByMonth, employee.NumberOfChildren, + employee.OfficePhone, employee.MclsUserName, employee.MclsPassword, + employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName, + employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword); + + employee.Authorized(); + + await _EmployeeRepository.SaveChangesAsync(); + + } + else + { + return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد"); + } + } + else if (employee.DateOfBirth.ToFarsi() != birthDate || employee.NationalCode != nationalCode) { return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد"); } } - else if (employee.DateOfBirth.ToFarsi() != birthDate || employee.NationalCode != nationalCode) - { - return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد"); - } + var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employee.id); if (leftWorkViewModel == null) diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml.cs index 88c84993..41b0a49b 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml.cs @@ -157,9 +157,10 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees }); } - public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode,string birthDate) + public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode,string birthDate, bool authorizedCanceled) { - var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate, _workshopId); + + var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate, authorizedCanceled, _workshopId); return new JsonResult(result); } diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/_Partials/IdentityInformationForm.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/_Partials/IdentityInformationForm.cshtml index ccdc3239..ef66e7d0 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/_Partials/IdentityInformationForm.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/_Partials/IdentityInformationForm.cshtml @@ -47,7 +47,7 @@ -
+
diff --git a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs index a1a432c6..d773e963 100644 --- a/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs @@ -777,9 +777,9 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall }); } - public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode, string birthDate) + public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode, string birthDate, bool? authorizedCanceled = null) { - var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate, _workshopId); + var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate,false, _workshopId); return new JsonResult(result); } diff --git a/ServiceHost/Areas/Client/Pages/Index.cshtml.cs b/ServiceHost/Areas/Client/Pages/Index.cshtml.cs index 12560871..0a15596b 100644 --- a/ServiceHost/Areas/Client/Pages/Index.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Index.cshtml.cs @@ -546,11 +546,11 @@ namespace ServiceHost.Areas.Client.Pages return new JsonResult(jobViewModels); } - public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode, string birthDate) + public async Task OnGetEmployeeDetailsWithNationalCode(string nationalCode, string birthDate, bool? authorizedCanceled = null) { var workshopSlug = User.FindFirst("WorkshopSlug")?.Value; long workshopIDecrypt = _passwordHasher.SlugDecrypt(workshopSlug); - var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate, workshopIDecrypt); + var result = await _employeeApplication.ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(nationalCode, birthDate,false, workshopIDecrypt); return new JsonResult(result); } diff --git a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeForm.js b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeForm.js index 6b0662fe..4541000d 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeForm.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeForm.js @@ -69,14 +69,14 @@ $(document).ready(function () { function checkInputs() { const genderSelected = $(".genderStatus:checked").length > 0; const maritalStatusSelected = $(".maritalStatus:checked").length > 0; - - const nationality = $("#NationalitySelect").val(); + ; + const nationality = $('#NationalitySelect option:selected').length > 0; const fName = $("#firstName").val(); const lName = $("#lastName").val(); const startWork = $("#startWork").val().trim(); const startWorkIsValidDate = /^\d{4}[-\/]\d{2}[-\/]\d{2}$/.test(startWork); const semat = $("#sematSelect").val(); - debugger; + let isEmpty = false; if (!genderSelected || !maritalStatusSelected || !nationality || !fName || !lName || !startWork || !startWorkIsValidDate || semat === "0") { @@ -88,6 +88,11 @@ function checkInputs() { validateField(".validMariage", "لطفا وضعیت تاهل را مشخص کنید."); return false; } + debugger; + if (!nationality) { + validateField("#NationalitySelect", "لطفا ملیت را مشخص نمایید."); + return false; + } if (!$("input[name='Command.Gender']:checked").val()) { validateField(".validGender", "لطفا جنسیت را مشخص کنید."); return false; diff --git a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeModal.js b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeModal.js index 075646b9..7d9db26d 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeModal.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/CreateEmployeeModal.js @@ -186,6 +186,14 @@ $(document).ready(function () { next() { if (goToStep2) { + if ($('#authorizedCheckboxInput').is(':checked')) { + $('#nationalCodeS2Section').removeClass('disable'); + $('#birthDateS2Section').removeClass('disable'); + $('#nameS2Section').removeClass('disable'); + $('#fNameS2Section').removeClass('disable'); + $('.disablemightBeNullDB1').removeClass('disable'); + } + this.modal.setState(this.modal.step2); } } @@ -454,7 +462,17 @@ function saveFullData() { formData.append("Command.CreateCustomizeEmployeeSettings.FridayWork", $('#Friday1').prop('checked') ? "Default" : "WorkInFriday"); formData.append("Command.CreateCustomizeEmployeeSettings.HolidayWork", $('#HolidayWork1').prop('checked') ? "Default" : "WorkInHolidays"); + var authorizedCanceled = false; + if ($('#authorizedCheckboxInput').is(':checked')) { + //$('#nationalCodeS2Section').removeClass('disable'); + //$('#birthDateS2Section').removeClass('disable'); + //$('#nameS2Section').removeClass('disable'); + //$('#fNameS2Section').removeClass('disable'); + //$('.disablemightBeNullDB1').removeClass('disable'); + formData.append("Command.CanceledAuthorize", true) + + } let pic1 = $("#pic1").attr('src'); let pic2 = $("#pic2").attr('src'); if (pic1) formData.append("Command.RollCallUploadEmployeePicture.Picture1", pic1); diff --git a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/IdentityInformationModal.js b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/IdentityInformationModal.js index 6e38b80c..304397c2 100644 --- a/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/IdentityInformationModal.js +++ b/ServiceHost/wwwroot/AssetsClient/pages/Employees/js/IdentityInformationModal.js @@ -82,12 +82,24 @@ function checkNationalCode(nationalCode, birthDate) { checkNationalUrl = getEmployeeDataByNationalCodeUrl; } + var authorizedCanceled = false; + if ($('#authorizedCheckboxInput').is(':checked')) { + //$('#nationalCodeS2Section').removeClass('disable'); + //$('#birthDateS2Section').removeClass('disable'); + //$('#nameS2Section').removeClass('disable'); + //$('#fNameS2Section').removeClass('disable'); + //$('.disablemightBeNullDB1').removeClass('disable'); + + authorizedCanceled = true; + + } + $("#IdentityLoading").show(); $.ajax({ async: false, url: checkNationalUrl, method: "GET", - data: { nationalCode: nationalCode, birthDate: birthDate }, + data: { nationalCode: nationalCode, birthDate: birthDate, authorizedCanceled: authorizedCanceled }, success: (response) => { if (response.isSuccedded) { if (response.data) {