Files
Backend-Api/ServiceHost/Areas/Admin/Pages/Company/InsuranceJobItem/Edit.cshtml
2025-05-04 17:29:58 +03:30

200 lines
6.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@model CompanyManagment.App.Contracts.DateSalary.CreateDateSalaryForInsuranceJob
<link href="@Href("~/admintheme/css/information-insurance-jobs.css")" rel="stylesheet"/>
@Html.AntiForgeryToken()
<div class="container">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="main-title">اطلاعات مربوط به مشاغل مقطوع </div>
<div class="box">
<form>
<div class="form">
<div class="col-md-6 inputs">
<input type="text" id="fromDate" placeholder="تاریخ شروع" class="input upper-in date" value="@Model.StartDateFa">
</div>
<div class="col-md-6 inputs">
<input type="text" id="toDate" placeholder="تاریخ پایان" class="input upper-in date" style="direction: rtl;" value="@Model.EndDateFa">
</div>
<div class="col-md-12 inputs" id="table-container">
<table id="table" class="table edit-table table-bordered table-striped">
<thead>
<tr>
<th> عملیات</th>
<th style="border-left: 0;">مبلغ </th>
<th>ضریب</th>
<th style="border-right: 0;"> #</th>
</tr>
</thead>
<tbody>
@{ var index = 1; }
@foreach (var item in Model.DateSalaryItems)
{
<tr>
<td>
@if (item.Id == 0)
{
<i class="fa fa-trash trash trash-icon" aria-hidden="true" onclick="removeItem(this)"></i>
}
</td>
<td class="col-md-6">
<input id="txtMoney-@index" class="items money" type="text" value="@item.StrSalary" onkeyup="getMoneyValue(this);" placeholder=""/>
<input class=" percentageId" type="hidden" value="@item.PercentageId"/>
<input class=" Id" type="hidden" value="@item.Id"/>
</td>
<td class="col-md-6">
<input class="items percentItem" type="text" placeholder="" disabled="disabled" value="@item.Percent"/>
</td>
<td class="col-md-1">@index</td>
</tr>
index = index + 1;
}
</tbody>
</table>
</div>
</div>
<div class="btns">
<div class="col-md-5">
<a href="#" class=" btn btn-modal" id="save">ذخیره</a>
<button class="btn btn-modal" id="close" data-dismiss="modal">بستن</button>
</div>
</div>
</form>
</div>
</div>
<script src="~/AdminTheme/js/numeral.min.js"></script>
<script>
$(document).ready(function() {
$(".date").mask("0000/00/00");
});
$(".date").keyup(function() {
const value = $(this).val();
const lengthValue = value.length;
if (lengthValue == 10) {
if (!dateValidCheck(this)) {
$(this).addClass("errored");
} else {
$(this).removeClass("errored");
}
}
});
function getMoneyValue(element) {
const text = getNumberValue($(element).val());
const textMoney = numeral(text).format();
const id = $(element).attr('id');
$(`#${id}`).val(textMoney);
}
$("#save").click(function() {
if (checkEmpty()) {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
if (fromDate != '' && !checkLength(fromDate, 10)) {
if (!dateValidCheckByValue($("#fromDate"))) {
$("#fromDate").addClass("errored");
} else {
$("#fromDate").removeClass("errored");
}
}
if (toDate != '' && !checkLength(toDate, 10)) {
if (!dateValidCheckByValue($("#toDate"))) {
$("#toDate").addClass("errored");
} else {
$("#toDate").removeClass("errored");
}
}
if ((fromDate != '' && checkLength(fromDate, 10)) && (toDate != '' && checkLength(toDate, 10)) && toDate < fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند کمتر از تاریخ شروع باشد.');
return;
} else if (toDate == fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند مساوی با تاریخ شروع باشد.');
return;
} else {
var dateSalaryItemsList = [];
$('#table tbody tr').each(function(index) {
const dateSalaryItems = {};
dateSalaryItems.Salary = getNumberValue($(this).find('input.money').val());
dateSalaryItems.Percent = $(this).find('input.percentItem').val();
dateSalaryItems.PercentageId = $(this).find('input.percentageId').val();
dateSalaryItems.DateSalaryId = @Model.Id;
dateSalaryItems.Id = $(this).find('input.Id').val();
dateSalaryItemsList.push(dateSalaryItems);
});
const command = {};
command.Id = @Model.Id;
command.StartDateFa = fromDate;
command.EndDateFa = toDate;
command.DateSalaryItems = dateSalaryItemsList;
// console.log(command);
$.ajax({
dataType: 'json',
type: 'POST',
url: '@Url.Page("/Company/InsuranceJobItem/Index", "Edit")',
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
data: command,
success: function(response) {
if (response.isSuccedded) {
$("#MainModal").modal('toggle');
$('.btn-search1').click();
$.Notification.autoHideNotify('success', 'top right', 'پیام سیستم ', response.message);
} else {
$.Notification.autoHideNotify('error', 'top right', response.message);
}
},
failure: function(response) {
console.log(5, response);
}
});
}
}
});
function checkEmpty() {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
var result = true;
if (fromDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع نمی تواند خالی باشد.');
result = false;
} else if (toDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند خالی باشد.');
result = false;
} else {
// $('#table tbody tr').each(function(index) {
// if ($(this).find('input.money').val() == '' || $(this).find('input.money').val() == '0') {
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);
// result = false;
// }
// });
}
return result;
}
function removeItem(this_) {
$(this_).closest('tr').remove();
setIndex();
}
function setIndex() {
$('#table tbody tr').each(function(index) {
$(this).find('td:eq(3)').text(index + 1);
});
}
</script>