ExcelGrouping Merge
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
|
||||
using OfficeOpenXml.Style;
|
||||
using OfficeOpenXml;
|
||||
using System.Drawing;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.CWS;
|
||||
public class CustomizeWorkshopGroupExcelViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ShiftType { get; set; }
|
||||
public string Shifts { get; set; }
|
||||
public string Salary { get; set; }
|
||||
public List<CustomizeWorkshopEmployeeExcelViewModel> EmployeeSettings { get; set; }
|
||||
}
|
||||
|
||||
public class CustomizeWorkshopEmployeeExcelViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ShiftType { get; set; }
|
||||
public string Shifts { get; set; }
|
||||
public int LeavePermitted { get; set; }
|
||||
public string Salary { get; set; }
|
||||
}
|
||||
public class CustomizeWorkshopGroupSettingExcelGenerator
|
||||
{
|
||||
public static byte[] Generate(List<CustomizeWorkshopGroupExcelViewModel> groups)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
using (var package = new ExcelPackage())
|
||||
{
|
||||
var worksheet = package.Workbook.Worksheets.Add("GroupsAndEmployees");
|
||||
|
||||
// Headers
|
||||
worksheet.Cells[1, 1].Value = "نام گروه";
|
||||
worksheet.Cells[1, 2].Value = "نوع شیفت گروه";
|
||||
worksheet.Cells[1, 3].Value = "شیفت گروه";
|
||||
worksheet.Cells[1, 4].Value = "حقوق گروه";
|
||||
|
||||
worksheet.Cells[1, 5].Value = "نام پرسنل";
|
||||
worksheet.Cells[1, 6].Value = "مجاز مرخصی پرسنل";
|
||||
worksheet.Cells[1, 7].Value = "نوع شیفت پرسنل";
|
||||
worksheet.Cells[1, 8].Value = "شیفت پرسنل";
|
||||
worksheet.Cells[1, 9].Value = "حقوق پرسنل";
|
||||
|
||||
using (var range = worksheet.Cells[1, 1, 1, 9])
|
||||
{
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
range.Style.Font.Bold = true;
|
||||
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
range.Style.Fill.BackgroundColor.SetColor(Color.LightGray); // رنگ پس زمینه خاکستری
|
||||
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
}
|
||||
|
||||
int row = 2;
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
var employees = group.EmployeeSettings ?? new List<CustomizeWorkshopEmployeeExcelViewModel>();
|
||||
int groupStartRow = row;
|
||||
int groupEndRow = employees.Count > 0 ? (row + employees.Count - 1) : row;
|
||||
|
||||
if (employees.Count == 0)
|
||||
{
|
||||
// گروه بدون پرسنل
|
||||
worksheet.Cells[row, 1].Value = group.Name;
|
||||
worksheet.Cells[row, 2].Value = group.ShiftType;
|
||||
worksheet.Cells[row, 3].Value = group.Shifts;
|
||||
worksheet.Cells[row, 4].Value = Convert.ToInt32(group.Salary);
|
||||
|
||||
ApplyGroupStyle(worksheet, row, row);
|
||||
worksheet.Cells[row, 4].Style.Numberformat.Format = "#,##0";
|
||||
using (var thickBorderRange = worksheet.Cells[groupEndRow, 1, groupEndRow, 9])
|
||||
{
|
||||
thickBorderRange.Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var employee in employees)
|
||||
{
|
||||
worksheet.Cells[row, 5].Value = employee.Name;
|
||||
worksheet.Cells[row, 6].Value = employee.LeavePermitted;
|
||||
worksheet.Cells[row, 7].Value = employee.ShiftType;
|
||||
worksheet.Cells[row, 8].Value = employee.Shifts;
|
||||
worksheet.Cells[row, 9].Value = Convert.ToInt32(employee.Salary);
|
||||
|
||||
ApplyEmployeeStyle(worksheet, row);
|
||||
worksheet.Cells[row, 9].Style.Numberformat.Format = "#,##0";
|
||||
row++;
|
||||
}
|
||||
|
||||
// Merge اطلاعات گروه برای تمام پرسنل
|
||||
worksheet.Cells[groupStartRow, 1, groupEndRow, 1].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 1].Value = group.Name;
|
||||
|
||||
worksheet.Cells[groupStartRow, 2, groupEndRow, 2].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 2].Value = group.ShiftType;
|
||||
|
||||
worksheet.Cells[groupStartRow, 3, groupEndRow, 3].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 3].Value = group.Shifts;
|
||||
|
||||
worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 4].Value = Convert.ToInt32(group.Salary);
|
||||
|
||||
ApplyGroupStyle(worksheet, groupStartRow, groupEndRow);
|
||||
|
||||
worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Style.Numberformat.Format = "#,##0";
|
||||
|
||||
|
||||
worksheet.Cells[groupEndRow, 1, groupEndRow, 9].Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
|
||||
|
||||
}
|
||||
}
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
|
||||
for (int i = 2; i <= worksheet.Dimension.Rows; i++)
|
||||
{
|
||||
worksheet.Row(i).Height = 50;
|
||||
}
|
||||
|
||||
int groupShiftCol = 3;
|
||||
int employeeShiftCol = 8;
|
||||
int groupSalary = 4;
|
||||
int employeeSalary = 9;
|
||||
int employeeName =5;
|
||||
worksheet.Columns[groupShiftCol].Width = 15;
|
||||
worksheet.Columns[employeeShiftCol].Width = 15;
|
||||
worksheet.Columns[groupSalary].Width = 16;
|
||||
worksheet.Columns[employeeSalary].Width = 16;
|
||||
worksheet.Columns[employeeName].Width = 24;
|
||||
worksheet.View.RightToLeft = true; // فارسی
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyEmployeeStyle(ExcelWorksheet worksheet, int row)
|
||||
{
|
||||
using (var range = worksheet.Cells[row, 5, row, 9])
|
||||
{
|
||||
//range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
//range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(198, 239, 206)); // سبز خیلی روشن
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
|
||||
// اضافه کردن بوردر به همهی سلولهای ردیف پرسنل
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
|
||||
range.Style.WrapText = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyGroupStyle(ExcelWorksheet worksheet, int startRow, int endRow)
|
||||
{
|
||||
using (var range = worksheet.Cells[startRow, 1, endRow, 4])
|
||||
{
|
||||
//range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
//range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 255, 204)); // زرد خیلی روشن
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
|
||||
// اضافه کردن بوردر به همهی سلولهای گروه
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
|
||||
range.Style.WrapText = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
@@ -9,4 +10,6 @@ public class CustomizeWorkshopSettingsViewModel
|
||||
public string Name { get; set; }
|
||||
public WorkshopShiftStatus WorkshopShiftStatus { get; set; }
|
||||
public List<CustomizeWorkshopGroupSettingsViewModel> GroupSettings { get; set; }
|
||||
public TimeOnly Offset { get; set; }
|
||||
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
return new CustomizeWorkshopSettingsViewModel()
|
||||
{
|
||||
Id = entity.id,
|
||||
Offset = entity.EndTimeOffSet,
|
||||
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
|
||||
new CustomizeWorkshopGroupSettingsViewModel()
|
||||
{
|
||||
@@ -106,7 +107,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
EmployeeId = y.EmployeeId,
|
||||
IsSettingChanged = y.IsSettingChanged,
|
||||
IsShiftChanged = y.IsShiftChanged,
|
||||
Name = $"{employee.FName} {employee.LName}",
|
||||
Name = $"{employee?.FName} {employee?.LName}",
|
||||
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
|
||||
new CustomizeWorkshopShiftViewModel()
|
||||
{
|
||||
@@ -115,7 +116,14 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
Salary = y.Salary,
|
||||
|
||||
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
LeavePermittedDays = y.LeavePermittedDays,
|
||||
IrregularShift = y.IrregularShift,
|
||||
WorkshopShiftStatus = y.WorkshopShiftStatus
|
||||
};
|
||||
}).ToList(),
|
||||
Salary = x.Salary,
|
||||
@@ -127,7 +135,16 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
|
||||
}).ToList(),
|
||||
MainGroup = x.MainGroup
|
||||
MainGroup = x.MainGroup,
|
||||
WorkshopShiftStatus = x.WorkshopShiftStatus,
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
IrregularShift = x.IrregularShift
|
||||
|
||||
|
||||
|
||||
}).ToList(),
|
||||
};
|
||||
|
||||
@@ -36,9 +36,28 @@
|
||||
</div>
|
||||
|
||||
<div class="col-12 p-0 mt-2">
|
||||
<button class="btnCreateNew" type="button" id="newCreateGroup">
|
||||
گروه جدید
|
||||
</button>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<button class="btnCreateNew" type="button" id="newCreateGroup" style="white-space: nowrap;">
|
||||
گروه جدید
|
||||
</button>
|
||||
<div style="white-space: nowrap;">
|
||||
<a class="btn btn-success btn-rounded text-white d-flex align-items-center align-content-center gap-2" href="./grouping/?handler=DownloadExcel">
|
||||
<svg width="24" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" fill="#000000">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
|
||||
<g id="SVGRepo_iconCarrier">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #ffffff;
|
||||
}</style>
|
||||
</defs> <title></title> <g id="xxx-word"> <path class="cls-1" d="M325,105H250a5,5,0,0,1-5-5V25a5,5,0,1,1,10,0V95h70a5,5,0,0,1,0,10Z"></path> <path class="cls-1" d="M325,154.83a5,5,0,0,1-5-5V102.07L247.93,30H100A20,20,0,0,0,80,50v98.17a5,5,0,0,1-10,0V50a30,30,0,0,1,30-30H250a5,5,0,0,1,3.54,1.46l75,75A5,5,0,0,1,330,100v49.83A5,5,0,0,1,325,154.83Z"></path> <path class="cls-1" d="M300,380H100a30,30,0,0,1-30-30V275a5,5,0,0,1,10,0v75a20,20,0,0,0,20,20H300a20,20,0,0,0,20-20V275a5,5,0,0,1,10,0v75A30,30,0,0,1,300,380Z"></path> <path class="cls-1" d="M275,280H125a5,5,0,1,1,0-10H275a5,5,0,0,1,0,10Z"></path> <path class="cls-1" d="M200,330H125a5,5,0,1,1,0-10h75a5,5,0,0,1,0,10Z"></path> <path class="cls-1" d="M325,280H75a30,30,0,0,1-30-30V173.17a30,30,0,0,1,30-30h.2l250,1.66a30.09,30.09,0,0,1,29.81,30V250A30,30,0,0,1,325,280ZM75,153.17a20,20,0,0,0-20,20V250a20,20,0,0,0,20,20H325a20,20,0,0,0,20-20V174.83a20.06,20.06,0,0,0-19.88-20l-250-1.66Z"></path> <path class="cls-1" d="M152.44,236H117.79V182.68h34.3v7.93H127.4v14.45h19.84v7.73H127.4v14.92h25Z"></path> <path class="cls-1" d="M190.18,236H180l-8.36-14.37L162.52,236h-7.66L168,215.69l-11.37-19.14h10.2l6.48,11.6,7.38-11.6h7.46L177,213.66Z"></path> <path class="cls-1" d="M217.4,221.51l7.66.78q-1.49,7.42-5.74,11A15.5,15.5,0,0,1,209,236.82q-8.17,0-12.56-6a23.89,23.89,0,0,1-4.39-14.59q0-8.91,4.8-14.73a15.77,15.77,0,0,1,12.81-5.82q12.89,0,15.35,13.59l-7.66,1.05q-1-7.34-7.23-7.34a6.9,6.9,0,0,0-6.58,4,20.66,20.66,0,0,0-2.05,9.59q0,6,2.13,9.22a6.74,6.74,0,0,0,6,3.24Q215.49,229,217.4,221.51Z"></path> <path class="cls-1" d="M257,223.42l8,1.09a16.84,16.84,0,0,1-6.09,8.83,18.13,18.13,0,0,1-11.37,3.48q-8.2,0-13.2-5.51t-5-14.92q0-8.94,5-14.8t13.67-5.86q8.44,0,13,5.78t4.61,14.84l0,1H238.61a22.12,22.12,0,0,0,.76,6.45,8.68,8.68,0,0,0,3,4.22,8.83,8.83,0,0,0,5.66,1.8Q254.67,229.83,257,223.42Zm-.55-11.8a9.92,9.92,0,0,0-2.56-7,8.63,8.63,0,0,0-12.36-.18,11.36,11.36,0,0,0-2.89,7.13Z"></path> <path class="cls-1" d="M282.71,236h-8.91V182.68h8.91Z"></path> </g>
|
||||
</g>
|
||||
</svg>
|
||||
خروجی EXCEL
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,8 @@ using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Infrastructure;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using CompanyManagement.Infrastructure.Excel.CWS;
|
||||
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
{
|
||||
@@ -29,12 +31,12 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
private readonly IHttpContextAccessor _contextAccessor;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
public bool GroupedAllEmployees;
|
||||
private readonly long _workshopId;
|
||||
public string WorkshopFullName;
|
||||
private readonly long _workshopId;
|
||||
public string WorkshopFullName;
|
||||
public CustomizeWorkshopSettingsViewModel RollCallWorkshopSettings;
|
||||
public List<RollCallEmployeeViewModel> RollCallEmployeeList;
|
||||
|
||||
public GroupingModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, ICustomizeWorkshopSettingsApplication rollCallWorkshopSettingsApplication, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, IRollCallEmployeeApplication rollCallEmployeeApplication)
|
||||
public GroupingModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, ICustomizeWorkshopSettingsApplication rollCallWorkshopSettingsApplication, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, IRollCallEmployeeApplication rollCallEmployeeApplication)
|
||||
{
|
||||
_passwordHasher = passwordHasher;
|
||||
_workshopApplication = workshopApplication;
|
||||
@@ -47,29 +49,29 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
|
||||
|
||||
if (_workshopId < 1)
|
||||
throw new InvalidDataException("اختلال در کارگاه");
|
||||
}
|
||||
throw new InvalidDataException("اختلال در کارگاه");
|
||||
}
|
||||
|
||||
public bool IrregularWorkshopHaveGroupedAllPersonnelValidation(long workshopId)
|
||||
{
|
||||
//var isWorkshopIrregular = _customizeWorkshopSettingsApplication
|
||||
// .GetWorkshopSettingsDetails(workshopId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular;
|
||||
//var isWorkshopIrregular = _customizeWorkshopSettingsApplication
|
||||
// .GetWorkshopSettingsDetails(workshopId).WorkshopShiftStatus == WorkshopShiftStatus.Irregular;
|
||||
|
||||
//if (isWorkshopIrregular == false)
|
||||
// return true;
|
||||
var employeesWithoutGroup = _customizeWorkshopSettingsApplication.HasAnyEmployeeWithoutGroup(workshopId);
|
||||
if (employeesWithoutGroup)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
//if (isWorkshopIrregular == false)
|
||||
// return true;
|
||||
var employeesWithoutGroup = _customizeWorkshopSettingsApplication.HasAnyEmployeeWithoutGroup(workshopId);
|
||||
if (employeesWithoutGroup)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
//if (_workshopId != 11)
|
||||
// return Redirect("/Client/Company/RollCall");
|
||||
//if (_workshopId != 11)
|
||||
// return Redirect("/Client/Company/RollCall");
|
||||
|
||||
RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(_workshopId);
|
||||
RollCallEmployeeList = _rollCallEmployeeApplication.GetEmployeeRollCalls(_workshopId);
|
||||
|
||||
var account = _authHelper.CurrentAccountInfo();
|
||||
var account = _authHelper.CurrentAccountInfo();
|
||||
GroupedAllEmployees = IrregularWorkshopHaveGroupedAllPersonnelValidation(_workshopId);
|
||||
|
||||
var workshop = _workshopApplication.GetWorkshopInfo(_workshopId);
|
||||
@@ -77,18 +79,18 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
|
||||
RollCallWorkshopSettings = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account);
|
||||
if (RollCallWorkshopSettings.Id == 0)
|
||||
{
|
||||
return Redirect("/Client/Company/RollCall");
|
||||
}
|
||||
{
|
||||
return Redirect("/Client/Company/RollCall");
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnGetWorkshopSettingsDataAjax()
|
||||
{
|
||||
var account = _authHelper.CurrentAccountInfo();
|
||||
var account = _authHelper.CurrentAccountInfo();
|
||||
|
||||
var result = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account);
|
||||
var result = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopId(_workshopId, account);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = true,
|
||||
@@ -107,16 +109,16 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
}
|
||||
|
||||
public IActionResult OnGetEmployeesGroupSettingsByEmployeeId(long employeeId)
|
||||
{
|
||||
var result = _customizeWorkshopSettingsApplication.GetEmployeesGroupSettingsByEmployeeId(employeeId, _workshopId);
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = result
|
||||
});
|
||||
{
|
||||
var result = _customizeWorkshopSettingsApplication.GetEmployeesGroupSettingsByEmployeeId(employeeId, _workshopId);
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = result
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCreateGroup(long workshopSettingId)
|
||||
public IActionResult OnGetCreateGroup(long workshopSettingId)
|
||||
{
|
||||
var command = new CreateCustomizeWorkshopGroupSettings
|
||||
{
|
||||
@@ -127,7 +129,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
|
||||
public IActionResult OnPostCreateGroup(CreateCustomizeWorkshopGroupSettings command)
|
||||
{
|
||||
command.Salary = "0";
|
||||
command.Salary = "0";
|
||||
OperationResult result = _customizeWorkshopSettingsApplication.CreateGroupSettingsByRollCallWorkshopSettingId(command);
|
||||
|
||||
return new JsonResult(new
|
||||
@@ -139,35 +141,35 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
|
||||
public IActionResult OnGetEditGroup(long groupId)
|
||||
{
|
||||
var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId);
|
||||
|
||||
command.IsShiftChanged = _customizeWorkshopSettingsApplication
|
||||
.GetEmployeeSettingsByGroupSettingsId(groupId)
|
||||
.Any(x => x.IsSettingChanged == true);
|
||||
return Partial("ModalEditGroup", command);
|
||||
}
|
||||
var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId);
|
||||
|
||||
command.IsShiftChanged = _customizeWorkshopSettingsApplication
|
||||
.GetEmployeeSettingsByGroupSettingsId(groupId)
|
||||
.Any(x => x.IsSettingChanged == true);
|
||||
return Partial("ModalEditGroup", command);
|
||||
}
|
||||
|
||||
public IActionResult OnPostEditGroup(EditCustomizeWorkshopGroupSettings command)
|
||||
{
|
||||
var result = _customizeWorkshopSettingsApplication.EditSimpleRollCallGroupSetting(command);
|
||||
var result = _customizeWorkshopSettingsApplication.EditSimpleRollCallGroupSetting(command);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetEmployeeIsChangeList(long groupId)
|
||||
{
|
||||
var result = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(groupId)
|
||||
.Where(x => x.IsSettingChanged).ToList();
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = result
|
||||
});
|
||||
}
|
||||
var result = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(groupId)
|
||||
.Where(x => x.IsSettingChanged).ToList();
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = result
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostDeleteGroup(long groupId)
|
||||
{
|
||||
@@ -179,7 +181,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetEmployeeGroupAjax(long rollCallWorkshopSettingId)
|
||||
public IActionResult OnGetEmployeeGroupAjax(long rollCallWorkshopSettingId)
|
||||
{
|
||||
var result = _customizeWorkshopSettingsApplication.GetEmployeesWithoutGroup(rollCallWorkshopSettingId);
|
||||
return new JsonResult(new
|
||||
@@ -202,8 +204,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
|
||||
public IActionResult OnPostCreateEmployee(CreateCustomizeEmployeeSettings command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
OperationResult result = _customizeWorkshopSettingsApplication.CreateEmployeeSettings(command);
|
||||
command.WorkshopId = _workshopId;
|
||||
OperationResult result = _customizeWorkshopSettingsApplication.CreateEmployeeSettings(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
@@ -223,29 +225,29 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
|
||||
public IActionResult OnGetEditEmployee(long groupId, List<long> employeeId)
|
||||
{
|
||||
var employee = _customizeWorkshopSettingsApplication.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(_workshopId, employeeId.First());
|
||||
var employee = _customizeWorkshopSettingsApplication.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(_workshopId, employeeId.First());
|
||||
var command = new EditCustomizeEmployeeSettings()
|
||||
{
|
||||
Id = employee.Id,
|
||||
Id = employee.Id,
|
||||
EmployeeIds = employeeId,
|
||||
EmployeeFullName = employee.EmployeeFullName,
|
||||
Salary = employee.Salary.ToMoney(),
|
||||
NameGroup = employee.Name,
|
||||
ShiftViewModel = employee.RollCallWorkshopShifts,
|
||||
ShiftViewModel = employee.RollCallWorkshopShifts,
|
||||
BreakTime = employee.BreakTime,
|
||||
WorkshopShiftStatus = employee.WorkshopShiftStatus,
|
||||
IrregularShift = employee.IrregularShift,
|
||||
FridayWork = employee.FridayWork,
|
||||
HolidayWork = employee.HolidayWork,
|
||||
CustomizeRotatingShifts = employee.CustomizeRotatingShiftsViewModels
|
||||
};
|
||||
};
|
||||
return Partial("ModalEditEmployeeFromGroup", command);
|
||||
}
|
||||
|
||||
public IActionResult OnPostChangeEditEmployee(EditCustomizeEmployeeSettings command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
OperationResult result = _customizeWorkshopSettingsApplication.EditSimpleRollCallEmployeeSetting(command);
|
||||
command.WorkshopId = _workshopId;
|
||||
OperationResult result = _customizeWorkshopSettingsApplication.EditSimpleRollCallEmployeeSetting(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
@@ -253,43 +255,113 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
});
|
||||
}
|
||||
|
||||
// public IActionResult OnGetGroupingSetting(long groupId)
|
||||
// {
|
||||
// var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId);
|
||||
public IActionResult OnGetDownloadExcel()
|
||||
{
|
||||
var groupData = _customizeWorkshopSettingsApplication.GetWorkshopSettingsByWorkshopIdForAdmin(_workshopId);
|
||||
|
||||
// return Partial("ModalSettingGroup", command);
|
||||
//}
|
||||
var data = groupData.GroupSettings.Select(x => new CustomizeWorkshopGroupExcelViewModel()
|
||||
{
|
||||
Name = x.GroupName,
|
||||
Salary = ((int)x.Salary).ToString(),
|
||||
ShiftType = x.WorkshopShiftStatus switch
|
||||
{
|
||||
WorkshopShiftStatus.Irregular => "مختلط",
|
||||
WorkshopShiftStatus.Regular => "منظم",
|
||||
WorkshopShiftStatus.Rotating => "گردشی",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
Shifts = x.WorkshopShiftStatus switch
|
||||
{
|
||||
WorkshopShiftStatus.Irregular => x.IrregularShift.WorkshopIrregularShifts switch
|
||||
{
|
||||
WorkshopIrregularShifts.None => "نامشخص",
|
||||
WorkshopIrregularShifts.TwelveThirtySix => "12/36",
|
||||
WorkshopIrregularShifts.TwelveTwentyFour => "12/24",
|
||||
WorkshopIrregularShifts.TwentyFourTwentyFour => "24/24",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
WorkshopShiftStatus.Regular => string.Join(Environment.NewLine,
|
||||
x.RollCallWorkshopShifts.Select(s => s.StartTime.ToString() + " - " + s.EndTime).ToList()),
|
||||
WorkshopShiftStatus.Rotating => string.Join(Environment.NewLine,
|
||||
x.CustomizeRotatingShiftsViewModels.Select(s => s.StartTime.ToString() + " - " + s.EndTime)
|
||||
.ToList()),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
EmployeeSettings = x.RollCallWorkshopEmployeesSettings.Select(e => new CustomizeWorkshopEmployeeExcelViewModel
|
||||
{
|
||||
Shifts = e.WorkshopShiftStatus switch
|
||||
{
|
||||
WorkshopShiftStatus.Irregular => e.IrregularShift.WorkshopIrregularShifts switch
|
||||
{
|
||||
WorkshopIrregularShifts.None => "نامشخص",
|
||||
WorkshopIrregularShifts.TwelveThirtySix => "12/36",
|
||||
WorkshopIrregularShifts.TwelveTwentyFour => "12/24",
|
||||
WorkshopIrregularShifts.TwentyFourTwentyFour => "24/24",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
WorkshopShiftStatus.Regular => string.Join(Environment.NewLine,
|
||||
e.RollCallWorkshopShifts.Select(s => s.StartTime.ToString() + " - " + s.EndTime).ToList()),
|
||||
WorkshopShiftStatus.Rotating => string.Join(Environment.NewLine,
|
||||
e.CustomizeRotatingShiftsViewModels.Select(s => s.StartTime.ToString() + " - " + s.EndTime)
|
||||
.ToList()),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
Salary = ((int)e.Salary).ToString(),
|
||||
ShiftType = e.WorkshopShiftStatus switch
|
||||
{
|
||||
WorkshopShiftStatus.Irregular => "مختلط",
|
||||
WorkshopShiftStatus.Regular => "منظم",
|
||||
WorkshopShiftStatus.Rotating => "گردشی",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
LeavePermitted = e.LeavePermittedDays,
|
||||
Name = e.Name
|
||||
}).ToList(),
|
||||
}).ToList();
|
||||
|
||||
// public IActionResult OnPostGroupingSetting(EditCustomizeWorkshopGroupSettings command)
|
||||
// {
|
||||
// command.EmployeeIds = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(command.Id).Select(x => x.EmployeeId).ToList();
|
||||
// OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallGroupSetting(command);
|
||||
var bytes = CustomizeWorkshopGroupSettingExcelGenerator.Generate(data);
|
||||
return File(bytes,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
$"اطلاعات گروهبندی.xlsx");
|
||||
}
|
||||
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = result.IsSuccedded,
|
||||
// message = result.Message
|
||||
// });
|
||||
//}
|
||||
// public IActionResult OnGetGroupingSetting(long groupId)
|
||||
// {
|
||||
// var command = _customizeWorkshopSettingsApplication.GetCustomizeWorkshopGroupSettingsDetails(groupId);
|
||||
|
||||
//public IActionResult OnGetGroupingEmployeeSetting(long customizeEmployeeId, List<long> employeeId)
|
||||
// {
|
||||
// var command = _customizeWorkshopSettingsApplication.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId);
|
||||
// command.EmployeeIds = employeeId;
|
||||
// return Partial("ModalSettingGroup", command);
|
||||
//}
|
||||
|
||||
// return Partial("ModalSettingGroupEmployee", command);
|
||||
// }
|
||||
// public IActionResult OnPostGroupingSetting(EditCustomizeWorkshopGroupSettings command)
|
||||
// {
|
||||
// command.EmployeeIds = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByGroupSettingsId(command.Id).Select(x => x.EmployeeId).ToList();
|
||||
// OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallGroupSetting(command);
|
||||
|
||||
// public IActionResult OnPostGroupingEmployeeSetting(EditCustomizeEmployeeSettings command)
|
||||
// {
|
||||
// command.WorkshopId = _workshopId;
|
||||
// OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallEmployeeSettings(command);
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = result.IsSuccedded,
|
||||
// message = result.Message
|
||||
// });
|
||||
//}
|
||||
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = result.IsSuccedded,
|
||||
// message = result.Message
|
||||
// });
|
||||
//}
|
||||
}
|
||||
//public IActionResult OnGetGroupingEmployeeSetting(long customizeEmployeeId, List<long> employeeId)
|
||||
// {
|
||||
// var command = _customizeWorkshopSettingsApplication.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId);
|
||||
// command.EmployeeIds = employeeId;
|
||||
|
||||
// return Partial("ModalSettingGroupEmployee", command);
|
||||
// }
|
||||
|
||||
// public IActionResult OnPostGroupingEmployeeSetting(EditCustomizeEmployeeSettings command)
|
||||
// {
|
||||
// command.WorkshopId = _workshopId;
|
||||
// OperationResult result = _customizeWorkshopSettingsApplication.EditRollCallEmployeeSettings(command);
|
||||
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = result.IsSuccedded,
|
||||
// message = result.Message
|
||||
// });
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user