diff --git a/Company.Domain/ClassificationSchemeAgg/ClassificationEmployee.cs b/Company.Domain/ClassificationSchemeAgg/ClassificationEmployee.cs index f8974273..e17a1e03 100644 --- a/Company.Domain/ClassificationSchemeAgg/ClassificationEmployee.cs +++ b/Company.Domain/ClassificationSchemeAgg/ClassificationEmployee.cs @@ -14,17 +14,15 @@ public class ClassificationEmployee : EntityBase /// /// /// - /// - /// - public ClassificationEmployee(long workshopId, long employeeId, long classificationSchemeId, long classificationGroupId, long classificationGroupJobId, DateTime? startGroupDate, DateTime? endGroupDate) + + public ClassificationEmployee(long workshopId, long employeeId, long classificationSchemeId, long classificationGroupId, long classificationGroupJobId) { WorkshopId = workshopId; EmployeeId = employeeId; ClassificationSchemeId = classificationSchemeId; ClassificationGroupId = classificationGroupId; ClassificationGroupJobId = classificationGroupJobId; - StartGroupDate = startGroupDate; - EndGroupDate = endGroupDate; + } /// @@ -73,17 +71,10 @@ public class ClassificationEmployee : EntityBase /// /// /// - /// - /// - public void Edit(long workshopId, long employeeId, long classificationSchemeId, long classificationGroupId, long classificationGroupJobId, DateTime? startGroupDate, DateTime? endGroupDate) + public void Edit(long classificationGroupId, long classificationGroupJobId) { - WorkshopId = workshopId; - EmployeeId = employeeId; - ClassificationSchemeId = classificationSchemeId; ClassificationGroupId = classificationGroupId; ClassificationGroupJobId = classificationGroupJobId; - StartGroupDate = startGroupDate; - EndGroupDate = endGroupDate; } } \ No newline at end of file diff --git a/Company.Domain/ClassificationSchemeAgg/IClassificationEmployeeRepository.cs b/Company.Domain/ClassificationSchemeAgg/IClassificationEmployeeRepository.cs new file mode 100644 index 00000000..35ad6e16 --- /dev/null +++ b/Company.Domain/ClassificationSchemeAgg/IClassificationEmployeeRepository.cs @@ -0,0 +1,25 @@ +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.ClassificationScheme; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Company.Domain.ClassificationSchemeAgg; + +public interface IClassificationEmployeeRepository : IRepository +{ + /// + /// دریافت لیست پرسنل کارگاه + /// تب افزودن پرسنل + /// + /// + /// + Task> GetEmployeeListData(long schemeId); + + + /// + /// دریافت اطلاعات عضویتی پرسنل در گروه + /// + /// + /// + Task GetEmployeeMemberizeData(long employeeId); +} \ No newline at end of file diff --git a/Company.Domain/ClassificationSchemeAgg/IClassificationGroupRepository.cs b/Company.Domain/ClassificationSchemeAgg/IClassificationGroupRepository.cs index fdcdb80a..e636b438 100644 --- a/Company.Domain/ClassificationSchemeAgg/IClassificationGroupRepository.cs +++ b/Company.Domain/ClassificationSchemeAgg/IClassificationGroupRepository.cs @@ -7,6 +7,13 @@ namespace Company.Domain.ClassificationSchemeAgg; public interface IClassificationGroupRepository : IRepository { + /// + /// دریافت گروه های طرح + /// + /// + /// + Task> GetGroups(long schemeId); + /// /// دریافت گروه ها و مشاغلشان برای تب تعیین مشاغل /// diff --git a/CompanyManagment.App.Contracts/ClassificationScheme/AddEmployeeToGroup.cs b/CompanyManagment.App.Contracts/ClassificationScheme/AddEmployeeToGroup.cs new file mode 100644 index 00000000..3b956a37 --- /dev/null +++ b/CompanyManagment.App.Contracts/ClassificationScheme/AddEmployeeToGroup.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; + +namespace CompanyManagment.App.Contracts.ClassificationScheme; + +/// +/// مدل برای مدال افزودن پرسنل ب گروه +/// +public class AddEmployeeToGroup +{ + /// + /// آی دی + /// + public long Id { get; set; } + + /// + /// نام کامل پرسنل + /// + public string EmployeeFullName { get; set; } + + /// + /// آی دی پرسنل + /// + public long EmployeeId { get; set; } + + /// + /// آی دی طرح + /// + public long SchemeId { get; set; } + + /// + /// آی دی گروه + /// + public long GroupId { get; set; } + + /// + /// شماره گروه + /// + public long GoroupNo { get; set; } + + /// + /// آی دی شغل + /// + public long JobId { get; set; } + + /// + /// نام شغل + /// + public string JobName { get; set; } + + /// + /// کد شغل + /// + public string JobCode { get; set; } + + + /// + /// لیست گروه ها + /// + public List ClassificationGroupList{ get; set; } +} + +/// +/// لیست گروه ها +/// +public class ClassificationGroupList +{ + /// + /// آی دی گروه + /// + public long GroupId { get; set; } + + /// + /// شماره گروه + /// استرینگ + /// + public string GroupNo { get; set; } + + + /// + /// شماره گروه + /// اینتیجر + /// + public int GroupNoInt { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/ClassificationScheme/EmployeeInfoTab.cs b/CompanyManagment.App.Contracts/ClassificationScheme/EmployeeInfoTab.cs new file mode 100644 index 00000000..bf40f427 --- /dev/null +++ b/CompanyManagment.App.Contracts/ClassificationScheme/EmployeeInfoTab.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; + +namespace CompanyManagment.App.Contracts.ClassificationScheme; + +/// +/// جستجوی پرسنل +/// تب افزودن پرسنل طبقه بندی مشاغل +/// +public class EmployeeInfoTab +{ + /// + /// آی دی کارگاه + /// + public long WorkshopId { get; set; } + + /// + /// آی دی پرسنل + /// + public long EmployeeId { get; set; } + + /// + /// نام کامل پرسنل + /// + public string FullName { get; set; } + + /// + /// آی دی طرح + /// + public long SchemeId { get; set; } + + /// + /// لیست پرسنل + /// + public List EmployeeInfoList { get; set; } +} + +/// +/// لیست پرسنل +/// تب افزودن پرسنل طبقه بندی مشاغل +/// +public class EmployeeInfoList +{ + /// + /// آی دی پرسنل + /// + public long EmployeeId { get; set; } + + /// + /// نام کامل پرسنل + /// + public string FullName { get; set; } + + /// + /// شماره گروه یا گره هایی که پرسنل در آن اضافه شده + /// + public string GroupNo { get; set; } + + /// + /// آیا پرسنل هیچ گروهی دارد؟ + /// + public bool HasGroup { get; set; } + + + /// + /// آخرین تاریخ شروع بکار قراداد + /// + public string LastStartContractWork { get; set; } + + /// + /// آخرین تاریخ ترک کار قراداد + /// + public string LastLeftContractWork { get; set; } + + /// + /// آخرین تاریخ شروع بکار بیمه + /// + public string LastStartInsuranceWork { get; set; } + + /// + /// آخرین تاریخ ترک کار بیمه + /// + public string LastLeftInsuranceWork { get; set; } + + /// + /// آیا پرسنل قرداد است + /// + public bool ContractPerson { get; set; } + + /// + /// آیا پرسنل بیمه است + /// + public bool InsurancePerson { get; set; } + + /// + /// آیا ترک کار قرارداد دارد + /// + public bool ContractLeft { get; set; } + + /// + /// آیا ترک کار بیمه دارد + /// + public bool InsuranceLeft { get; set; } + + /// + /// آیا کلا ترک کار کرده است + /// + public bool Black { get; set; } +} diff --git a/CompanyManagment.App.Contracts/ClassificationScheme/IClassificationSchemeApplication.cs b/CompanyManagment.App.Contracts/ClassificationScheme/IClassificationSchemeApplication.cs index a554c76f..75c55730 100644 --- a/CompanyManagment.App.Contracts/ClassificationScheme/IClassificationSchemeApplication.cs +++ b/CompanyManagment.App.Contracts/ClassificationScheme/IClassificationSchemeApplication.cs @@ -110,4 +110,41 @@ public interface IClassificationSchemeApplication /// Task EditGroupSalaryAndCoefficient(SalaryAndRialCoefficientModel command); + + /// + /// دریافت لیست پرسنل برای تب افزودن پرسنل + /// + /// + /// + Task GetEmployeeDataTab(EmployeeInfoTab command); + + + /// + /// دریافت گروه های طرح + /// + /// + /// + Task> GetGroups(long schemeId); + + /// + /// ذخیره پرسنل افزوده شده در گروه + /// + /// + /// + Task AddEmployeeToGroup(AddEmployeeToGroup command); + + /// + /// ذخیره ویرایش گروه پرسنل + /// + /// + /// + Task EditGroupMember(AddEmployeeToGroup command); + + /// + /// دریافت اطلاعات عضویتی پرسنل در گروه + /// + /// + /// + Task GetEmployeeMemberizeData(long employeeId); + } \ No newline at end of file diff --git a/CompanyManagment.Application/ClassificationSchemeApplication.cs b/CompanyManagment.Application/ClassificationSchemeApplication.cs index fc3f9d08..6bfe8b37 100644 --- a/CompanyManagment.Application/ClassificationSchemeApplication.cs +++ b/CompanyManagment.Application/ClassificationSchemeApplication.cs @@ -16,13 +16,15 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication private readonly IClassificationGroupRepository _classificationGroupRepository; private readonly IClassificationGroupSalariesRepository _classificationGroupSalariesRepository; private readonly IClassificationRialCoefficientRepository _classificationRialCoefficientRepository; + private readonly IClassificationEmployeeRepository _classificationEmployeeRepository; - public ClassificationSchemeApplication(IClassificationSchemeRepository classificationSchemeRepository, IClassificationGroupRepository classificationGroupRepository, IClassificationGroupSalariesRepository classificationGroupSalariesRepository, IClassificationRialCoefficientRepository classificationRialCoefficientRepository) + public ClassificationSchemeApplication(IClassificationSchemeRepository classificationSchemeRepository, IClassificationGroupRepository classificationGroupRepository, IClassificationGroupSalariesRepository classificationGroupSalariesRepository, IClassificationRialCoefficientRepository classificationRialCoefficientRepository, IClassificationEmployeeRepository classificationEmployeeRepository) { _classificationSchemeRepository = classificationSchemeRepository; _classificationGroupRepository = classificationGroupRepository; _classificationGroupSalariesRepository = classificationGroupSalariesRepository; _classificationRialCoefficientRepository = classificationRialCoefficientRepository; + _classificationEmployeeRepository = classificationEmployeeRepository; } public Task ClassificationSchemePartialModel(long workshopId) @@ -303,4 +305,96 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication return op.Succcedded(); } + + + + public async Task GetEmployeeDataTab(EmployeeInfoTab command) + { + var employeeInfoTab = new EmployeeInfoTab(); + var employeeInfoList = _classificationEmployeeRepository.GetEmployeeListData(command.SchemeId).GetAwaiter().GetResult(); + if (employeeInfoList.Any()) + { + if (!string.IsNullOrWhiteSpace(command.FullName)) + employeeInfoList = employeeInfoList.Where(x => x.FullName.Contains(command.FullName)).ToList(); + + employeeInfoTab.EmployeeInfoList = employeeInfoList; + employeeInfoTab.FullName = command.FullName; + + + } + + + return employeeInfoTab; + } + + public async Task> GetGroups(long schemeId) + { + return await _classificationGroupRepository.GetGroups(schemeId); + } + + + public async Task AddEmployeeToGroup(AddEmployeeToGroup command) + { + var op = new OperationResult(); + #region Validation + + if (command.GroupId == 0) + return op.Failed("لطفا گروه را انتخاب کنید"); + + if (command.JobId == 0) + return op.Failed("لطفا سمت را انتخاب کنید"); + + #endregion + + + var scheme = _classificationSchemeRepository.GetClassificationScheme(command.SchemeId).GetAwaiter().GetResult(); + + var create = new ClassificationEmployee(scheme.WorkshopId, command.EmployeeId, command.SchemeId, + command.GroupId, command.JobId); + await _classificationEmployeeRepository.CreateAsync(create); + await _classificationEmployeeRepository.SaveChangesAsync(); + + return op.Succcedded(); + } + + + public async Task EditGroupMember(AddEmployeeToGroup command) + { + var op = new OperationResult(); + #region Validation + + if (command.GroupId == 0) + return op.Failed("لطفا گروه را انتخاب کنید"); + + if (command.JobId == 0) + return op.Failed("لطفا سمت را انتخاب کنید"); + + #endregion + + + var editGroup = _classificationEmployeeRepository.Get(command.Id); + editGroup.Edit(command.GroupId, command.JobId); + await _classificationEmployeeRepository.SaveChangesAsync(); + + return op.Succcedded(); + } + + + /// + /// دریافت اطلاعات عضویتی پرسنل در گروه + /// + /// + /// + public async Task GetEmployeeMemberizeData(long employeeId) + { + var result = new AddEmployeeToGroup(); + var res = await _classificationEmployeeRepository.GetEmployeeMemberizeData(employeeId); + result.EmployeeId = employeeId; + result.GroupId = res.ClassificationGroupId; + result.JobId = res.ClassificationGroupJobId; + result.Id = res.id; + return result; + + + } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/ClassificationEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/ClassificationEmployeeRepository.cs new file mode 100644 index 00000000..36566703 --- /dev/null +++ b/CompanyManagment.EFCore/Repository/ClassificationEmployeeRepository.cs @@ -0,0 +1,192 @@ +using System.Collections.Generic; +using System.Linq; +using System; +using System.Threading.Tasks; +using _0_Framework.Application; +using _0_Framework.InfraStructure; +using Company.Domain.ClassificationSchemeAgg; +using CompanyManagment.App.Contracts.ClassificationScheme; +using CompanyManagment.App.Contracts.Workshop; +using Microsoft.EntityFrameworkCore; + +namespace CompanyManagment.EFCore.Repository; + +public class ClassificationEmployeeRepository : RepositoryBase, IClassificationEmployeeRepository +{ + private readonly CompanyContext _context; + public ClassificationEmployeeRepository(CompanyContext context) : base(context) + { + _context = context; + } + + + public async Task> GetEmployeeListData(long schemeId) + { + var leftDate = new DateTime(2121, 3, 21); + var workshopId = _context.ClassificationSchemes.FirstOrDefault(x => x.id == schemeId)!.WorkshopId; + var join = new List(); + var contractLeftWork =await _context.LeftWorkList.Include(em=>em.Employee).Select(x => new PersonnelInfoViewModel() + { + WorkshopId = x.WorkshopId, + EmployeeId = x.EmployeeId, + FullName = x.Employee.FullName, + PersonnelCode = 0, + ContractPerson = true, + ContractLeft = x.LeftWorkDate != leftDate, + StartWork = x.StartWorkDate, + LeftWork = x.LeftWorkDate, + LastStartInsuranceWork = "-", + LastLeftInsuranceWork = "-", + }).Where(x => x.WorkshopId == workshopId) + .OrderByDescending(x => x.StartWork) + .ToListAsync(); + + contractLeftWork = contractLeftWork.Select(x => new PersonnelInfoViewModel() + { + WorkshopId = x.WorkshopId, + EmployeeId = x.EmployeeId, + FullName = x.FullName, + + ContractPerson = true, + ContractLeft = x.ContractLeft, + LastStartContractWork = x.StartWork.ToFarsi(), + LastLeftContractWork = x.LeftWork != leftDate ? x.LeftWork.ToFarsi() : "-", + StartWork = x.StartWork, + LeftWork = x.LeftWork, + LastStartInsuranceWork = x.LastStartInsuranceWork, + LastLeftInsuranceWork = x.LastLeftInsuranceWork, + }).ToList(); + + var insuranceLeftWork =await _context.LeftWorkInsuranceList.Include(em=> em.Employee).Select(x => new PersonnelInfoViewModel() + { + WorkshopId = x.WorkshopId, + EmployeeId = x.EmployeeId, + FullName = x.Employee.FullName, + PersonnelCode = 0, + InsurancePerson = true, + InsuranceLeft = x.LeftWorkDate != null, + StartWork = x.StartWorkDate, + LastStartInsuranceWork = x.StartWorkDate.ToFarsi(), + LastLeftInsuranceWork = x.LeftWorkDate != null ? x.LeftWorkDate.ToFarsi() : "-", + }).Where(x => x.WorkshopId == workshopId) + .OrderByDescending(x => x.StartWork).ToListAsync(); + + insuranceLeftWork = insuranceLeftWork.Select(x => new PersonnelInfoViewModel() + { + WorkshopId = x.WorkshopId, + EmployeeId = x.EmployeeId, + FullName = x.FullName, + PersonnelCode = _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, + InsuranceLeft = x.InsuranceLeft, + StartWork = x.StartWork, + LastStartInsuranceWork = x.LastStartInsuranceWork, + LastLeftInsuranceWork = x.LastLeftInsuranceWork, + }).ToList(); + + var joinEqualList = contractLeftWork.Join(insuranceLeftWork, + x => x.EmployeeId, + c => c.EmployeeId, + (first, second) => new PersonnelInfoViewModel + { + EmployeeId = first.EmployeeId, + ContractPerson = first.ContractPerson, + ContractLeft = first.ContractLeft, + InsurancePerson = second.InsurancePerson, + InsuranceLeft = second.InsuranceLeft, + LastStartContractWork = first.LastStartContractWork, + LastLeftContractWork = first.LastLeftContractWork, + StartWork = first.StartWork, + LeftWork = first.LeftWork, + LastStartInsuranceWork = second.LastStartInsuranceWork, + LastLeftInsuranceWork = second.LastLeftInsuranceWork, + }).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 new List(); + + //join = join.GroupBy(x => x.EmployeeId).Select(d => d.First()).ToList(); + + + var employeeWhitGroup = _context.ClassificationEmployees.Include(g=>g.ClassificationGroup) + .Where(x => x.ClassificationSchemeId == schemeId); + + + + + + var finalList = join.Select(x => + { + var hasGroup = employeeWhitGroup.Any(em => em.EmployeeId == x.EmployeeId); + var groupNo = ""; + if (hasGroup) + { + var group = employeeWhitGroup.Where(g => g.EmployeeId == x.EmployeeId) + .Select(n => n.ClassificationGroup.GroupNo).ToList(); + if (group.Count > 0) + groupNo = string.Join(" - ", group); + + + + } + + + var contractPerson = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.ContractPerson : x.ContractPerson; + var insurancePerson = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.InsurancePerson : x.InsurancePerson; + var contractLeft = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.ContractLeft : x.ContractLeft; + var insuranceLeft = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.InsuranceLeft : x.InsuranceLeft; + + + var lastStartInsuranceWork = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.LastStartInsuranceWork : x.LastStartInsuranceWork; + var lastLeftInsuranceWork = joinEqualList.Any(c => c.EmployeeId == x.EmployeeId) ? joinEqualList.FirstOrDefault(c => c.EmployeeId == x.EmployeeId)!.LastLeftInsuranceWork : x.LastLeftInsuranceWork; + + return new EmployeeInfoList + { + HasGroup = hasGroup, + GroupNo = groupNo, + EmployeeId = x.EmployeeId, + FullName = x.FullName, + ContractPerson = contractPerson, + InsurancePerson = insurancePerson, + ContractLeft = contractLeft, + InsuranceLeft = insuranceLeft, + Black = ((contractPerson && insurancePerson && insuranceLeft && contractLeft) || (contractPerson && !insurancePerson && contractLeft) || (insurancePerson && !contractPerson && insuranceLeft)) ? true : false, + LastStartContractWork = x.LastStartContractWork, + LastLeftContractWork = x.LastLeftContractWork, + LastStartInsuranceWork = lastStartInsuranceWork, + LastLeftInsuranceWork = lastLeftInsuranceWork, + }; + }).ToList(); + + + var final = finalList.GroupBy(x => x.EmployeeId).Select(x => x.First()).ToList(); + return final; + } + + + /// + /// دریافت اطلاعات عضویتی پرسنل در گروه + /// + /// + /// + public async Task GetEmployeeMemberizeData(long employeeId) + { + return await _context.ClassificationEmployees.FirstOrDefaultAsync(x => x.EmployeeId == employeeId); + + + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/ClassificationGroupRepository.cs b/CompanyManagment.EFCore/Repository/ClassificationGroupRepository.cs index d800c2ba..9b33ab36 100644 --- a/CompanyManagment.EFCore/Repository/ClassificationGroupRepository.cs +++ b/CompanyManagment.EFCore/Repository/ClassificationGroupRepository.cs @@ -17,6 +17,25 @@ public class ClassificationGroupRepository : RepositoryBase + /// دریافت گروه های طرح + /// + /// + /// + public async Task> GetGroups(long schemeId) + { + return await _context.ClassificationGroups + .Where(x => x.ClassificationSchemeId == schemeId) + .Select(x=> new ClassificationGroupList + { + + GroupId = x.id, + GroupNo = x.GroupNo, + GroupNoInt = Convert.ToInt32(x.GroupNo) + + }).OrderBy(x=>x.GroupNoInt).ToListAsync(); + } + /// /// دریافت گروه ها و مشاغلشان برای تب تعیین مشاغل /// diff --git a/PersonalContractingParty.Config/PersonalBootstrapper.cs b/PersonalContractingParty.Config/PersonalBootstrapper.cs index adce4304..5dff1aa7 100644 --- a/PersonalContractingParty.Config/PersonalBootstrapper.cs +++ b/PersonalContractingParty.Config/PersonalBootstrapper.cs @@ -506,6 +506,7 @@ public class PersonalBootstrapper services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); #endregion //=========End Of Main==================================== diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml index d18b8ce0..7f0a54f7 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml @@ -72,7 +72,7 @@ تعیین دستمزد گروه ها - + @@ -163,9 +163,17 @@ break; case "addEmployeesTab" : if(hasScheme === "true"){ - loadPartial(url); - $("#schemeTab, #jobsTab, #salariesTab, #addEmployeesTab").removeClass("active"); - $(this).addClass("active"); + + checkEmptyGroup(function (result) { + if (result) { + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', 'لطفا ابتدا مشاغل تمامی گروه ها را تعیین نمایید'); + } else { + url += "&schemeId=" + schemeId; + loadPartial(url); + $("#schemeTab, #jobsTab, #salariesTab").removeClass("active"); + $('#addEmployeesTab').addClass("active"); + } + }); }else{ $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', 'ابتدا باید طرح ایجاد کنید'); @@ -188,6 +196,8 @@ callback(data.hasEmptyGroup); }); } + + }); diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml.cs index 334e0bf3..8e546626 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/ClassificationScheme.cshtml.cs @@ -1,6 +1,7 @@ using Company.Domain.ClassificationSchemeAgg; using CompanyManagment.App.Contracts.ClassificationScheme; using CompanyManagment.App.Contracts.Job; +using CompanyManagment.App.Contracts.Workshop; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -290,9 +291,162 @@ public class ClassificationSchemeModel : PageModel #endregion - public IActionResult OnGetAddEmployees() + + #region EmployeesTab + + /// + /// تب افزودن پرسنل + /// + /// + /// + public IActionResult OnGetAddEmployeesTab(long schemeId) { - return Partial("_ClassificationPartials/AddClassificationEmployees"); + var model = new EmployeeInfoTab + { + SchemeId = schemeId, + }; + + //var result = _classificationSchemeApplication.GetEmployeeDataTab(command).GetAwaiter().GetResult(); + return Partial("_ClassificationPartials/ClassificationEmployeesTab", model); } + /// + /// دریافت نتیجه جستجو در تب پرسنل + /// + /// + /// + /// + public IActionResult OnGetAjaxDataLoading(long schemeId, string fullName) + { + var command = new EmployeeInfoTab + { + SchemeId = schemeId, + FullName = fullName, + }; + var result = _classificationSchemeApplication.GetEmployeeDataTab(command).GetAwaiter().GetResult(); + if(result.EmployeeInfoList == null || !result.EmployeeInfoList.Any()) + return new JsonResult(new + { + hasEmployee = false + + }); + var personnelList = result.EmployeeInfoList.OrderBy(x => x.Black ? 1 : 0); + + return new JsonResult(new + { + hasEmployee = true, + personnelList + }); + } + + + /// + ///لود مودال افزودن پرسنل به گروه + /// + /// + /// + /// + /// + public IActionResult OnGetAddToGroup(long employeeId, long schemeId, string employeeFullName) + { + var model = new AddEmployeeToGroup(); + var groups = _classificationSchemeApplication.GetGroups(schemeId).GetAwaiter().GetResult(); + + model.SchemeId = schemeId; + model.EmployeeId = employeeId; + model.EmployeeFullName = employeeFullName; + model.ClassificationGroupList = groups; + + + return Partial("_ClassificationPartials/AddEmployeeToGroup", model); + } + + /// + /// ذخیره انتخاب گروه و شغل برای پرسنل + /// + /// + /// + public IActionResult OnPostAddToGroup(AddEmployeeToGroup command) + { + + var result = _classificationSchemeApplication.AddEmployeeToGroup(command).GetAwaiter().GetResult(); + if (!result.IsSuccedded) + { + return new JsonResult(new + { + isSuccess = false, + message = result.Message, + }); + } + return new JsonResult(new + { + isSuccess = true, + message = result.Message, + }); + } + /// + /// دریافت لیست مشاغل با ای دی گروه + /// + /// + /// + /// + public IActionResult OnGetJobList(long schemeId, long groupId) + { + var jobList = _classificationSchemeApplication.GetGroupJobs(groupId).GetAwaiter().GetResult(); + return new JsonResult(new + { + jobs = jobList, + }); + } + + /// + ///لود مودال ویرایش پرسنل گروه + /// + /// + /// + /// + /// + public IActionResult OnGetEditGroupMember(long employeeId, long schemeId, string employeeFullName) + { + var model = new AddEmployeeToGroup(); + var groups = _classificationSchemeApplication.GetGroups(schemeId).GetAwaiter().GetResult(); + var employeeMemberizeData = _classificationSchemeApplication.GetEmployeeMemberizeData(employeeId).GetAwaiter().GetResult(); + + model.SchemeId = schemeId; + model.EmployeeId = employeeId; + model.EmployeeFullName = employeeFullName; + model.ClassificationGroupList = groups; + model.GroupId = employeeMemberizeData.GroupId; + model.JobId = employeeMemberizeData.JobId; + model.Id = employeeMemberizeData.Id; + return Partial("_ClassificationPartials/EditGroupMember", model); + } + + + /// + /// ذخیره ویرایش گروه پرسنل + /// + /// + /// + public IActionResult OnPostEditGroupMember(AddEmployeeToGroup command) + { + + var result = _classificationSchemeApplication.EditGroupMember(command).GetAwaiter().GetResult(); + if (!result.IsSuccedded) + { + return new JsonResult(new + { + isSuccess = false, + message = result.Message, + }); + } + return new JsonResult(new + { + isSuccess = true, + message = result.Message, + }); + } + + #endregion + } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddClassificationEmployees.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddClassificationEmployees.cshtml deleted file mode 100644 index 8f5ca5d6..00000000 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddClassificationEmployees.cshtml +++ /dev/null @@ -1,9 +0,0 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ -} - - - ایجاد پرسنل طرح - diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddEmployeeToGroup.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddEmployeeToGroup.cshtml new file mode 100644 index 00000000..fdd847fd --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/AddEmployeeToGroup.cshtml @@ -0,0 +1,185 @@ +@model CompanyManagment.App.Contracts.ClassificationScheme.AddEmployeeToGroup +@Html.AntiForgeryToken() +@{ + + +} + + + افزودن پرسنل به گروه + + × + + + + + + + @Model.EmployeeFullName + + + + + + + + + + + + انتخاب گروه + @foreach (var item in @Model.ClassificationGroupList) + { + گروه @item.GroupNo + } + + + + + + انتخاب سمت + + + + + + + + + + + + + + + + + + + + + diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationEmployeesTab.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationEmployeesTab.cshtml new file mode 100644 index 00000000..17147c21 --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationEmployeesTab.cshtml @@ -0,0 +1,697 @@ +@model CompanyManagment.App.Contracts.ClassificationScheme.EmployeeInfoTab +@{ + + var i = 1; + var successSend = "successSend"; +} + + + + جستجو + + + + + + + + + + + + + + + + لیست پرسنل + + + + + + + @for (var j = 0; j < 16; j++) + { + + } + + + + + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationGroupSalariesTab.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationGroupSalariesTab.cshtml index f4c171f5..0a989c47 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationGroupSalariesTab.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/ClassificationGroupSalariesTab.cshtml @@ -32,6 +32,8 @@ border-radius: 5px; padding: 4px 1px; margin-bottom: 5px; + font-family: "IranText" !important; + } .row-number { @@ -87,7 +89,7 @@ سال تاریخ شروع تاریخ پایان - ضریب ریالی + ضریب ریالی عملیات @@ -106,9 +108,11 @@ @rowIndex @item.Year - @item.StartDateFa - @item.EndDateFa - @item.RialCoefficientStr + + @item.StartDateFa + + @item.EndDateFa + @item.RialCoefficientStr @{ rowIndex++; } diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/CreateOrEditGroupJobs.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/CreateOrEditGroupJobs.cshtml index 528b03aa..da40f9fc 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/CreateOrEditGroupJobs.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/CreateOrEditGroupJobs.cshtml @@ -22,7 +22,7 @@ box-shadow: 0 1px 2px 0 rgba(0,0,0,.1); border-top: none; border-radius: 7px; - background-color: #e8e8e8 !important; + background-color: #e8e8e8; cursor: pointer; color: #504f4f; } @@ -56,9 +56,13 @@ box-sizing: border-box; } - + .arrowselected{ + background-color: #69a3a3 !important; + color: #ffffff !important; + } - + + } تعیین مشاغل گروه @Model.GroupNo @@ -501,5 +505,72 @@ // console.log(1); } } + + + + document.onkeydown = function (e) { + + var ul = $('.dadmehr-select-search').find('.result'); + + if (ul.is(":visible")) { + + switch (e.which) { + case 38: // Up arrow + e.preventDefault(); + ul.find("li").removeClass('arrowselected'); + if ((index - 1) >= 0) { + index--; + ul.find("li.select-item:eq(" + index + ")").addClass('arrowselected'); + ul.scrollTop(index * (ul.find("li.select-item:eq(" + index + ")").outerHeight()+5)); + ul.find("li.arrowselected").focus(); + } else { + index = -1; + } + + break; + case 40: // Down arrow + e.preventDefault(); + if ((index + 1) < ul.find("li").length) { + + + ul.find("li.select-item").removeClass('arrowselected'); + index++; + //console.log(index); + console.log(index); + ul.find("li.select-item:eq(" + index + ")").addClass('arrowselected'); + ul.scrollTop(index * (ul.find("li.select-item:eq(" + index + ")").outerHeight()+5)); + ul.find("li.arrowselected").focus(); + console.log(index * ul.find("li.select-item:eq(" + index + ")").outerHeight()); + console.log(ul.find("li.select-item:eq(" + index + ")").outerHeight()); + + } + break; + case 13: // Enter + if (index > -1) { + var selectItem = ul.find('li.arrowselected'); + selectItemSearch(selectItem); + } + index = -1; + //proposalList.empty(); + //params.onSubmit(input.val()); + break; + case 9: // Tab + if (index > -1) { + var selectItem = ul.find('li.arrowselected'); + selectItemSearch(selectItem); + } + index = -1; + //proposalList.empty(); + //params.onSubmit(input.val()); + break; + case 27: // Esc button + index = -1; + //proposalList.empty(); + //input.val(''); + break; + } + + } + }; diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/EditGroupMember.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/EditGroupMember.cshtml new file mode 100644 index 00000000..ead5ebd3 --- /dev/null +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/_ClassificationPartials/EditGroupMember.cshtml @@ -0,0 +1,228 @@ +@model CompanyManagment.App.Contracts.ClassificationScheme.AddEmployeeToGroup +@Html.AntiForgeryToken() +@{ + + +} + + + افزودن پرسنل به گروه + + × + + + + + + + @Model.EmployeeFullName + + + + + + + + + + + + انتخاب گروه + @foreach (var item in @Model.ClassificationGroupList) + { + گروه @item.GroupNo + } + + + + + + انتخاب سمت + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ServiceHost/wwwroot/AdminTheme/assets/js/site.js b/ServiceHost/wwwroot/AdminTheme/assets/js/site.js index 1eb4ade5..36398c8c 100644 --- a/ServiceHost/wwwroot/AdminTheme/assets/js/site.js +++ b/ServiceHost/wwwroot/AdminTheme/assets/js/site.js @@ -327,6 +327,7 @@ function CallBackHandler(data, action, form) { } break; + case "RefereshList": { if(data.IsSucceedded==true)