fix employee documet and send to checker button on workflow admin
This commit is contained in:
@@ -53,6 +53,12 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
|
||||
Task<int> GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
OperationResult RemoveByAdmin(long documentItemId);
|
||||
Task<int> GetCheckerWorkFlowCount();
|
||||
|
||||
/// <summary>
|
||||
/// برای افزودن یکباره مدارک در افزودن پرسنل توسط ادمین
|
||||
/// </summary>
|
||||
OperationResult AddRangeEmployeeDocumentItemsByAdmin(long workshopId, long employeeId,
|
||||
List<AddEmployeeDocumentItem> command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1386,6 +1386,81 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
return await _employeeDocumentsRepository.GetCheckerWorkFlowCount();
|
||||
}
|
||||
|
||||
public OperationResult AddRangeEmployeeDocumentItemsByAdmin(long workshopId, long employeeId, List<AddEmployeeDocumentItem> command)
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
|
||||
return op.Failed("پرسنل یافت نشد");
|
||||
|
||||
|
||||
if (!_workshopRepository.Exists(x => x.id == workshopId))
|
||||
return op.Failed("کارگاه وجود ندارد");
|
||||
|
||||
|
||||
var entity =
|
||||
_employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId);
|
||||
|
||||
|
||||
|
||||
using var scope = new TransactionScope();
|
||||
|
||||
|
||||
//if record doesn't exist but employee exists and also the workshop, create a new record
|
||||
if (entity == null)
|
||||
{
|
||||
var opCreate = Create(new CreateEmployeeDocuments()
|
||||
{ EmployeeId = employeeId, WorkshopId = workshopId });
|
||||
if (opCreate.IsSuccedded == false) return opCreate;
|
||||
entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopId(employeeId, workshopId);
|
||||
}
|
||||
|
||||
List<EmployeeDocumentItem> newEntities = new();
|
||||
foreach (var item in command)
|
||||
{
|
||||
DeleteMultipleUnsubmittedDocumentsByLabel(entity, item.Label, uploaderType);
|
||||
|
||||
var mediaOpResult = UploadDocumentItemFile(item.PictureFile, item.Label.ToString(),
|
||||
$"temp/{workshopId}/{employeeId}");
|
||||
|
||||
if (mediaOpResult.IsSuccedded == false)
|
||||
return mediaOpResult;
|
||||
|
||||
|
||||
//if the mediaId is already in use in our table return failed
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType, DocumentStatus.SubmittedByAdmin);
|
||||
newEntities.Add(newEntity);
|
||||
}
|
||||
|
||||
var currentItems = entity.EmployeeDocumentItemCollection.GroupBy(x => x.DocumentLabel)
|
||||
.Where(x => command.Any(a => a.Label == x.Key))
|
||||
.Select(x => x.MaxBy(y => y.CreationDate));
|
||||
|
||||
//This can bite!
|
||||
_employeeDocumentItemRepository.RemoveRange(currentItems);
|
||||
_employeeDocumentItemRepository.SaveChanges();
|
||||
|
||||
_employeeDocumentItemRepository.AddRange(newEntities);
|
||||
_employeeDocumentItemRepository.SaveChanges();
|
||||
|
||||
SubmitDocumentItemsByEmployeeIdWorkshopId(employeeId, workshopId);
|
||||
|
||||
entity.UpdateIsConfirmed();
|
||||
entity.UpdateIsSentToChecker();
|
||||
_employeeDocumentsRepository.SaveChanges();
|
||||
|
||||
scope.Complete();
|
||||
return op.Succcedded(entity.id);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
private readonly IAuthHelper _authHelper;
|
||||
public int EmployeeDocumentsAwaitingSubmitCount;
|
||||
|
||||
public EmployeesDocumentsModel(IAdminWorkFlowApplication adminWorkFlowApplication, IWorkshopApplication workshopApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IWorkshopAccountRepository workshopAccountRepository, IAuthHelper authHelper)
|
||||
public EmployeesDocumentsModel(IAdminWorkFlowApplication adminWorkFlowApplication, IWorkshopApplication workshopApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IWorkshopAccountRepository workshopAccountRepository, IAuthHelper authHelper)
|
||||
{
|
||||
_adminWorkFlowApplication = adminWorkFlowApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
@@ -148,5 +148,15 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostGroupSave(long workshopId, long employeeId, List<AddEmployeeDocumentItem> command)
|
||||
{
|
||||
var result = _employeeDocumentsApplication.AddRangeEmployeeDocumentItemsByAdmin(workshopId, employeeId, command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div>
|
||||
|
||||
<form class="row mt-3" role="form" method="post" name="create-employee-form" id="create-employee-form" autocomplete="off">
|
||||
<div class="col-6 position-relative details">
|
||||
<div class="col-6 position-relative details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm ">
|
||||
جنسیت
|
||||
@@ -48,7 +48,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 position-relative details">
|
||||
<div class="col-6 position-relative details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
ملیت
|
||||
@@ -70,7 +70,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
نام
|
||||
@@ -78,7 +78,7 @@
|
||||
<input type="text" class="form-control" name="Command.FName" id="FName" value="@Model.FName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
نام خانوادگی
|
||||
@@ -86,7 +86,7 @@
|
||||
<input type="text" class="form-control" name="Command.LName" id="LName" value="@Model.LName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
کد ملی
|
||||
@@ -94,7 +94,7 @@
|
||||
<input type="text" class="form-control" name="Command.NationalCode" id="NationalCode" value="@Model.NationalCode" style="direction: ltr;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
شماره شناسنامه
|
||||
@@ -102,7 +102,7 @@
|
||||
<input type="text" class="form-control" name="Command.IdNumber" id="IdNumber" value="@Model.IdNumber" style="direction: ltr;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
نام پدر
|
||||
@@ -110,7 +110,7 @@
|
||||
<input type="text" class="form-control" name="Command.FatherName" id="FatherName" value="@Model.FatherName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 details">
|
||||
<div class="col-6 details @(Model.IsAuthorized ? "disable" : "")">
|
||||
<div class="form-group d-flex p-0">
|
||||
<label class="titleForm">
|
||||
تاریخ تولد
|
||||
@@ -146,6 +146,7 @@
|
||||
نظام وظیفه
|
||||
</label>
|
||||
<select class="form-select form-select-sm" id="militaryStatus" asp-for="@Model.MilitaryService">
|
||||
<option value="">انتخاب ...</option>
|
||||
<option value="مشمول">مشمول</option>
|
||||
<option value="پایان خدمت">پایان خدمت</option>
|
||||
<option value="معاف">معاف</option>
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="pdBoxGrid">
|
||||
<div class="pdBox">
|
||||
@@ -78,7 +81,7 @@
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="0">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="0">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.EmployeePicture.PicturePath) ? Model.EmployeePicture.Status.ToString() : "") @(string.IsNullOrWhiteSpace(Model.EmployeePicture.PicturePath) ? "disable" : "")" data-index="0">حذف</button>
|
||||
</div>
|
||||
@@ -130,9 +133,9 @@
|
||||
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="1">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="1">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.NationalCardFront.PicturePath) ? Model.NationalCardFront.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.NationalCardFront?.PicturePath) ? "" : "disable")" data-index="1">حذف</button>
|
||||
</div>
|
||||
@@ -183,8 +186,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="2">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="2">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.NationalCardRear.PicturePath) ? Model.NationalCardRear.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.NationalCardRear.PicturePath) ? "" : "disable")" data-index="2">حذف</button>
|
||||
</div>
|
||||
@@ -193,7 +196,7 @@
|
||||
<span class="text-white percentageText"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pdBox @(Model.Gender == "زن" ? "disable" : "") ">
|
||||
<div class="pdBox militaryService @(Model.Gender == "زن" ? "disable" : "") ">
|
||||
<div class="d-flex align-items-center justify-content-start w90">
|
||||
<div class="pdImageBox">
|
||||
@if (!string.IsNullOrWhiteSpace(Model.MilitaryServiceCard.PicturePath))
|
||||
@@ -235,8 +238,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="3">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="3">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(Model.Gender == "مرد" && !string.IsNullOrWhiteSpace(Model.MilitaryServiceCard.PicturePath)? Model.MilitaryServiceCard.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.MilitaryServiceCard.PicturePath) ? "" : "disable")" data-index="3">حذف</button>
|
||||
</div>
|
||||
@@ -288,8 +291,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="4">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="4">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.IdCardPage1.PicturePath) ? Model.IdCardPage1.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.IdCardPage1.PicturePath) ? "" : "disable")" data-index="4">حذف</button>
|
||||
</div>
|
||||
@@ -341,8 +344,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="5">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="5">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.IdCardPage2.PicturePath) ? Model.IdCardPage2.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.IdCardPage2.PicturePath) ? "" : "disable")" data-index="5">حذف</button>
|
||||
</div>
|
||||
@@ -393,8 +396,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="6">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="6">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.IdCardPage3.PicturePath) ? Model.IdCardPage3.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.IdCardPage3.PicturePath) ? "" : "disable")" data-index="6">حذف</button>
|
||||
</div>
|
||||
@@ -445,8 +448,8 @@
|
||||
<div>
|
||||
<button type="button" class="btnUploadingPD d-block mb-1" data-index="7">آپلود عکس</button>
|
||||
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EmployeeModal")')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable">ارسال به ناظر</button>
|
||||
<button type="button" class="btnEditEmployee d-block mb-1 disable" onclick="LoadCustomPartial('@Url.Page("./EmployeesDocuments", "EditEmployeeModal", new { employeeId = Model.EmployeeId, workshopId = Model.WorkshopId})')">ویرایش پرسنل</button>
|
||||
<button type="button" class="btnSendToChecker d-block mb-1 disable" data-index="7">ارسال به ناظر</button>
|
||||
|
||||
<button type="button" class="btnDeletingPD d-block @(!string.IsNullOrWhiteSpace(Model.IdCardPage4.PicturePath) ? Model.IdCardPage4.Status.ToString():"") @(!string.IsNullOrWhiteSpace(Model.IdCardPage4.PicturePath) ? "" : "disable")" data-index="7">حذف</button>
|
||||
</div>
|
||||
@@ -494,6 +497,8 @@
|
||||
<script>
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = '/assetsclient/libs/pdf/pdf.worker.js';
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveGroupSubmitAjax = `@Url.Page("./EmployeesDocuments", "GroupSave")`;
|
||||
|
||||
var saveUploadFileModalAjax = `@Url.Page("./EmployeesDocuments", "CreateUploadDocument")`;
|
||||
var saveSubmitAjax = `@Url.Page("./EmployeesDocuments", "SaveSubmit")`;
|
||||
var deleteFileAjaxUrl = `@Url.Page("./EmployeesDocuments", "RemoveEmployeeDocumentByLabel")`;
|
||||
@@ -501,5 +506,7 @@
|
||||
var employeeId = Number(@Model.EmployeeId);
|
||||
var workshopId = Number(@Model.WorkshopId);
|
||||
var UploadedCount = Number(@Model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(EmployeeDocumentItemViewModel)).Select(y => y.GetValue(@Model) as EmployeeDocumentItemViewModel).Count(x=>x.Status == DocumentStatus.Unsubmitted && !string.IsNullOrWhiteSpace(x.PicturePath)));
|
||||
|
||||
var hasGenderFemale = @(Model.Gender == "زن" ? "true" : "false");
|
||||
</script>
|
||||
<script src="~/assetsadminnew/workflow/js/modaluploaddocument.js?ver=@adminVersion"></script>
|
||||
@@ -243,4 +243,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="~/assetsclient/libs/pdf/pdf.js"></script>
|
||||
<script>
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = '/assetsclient/libs/pdf/pdf.worker.js';
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/employees/js/ModalUploadDocument.js?ver=@clientVersion"></script>
|
||||
|
||||
@@ -126,7 +126,7 @@ async function loadWorkshopsWithDocumentsAwaitingUpload() {
|
||||
data.forEach(function (item) {
|
||||
html += `
|
||||
<div id="Main_${item.workshopId}" class="Rtable-row Rtable-row--head align-items-center d-flex sticky openActionMain" onclick="loadByWorkshopIdWithItemsForAdminWorkFlow('${item.workshopId}')" style="background: #58B3B3;border: none !important; cursor: pointer; ">
|
||||
<div class="col-2 col-md-4 text-start">
|
||||
<div class="col-2 col-md-2 text-start">
|
||||
<div class="Rtable-cell width1">
|
||||
<div class="Rtable-cell--content">
|
||||
<span class="d-flex justify-content-center align-items-center justify-content-center table-number" style="background: #deffff;margin: 0 10px 0 0;">
|
||||
@@ -135,24 +135,24 @@ async function loadWorkshopsWithDocumentsAwaitingUpload() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8 col-md-4 text-center d-flex">
|
||||
<div class="col-4 text-center">
|
||||
<div class="col-8 col-md-8 text-center d-flex">
|
||||
<div class="col-5 text-center">
|
||||
<div class="Rtable-cell column-heading text-end">
|
||||
<span>${item.workshopName}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 text-start">
|
||||
<div class="col-5 text-start">
|
||||
<div class="Rtable-cell column-heading text-center justify-content-center">
|
||||
<span>${item.employerName}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 text-center">
|
||||
<div class="col-1 text-center">
|
||||
<div class="Rtable-cell column-heading text-center justify-content-center">
|
||||
<span id="EmployeeCountOfWorkshop_${item.workshopId}" class="number-of-count">${item.uploadItemsCount}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2 col-md-4 text-end">
|
||||
<div class="col-2 col-md-2 text-end">
|
||||
<span class="toggle">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15 18L9 12L15 6" stroke-width="2" stroke-linecap="round" />
|
||||
|
||||
@@ -7,28 +7,18 @@ var idCardPage2;
|
||||
var idCardPage3;
|
||||
var idCardPage4;
|
||||
var uploadFileCount = UploadedCount;
|
||||
var command = [];
|
||||
|
||||
var pendingMessage = `<div class="pendingMessage">بررسی</div>`;
|
||||
var pendingIcon = `<svg width="24" height="24" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11 19.25C15.5563 19.25 19.25 15.5563 19.25 11C19.25 6.44365 15.5563 2.75 11 2.75C6.44365 2.75 2.75 6.44365 2.75 11C2.75 15.5563 6.44365 19.25 11 19.25Z" fill="#FDBA74"/>
|
||||
<path d="M11.4168 14.6667C11.4168 14.8968 11.2303 15.0833 11.0002 15.0833C10.77 15.0833 10.5835 14.8968 10.5835 14.6667C10.5835 14.4365 10.77 14.25 11.0002 14.25C11.2303 14.25 11.4168 14.4365 11.4168 14.6667Z" fill="white" stroke="white"/>
|
||||
<path d="M11 11.916V6.41602V11.916Z" fill="white"/>
|
||||
<path d="M11 11.916V6.41602" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>`;
|
||||
var pendingIcon = `<svg width="24" height="24" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11 19.25C15.5563 19.25 19.25 15.5563 19.25 11C19.25 6.44365 15.5563 2.75 11 2.75C6.44365 2.75 2.75 6.44365 2.75 11C2.75 15.5563 6.44365 19.25 11 19.25Z" fill="#FDBA74"/><path d="M11.4168 14.6667C11.4168 14.8968 11.2303 15.0833 11.0002 15.0833C10.77 15.0833 10.5835 14.8968 10.5835 14.6667C10.5835 14.4365 10.77 14.25 11.0002 14.25C11.2303 14.25 11.4168 14.4365 11.4168 14.6667Z" fill="white" stroke="white"/><path d="M11 11.916V6.41602V11.916Z" fill="white"/><path d="M11 11.916V6.41602" stroke="white" stroke-width="1.5" stroke-linecap="round"/></svg>`;
|
||||
var confirmMessage = `<div class="confirmedMessage">تایید</div>`;
|
||||
var confirmIcon = `<svg width="24" height="24" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7" cy="7" r="5.25" fill="#00C04D"/>
|
||||
<path d="M4.66659 7L6.41659 8.75L9.33325 5.25" stroke="white" stroke-linecap="round"/>
|
||||
</svg>`;
|
||||
var confirmIcon = `<svg width="24" height="24" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="7" cy="7" r="5.25" fill="#00C04D"/><path d="M4.66659 7L6.41659 8.75L9.33325 5.25" stroke="white" stroke-linecap="round"/></svg>`;
|
||||
var rejectMessage = `<div class="rejectMessage">رد شده</div>`;
|
||||
var rejectIcon = `<svg width="24" height="24" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7" cy="7" r="5.25" fill="#FF5D5D"/>
|
||||
<path d="M9.33341 4.66602L4.66675 9.33268" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.66659 4.66602L9.33325 9.33268" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>`;
|
||||
var rejectIcon = `<svg width="24" height="24" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="7" cy="7" r="5.25" fill="#FF5D5D"/><path d="M9.33341 4.66602L4.66675 9.33268" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M4.66659 4.66602L9.33325 9.33268" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var employeeId = $("#employeeIdForList").val();
|
||||
|
||||
//$('.btnDeletingPD').each(function () {
|
||||
@@ -37,7 +27,6 @@ $(document).ready(function () {
|
||||
// }
|
||||
//});
|
||||
|
||||
|
||||
$(".btnDeletingPD ").each(function () {
|
||||
if ($(this).hasClass("SubmittedByAdmin") || $(this).hasClass("Rejected") || $(this).hasClass("Confirmed")) {
|
||||
$(this).addClass("disable");
|
||||
@@ -83,6 +72,80 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
//$(document).off('change', '.file-input').on('change', '.file-input', function (e) {
|
||||
// e.preventDefault();
|
||||
|
||||
// const fileInputFile = this.files[0];
|
||||
// const indexFileValue = $(this).data('index');
|
||||
// const validExtensions = ['jpg', 'jpeg', 'png'];
|
||||
// const validPdfExtensions = ['pdf'];
|
||||
|
||||
// const label = $(`#label_${indexFileValue}`).val();
|
||||
|
||||
// if (fileInputFile) {
|
||||
// const fileName = fileInputFile.name.toLowerCase();
|
||||
// const extension = fileName.split('.').pop();
|
||||
|
||||
// if (validExtensions.includes(extension)) {
|
||||
// if (fileInputFile.size > 5000000) {
|
||||
// showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 5 مگابایت را آپلود کنید.', 3500);
|
||||
// $(this).val('');
|
||||
// return;
|
||||
// }
|
||||
// uploadFile(fileInputFile, indexFileValue, label);
|
||||
// } else if (validPdfExtensions.includes(extension)) {
|
||||
|
||||
// var fileReader = new FileReader();
|
||||
|
||||
// fileReader.onload = function () {
|
||||
// var typedarray = new Uint8Array(this.result);
|
||||
// pdfjsLib.getDocument(typedarray).promise.then(function (pdf) {
|
||||
// totalPageCount = pdf.numPages;
|
||||
|
||||
// if (totalPageCount > 1) {
|
||||
// showAlertMessage('.alert-msg', 'آپلود مجاز نیست! تعداد صفحات نباید بیشتر از ۱ باشد.', 3500);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// pdf.getPage(1).then(function (page) { // فقط صفحه اول پردازش میشود
|
||||
// var scale = 2.0;
|
||||
// var viewport = page.getViewport({ scale: scale });
|
||||
|
||||
// var canvas = document.createElement("canvas");
|
||||
// canvas.className = "page";
|
||||
// canvas.title = "Page 1";
|
||||
// canvas.height = viewport.height;
|
||||
// canvas.width = viewport.width;
|
||||
|
||||
// var context = canvas.getContext("2d");
|
||||
|
||||
// page.render({
|
||||
// canvasContext: context,
|
||||
// viewport: viewport
|
||||
// })
|
||||
// .promise.then(function () {
|
||||
// uploadCanvasAsFile(canvas, `${label}_${indexFileValue}.jpg`, indexFileValue, label);
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// showAlertMessage('.alert-msg', 'مشکلی در پردازش PDF رخ داده است!', 3500);
|
||||
// });
|
||||
// }).catch(function (error) {
|
||||
// showAlertMessage('.alert-msg', 'خطا در دریافت صفحه PDF!', 3500);
|
||||
// });
|
||||
|
||||
// }).catch(function (error) {
|
||||
// showAlertMessage('.alert-msg', 'خطا در بارگذاری فایل PDF!', 3500);
|
||||
// });
|
||||
// };
|
||||
|
||||
// fileReader.readAsArrayBuffer(fileInputFile);
|
||||
|
||||
// } else {
|
||||
// showAlertMessage('.alert-msg', 'فرمت فایل باید یکی از موارد jpeg, jpg یا png باشد.', 3500);
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
$(document).off('change', '.file-input').on('change', '.file-input', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -92,20 +155,58 @@ $(document).ready(function () {
|
||||
const validPdfExtensions = ['pdf'];
|
||||
|
||||
const label = $(`#label_${indexFileValue}`).val();
|
||||
const pdBox = $(this).closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
var deleteButton = pdBox.find('.btnDeletingPD');
|
||||
deleteButton.removeClass('disable');
|
||||
|
||||
if (fileInputFile) {
|
||||
const fileName = fileInputFile.name.toLowerCase();
|
||||
const extension = fileName.split('.').pop();
|
||||
|
||||
// بررسی فرمتهای تصویر (jpeg, jpg, png)
|
||||
if (validExtensions.includes(extension)) {
|
||||
if (fileInputFile.size > 5000000) {
|
||||
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 5 مگابایت را آپلود کنید.', 3500);
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
uploadFile(fileInputFile, indexFileValue, label);
|
||||
} else if (validPdfExtensions.includes(extension)) {
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
img.attr('src', event.target.result);
|
||||
|
||||
const base64String = event.target.result.split(',')[1];
|
||||
const byteCharacters = atob(base64String);
|
||||
const byteNumbers = new Array(byteCharacters.length);
|
||||
for (let i = 0; i < byteCharacters.length; i++) {
|
||||
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
||||
}
|
||||
const byteArray = new Uint8Array(byteNumbers);
|
||||
const blob = new Blob([byteArray], { type: fileInputFile.type });
|
||||
const newFile = new File([blob], fileInputFile.name, { type: fileInputFile.type });
|
||||
|
||||
let existingIndex = command.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
command[existingIndex].PictureFile = newFile;
|
||||
} else {
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: newFile
|
||||
};
|
||||
command.push(picturesPart);
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(fileInputFile);
|
||||
$('#createUploadingFiles').prop('disabled', false).removeClass('disable');
|
||||
|
||||
pdBox.removeClass();
|
||||
pdBox.addClass('pdBox');
|
||||
|
||||
showLoadingAnimation(indexFileValue);
|
||||
}
|
||||
else if (validPdfExtensions.includes(extension)) {
|
||||
var fileReader = new FileReader();
|
||||
|
||||
fileReader.onload = function () {
|
||||
@@ -118,7 +219,7 @@ $(document).ready(function () {
|
||||
return;
|
||||
}
|
||||
|
||||
pdf.getPage(1).then(function (page) { // فقط صفحه اول پردازش میشود
|
||||
pdf.getPage(1).then(function (page) {
|
||||
var scale = 2.0;
|
||||
var viewport = page.getViewport({ scale: scale });
|
||||
|
||||
@@ -133,13 +234,13 @@ $(document).ready(function () {
|
||||
page.render({
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
})
|
||||
.promise.then(function () {
|
||||
uploadCanvasAsFile(canvas, `${label}_${indexFileValue}.jpg`, indexFileValue, label);
|
||||
})
|
||||
.catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'مشکلی در پردازش PDF رخ داده است!', 3500);
|
||||
});
|
||||
}).promise.then(function () {
|
||||
pdBox.removeClass();
|
||||
pdBox.addClass('pdBox');
|
||||
uploadCanvasAsFile(canvas, `${label}_${indexFileValue}.jpg`, indexFileValue, label);
|
||||
}).catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'مشکلی در پردازش PDF رخ داده است!', 3500);
|
||||
});
|
||||
}).catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'خطا در دریافت صفحه PDF!', 3500);
|
||||
});
|
||||
@@ -151,19 +252,49 @@ $(document).ready(function () {
|
||||
|
||||
fileReader.readAsArrayBuffer(fileInputFile);
|
||||
|
||||
} else {
|
||||
showAlertMessage('.alert-msg', 'فرمت فایل باید یکی از موارد jpeg, jpg یا png باشد.', 3500);
|
||||
}
|
||||
else {
|
||||
showAlertMessage('.alert-msg', 'فرمت فایل باید یکی از موارد jpeg, jpg, png یا pdf باشد.', 3500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//$(document).off('click', '.btnDeletingPD').on('click', '.btnDeletingPD', function (event) {
|
||||
// event.preventDefault();
|
||||
// const indexId = $(this).data('index');
|
||||
|
||||
// swal.fire({
|
||||
// title: "اخطار",
|
||||
// text: "آیا میخواهید تصویر موجود را حذف کنید؟",
|
||||
// icon: "warning",
|
||||
// showCancelButton: true,
|
||||
// confirmButtonText: "بله",
|
||||
// cancelButtonText: "خیر",
|
||||
// confirmButtonColor: '#84cc16',
|
||||
// reverseButtons: true
|
||||
// }).then((result) => {
|
||||
// if (result.isConfirmed) {
|
||||
// removeEmployeeDocumentByLabel(indexId, employeeId);
|
||||
// const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
// const img = pdBox.find('.preview-image');
|
||||
// img.attr('src', '/assetsclient/images/pd-image.png');
|
||||
// $(this).addClass('disable');
|
||||
// } else {
|
||||
// $(this).removeClass('disable');
|
||||
// }
|
||||
// });
|
||||
|
||||
//});
|
||||
|
||||
$(document).off('click', '.btnDeletingPD').on('click', '.btnDeletingPD', function (event) {
|
||||
event.preventDefault();
|
||||
const indexId = $(this).data('index');
|
||||
const label = $(`#label_${indexId}`).val();
|
||||
|
||||
swal.fire({
|
||||
title: "اخطار",
|
||||
text: "آیا میخواهید تصویر موجود را حذف کنید؟",
|
||||
text: "آیا میخواهید عکس را حذف کنید؟",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "بله",
|
||||
@@ -172,21 +303,31 @@ $(document).ready(function () {
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
removeEmployeeDocumentByLabel(indexId, employeeId);
|
||||
const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
img.attr('src', '/assetsclient/images/pd-image.png');
|
||||
$(this).addClass('disable');
|
||||
} else {
|
||||
$(this).removeClass('disable');
|
||||
removeCommand(label);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).off('click', '.btnSendToChecker').on('click', '.btnSendToChecker', function(event) {
|
||||
$(document).off('click', '.btnSendToChecker').on('click', '.btnSendToChecker', function (event) {
|
||||
uploadFileCount = uploadFileCount + 1;
|
||||
event.preventDefault();
|
||||
|
||||
const indexFileValue = $(this).data('index');
|
||||
const label = $(`#label_${indexFileValue}`).val();
|
||||
const pdBox = $(this).closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
const imageSrc = img.attr('src');
|
||||
const $button = $(this);
|
||||
|
||||
if (!imageSrc) {
|
||||
swal.fire("خطا", "تصویری برای ارسال وجود ندارد", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
swal.fire({
|
||||
title: "اخطار",
|
||||
text: "آیا میخواهید این مورد را به ناظر ارسال کنید؟",
|
||||
@@ -198,10 +339,42 @@ $(document).ready(function () {
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
sendToCheckerAjax();
|
||||
$(this).addClass('disable');
|
||||
fetch(imageSrc)
|
||||
.then(res => res.blob())
|
||||
.then(blob => {
|
||||
|
||||
const fileName = `image_${indexFileValue || Date.now()}.png`;
|
||||
const newFile = new File([blob], fileName, { type: blob.type });
|
||||
|
||||
const picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: newFile
|
||||
};
|
||||
|
||||
const existingIndex = command.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
command[existingIndex] = picturesPart;
|
||||
} else {
|
||||
command.push(picturesPart);
|
||||
}
|
||||
|
||||
$button.addClass('disable');
|
||||
|
||||
pdBox.addClass('pending');
|
||||
pdBox.find(".pdImageBox .sign").removeClass().addClass("sign").addClass('pendingSign').html(pendingIcon);
|
||||
pdBox.find(".btnUploadingPD").addClass("disable");
|
||||
pdBox.find(".btnEditEmployee").addClass("disable");
|
||||
pdBox.find(".resultMessage").html(pendingMessage);
|
||||
|
||||
$('#createUploadingFiles').prop('disabled', false).removeClass('disable');
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("خطا در خواندن تصویر:", err);
|
||||
swal.fire("خطا", "خواندن فایل تصویر ناموفق بود", "error");
|
||||
});
|
||||
} else {
|
||||
$(this).removeClass('disable');
|
||||
$button.removeClass('disable');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -210,7 +383,7 @@ $(document).ready(function () {
|
||||
if (uploadFileCount > 0) {
|
||||
swal.fire({
|
||||
title: "اخطار",
|
||||
text: "در صورت انصراف عملیات ثبت نخواهد شد!",
|
||||
text: "در صورت انصراف، عملیات ثبت نخواهد شد. آیا از انصراف خود اطمینان دارید؟",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "بله",
|
||||
@@ -228,6 +401,16 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
function removeCommand(label) {
|
||||
uploadFileCount = uploadFileCount - 1;
|
||||
//command = command.filter(image => image.Label.toLowerCase() !== label.toLowerCase());
|
||||
command = command.filter(image => image.Label !== label);
|
||||
|
||||
if (command.length === 0) {
|
||||
$('#createUploadingFiles').prop('disabled', true).addClass('disable');
|
||||
}
|
||||
}
|
||||
|
||||
function cancelOperation() {
|
||||
$.ajax({
|
||||
url: cancelOperationUrl,
|
||||
@@ -249,138 +432,177 @@ function cancelOperation() {
|
||||
|
||||
var indexCount = 0;
|
||||
var activeUploads = 0;
|
||||
function uploadFile(file, indexId, label) {
|
||||
const formData = new FormData();
|
||||
formData.append('command.EmployeeId', employeeId);
|
||||
formData.append('command.WorkshopId', workshopId);
|
||||
formData.append('command.Label', label);
|
||||
formData.append('command.PictureFile', file);
|
||||
function showLoadingAnimation(indexId) {
|
||||
uploadFileCount = uploadFileCount + 1;
|
||||
|
||||
const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
const spinner = pdBox.find('.spinner-loading-progress');
|
||||
//const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
//const spinner = pdBox.find('.spinner-loading-progress');
|
||||
//const percentageText = pdBox.find('.percentageText');
|
||||
|
||||
//spinner.show();
|
||||
//activeUploads++;
|
||||
//$('#createUploadingFiles').prop('disabled', true).addClass('disable');
|
||||
|
||||
//let simulatedProgress = 0;
|
||||
//const progressInterval = setInterval(function () {
|
||||
// if (simulatedProgress < 100) {
|
||||
// simulatedProgress += 2;
|
||||
// spinner.css('width', `${simulatedProgress}%`);
|
||||
// percentageText.text(`${simulatedProgress}%`);
|
||||
// }
|
||||
|
||||
const percentageText = pdBox.find('.percentageText');
|
||||
// if (simulatedProgress >= 100) {
|
||||
// clearInterval(progressInterval);
|
||||
// }
|
||||
//}, 30);
|
||||
|
||||
spinner.show();
|
||||
activeUploads++;
|
||||
$('#createUploadingFiles').prop('disabled', true).addClass('disable');
|
||||
//setTimeout(function () {
|
||||
// clearInterval(progressInterval);
|
||||
// spinner.css('width', '100%');
|
||||
// percentageText.text('100%');
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', saveUploadFileModalAjax, true);
|
||||
xhr.setRequestHeader('RequestVerificationToken', antiForgeryToken);
|
||||
|
||||
const uploadStartTime = new Date().getTime();
|
||||
let simulatedProgress = 0;
|
||||
let actualProgress = 0;
|
||||
let isUploadComplete = false;
|
||||
|
||||
// Simulate progress every 20ms, gradually increasing the bar until the actual progress is reached
|
||||
const progressInterval = setInterval(function () {
|
||||
if (simulatedProgress < actualProgress && !isUploadComplete) {
|
||||
simulatedProgress += 1; // Gradually increase simulated progress
|
||||
spinner.css('width', `${simulatedProgress}%`);
|
||||
percentageText.text(`${simulatedProgress}%`);
|
||||
}
|
||||
|
||||
if (simulatedProgress >= 100) {
|
||||
clearInterval(progressInterval); // Stop once the progress hits 100%
|
||||
}
|
||||
}, 30); // Increases by 1% every 20ms, making it smooth
|
||||
|
||||
// Actual upload progress listener
|
||||
xhr.upload.addEventListener('progress', function (e) {
|
||||
if (e.lengthComputable) {
|
||||
actualProgress = Math.round((e.loaded / e.total) * 100);
|
||||
|
||||
// If the actual progress is slow, allow the simulated progress to match it naturally
|
||||
if (actualProgress >= simulatedProgress) {
|
||||
simulatedProgress = actualProgress;
|
||||
spinner.css('width', `${simulatedProgress}%`);
|
||||
percentageText.text(`${simulatedProgress}%`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// On upload completion
|
||||
xhr.onload = function () {
|
||||
spinner.css('transition', 'all 2s ease-in');
|
||||
const uploadEndTime = new Date().getTime();
|
||||
const timeDiff = uploadEndTime - uploadStartTime;
|
||||
const minUploadTime = 2500; // Minimum of 2 seconds for the whole process
|
||||
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
isUploadComplete = true; // Mark the upload as complete
|
||||
const delayTime = Math.max(minUploadTime - timeDiff, 0);
|
||||
|
||||
setTimeout(function () {
|
||||
clearInterval(progressInterval); // Clear the interval when done
|
||||
simulatedProgress = 100;
|
||||
spinner.css('width', '100%');
|
||||
percentageText.text('100%');
|
||||
|
||||
var id2 = $("#employeeIdForList").val();
|
||||
|
||||
if (xhr.status === 200 && response.isSuccedded) {
|
||||
indexCount++;
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
|
||||
uploadFileCount = uploadFileCount + 1;
|
||||
|
||||
const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
img.attr('src', e.target.result);
|
||||
|
||||
//employeePicture = $('#EmployeePicture').attr('src');
|
||||
//nationalCardFront = $('#NationalCardFront').attr('src');
|
||||
//nationalCardRear = $('#NationalCardRear').attr('src');
|
||||
//militaryServiceCard = $('#MilitaryServiceCard').attr('src');
|
||||
//idCardPage1 = $('#IdCardPage1').attr('src');
|
||||
//idCardPage2 = $('#IdCardPage2').attr('src');
|
||||
//idCardPage3 = $('#IdCardPage3').attr('src');
|
||||
//idCardPage4 = $('#IdCardPage4').attr('src');
|
||||
//console.log(idCardPage2);
|
||||
|
||||
// updatePreviewImage(indexId, id2, e.target.result);
|
||||
|
||||
};
|
||||
|
||||
if (pdBox.hasClass("complete") || pdBox.hasClass("discomplete")) {
|
||||
|
||||
pdBox.removeClass("discomplete complete");
|
||||
pdBox.find(".sign").removeClass("discompleteSign completeSign");
|
||||
pdBox.find(".sign").empty();
|
||||
pdBox.find(".btnDeletingPD").removeClass("Rejected Confirmed");
|
||||
pdBox.find("confirmedMessage ").remove();
|
||||
pdBox.find(".resultMessage").empty();
|
||||
}
|
||||
|
||||
pdBox.find('.btnDeletingPD').removeClass('disable').addClass("Unsubmitted");
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
showAlertMessage('.alert-msg', response.message || 'Error uploading file', 3500);
|
||||
$('input[type="file"][data-index="' + indexId + '"]').val('');
|
||||
}
|
||||
spinner.css('width', '0%'); // Reset the progress bar
|
||||
spinner.hide();
|
||||
handleActiveUploads();
|
||||
}, delayTime); // Ensure a minimum of 2 seconds for the full process
|
||||
};
|
||||
|
||||
// Handle upload error
|
||||
xhr.onerror = function () {
|
||||
clearInterval(progressInterval); // Stop progress on error
|
||||
showAlertMessage('.alert-msg', 'مشکلی در آپلود فایل به وجود آمد.', 3500);
|
||||
$('input[type="file"][data-index="' + indexId + '"]').val('');
|
||||
spinner.css('width', '0%');
|
||||
spinner.hide();
|
||||
handleActiveUploads();
|
||||
};
|
||||
|
||||
xhr.send(formData);
|
||||
// spinner.hide();
|
||||
// spinner.css('width', '0%');
|
||||
// handleActiveUploads();
|
||||
//}, 2300);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var indexCount = 0;
|
||||
//var activeUploads = 0;
|
||||
//function uploadFile(file, indexId, label) {
|
||||
// const formData = new FormData();
|
||||
// formData.append('command.EmployeeId', employeeId);
|
||||
// formData.append('command.WorkshopId', workshopId);
|
||||
// formData.append('command.Label', label);
|
||||
// formData.append('command.PictureFile', file);
|
||||
|
||||
// const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
// const spinner = pdBox.find('.spinner-loading-progress');
|
||||
|
||||
// const percentageText = pdBox.find('.percentageText');
|
||||
|
||||
// spinner.show();
|
||||
// activeUploads++;
|
||||
// $('#createUploadingFiles').prop('disabled', true).addClass('disable');
|
||||
|
||||
// const xhr = new XMLHttpRequest();
|
||||
// xhr.open('POST', saveUploadFileModalAjax, true);
|
||||
// xhr.setRequestHeader('RequestVerificationToken', antiForgeryToken);
|
||||
|
||||
// const uploadStartTime = new Date().getTime();
|
||||
// let simulatedProgress = 0;
|
||||
// let actualProgress = 0;
|
||||
// let isUploadComplete = false;
|
||||
|
||||
// // Simulate progress every 20ms, gradually increasing the bar until the actual progress is reached
|
||||
// const progressInterval = setInterval(function () {
|
||||
// if (simulatedProgress < actualProgress && !isUploadComplete) {
|
||||
// simulatedProgress += 1; // Gradually increase simulated progress
|
||||
// spinner.css('width', `${simulatedProgress}%`);
|
||||
// percentageText.text(`${simulatedProgress}%`);
|
||||
// }
|
||||
|
||||
// if (simulatedProgress >= 100) {
|
||||
// clearInterval(progressInterval); // Stop once the progress hits 100%
|
||||
// }
|
||||
// }, 30); // Increases by 1% every 20ms, making it smooth
|
||||
|
||||
// // Actual upload progress listener
|
||||
// xhr.upload.addEventListener('progress', function (e) {
|
||||
// if (e.lengthComputable) {
|
||||
// actualProgress = Math.round((e.loaded / e.total) * 100);
|
||||
|
||||
// // If the actual progress is slow, allow the simulated progress to match it naturally
|
||||
// if (actualProgress >= simulatedProgress) {
|
||||
// simulatedProgress = actualProgress;
|
||||
// spinner.css('width', `${simulatedProgress}%`);
|
||||
// percentageText.text(`${simulatedProgress}%`);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// // On upload completion
|
||||
// xhr.onload = function () {
|
||||
// spinner.css('transition', 'all 2s ease-in');
|
||||
// const uploadEndTime = new Date().getTime();
|
||||
// const timeDiff = uploadEndTime - uploadStartTime;
|
||||
// const minUploadTime = 2500; // Minimum of 2 seconds for the whole process
|
||||
|
||||
// const response = JSON.parse(xhr.responseText);
|
||||
// isUploadComplete = true; // Mark the upload as complete
|
||||
// const delayTime = Math.max(minUploadTime - timeDiff, 0);
|
||||
|
||||
// setTimeout(function () {
|
||||
// clearInterval(progressInterval); // Clear the interval when done
|
||||
// simulatedProgress = 100;
|
||||
// spinner.css('width', '100%');
|
||||
// percentageText.text('100%');
|
||||
|
||||
// var id2 = $("#employeeIdForList").val();
|
||||
|
||||
// if (xhr.status === 200 && response.isSuccedded) {
|
||||
// indexCount++;
|
||||
// const reader = new FileReader();
|
||||
// reader.onload = function (e) {
|
||||
|
||||
// uploadFileCount = uploadFileCount + 1;
|
||||
|
||||
// const pdBox = $('input[data-index="' + indexId + '"]').closest('.pdBox');
|
||||
// const img = pdBox.find('.preview-image');
|
||||
// img.attr('src', e.target.result);
|
||||
|
||||
// //employeePicture = $('#EmployeePicture').attr('src');
|
||||
// //nationalCardFront = $('#NationalCardFront').attr('src');
|
||||
// //nationalCardRear = $('#NationalCardRear').attr('src');
|
||||
// //militaryServiceCard = $('#MilitaryServiceCard').attr('src');
|
||||
// //idCardPage1 = $('#IdCardPage1').attr('src');
|
||||
// //idCardPage2 = $('#IdCardPage2').attr('src');
|
||||
// //idCardPage3 = $('#IdCardPage3').attr('src');
|
||||
// //idCardPage4 = $('#IdCardPage4').attr('src');
|
||||
// //console.log(idCardPage2);
|
||||
|
||||
// // updatePreviewImage(indexId, id2, e.target.result);
|
||||
|
||||
// };
|
||||
|
||||
// if (pdBox.hasClass("complete") || pdBox.hasClass("discomplete")) {
|
||||
|
||||
// pdBox.removeClass("discomplete complete");
|
||||
// pdBox.find(".sign").removeClass("discompleteSign completeSign");
|
||||
// pdBox.find(".sign").empty();
|
||||
// pdBox.find(".btnDeletingPD").removeClass("Rejected Confirmed");
|
||||
// pdBox.find("confirmedMessage ").remove();
|
||||
// pdBox.find(".resultMessage").empty();
|
||||
// }
|
||||
|
||||
// pdBox.find('.btnDeletingPD').removeClass('disable').addClass("Unsubmitted");
|
||||
|
||||
// reader.readAsDataURL(file);
|
||||
// } else {
|
||||
// showAlertMessage('.alert-msg', response.message || 'Error uploading file', 3500);
|
||||
// $('input[type="file"][data-index="' + indexId + '"]').val('');
|
||||
// }
|
||||
// spinner.css('width', '0%'); // Reset the progress bar
|
||||
// spinner.hide();
|
||||
// handleActiveUploads();
|
||||
// }, delayTime); // Ensure a minimum of 2 seconds for the full process
|
||||
// };
|
||||
|
||||
// // Handle upload error
|
||||
// xhr.onerror = function () {
|
||||
// clearInterval(progressInterval); // Stop progress on error
|
||||
// showAlertMessage('.alert-msg', 'مشکلی در آپلود فایل به وجود آمد.', 3500);
|
||||
// $('input[type="file"][data-index="' + indexId + '"]').val('');
|
||||
// spinner.css('width', '0%');
|
||||
// spinner.hide();
|
||||
// handleActiveUploads();
|
||||
// };
|
||||
|
||||
// xhr.send(formData);
|
||||
//}
|
||||
|
||||
function handleActiveUploads() {
|
||||
activeUploads--;
|
||||
if (activeUploads === 0) {
|
||||
@@ -388,6 +610,20 @@ function handleActiveUploads() {
|
||||
}
|
||||
}
|
||||
|
||||
//function uploadCanvasAsFile(canvas, fileName, indexFileValue, label) {
|
||||
// canvas.toBlob(function (blob) {
|
||||
// if (!blob) {
|
||||
// showAlertMessage('.alert-msg', 'مشکلی در تبدیل تصویر رخ داده است!', 3500);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// let file = new File([blob], fileName, { type: 'image/png' });
|
||||
|
||||
// //uploadFile(file, indexFileValue, label);
|
||||
|
||||
// }, "image/png");
|
||||
//}
|
||||
|
||||
function uploadCanvasAsFile(canvas, fileName, indexFileValue, label) {
|
||||
canvas.toBlob(function (blob) {
|
||||
if (!blob) {
|
||||
@@ -396,13 +632,27 @@ function uploadCanvasAsFile(canvas, fileName, indexFileValue, label) {
|
||||
}
|
||||
|
||||
let file = new File([blob], fileName, { type: 'image/png' });
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
|
||||
uploadFile(file, indexFileValue, label);
|
||||
const img = $(`#${label}`);
|
||||
img.attr('src', imageUrl);
|
||||
|
||||
let existingIndex = command.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
command[existingIndex].PictureFile = file;
|
||||
} else {
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: file
|
||||
};
|
||||
command.push(picturesPart);
|
||||
}
|
||||
|
||||
showLoadingAnimation(indexFileValue);
|
||||
|
||||
}, "image/png");
|
||||
}
|
||||
|
||||
|
||||
function showAlertMessage(selector, message, timeout) {
|
||||
$(selector).show();
|
||||
$(selector + ' p').text(message);
|
||||
@@ -478,40 +728,55 @@ function saveSubmit(id) {
|
||||
|
||||
loading.show();
|
||||
|
||||
var data = {
|
||||
'cmd.EmployeeDocumentsId': id
|
||||
}
|
||||
//var data = {
|
||||
// 'cmd.EmployeeDocumentsId': id
|
||||
//}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('workshopId', workshopId);
|
||||
formData.append('employeeId', employeeId);
|
||||
|
||||
command.forEach((item, index) => {
|
||||
formData.append(`command[${index}].Label`, item.Label);
|
||||
formData.append(`command[${index}].PictureFile`, item.PictureFile);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: saveSubmitAjax,
|
||||
url: saveGroupSubmitAjax,
|
||||
method: 'POST',
|
||||
data: data,
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: { 'RequestVerificationToken': antiForgeryToken },
|
||||
success: function (response) {
|
||||
loading.hide();
|
||||
|
||||
if (response.isSuccedded) {
|
||||
if (response.success) {
|
||||
|
||||
var employeeSectionDiv = $(`[data-employee-id="${employeeId}"]`);
|
||||
employeeSectionDiv.remove();
|
||||
//var employeeSectionDiv = $(`[data-employee-id="${employeeId}"]`);
|
||||
//employeeSectionDiv.remove();
|
||||
|
||||
var employeeCountElement = $(`#EmployeeCountOfWorkshop_${workshopId}`);
|
||||
var employeeNumberOfWorkshop = Number(employeeCountElement.text().trim());
|
||||
employeeNumberOfWorkshop -= 1;
|
||||
employeeCountElement.text(employeeNumberOfWorkshop);
|
||||
//var employeeCountElement = $(`#EmployeeCountOfWorkshop_${workshopId}`);
|
||||
//var employeeNumberOfWorkshop = Number(employeeCountElement.text().trim());
|
||||
//employeeNumberOfWorkshop -= 1;
|
||||
//employeeCountElement.text(employeeNumberOfWorkshop);
|
||||
|
||||
if (employeeNumberOfWorkshop === 0) {
|
||||
var mainElement = $(`#Main_${workshopId}`);
|
||||
mainElement.next(".operation-div").remove();
|
||||
mainElement.remove();
|
||||
}
|
||||
//if (employeeNumberOfWorkshop === 0) {
|
||||
// var mainElement = $(`#Main_${workshopId}`);
|
||||
// mainElement.next(".operation-div").remove();
|
||||
// mainElement.remove();
|
||||
//}
|
||||
|
||||
var countDocumentsElement = $(`#CountDocumentsAwaitingUpload`);
|
||||
var countDocumentsAwaitingUpload = Number(countDocumentsElement.text().trim());
|
||||
countDocumentsAwaitingUpload -= 1;
|
||||
countDocumentsElement.text(countDocumentsAwaitingUpload);
|
||||
//var countDocumentsElement = $(`#CountDocumentsAwaitingUpload`);
|
||||
//var countDocumentsAwaitingUpload = Number(countDocumentsElement.text().trim());
|
||||
//countDocumentsAwaitingUpload -= 1;
|
||||
//countDocumentsElement.text(countDocumentsAwaitingUpload);
|
||||
|
||||
updateMainWorkFlow();
|
||||
updateIndexesWorkFlow(`DocumentsAwaitingUpload_${workshopId}`);
|
||||
//updateMainWorkFlow();
|
||||
//updateIndexesWorkFlow(`DocumentsAwaitingUpload_${workshopId}`);
|
||||
|
||||
$(`.workshopID_${workshopId}`).html('');
|
||||
loadByWorkshopIdWithItemsForAdminWorkFlow(workshopId);
|
||||
|
||||
_RefreshWorkFlowCountMenu();
|
||||
_RefreshCheckerCountMenu();
|
||||
@@ -553,6 +818,34 @@ function cancelOP() {
|
||||
});
|
||||
}
|
||||
|
||||
function sendToCheckerAjax() {
|
||||
alert('anjam shod!!');
|
||||
function canDeleteRecord() {
|
||||
var statusCounter = {
|
||||
total: 0,
|
||||
confirmed: 0,
|
||||
pending: 0,
|
||||
rejected: 0,
|
||||
notUploaded: 0
|
||||
};
|
||||
|
||||
$('.pdBox').each(function () {
|
||||
if (hasGenderFemale && $(this).hasClass('militaryService')) {
|
||||
return;
|
||||
}
|
||||
|
||||
statusCounter.total++;
|
||||
if ($(this).find('button.Confirmed').length > 0) {
|
||||
statusCounter.confirmed++;
|
||||
} else if ($(this).find('button.SubmittedByAdmin').length > 0) {
|
||||
statusCounter.pending++;
|
||||
} else if ($(this).find('button.Rejected').length > 0) {
|
||||
statusCounter.rejected++;
|
||||
} else {
|
||||
statusCounter.notUploaded++;
|
||||
}
|
||||
});
|
||||
|
||||
let totalRequired = hasGenderFemale ? 7 : 8;
|
||||
let uploadedOrPending = statusCounter.confirmed + statusCounter.pending;
|
||||
|
||||
return uploadedOrPending < totalRequired;
|
||||
}
|
||||
@@ -28,6 +28,9 @@ $(document).ready(function () {
|
||||
const pdBox = $(this).closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
|
||||
var deleteButton = pdBox.find('.btnDeletingPD');
|
||||
deleteButton.removeClass('disable');
|
||||
|
||||
if (fileInputFile) {
|
||||
const fileName = fileInputFile.name.toLowerCase();
|
||||
const extension = fileName.split('.').pop();
|
||||
@@ -54,11 +57,16 @@ $(document).ready(function () {
|
||||
const blob = new Blob([byteArray], { type: fileInputFile.type });
|
||||
const newFile = new File([blob], fileInputFile.name, { type: fileInputFile.type });
|
||||
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: newFile
|
||||
};
|
||||
pictures.push(picturesPart);
|
||||
let existingIndex = pictures.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
pictures[existingIndex].PictureFile = newFile;
|
||||
} else {
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: newFile
|
||||
};
|
||||
pictures.push(picturesPart);
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(fileInputFile);
|
||||
@@ -70,6 +78,113 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
$(document).off('change', '.file-input').on('change', '.file-input', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const fileInputFile = this.files[0];
|
||||
const indexFileValue = $(this).data('index');
|
||||
const validExtensions = ['jpg', 'jpeg', 'png'];
|
||||
const validPdfExtensions = ['pdf'];
|
||||
|
||||
const label = $(`#label_${indexFileValue}`).val();
|
||||
const pdBox = $(this).closest('.pdBox');
|
||||
const img = pdBox.find('.preview-image');
|
||||
var deleteButton = pdBox.find('.btnDeletingPD');
|
||||
deleteButton.removeClass('disable');
|
||||
|
||||
if (fileInputFile) {
|
||||
const fileName = fileInputFile.name.toLowerCase();
|
||||
const extension = fileName.split('.').pop();
|
||||
|
||||
// بررسی فرمتهای تصویر (jpeg, jpg, png)
|
||||
if (validExtensions.includes(extension)) {
|
||||
if (fileInputFile.size > 5000000) {
|
||||
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 5 مگابایت را آپلود کنید.', 3500);
|
||||
$(this).val('');
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
img.attr('src', event.target.result);
|
||||
|
||||
const base64String = event.target.result.split(',')[1];
|
||||
const byteCharacters = atob(base64String);
|
||||
const byteNumbers = new Array(byteCharacters.length);
|
||||
for (let i = 0; i < byteCharacters.length; i++) {
|
||||
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
||||
}
|
||||
const byteArray = new Uint8Array(byteNumbers);
|
||||
const blob = new Blob([byteArray], { type: fileInputFile.type });
|
||||
const newFile = new File([blob], fileInputFile.name, { type: fileInputFile.type });
|
||||
|
||||
let existingIndex = pictures.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
pictures[existingIndex].PictureFile = newFile;
|
||||
} else {
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: newFile
|
||||
};
|
||||
pictures.push(picturesPart);
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(fileInputFile);
|
||||
|
||||
console.log(pictures);
|
||||
}
|
||||
else if (validPdfExtensions.includes(extension)) {
|
||||
var fileReader = new FileReader();
|
||||
|
||||
fileReader.onload = function () {
|
||||
var typedarray = new Uint8Array(this.result);
|
||||
pdfjsLib.getDocument(typedarray).promise.then(function (pdf) {
|
||||
totalPageCount = pdf.numPages;
|
||||
|
||||
if (totalPageCount > 1) {
|
||||
showAlertMessage('.alert-msg', 'آپلود مجاز نیست! تعداد صفحات نباید بیشتر از ۱ باشد.', 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
pdf.getPage(1).then(function (page) {
|
||||
var scale = 2.0;
|
||||
var viewport = page.getViewport({ scale: scale });
|
||||
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.className = "page";
|
||||
canvas.title = "Page 1";
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
page.render({
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
}).promise.then(function () {
|
||||
uploadCanvasAsFile(canvas, `${label}_${indexFileValue}.jpg`, indexFileValue, label);
|
||||
}).catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'مشکلی در پردازش PDF رخ داده است!', 3500);
|
||||
});
|
||||
}).catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'خطا در دریافت صفحه PDF!', 3500);
|
||||
});
|
||||
|
||||
}).catch(function (error) {
|
||||
showAlertMessage('.alert-msg', 'خطا در بارگذاری فایل PDF!', 3500);
|
||||
});
|
||||
};
|
||||
|
||||
fileReader.readAsArrayBuffer(fileInputFile);
|
||||
|
||||
}
|
||||
else {
|
||||
showAlertMessage('.alert-msg', 'فرمت فایل باید یکی از موارد jpeg, jpg, png یا pdf باشد.', 3500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).off('click', '.btnDeletingPD').on('click', '.btnDeletingPD', function (event) {
|
||||
event.preventDefault();
|
||||
const pdBox = $(this).closest('.pdBox');
|
||||
@@ -104,6 +219,35 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
function uploadCanvasAsFile(canvas, fileName, indexFileValue, label) {
|
||||
canvas.toBlob(function (blob) {
|
||||
if (!blob) {
|
||||
showAlertMessage('.alert-msg', 'مشکلی در تبدیل تصویر رخ داده است!', 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
let file = new File([blob], fileName, { type: 'image/png' });
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
|
||||
const img = $(`[data-label="${label}"]`);
|
||||
img.attr('src', imageUrl);
|
||||
|
||||
let existingIndex = pictures.findIndex(item => item.Label === label);
|
||||
if (existingIndex !== -1) {
|
||||
pictures[existingIndex].PictureFile = file;
|
||||
} else {
|
||||
let picturesPart = {
|
||||
Label: label,
|
||||
PictureFile: file
|
||||
};
|
||||
pictures.push(picturesPart);
|
||||
}
|
||||
console.log(pictures);
|
||||
|
||||
}, "image/png");
|
||||
}
|
||||
|
||||
|
||||
var indexCount = 0;
|
||||
function uploadFile(file, indexId, label) {
|
||||
const formData = new FormData();
|
||||
|
||||
Reference in New Issue
Block a user