EBI Excel generator

This commit is contained in:
SamSys
2025-02-09 20:36:53 +03:30
parent d407720368
commit 5afe91ce38
15 changed files with 478 additions and 48 deletions

View File

@@ -0,0 +1,227 @@
using System.Collections.Generic;
using System.Drawing;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using System.Linq;
using OfficeOpenXml.Table.PivotTable;
namespace _0_Framework.Excel.EmployeeBankInfo;
public class EmployeeBankInfoExcelGenerator
{
public static byte[] Generate(List<EmployeeBankInfoExcelViewModel> list)
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("EmployeeBankInfo");
worksheet.Cells[1, 1].Value = "نام پرسنل";
// پیدا کردن بیشترین تعداد حساب بانکی در بین افراد
int maxAccounts = list.Max(p => p.BankAccounts.Count);
for (int i = 0; i < maxAccounts; i++)
{
worksheet.Cells[1, 2 + i * 3].Value = $"نام بانک";
worksheet.Cells[1, 3 + i * 3].Value = $"مشخصات حساب";
worksheet.Cells[1, 3 + i * 3, 1, 4 + i * 3].Merge = true;
}
// تنظیم رنگ خاکستری برای هدر
using (var range = worksheet.Cells[1, 1, 1, 1 + maxAccounts * 3])
{
range.Style.Font.Bold = true;
range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick;
range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick;
range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick;
range.Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick;
}
for (int i = 0; i < maxAccounts; i++)
{
worksheet.Cells[1, 2 + i * 3].Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
worksheet.Cells[1, 2 + i * 3].Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
worksheet.Cells[1, 3 + i * 3].Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
worksheet.Cells[1, 3 + i * 3].Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
}
int row = 2;
foreach (var personnel in list)
{
int startRow = row;
int endRow = row + 2;
var personnelNameCell = worksheet.Cells[startRow, 1, endRow, 1];
personnelNameCell.Merge = true;
personnelNameCell.Value = personnel.Name;
personnelNameCell.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
personnelNameCell.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
personnelNameCell.Style.Border.BorderAround(ExcelBorderStyle.Thick);
int bankNameCol = 2;
for (int j = 0; j < maxAccounts; j++)
{
var bankCell = worksheet.Cells[row, bankNameCol, row + 2, bankNameCol];
bankCell.Merge = true;
bankCell.Style.Border.BorderAround(ExcelBorderStyle.Thick);
bankCell.Style.Border.Right.Style = ExcelBorderStyle.Thin;
bankCell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
bankCell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[row, bankNameCol + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, bankNameCol + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
worksheet.Cells[row + 1, bankNameCol + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row + 1, bankNameCol + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
worksheet.Cells[row + 2, bankNameCol + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row + 2, bankNameCol + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
worksheet.Cells[row + 2, bankNameCol + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
worksheet.Cells[row, bankNameCol + 2].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, bankNameCol + 2].Style.Border.Right.Style = ExcelBorderStyle.Thick;
worksheet.Cells[row + 1, bankNameCol + 2].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row + 1, bankNameCol + 2].Style.Border.Right.Style = ExcelBorderStyle.Thick;
worksheet.Cells[row + 2, bankNameCol + 2].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row + 2, bankNameCol + 2].Style.Border.Right.Style = ExcelBorderStyle.Thick;
worksheet.Cells[row + 2, bankNameCol + 2].Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
var bankAccountsCount = personnel.BankAccounts.Count;
if (j < bankAccountsCount)
{
worksheet.Cells[row, bankNameCol + 1].Value = "کارت";
worksheet.Cells[row + 1, bankNameCol + 1].Value = "شبا";
worksheet.Cells[row + 2, bankNameCol + 1].Value = "حساب";
var bankInfo = personnel.BankAccounts.OrderByDescending(x => x.IsDefault).ToList()[j];
bankCell.Value = string.IsNullOrWhiteSpace(bankInfo.BankName) ? "-" : bankInfo.BankName;
worksheet.Cells[row , bankNameCol + 2].Style.HorizontalAlignment = string.IsNullOrWhiteSpace(bankInfo.CardNumber)? ExcelHorizontalAlignment.Center:ExcelHorizontalAlignment.General;
worksheet.Cells[row + 1, bankNameCol + 2].Style.HorizontalAlignment = string.IsNullOrWhiteSpace(bankInfo.ShebaNumber) ? ExcelHorizontalAlignment.Center : ExcelHorizontalAlignment.General;
worksheet.Cells[row + 2, bankNameCol + 2].Style.HorizontalAlignment = string.IsNullOrWhiteSpace(bankInfo.AccountNumber) ? ExcelHorizontalAlignment.Center : ExcelHorizontalAlignment.General;
worksheet.Cells[row, bankNameCol + 2].Value = string.IsNullOrWhiteSpace(bankInfo.CardNumber) ? "-" : bankInfo.CardNumber;
worksheet.Cells[row + 1, bankNameCol + 2].Value = string.IsNullOrWhiteSpace(bankInfo.ShebaNumber) ? "-" : bankInfo.ShebaNumber;
worksheet.Cells[row + 2, bankNameCol + 2].Value = string.IsNullOrWhiteSpace(bankInfo.AccountNumber) ? "-" : bankInfo.AccountNumber;
if (bankInfo.IsDefault)
{
worksheet.Cells[row, bankNameCol, row + 2, bankNameCol + 2].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
worksheet.Cells[row, bankNameCol, row + 2, bankNameCol + 2].Style.Fill.BackgroundColor.SetColor(1, 198, 224, 180);
}
}
else
{
bankCell.Value = "-";
worksheet.Cells[row, bankNameCol + 1].Value = "-";
worksheet.Cells[row + 1, bankNameCol + 1].Value = "-";
worksheet.Cells[row + 2, bankNameCol + 1].Value = "-";
}
worksheet.Columns[bankNameCol].Width = 15;
worksheet.Columns[bankNameCol + 2].Width = 16;
worksheet.Columns[1].Width = 16;
bankNameCol += 3;
}
row += 3;
}
// Adjust column widths
//worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.View.RightToLeft = true;
return package.GetAsByteArray();
}
public static byte[] Generate2(List<EmployeeBankInfoExcelViewModel> list)
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new ExcelPackage();
foreach (var employee in list)
{
var worksheet = package.Workbook.Worksheets.Add(employee.Name);
// تنظیم هدر ستون‌ها
worksheet.Cells[1, 1].Value = "Bank Name";
worksheet.Cells[1, 2].Value = "Card Number";
worksheet.Cells[1, 3].Value = "Account Number";
worksheet.Cells[1, 4].Value = "Sheba Number";
worksheet.Cells[1, 5].Value = "Is Default";
for (int i = 0; i < employee.BankAccounts.Count; i++)
{
var account = employee.BankAccounts[i];
int row = i + 2;
worksheet.Cells[row, 1].Value = account.BankName;
worksheet.Cells[row, 2].Value = account.CardNumber;
worksheet.Cells[row, 3].Value = account.AccountNumber;
worksheet.Cells[row, 4].Value = account.ShebaNumber;
worksheet.Cells[row, 5].Value = account.IsDefault ? "Yes" : "No";
// استایل‌دهی به سطرها
worksheet.Cells[row, 1, row, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[row, 1, row, 5].Style.Fill.BackgroundColor
.SetColor(account.IsDefault ? System.Drawing.Color.Green : System.Drawing.Color.White);
// استایل‌دهی به متن
worksheet.Cells[row, 1, row, 5].Style.Font.Color
.SetColor(account.IsDefault ? System.Drawing.Color.White : System.Drawing.Color.Black);
}
}
return package.GetAsByteArray();
}
private static void ApplyHeaderStyle(ExcelRange cell)
{
cell.Style.Font.Bold = true;
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
}
private static void ApplyGeneralDataStyle(ExcelRange cell)
{
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace _0_Framework.Excel.EmployeeBankInfo;
public class EmployeeBankInfoExcelViewModel
{
public string Name { get; set; }
public List<BankInfoExcelViewModel> BankAccounts { get; set; }
}
public class BankInfoExcelViewModel
{
public string BankName { get; set; }
public string CardNumber { get; set; }
public string AccountNumber { get; set; }
public string ShebaNumber { get; set; }
public bool IsDefault { get; set; } // تعیین حساب پیش‌فرض
}

View File

@@ -19,5 +19,6 @@ namespace Company.Domain.EmployeeBankInformationAgg
List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId);
List<EmployeeBankInformationViewModelForExcel> SearchForExcel(long workshopId, EmployeeBankInformationSearchModel searchParams);
}
}

View File

@@ -1,7 +1,10 @@
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EmployeeBankInformationSearchModel
{
public long EmployeeId { get; set; }
public List<long> EmployeeBankInfoIds { get; set; } = new();
public long EmployeeId { get; set; }
public long BankId { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EmployeeBankInformationViewModelForExcel
{
public string EmployeeName { get; set; }
public List<BankInformationDtoForExcel> BankInformationList { get; set; }
}
public class BankInformationDtoForExcel
{
public string BankName { get; set; }
public string CardNumber { get; set; }
public string ShebaNumber { get; set; }
public string BankAccountNumber { get; set; }
public bool IsDefault { get; set; }
}

View File

@@ -9,7 +9,9 @@ namespace CompanyManagment.App.Contracts.EmployeeBankInformation
OperationResult GroupCreate(long workshopId, List<CreateEmployeeInformation> command);
OperationResult Edit(EditEmployeeInformation command);
List<GroupedEmployeeBankInformationViewModel> Search(long workshopId, EmployeeBankInformationSearchModel searchParams);
GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId);
List<EmployeeBankInformationViewModelForExcel> SearchForExcel(long workshopId,
EmployeeBankInformationSearchModel searchParams);
GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId);
EmployeeBankInformationViewModel GetDetails(long id);
OperationResult Remove(long id);
OperationResult RemoveByEmployeeId(long workshopId, long employeeId);

View File

@@ -149,6 +149,12 @@ namespace CompanyManagment.Application
{
return _employeeBankInformationRepository.Search(workshopId, searchParams);
}
public List<EmployeeBankInformationViewModelForExcel> SearchForExcel(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
return _employeeBankInformationRepository.SearchForExcel(workshopId, searchParams);
}
public List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
return _employeeBankInformationRepository.GetAllByWorkshopId(workshopId);

View File

@@ -80,8 +80,8 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
{
case "0000000000":
case "1111111111":
case "22222222222":
case "33333333333":
case "2222222222":
case "3333333333":
case "4444444444":
case "5555555555":
case "6666666666":

View File

@@ -216,5 +216,54 @@ namespace CompanyManagment.EFCore.Repository
}
public List<EmployeeBankInformationViewModelForExcel> SearchForExcel(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
var bankInfoQuery = _companyContext.EmployeeBankInformationSet.Where(x => x.WorkshopId == workshopId)
.Include(x => x.Employee).Include(x => x.Bank)
.Select(x => new
{
x.Bank.BankName,
x.BankId,
FullName = (x.Employee.FName + " " + x.Employee.LName),
x.EmployeeId,
x.WorkshopId,
Id = x.id,
x.CardNumber,
x.ShebaNumber,
x.BankAccountNumber,
x.IsDefault
});
if (searchParams.BankId > 0)
bankInfoQuery = bankInfoQuery.Where(x => x.BankId == searchParams.BankId);
if (searchParams.EmployeeId > 0)
bankInfoQuery = bankInfoQuery.Where(x => x.EmployeeId == searchParams.EmployeeId);
if (searchParams.EmployeeBankInfoIds.Any())
bankInfoQuery = bankInfoQuery.Where(x => searchParams.EmployeeBankInfoIds.Contains(x.Id));
var bankInfoList = bankInfoQuery.ToList();
return bankInfoList.GroupBy(x => x.EmployeeId).Select(x =>
{
return new EmployeeBankInformationViewModelForExcel()
{
EmployeeName = x.FirstOrDefault()?.FullName ?? "",
BankInformationList = x.Select(y => new BankInformationDtoForExcel()
{
BankName = y.BankName,
CardNumber = y.CardNumber,
BankAccountNumber = y.BankAccountNumber,
ShebaNumber = y.ShebaNumber,
IsDefault = y.IsDefault
}).ToList()
};
}).ToList();
}
}
}

View File

@@ -118,7 +118,8 @@
<script src="~/assetsclient/js/site.js?ver=@clientVersion"></script>
<script src="~/assetsclient/libs/jalaali-js/jalaali.js"></script>
<script src="~/admintheme/js/jquery.mask_1.14.16.min.js"></script>
@* <script src="~/admintheme/js/jquery.mask_1.14.16.min.js"></script> *@
<script src="~/assetsclient/js/jquery-mask-v1.13.4.js"></script>
<script src="~/assetsclient/libs/cleave/cleave.min.js"></script>
<script>

View File

@@ -134,8 +134,23 @@
</span>
</div>
<div class="col-6 col-md-4 text-end">
@* <div class="d-flex align-items-center justify-content-end my-1">
<button class="btn-print-all" type="button" onclick="printAll()">
<div class="d-flex align-items-center justify-content-end my-1">
<button onclick="downloadExcelAll()" class="btn-excel text-nowrap" type="button">
<svg width="20" height="20" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" fill="#000000">
<g id="SVGRepo_bgCarrier" stroke-width="1"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<defs>
<style>
.cls-1 {
fill: #0f773d;
}</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>
<span>خروجی اکسل</span>
</button>
@* <button class="btn-print-all" type="button" onclick="printAll()">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M15.0001 11.2493H15.139C16.0279 11.2493 16.4723 11.2493 16.759 10.9866C16.7805 10.967 16.801 10.9464 16.8207 10.9249C17.0834 10.6382 17.0834 10.1938 17.0834 9.3049V9.3049C17.0834 7.52714 17.0834 6.63826 16.558 6.06484C16.5187 6.02194 16.4775 5.98077 16.4346 5.94146C15.8612 5.41602 14.9723 5.41602 13.1945 5.41602H6.91675C5.03113 5.41602 4.08832 5.41602 3.50253 6.0018C2.91675 6.58759 2.91675 7.5304 2.91675 9.41602V10.2493C2.91675 10.7208 2.91675 10.9565 3.06319 11.1029C3.20964 11.2493 3.44534 11.2493 3.91675 11.2493H5.00008" stroke="#1E293B"/>
<path d="M5.41675 16.3903L5.41675 9.91732C5.41675 8.97451 5.41675 8.5031 5.70964 8.21021C6.00253 7.91732 6.47394 7.91732 7.41675 7.91732L12.5834 7.91732C13.5262 7.91732 13.9976 7.91732 14.2905 8.21021C14.5834 8.5031 14.5834 8.97451 14.5834 9.91732L14.5834 16.3903C14.5834 16.7068 14.5834 16.8651 14.4796 16.9399C14.3758 17.0148 14.2256 16.9647 13.9253 16.8646L12.2572 16.3086C12.1712 16.2799 12.1282 16.2656 12.0839 16.2669C12.0396 16.2682 11.9975 16.285 11.9134 16.3187L10.1858 17.0097C10.0941 17.0464 10.0482 17.0647 10.0001 17.0647C9.95194 17.0647 9.90609 17.0464 9.81439 17.0097L8.0868 16.3187C8.00267 16.285 7.9606 16.2682 7.91627 16.2669C7.87194 16.2656 7.82896 16.2799 7.74299 16.3086L6.07486 16.8646C5.77455 16.9647 5.62439 17.0148 5.52057 16.9399C5.41675 16.8651 5.41675 16.7068 5.41675 16.3903Z" stroke="#1E293B"/>
@@ -153,8 +168,8 @@
<path d="M8.70841 3.20595C8.70841 3.20595 9.16675 2.28906 11.0001 2.28906C12.8334 2.28906 13.2917 3.20573 13.2917 3.20573" stroke="#BF3737" stroke-linecap="round"/>
</svg>
<span>حذف گروهی</span>
</button>
</div> *@
</button>*@
</div>
</div>
</div>
@@ -162,8 +177,11 @@
<div class="fineList Rtable Rtable--collapse">
<div class="Rtable-row Rtable-row--head align-items-center sticky-div">
<div class="Rtable-cell column-heading width1 d-flex align-items-center">
<label for="checkAll2">ردیف</label>
<div class="Rtable-cell column-heading width1">
<span class="d-flex justify-content-start align-items-center gap-1">
<input type="checkbox" class="form-check-input checkAll" name="" id="checkAll2">
<label for="checkAll2" class="prevent-select text-white">ردیف</label>
</span>
</div>
<div class="Rtable-cell column-heading width2">نام پرسنل</div>
<div class="Rtable-cell column-heading width3 text-center">شماره پرسنلی</div>
@@ -262,6 +280,7 @@
var employeeListAjax = `@Url.Page("./Index", "EmployeeListAjax")`;
var bankListAjax = `@Url.Page("./Index", "BankListAjax")`;
var removeByEmployeeIdAjax = `@Url.Page("./Index", "DeleteByEmployeeId")`;
var CheckoutExcelAllUrl = `@Url.Page("./Index", "DownloadExcelAll")`;
</script>
<script src="~/assetsclient/pages/employeesbankinfo/js/index.js?ver=@clientVersion"></script>

View File

@@ -1,4 +1,5 @@
using _0_Framework.Application;
using _0_Framework.Excel.EmployeeBankInfo;
using CompanyManagment.App.Contracts.Bank;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
@@ -166,9 +167,13 @@ namespace ServiceHost.Areas.Client.Pages.Company.EmployeesBankInfo
public IActionResult OnPostEdit(EditEmployeeInformation command)
{
command.WorkshopId = _workshopId;
command.CardNumber = command.CardNumber.Replace("-", "");
command.ShebaNumber = command.ShebaNumber.Replace("-", "");
var result = _employeeBankInformationApplication.Edit(command);
if (!string.IsNullOrWhiteSpace(command.CardNumber))
command.CardNumber = command.CardNumber.Replace("-", "");
if (!string.IsNullOrWhiteSpace(command.ShebaNumber))
command.ShebaNumber = command.ShebaNumber.Replace("-", "");
var result = _employeeBankInformationApplication.Edit(command);
return new JsonResult(new
{
success = result.IsSuccedded,
@@ -210,5 +215,31 @@ namespace ServiceHost.Areas.Client.Pages.Company.EmployeesBankInfo
var contentType = Tools.GetContentTypeImage(Path.GetExtension(path));
return PhysicalFile(path, contentType);
}
public IActionResult OnGetDownloadExcelAll(string idList)
{
var ids = idList.ExtractNumbers();
var employeeBankInformationViewModelForExcels = _employeeBankInformationApplication.SearchForExcel(_workshopId,
new EmployeeBankInformationSearchModel() { EmployeeBankInfoIds = ids });
var resultViewModel = employeeBankInformationViewModelForExcels.Select(x=>new EmployeeBankInfoExcelViewModel
{
Name = x.EmployeeName,
BankAccounts = x.BankInformationList.Select(b=>new BankInfoExcelViewModel()
{
IsDefault = b.IsDefault,
ShebaNumber = b.ShebaNumber,
AccountNumber = b.BankAccountNumber,
BankName = b.BankName,
CardNumber = b.CardNumber
}).ToList()
}).ToList();
var bytes = EmployeeBankInfoExcelGenerator.Generate(resultViewModel);
return File(bytes,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
$"اطلاعات بانکی پرسنل.xlsx");
}
}
}

View File

@@ -193,7 +193,24 @@
/************************ Radio Button Input (Like Checkbox appearance) ************************/
.btn-excel {
border-radius: 7px;
padding: 3px 7px;
color: #000000;
background-color: #afffcc
}
.btn-excel span {
color: #1E293B;
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 24px;
}
.btn-excel:hover {
background-color: #a8ebc1;
}
@media (max-width: 1366px) {
.fineListModal-width {

View File

@@ -126,7 +126,7 @@ $(document).on('change', '#employeeSelectCreate', function () {
if (item.shebaNumber !== null) resultBankCount++;
html += `
<div class="Rtable-row align-items-center openAction load-create-row" id="Employees" data-employee-id="${response.data.employeeId}">
<div class="Rtable-row align-items-center openAction load-create-row" id="Employees" data-employee-id="${response.data.employeeId}" data-bank-id="${item.id}">
<div class="Rtable-cell width1 widthNumberCustom1">
<label for="${n}" class="Rtable-cell--content prevent-select">
<span class="d-flex justify-content-center align-items-center justify-content-center row-number">
@@ -145,24 +145,7 @@ $(document).on('change', '#employeeSelectCreate', function () {
</div>
<div class="Rtable-cell width5 text-end">
<div class="Rtable-cell--content align-items-center justify-content-end d-none text-end">
<button class="btn-edit position-relative d-md-block d-none disable">
<svg width="20" height="20" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.6027 6.838L5.85304 13.5876C5.84201 13.5987 5.83107 13.6096 5.8202 13.6204C5.65773 13.7825 5.5139 13.9261 5.41254 14.1051C5.31117 14.2841 5.2621 14.4813 5.20667 14.704C5.20296 14.7189 5.19923 14.7339 5.19545 14.7491L4.5813 17.2057C4.57908 17.2145 4.57686 17.2234 4.57462 17.2323C4.53537 17.389 4.49347 17.5564 4.47972 17.6969C4.46458 17.8516 4.46811 18.1127 4.67752 18.3221L5.03035 17.9693L4.67752 18.3221C4.88693 18.5315 5.14799 18.535 5.30272 18.5199C5.44326 18.5062 5.6106 18.4643 5.76728 18.425C5.77622 18.4228 5.78512 18.4205 5.79398 18.4183L8.25057 17.8042C8.26569 17.8004 8.28069 17.7967 8.29558 17.793C8.51832 17.7375 8.71549 17.6885 8.89452 17.5871C9.07356 17.4857 9.21708 17.3419 9.37921 17.1794C9.39005 17.1686 9.40097 17.1576 9.412 17.1466L16.1616 10.397L16.1849 10.3737C16.4983 10.0603 16.7684 9.79025 16.9556 9.54492C17.1562 9.282 17.3081 8.98958 17.3081 8.6292C17.3081 8.26759 17.1541 7.97384 16.9522 7.71001C16.7633 7.46303 16.4905 7.1903 16.1731 6.87292L16.1499 6.84972L16.1267 6.82652C15.8093 6.5091 15.5366 6.23634 15.2896 6.04738C15.0258 5.84553 14.732 5.69156 14.3704 5.69156C14.01 5.69156 13.7176 5.84345 13.4547 6.04405C13.2094 6.23123 12.9393 6.5013 12.6259 6.81474L12.6027 6.838Z" stroke-width="1.5" stroke="#4DA9D1" />
<path d="M11.9939 7.20397L14.8457 5.30273L17.6976 8.15459L15.7964 11.0064L11.9939 7.20397Z" fill="#4DA9D1" />
</svg>
<span class="mx-1">ویرایش</span>
</button>
<button onclick="alertRemoveBank(${item.id})" type="button" class="btn-none d-md-block d-none">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 22 22" fill="none" stroke="currentColor">
<path d="M8.70825 13.2915L8.70825 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M13.2917 13.2915L13.2917 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M2.75 5.9585H19.25V5.9585C18.122 5.9585 17.558 5.9585 17.1279 6.17946C16.7561 6.3704 16.4536 6.67297 16.2626 7.04469C16.0417 7.47488 16.0417 8.03886 16.0417 9.16683V13.8752C16.0417 15.7608 16.0417 16.7036 15.4559 17.2894C14.8701 17.8752 13.9273 17.8752 12.0417 17.8752H9.95833C8.07271 17.8752 7.12991 17.8752 6.54412 17.2894C5.95833 16.7036 5.95833 15.7608 5.95833 13.8752V9.16683C5.95833 8.03886 5.95833 7.47488 5.73737 7.04469C5.54643 6.67297 5.24386 6.3704 4.87214 6.17946C4.44195 5.9585 3.87797 5.9585 2.75 5.9585V5.9585Z" stroke-width="1.5" stroke-linecap="round" />
<path d="M8.70841 3.20839C8.70841 3.20839 9.16675 2.2915 11.0001 2.2915C12.8334 2.2915 13.2917 3.20817 13.2917 3.20817" stroke-width="1.5" stroke-linecap="round" />
</svg>
<span class="mx-1">حذف</span>
</button>
</div>
</div>
</div>`;
@@ -464,8 +447,8 @@ function removeBank(id) {
$('.alert-success-msg').hide();
$('.alert-success-msg p').text('');
}, 2000);
$(`[data-employee-id="${id}"]`).remove();
$(`[data-bank-id="${id}"]`).remove();
updateRows();
$('#EmployeeBankListAjax').html('');
loadEmployeeBankList();
@@ -527,14 +510,12 @@ function removeRecordAfterAddNewItem(id) {
function editNewItem(newId) {
$('#addNewItemBtn').hide();
$('#editNewItemBtn').show();
$('#editNewItemBtn').show().attr('onclick', `saveEditNewItem(${newId})`);
$('#createData').addClass("disable");
let employeeBankInfo = command.find(employee => employee.newItemId === newId);
$('#editNewItemBtn').attr('onclick', 'saveEditNewItem(' + newId + ')');
$('#bankSelectCreate').val(employeeBankInfo.BankId).trigger('change');
$('#CardNumber').val(employeeBankInfo.CardNumber);
$('#ShebaNumber').val(employeeBankInfo.ShebaNumber);
@@ -543,13 +524,13 @@ function editNewItem(newId) {
$('#CardNumber').mask("0000-0000-0000-0000", {
placeholder: "XXXX-XXXX-XXXX-XXXX"
});
$('#CardNumber').val(cardNumber).keyup();
$('#CardNumber').val(employeeBankInfo.CardNumber).keyup();
$('#ShebaNumber').mask("IR-00-0000-0000-0000-0000-0000-00", {
placeholder: "IR-XX-XXXX-XXXX-XXXX-XXXX-XXXX-XX"
});
$('#ShebaNumber').val(shebaNumber).keyup();
$('#ShebaNumber').val(employeeBankInfo.ShebaNumber).keyup();
}
function saveEditNewItem(newId) {
@@ -675,7 +656,7 @@ function saveEditNewItem(newId) {
}
function updateRows() {
$('.load-create-row.width1').each(function (index) {
$(this).find('span.row-number').text(index + 1);
$('.load-create-row .width1').each(function (index) {
$(this).find('label span.row-number').text(index + 1);
});
}

View File

@@ -1,4 +1,21 @@
var searchName = '';
$(document).ready(function () {
let $checkAll = $("#checkAll2");
let $checkboxes = $(".foo");
$checkAll.on("change", function () {
$checkboxes.prop("checked", this.checked);
});
$checkboxes.on("change", function () {
let allChecked = $checkboxes.length === $checkboxes.filter(":checked").length;
let someChecked = $checkboxes.filter(":checked").length > 0;
$checkAll.prop("checked", allChecked);
$checkAll.prop("indeterminate", !allChecked && someChecked);
});
});
var searchName = '';
var searchBank = '';
$(document).ready(function () {
@@ -142,10 +159,11 @@ function loadEmployeeBankList() {
}" id="Employees">
<div class="Rtable-cell width1 widthNumberCustom1">
<label for="${index}" class="Rtable-cell--content prevent-select">
<span class="d-flex justify-content-center align-items-center justify-content-center">
<input id="${index
}" type="checkbox" class="d-none form-check-input foo" name="foo" value="${item.Id}">
${index}
<span class="d-flex justify-content-between align-items-center" style="width: 45px">
<input id="${index}" type="checkbox" class="form-check-input foo" name="foo" value="${item.Id}">
<div class="row-number">
${index}
</div>
</span>
</label>
</div>
@@ -375,4 +393,43 @@ function removeByEmployeeId(id) {
console.log(err);
}
});
}
function downloadExcelAll() {
if (!($('.foo:checkbox').is(":checked"))) {
$('.alert-msg').show();
$('.alert-msg p').text('هیچ موردی انتخاب نشده است.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
return;
}
var idlist = "";
$('.foo').each(function () {
if ($(this).is(":checked")) {
var a = $(this).val();
var b = a + "+";
idlist += b;
}
});
var filterArray = [];
$("input[name='filter[]']:checked").each(function () {
filterArray.push($(this).val());
});
if (idlist !== "") {
//var url = CheckoutExcelAllUrl + "&idList=" + idlist;
var url = CheckoutExcelAllUrl + "&idList=" + encodeURIComponent(idlist);
filterArray.forEach(function (filter) {
url += "&filter=" + encodeURIComponent(filter);
});
window.open(url, "_blank");
}
}