3077 lines
172 KiB
Plaintext
3077 lines
172 KiB
Plaintext
@using Version = _0_Framework.Application.Version
|
||
@model CompanyManagment.App.Contracts.LeftWorkInsurance.LeftworkInsuranceDividedList
|
||
@*adding bime*@
|
||
|
||
<link href="@Href("~/DadmehrSelect/dad-mehr-select.css?ver=")@Version.AdminVersion" rel="stylesheet" />
|
||
<link href="@Href("~/admintheme/css/left-work-insurance.css")" rel="stylesheet" />
|
||
|
||
@Html.AntiForgeryToken()
|
||
<div class="container" id="LeftWorkInsuranceForm">
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
<div class="main-title"> شروع بکار و ترک کار پرسنل در بخش بیمه </div>
|
||
<fieldset class="box">
|
||
<legend>@Model.EmployeeName</legend>
|
||
<div class="fdiv">
|
||
<label class="first-label">افزودن کارگاه</label>
|
||
<div class="d-flex">
|
||
<select class="form-control select-city input" id="input1" asp-items="@Model.Workshops">
|
||
<option value="0">انتخاب کارگاه</option>
|
||
</select>
|
||
<button class="btn save" id="save1">ثبت</button>
|
||
</div>
|
||
</div>
|
||
<div class="tabbed-navigation">
|
||
<div class="nav-tabs hide-scrollbar">
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
var index = 1;
|
||
@foreach (var item in Model.LeftWorkInsuranceGroups)
|
||
{
|
||
<a href="#tab-@index" class="@(index == 1 ? "active" : "") nav-link">
|
||
<span class="del-com">
|
||
<i onclick="deleteLeftwork(this, @item.WorkshopId)" class="fa fa-trash trash-icon delworkshop" aria-hidden="true" style="color: white;" permission="10419"></i>
|
||
</span><span data-workshopid="@item.WorkshopId" class="nav-title" id="nav-title1"> @item.WorkshopName</span>
|
||
</a>
|
||
index = index + 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
<a href="#tab-1" class="active nav-link">
|
||
<span class="del-com">
|
||
<i onclick="deleteLeftwork(this, 0)" newItem="true" class="fa fa-trash trash-icon delworkshop" aria-hidden="true" style="color: white;" permission="10419"></i>
|
||
</span><span data-workshopid="0" class="nav-title" id="nav-title1"> نام شرکت</span>
|
||
</a>
|
||
}
|
||
|
||
</div>
|
||
<div class="tab-content">
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
var index = 1;
|
||
@foreach (var item in Model.LeftWorkInsuranceGroups)
|
||
{
|
||
<div class="tab-pane @(index == 1 ? "active" : "")" data-workshopId="@item.WorkshopId" data-workshopName="@item.WorkshopName" id="tab-@index" data-pane="index">
|
||
<div class="pane-content">
|
||
<div class="top-content first-row">
|
||
<div class="first-col-content">
|
||
<div class="select-container">
|
||
<label> سمت </label>
|
||
<div class="dadmehr-select-search" onclick="inputFocus(this), employerDiagnose()">
|
||
<div class="custom-select text-right">
|
||
|
||
|
||
<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobByTextSearch")">
|
||
@if (item.JobId != 0)
|
||
{
|
||
<li onclick="openSearchResultByCodeLeftWorkInsurance(this, @item.WorkshopId)" class="singleItem"><span class="value" data-value="@item.LeftworkInsuranceViewModels[0].JobId">@item.LeftworkInsuranceViewModels[0].JobName</span>|<span class="code">@item.LeftworkInsuranceViewModels[0].JobCode</span></li>
|
||
}
|
||
else
|
||
{
|
||
<li>
|
||
<input onkeyup="searchTextLeftWorkInsurance(event, this, '@Url.Page("/Company/Employees/Index", "JobListByText")', @Model.WorkshopId)" class="text-right input-text" />
|
||
</li>
|
||
}
|
||
</ul>
|
||
<ul class="result options text-right">
|
||
</ul>
|
||
|
||
</div>
|
||
<span class="span-input"></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="second-col-content">
|
||
<label> شماره پرسنلی </label>
|
||
<input type="text" class="position-code" value="@item.PersonnelCode" checked="checked" data-haspersonelcode="@(item.HasPersonelCode ? true : false)" disabled="disabled">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<div class="d-flex position-check">
|
||
<span class="position-type">مشمول مزایا </span>
|
||
<div class="checkbox-wrapper">
|
||
@if (item.LeftworkInsuranceViewModels != null && item.LeftworkInsuranceViewModels.Count > 0)
|
||
{
|
||
<input @(item.LeftworkInsuranceViewModels[0].IncludeStatus ? "checked" : "") type="checkbox" class="setContract">
|
||
}
|
||
else
|
||
{
|
||
<input type="checkbox" checked class="setContract">
|
||
}
|
||
</div>
|
||
<span class="position-type"> عدم شمول مزایا </span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="top-content">
|
||
@if (index == 1)
|
||
{
|
||
<div class="first-col-content">
|
||
<input type="text" class="persianDateInput date-input date input2" maxlength="10" id="startDate1" placeholder="تاریخ شروع بکار" tabindex="1">
|
||
</div>
|
||
<div class="second-col-content">
|
||
<input type="text" class="persianDateInput date-input date input3" maxlength="10" id="lastDay1" placeholder="تاریخ آخرین روز کاری" tabindex="2">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<input type="text" class="persianDateInput date-input date input4" maxlength="10" id="endDate1" placeholder="تاریخ ترک کار" tabindex="3">
|
||
<button class=" btn save2" id="save">ثبت</button>
|
||
</div>
|
||
}
|
||
else
|
||
{
|
||
<div class="first-col-content">
|
||
<input type="text" class="persianDateInput date-input date input2" maxlength="10" id="start-date-@(index - 1)" placeholder="تاریخ شروع بکار" tabindex="1">
|
||
</div>
|
||
<div class="second-col-content">
|
||
<input type="text" class="persianDateInput date-input date input3" maxlength="10" id="last-day-@(index - 1)" placeholder="تاریخ آخرین روز کاری" tabindex="2">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<input type="text" class="persianDateInput date-input date input4" maxlength="10" id="end-date-@(index - 1)" placeholder="تاریخ ترک کار" tabindex="3">
|
||
<button class="btn save" onclick="saveData()">ثبت</button>
|
||
</div>
|
||
}
|
||
</div>
|
||
<div class="table-content">
|
||
<table class="table table-bordered table-striped workDate-table" @(index == 1 ? "id='modal-table'" : "")>
|
||
<colgroup>
|
||
<col style="width: 20px;">
|
||
<col style="width: 140px;">
|
||
<col class="col-edit" style="width: 5px;">
|
||
<col style="width: 140px;">
|
||
<col style="width: 140px;">
|
||
<col class="col-remove" style="width: 5px;">
|
||
<col style="width: 30px;">
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th style="text-align: end;">تاریخ شروع بکار</th>
|
||
<th style="border-right-width: 0;" class="permision"></th>
|
||
<th>تاریخ آخرین روز کاری</th>
|
||
<th style="text-align: end;">تاریخ ترک کار</th>
|
||
<th style="border-right-width: 0;" class="permision"></th>
|
||
<th class="text-small">روزهای کارکرد</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@if (item.LeftworkInsuranceViewModels != null)
|
||
{
|
||
var leftworkInsuranceViewModelList = item.LeftworkInsuranceViewModels;
|
||
for (var i = 0; i < leftworkInsuranceViewModelList.Count; i++)
|
||
{
|
||
<tr data-hasInsuranceList="@leftworkInsuranceViewModelList[i].HasInsuranceList" data-id="@leftworkInsuranceViewModelList[i].Id">
|
||
<td>@(i + 1)</td>
|
||
<td>@leftworkInsuranceViewModelList[i].StartWorkDate</td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '@leftworkInsuranceViewModelList[i].StartWorkDate', @leftworkInsuranceViewModelList[i].WorkshopId, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td>@leftworkInsuranceViewModelList[i].EndWorkDate</td>
|
||
<td>@leftworkInsuranceViewModelList[i].LeftWorkDate</td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '@leftworkInsuranceViewModelList[i].LeftWorkDate', @leftworkInsuranceViewModelList[i].WorkshopId, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td>_</td>
|
||
</tr>
|
||
}
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
index = index + 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
<div class="tab-pane active" data-workshopid="" data-workshopName="" id="tab-1" data-pane="1">
|
||
<div class="pane-content">
|
||
<div class="top-content first-row">
|
||
<div class="first-col-content">
|
||
<div class="select-container">
|
||
<label> سمت </label>
|
||
<div class="dadmehr-select-search" onclick="inputFocus(this), employerDiagnose()">
|
||
<div class="custom-select text-right">
|
||
<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobListByText")">
|
||
<li>
|
||
<input onkeyup="searchTextLeftWorkInsurance(event, this, '@Url.Page("/Company/Employees/Index", "JobListByText")', @Model.WorkshopId)" class="text-right input-text" />
|
||
</li>
|
||
</ul>
|
||
<ul class="result options text-right">
|
||
</ul>
|
||
</div>
|
||
<span class="span-input"></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="second-col-content">
|
||
<label> شماره پرسنلی </label>
|
||
<input type="text" data-haspersonelcode="" class="position-code" disabled="disabled">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<div class="d-flex position-check">
|
||
<span class="position-type"> مشمول مزایا </span>
|
||
<div class="checkbox-wrapper">
|
||
<input type="checkbox" checked class="setContract">
|
||
</div>
|
||
<span class="position-type">عدم شمول مزایا</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="top-content">
|
||
<div class="first-col-content">
|
||
<input type="text" class="persianDateInput date-input date input2" maxlength="10" id="startDate1" placeholder="تاریخ شروع بکار" tabindex="1">
|
||
</div>
|
||
<div class="second-col-content">
|
||
<input type="text" class="persianDateInput date-input date input3" maxlength="10" id="lastDay1" placeholder="تاریخ آخرین روز کاری" tabindex="2">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<input type="text" class="persianDateInput date-input date input4" maxlength="10" id="endDate1" placeholder="تاریخ ترک کار" tabindex="3">
|
||
<button class=" btn save2" id="save">ثبت</button>
|
||
</div>
|
||
</div>
|
||
<div class="table-content">
|
||
<table class="table table-bordered table-striped workDate-table" id="modal-table">
|
||
<colgroup>
|
||
<col style="width: 20px;">
|
||
<col style="width: 140px;">
|
||
<col class="col-edit" style="width: 5px;">
|
||
<col style="width: 140px;">
|
||
<col style="width: 140px;">
|
||
<col class="col-remove" style="width: 5px;">
|
||
<col style="width: 30px;">
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th style="text-align: end;">تاریخ شروع بکار</th>
|
||
<th style="border-right-width: 0;" class="permision"></th>
|
||
<th>تاریخ آخرین روز کاری</th>
|
||
<th style="text-align: end;">تاریخ ترک کار</th>
|
||
<th style="border-right-width: 0;" class="permision"></th>
|
||
<th class="text-small">روزهای کارکرد</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
|
||
<tr data-id="0">
|
||
<td>1</td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
</tr>
|
||
<tr data-id="0">
|
||
<td>2</td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
</tr>
|
||
<tr data-id="0">
|
||
<td>3</td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
<td></td>
|
||
@*<td><i class="fa fa-edit edit-icon permission-editDate " aria-hidden="true"></i></td>*@
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
</tr>
|
||
<tr data-id="0">
|
||
<td>4</td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
<td></td>
|
||
@*<td><i class="fa fa-edit edit-icon permission-editDate " aria-hidden="true"></i></td>*@
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
</tr>
|
||
<tr data-id="0">
|
||
<td>5</td>
|
||
<td></td>
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'first')" href="#" class="edit-date first-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
<td></td>
|
||
@*<td><i class="fa fa-edit edit-icon permission-editDate " aria-hidden="true"></i></td>*@
|
||
<td style="border-right-width: 0;" class="permision">
|
||
<a onclick="deleteDate(this, '', 0, 'last')" href="#" class=" edit-date second-edit permission-removeDate">
|
||
<i style="color: red;" class="ion-close-circled"></i>
|
||
</a>
|
||
<a href="#" class="edit-icon permission-editDate">
|
||
<i style="color: #f9792bf7;" class="fa fa-edit"></i>
|
||
</a>
|
||
</td>
|
||
<td></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="last-div">
|
||
@* <div class="d-flex work-history">
|
||
<div class="col-md-4 col-4 col-sm-4 last-titles">سابقه کار در کارگاه</div>
|
||
<div class="col-md-8 col-8 col-sm-8 d-flex" style="direction: ltr">
|
||
<div class="date-sums">312</div>
|
||
<div class="dates">1323</div>
|
||
<div class="dates">1323</div>
|
||
<div class="dates">2131</div>
|
||
</div>
|
||
</div>*@
|
||
<div class="d-flex in-history">
|
||
<div class="col-md-4 col-4 col-sm-4 last-titles">سابقه بیمه در کارگاه</div>
|
||
<div class="col-md-8 col-8 col-sm-8 d-flex" style="direction: ltr">
|
||
<div class="date-sums">312</div>
|
||
<div class="dates blue">1323</div>
|
||
<div class="dates blue">1323</div>
|
||
<div class="dates blue">2131</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="btns">
|
||
<a href="#" id="btnSaveData" class="btn btn-modal" style="background-color: #0f9500;color: white;">ذخیره</a>
|
||
<button class="btn btn-modal" data-dismiss="modal" style="background-color: white;color: #323030;">بستن</button>
|
||
</div>
|
||
</fieldset>
|
||
</div>
|
||
|
||
|
||
<form asp-page="./Index" asp-page-handler="CreateLeftWorkInsurance" id="employee" autocomplete="off"
|
||
method="post"
|
||
data-ajax="true"
|
||
data-callback=""
|
||
data-action="leftworkinsurance">
|
||
<div id="divAppendData">
|
||
<input type="hidden" asp-for="EmployeeId" value="@Model.EmployeeId" />
|
||
<input type="hidden" asp-for="IsDelete" />
|
||
</div>
|
||
@* <button type="submit" id="sendData" style="display: none"></button>*@
|
||
</form>
|
||
<input type="hidden" id="editStartDate" />
|
||
<input type="hidden" id="editEndDate" />
|
||
<input type="hidden" id="editLeftDate" />
|
||
<input type="hidden" id="deleteStartDate" />
|
||
<input type="hidden" id="editIndex" />
|
||
<input type="hidden" id="deleteIndex" />
|
||
<div class="modal fade" id="result-modal" tabindex="-1" role="dialog" aria-labelledby="regModalLabel" aria-hidden="true">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content" id="ModalContent">
|
||
<div class="modal-header" dir="ltr">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" data-parent-modal="#result-modal">
|
||
<span aria-hidden="true">×</span>
|
||
</button>
|
||
<div class="main-title">نتیجه ثبت اطلاعات ترک کار</div>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div id="resultdiv" class="row" style="font-size: 16px;">
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" style="border-radius: 25px;" id="closing" class="btn btn-secondary" data-dismiss="modal" data-parent-modal="#result-modal">بستن</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="~/DadmehrSelect/dadmehr-select-leftWork.js?v=1.2"></script>
|
||
<script src="~/ClientTheme/js/insurance-list.js?v=1"></script>
|
||
<script>
|
||
|
||
var list = [];
|
||
$(document).ready(function () {
|
||
handleScroll();
|
||
handleCompanyScroll();
|
||
employerDiagnose();
|
||
disappearIcon();
|
||
// checkPremision();
|
||
@if (Model.LeftWorkInsuranceGroups == null || (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count == 0))
|
||
{
|
||
<text>disabledJob(); </text>
|
||
}
|
||
|
||
|
||
@foreach (var item in Model.PermissionIds)
|
||
{
|
||
<text>
|
||
list.push(@item);
|
||
</text>
|
||
}
|
||
const navTitle = $('.nav-title');
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
navTitle.addClass("disactive");
|
||
}
|
||
//adding / between dates
|
||
$(".date").mask("0000/00/00");
|
||
//this function is for disabling the first tab and adding a new row to the table of the first tab
|
||
checkcountRow();
|
||
//this code adds a new tab(with the content in it)...
|
||
const addTab = (counter) => {
|
||
var workshopId = $('#input1').val();
|
||
var workshopName = $('#input1 option:selected').text();
|
||
//the data in each tab...
|
||
const newTab = $(`<div class="tab-pane" data-workshopId="${workshopId}" data-workshopName="${workshopName}"id="tab${counter}" data-pane="${counter
|
||
}"><div class="pane-content"><div class="top-content first-row"><div class="first-col-content"><div class= "select-container" ><label>سمت </label><div class= "dadmehr-select-search" onclick = "inputFocus(this),employerDiagnose()" ><div class="custom-select text-right" ><ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobListByText")" ><li><input onkeyup=searchTextLeftWorkInsurance(event,this,"@Url.Page("/Company/Employees/Index", "JobListByText")",${workshopId
|
||
}) class= "text-right input-text" /> </li></ul><ul class= "result options text-right" ></ul></div><span class= "span-input" > </span></div></div></div><div class="second-col-content"><label> شماره پرسنلی </label><input type ="text" data-haspersonelcode="" class="position-code"></div><div class="third-col-content"><div class="d-flex position-check"><span class="position-type"> مشمول مزایا </span><div class="checkbox-wrapper"><input type="checkbox" checked class="setContract"></div><span class="position-type"> عدم شمول مزایا </span></div></div></div><div class="top-content"><div class="first-col-content"><input type="text" class="persianDateInput date-input date input2 start-date" maxlength="10" id="start-date-${counter
|
||
}" placeholder="تاریخ شروع بکار" tabindex="1"></div><div class="second-col-content"><input type="text" class="persianDateInput date-input date input3 last-day" maxlength="10" id="last-day-${counter
|
||
}" placeholder="تاریخ آخرین روز کاری" tabindex="2"></div><div class="third-col-content"><input type="text" class="persianDateInput date-input date input4 end-date" maxlength="10" id="end-date-${counter
|
||
}" placeholder="تاریخ ترک کار" tabindex="3"><button class="btn save" onclick="saveData()">ثبت</button></div></div><div class="table-content"><table class="table table-bordered table-striped workDate-table"><colgroup><col style="width: 20px;"><col style="width: 140px;"><col class="col-edit" style="width: 5px;"><col style="width: 140px;"><col style="width: 140px;"><col class="col-remove" style="width: 5px;"><col style="width: 30px;"></colgroup><thead><tr><th>#</th><th style="text-align: end;">تاریخ شروع بکار</th><th style="border-right-width: 0;" class="permision"></th><th>تاریخ آخرین روز کاری</th><th style="text-align: end;">تاریخ ترک کار</th><th style="border-right-width: 0;" class="permision"></th><th class="text-small">روزهای کارکرد</th></tr></thead><tbody><tr data-id="0"><td>1</td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"last") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>2</td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"last") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>3</td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"last") href="#" class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>4</td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>5</td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class=" edit-date second-edit permission-removeDate d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr></tbody></table></div></div></div></div>`);
|
||
$(".tab-content").prepend(newTab);
|
||
const endDateInput = newTab.find('.end-date');
|
||
const startDateInput = newTab.find('.start-date');
|
||
getPersonelCode(workshopId);
|
||
|
||
getJobByWorkshopId(workshopId);
|
||
|
||
$(".edit-icon").unbind('click').on("click",
|
||
function (e) {
|
||
editDate(this);
|
||
e.preventDefault();
|
||
});
|
||
//this code checks the date in keyup function...
|
||
$(".date").keyup(function () {
|
||
const value = $(this).val();
|
||
const lengthValue = value.length;
|
||
const id = $(this).attr('id');
|
||
if (lengthValue == 10) {
|
||
if (!dateValidCheck(this)) {
|
||
$(this).addClass("errored");
|
||
} else {
|
||
$(this).removeClass("errored");
|
||
|
||
if (id == 'last-day-' + counter) {
|
||
setDate(value, `last-day-${counter}`, `end-date-${counter}`, true);
|
||
} else if (id == 'end-date-' + counter) {
|
||
setDate(value, `end-date-${counter}`, `end-date-${counter}`, false);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
//the save button in the new tab...
|
||
////////newTab.find('.save').click(function (e) {
|
||
//////// console.log(3333);--------
|
||
//////// e.preventDefault();------
|
||
//////// let activeTabPane = $('.tab-pane.active');-------
|
||
|
||
//////// let paneNumber = newTab.data('pane');
|
||
//////// let startDate = $('#start-date-' + paneNumber).val();
|
||
//////// let lastDay = $('#last-day-' + paneNumber).val();
|
||
//////// let endDate = $('#end-date-' + paneNumber).val();
|
||
|
||
//////// if (startDate != '' && !checkLength($('#start-date-' + counter).val(), 10)) {
|
||
//////// if (!dateValidCheckByValue($('#start-date-' + counter))) {
|
||
//////// $('#start-date-' + counter).addClass("errored");
|
||
//////// } else {
|
||
//////// $('#start-date-' + counter).removeClass("errored");
|
||
//////// }
|
||
|
||
//////// }
|
||
//////// if (lastDay != '' && !checkLength($('#last-day-' + counter).val(), 10)) {
|
||
//////// if (!dateValidCheckByValue($('#start-date-' + counter))) {
|
||
//////// $('#last-day-' + counter).addClass("errored");
|
||
//////// } else {
|
||
//////// $('#last-day-' + counter).removeClass("errored");
|
||
//////// }
|
||
|
||
//////// }
|
||
//////// if (endDate != '' && !checkLength($('#end-date-' + counter).val(), 10)) {
|
||
//////// if (!dateValidCheckByValue($('#end-date-' + counter))) {
|
||
//////// $('#end-date-' + counter).addClass("errored");
|
||
//////// } else {
|
||
//////// $('#end-date-' + counter).removeClass("errored");
|
||
//////// }
|
||
|
||
//////// }
|
||
//////// var editable = false;
|
||
//////// if (startDate != '' && !$('.date').hasClass('errored') && $("#editStartDate").val() != '') {
|
||
//////// var workshopId = activeTabPane.attr("data-workshopid");
|
||
//////// $.ajax({
|
||
//////// dataType: 'json',
|
||
//////// type: 'POST',
|
||
//////// url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
//////// headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
//////// data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": startDate, "type": 1 },
|
||
//////// success: function (response) {
|
||
//////// // console.log(response);
|
||
//////// if (response.isSuccedded == true) {
|
||
//////// if (!$('#start-date-' + paneNumber).hasClass('errored') && !$('#last-day-' + paneNumber).hasClass('errored') && !$('#end-date-' + paneNumber).hasClass('errored')) {
|
||
//////// addRow2(counter, startDate, lastDay, endDate);
|
||
//////// console.log(2222);
|
||
//////// disableInput();
|
||
//////// disableSaveBtn();
|
||
//////// handleScroll();
|
||
//////// $('#start-date-' + paneNumber).val("");
|
||
//////// $('#last-day-' + paneNumber).val("");
|
||
//////// $('#end-date-' + paneNumber).val("");
|
||
//////// let editIcon = activeTabPane.find(".edit-icon");
|
||
//////// let deleteIcon = activeTabPane.find(".edit-date");
|
||
//////// deleteIcon.removeClass("disabled-edit");
|
||
//////// editIcon.removeClass("disabled-edit");
|
||
//////// activeTabPane.find(".date").removeClass("blinking");
|
||
//////// }
|
||
//////// $('.workDate-table').find("tbody tr").each(function () {
|
||
//////// let row = $(this);
|
||
//////// let rowStartDate = row.find('td:eq(1)');
|
||
//////// let rowEndDate = row.find('td:eq(4)');
|
||
//////// let rowStartDateText = row.find('td:eq(1)').text();
|
||
//////// let rowEndDateText = row.find('td:eq(4)').text();
|
||
//////// if (rowStartDateText != '') {
|
||
//////// rowStartDate.removeClass("emptyStart");
|
||
//////// }
|
||
//////// });
|
||
//////// }
|
||
//////// else {
|
||
//////// swal({
|
||
//////// title: "امکان ویرایش تاریخ وجود ندارد.",
|
||
//////// text: " به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ویرایش تاریخ قبل از تاریخ " + $("#editStartDate").val() + "امکان پذیر می باشد. ",
|
||
//////// type: "warning",
|
||
//////// showCancelButton: true,
|
||
//////// confirmButtonColor: "#DD6B55",
|
||
//////// //confirmButtonText: "بستن",
|
||
//////// cancelButtonText: "بستن",
|
||
//////// closeOnConfirm: false,
|
||
//////// customClass: "errorSwall"
|
||
//////// });
|
||
//////// // var tr = $(activeTabPane).find('.workDate-table tbody tr');
|
||
//////// // tr.find('td:eq(1)').text($("#editStartDate").val());
|
||
|
||
//////// }
|
||
//////// },
|
||
//////// error: function (response) {
|
||
//////// console.log(5, response);
|
||
//////// }
|
||
//////// });
|
||
//////// }
|
||
//////// else {
|
||
//////// if (!activeTabPane.find('.date').hasClass('errored'))
|
||
//////// {
|
||
//////// if ($("#deleteStartDate").val() != '' && $("#deleteStartDate").val() < startDate) {
|
||
//////// swal({
|
||
//////// title: "امکان حذف تاریخ وجود ندارد.",
|
||
//////// text: " به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ثبت تاریخ جدید قبل از تاریخ " + $("#deleteStartDate").val() + "امکان پذیر می باشد. ",
|
||
//////// type: "warning",
|
||
//////// showCancelButton: true,
|
||
//////// confirmButtonColor: "#DD6B55",
|
||
//////// //confirmButtonText: "بستن",
|
||
//////// cancelButtonText: "بستن",
|
||
//////// closeOnConfirm: false,
|
||
//////// customClass: "errorSwall"
|
||
//////// });
|
||
//////// }
|
||
//////// else
|
||
//////// {
|
||
//////// $("#deleteStartDate").val('');
|
||
|
||
//////// addRow2(counter, startDate, lastDay, endDate);
|
||
//////// disableInput();
|
||
//////// disableSaveBtn();
|
||
//////// handleScroll();
|
||
|
||
//////// $('#start-date-' + paneNumber).val("");
|
||
//////// $('#last-day-' + paneNumber).val("");
|
||
//////// $('#end-date-' + paneNumber).val("");
|
||
//////// }
|
||
//////// }
|
||
//////// $('.workDate-table').find("tbody tr").each(function () {
|
||
//////// let row = $(this);
|
||
//////// let rowStartDate = row.find('td:eq(1)');
|
||
//////// let rowEndDate = row.find('td:eq(4)');
|
||
//////// let rowStartDateText = row.find('td:eq(1)').text();
|
||
//////// let rowEndDateText = row.find('td:eq(4)').text();
|
||
//////// if (rowStartDateText != '') {
|
||
//////// rowStartDate.removeClass("emptyStart");
|
||
//////// }
|
||
//////// });
|
||
//////// }
|
||
|
||
|
||
//////// $('.workDate-table').find("tbody tr").each(function () {
|
||
//////// let row = $(this);
|
||
//////// let rowStartDate = row.find('td:eq(1)');
|
||
//////// let rowEndDate = row.find('td:eq(4)');
|
||
//////// let rowStartDateText = row.find('td:eq(1)').text();
|
||
//////// let rowEndDateText = row.find('td:eq(4)').text();
|
||
//////// if (rowStartDateText != '') {
|
||
//////// rowStartDate.removeClass("emptyStart");
|
||
//////// }
|
||
//////// });
|
||
|
||
|
||
//////// });
|
||
|
||
};
|
||
//this code handles the first button(for adding new tabs)
|
||
$(function () {
|
||
var counter = 1; // start counter from 2 since we already have one tab
|
||
$('#save1').on('click',
|
||
function (e) {
|
||
e.preventDefault();
|
||
if ($('#input1').val() != '0') {
|
||
$("#IsDelete").val('false');
|
||
var workshopId = $('#input1').val();
|
||
var workshopname = $('#input1 option:selected').text();
|
||
|
||
let navLink = $('.nav-link');
|
||
let navTitle = navLink.find('.nav-title');
|
||
// Vafa
|
||
removeDisabledJob();
|
||
$('.setContract').prop('disabled', false);
|
||
$('#startDate1').prop('disabled', false);
|
||
// Vafa
|
||
|
||
//if there was only one tab...
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
$('#tab-1').attr("data-workshopId", workshopId);
|
||
$('#tab-1').attr("data-workshopname", workshopname);
|
||
navTitle.text($('#input1 option:selected').text());
|
||
|
||
navTitle.attr("data-workshopid", workshopId);
|
||
navLink.find('.trash-icon').attr("onclick", `deleteLeftwork(this,${workshopId})`);
|
||
|
||
navTitle.removeClass("disactive");
|
||
navTitle.addClass("active");
|
||
$('#input1').val('0').trigger('change');
|
||
//$('#startDate1').prop('disabled', false);
|
||
getPersonelCode(workshopId);
|
||
$('.position-name').prop('id', `select-${workshopId}`);
|
||
getJobByWorkshopId(workshopId);
|
||
} else {
|
||
counter++;
|
||
$("#nav-title1").removeClass("active");
|
||
$('.position-name').prop('disabled', false);
|
||
|
||
// $('.position-code').prop('disabled', false);
|
||
|
||
$('.setContract').prop('disabled', false);
|
||
const newTitle = $('#input1 option:selected').text();
|
||
const newworkshopId = $('#input1 option:selected').val();
|
||
//const $existingTitle = $('.nav-title:contains("' + newTitle + '")');
|
||
var $existingTitle = false;
|
||
$('.nav-title').each(function () {
|
||
if ($(this).attr("data-workshopid") == newworkshopId) {
|
||
$existingTitle = true;
|
||
}
|
||
});
|
||
if ($existingTitle) {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
swal({
|
||
title: 'شرکت انتخاب شده در لیست وجود دارد.',
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
return;
|
||
} else {
|
||
addTab(counter);
|
||
// var selectItem = $('.tab-pane.active').find('.select-city');
|
||
// selectItem.select2();
|
||
const newTabLink = $(`<a href="#tab${counter}" class="nav-link"><span class="del-com"><i newItem="true" onclick="deleteLeftwork(this,${newworkshopId
|
||
})" class="delworkshop fa fa-trash trash-icon" style = "color: white;"></i></span><span data-workshopid="${newworkshopId
|
||
}" class="nav-title">${newTitle}</span></a>`);
|
||
$(".nav-tabs").prepend(newTabLink);
|
||
handleCompanyScroll();
|
||
|
||
// tooltip for when the title of the tabs are long
|
||
$(function () {
|
||
$('.nav-title').tooltip({
|
||
container: 'body',
|
||
fontFamily: 'IranSans',
|
||
background: 'grey',
|
||
placement: 'top',
|
||
offset: { x: 300, y: 20 },
|
||
trigger: 'hover',
|
||
html: true,
|
||
title: function () {
|
||
return `<span style="font-family: IranSans, sans-serif;">${$(this).text()}</span>`;
|
||
}
|
||
});
|
||
});
|
||
|
||
// Add the click event listener to the new tab link
|
||
newTabLink.on('click',
|
||
function (e) {
|
||
e.preventDefault();
|
||
const $tab = $(this);
|
||
const target = $tab.attr('href');
|
||
$('.nav-tabs .nav-link, .tab-pane').removeClass('active');
|
||
$tab.addClass('active');
|
||
$(target).addClass('active');
|
||
disableSaveBtn();
|
||
disableInput();
|
||
});
|
||
newTabLink.trigger('click');
|
||
var selectItem = $('.tab-pane.active').find('.select-city');
|
||
selectItem.select2();
|
||
}
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
$('#input1').val('0').trigger('change');
|
||
};
|
||
|
||
}
|
||
|
||
handleScroll();
|
||
disappearIcon();
|
||
checkPremision();
|
||
|
||
});
|
||
});
|
||
|
||
|
||
//this code handles the second button(for adding data in the first tabs table)
|
||
$(function () {
|
||
$('#save').on('click',
|
||
function (e) {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
e.preventDefault();
|
||
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let date1 = $('#startDate1').val();
|
||
let date2 = $('#lastDay1').val();
|
||
let date3 = $('#endDate1').val();
|
||
// let editIcon = activeTabPane.find(".edit-icon permission-editDate");
|
||
// let deleteIcon = activeTabPane.find(".edit-date");
|
||
// deleteIcon.removeClass("disabled-edit");
|
||
// editIcon.removeClass("disabled-edit");
|
||
let positionCode = $('.position-code').val();
|
||
let positionName = $(".position-name").val();
|
||
if (positionCode == "") {
|
||
activeTabPane.find('.position-code').addClass("errored");
|
||
} else {
|
||
activeTabPane.find('.position-code').removeClass("errored");
|
||
}
|
||
if (positionName == "") {
|
||
activeTabPane.find('.custom-select').addClass("errored");
|
||
} else {
|
||
activeTabPane.find('.custom-select').removeClass("errored");
|
||
}
|
||
if (positionName == 0) {
|
||
activeTabPane.find('.position-name').addClass("errored");
|
||
} else {
|
||
activeTabPane.find('.position-name').addClass("errored");
|
||
}
|
||
|
||
if (date1 != '' && !checkLength($('#startDate1').val(), 10)) {
|
||
if (!dateValidCheckByValue($('#startDate1'))) {
|
||
$('#startDate1').addClass("errored");
|
||
} else {
|
||
$('#startDate1').removeClass("errored");
|
||
}
|
||
}
|
||
if (date2 != '' && !checkLength($('#lastDay1').val(), 10)) {
|
||
if (!dateValidCheckByValue($('#lastDay1'))) {
|
||
$('#lastDay1').addClass("errored");
|
||
} else {
|
||
$('#lastDay1').removeClass("errored");
|
||
}
|
||
|
||
}
|
||
if (date3 != '' && !checkLength($('#endDate1').val(), 10)) {
|
||
if (!dateValidCheckByValue($('#endDate1'))) {
|
||
$('#endDate1').addClass("errored");
|
||
} else {
|
||
$('#endDate1').removeClass("errored");
|
||
}
|
||
}
|
||
|
||
var editable = false;
|
||
|
||
if ((!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) && $("#editStartDate").val() == '' && $("#editEndDate").val() == '' && $("#deleteStartDate").val() == '') {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
//check edit for startDate
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckBeforeSaveLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: {
|
||
"workshopId": workshopId,
|
||
"employeeId": @Model.EmployeeId,
|
||
"date": (date3 != '') ? date3 : date1,
|
||
"type": (date3 != '') ? 2 : 1
|
||
},
|
||
success: function (response) {
|
||
// console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
addRow(date1, date2, date3);
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ثبت تاریخ وجود ندارد.",
|
||
text: response.message,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else if (date1 != '' && (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) && $("#editStartDate").val() != '') {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
//check edit for startDate
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": date1, "type": 1 },
|
||
success: function (response) {
|
||
// console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
addRow(date1, date2, date3);
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ویرایش تاریخ وجود ندارد.",
|
||
text: response.message,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
// var tr = $(activeTabPane).find('.workDate-table tbody tr');
|
||
// tr.find('td:eq(1)').text($("#editStartDate").val());
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else {
|
||
if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
//check after Delete for startDate
|
||
if ($("#deleteStartDate").val() != '') {
|
||
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": $('#startDate1').val(), "type": 1 },
|
||
success: function (response) {
|
||
if (response.isSuccedded == true) {
|
||
if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
addRow(date1, date2, date3);
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
$("#deleteStartDate").val('');
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
|
||
swal({
|
||
title: "امکان ثبت تاریخ وجود ندارد",
|
||
text: response.message,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
|
||
|
||
} else {
|
||
|
||
if ($('#lastDay1').val() != '' && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
//check edit for endDate
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": $('#endDate1').val(), "type": 2 },
|
||
success: function (response) {
|
||
if (response.isSuccedded == true) {
|
||
if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) {
|
||
addRow(date1, date2, date3);
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
$("#deleteStartDate").val('');
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
if ($("#editLeftDate").val() != '') {
|
||
swal({
|
||
title: "امکان ویرایش تاریخ وجود ندارد",
|
||
text: `در صورت تمایل به ثبت تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید.`,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ثبت تاریخ وجود ندارد",
|
||
text: `در صورت تمایل به ثبت تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید.`,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
}
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
|
||
} else if ($('#startDate1').val() != '' && !$('#startDate1').hasClass('errored')) {
|
||
addRow(date1, date2, date3);
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
|
||
$('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
}
|
||
// addRow(date1, date2, date3);
|
||
// handleScroll();
|
||
// disableInput();
|
||
// disableSaveBtn();
|
||
// $("#deleteStartDate").val('');
|
||
}
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
});
|
||
// Add the click event listener to the new tab link
|
||
$('.nav-tabs .nav-link').on('click',
|
||
function (e) {
|
||
e.preventDefault();
|
||
updateRowNumbers();
|
||
const $tab = $(this);
|
||
const target = $tab.attr('href');
|
||
$('.nav-tabs .nav-link, .tab-pane').removeClass('active');
|
||
$tab.addClass('active');
|
||
$(target).addClass('active');
|
||
const selectItem = $('.tab-pane.active').find('.select-city');
|
||
selectItem.select2();
|
||
handleScroll();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
//employerDiagnose();
|
||
});
|
||
|
||
checkPremision();
|
||
});
|
||
|
||
$(document).on('keyup',
|
||
function (event) {
|
||
if (event.key === 'Enter' || event.key === 'Tab') {
|
||
employerDiagnose();
|
||
}
|
||
});
|
||
|
||
function vibratingAnimation(element) {
|
||
$(element).animate({ left: "-2px" }, 50)
|
||
.animate({ left: "2px" }, 50)
|
||
.animate({ left: "0px" }, 50);
|
||
}
|
||
|
||
function startDateEdit(element) {
|
||
const deletedRow = $(element).closest('tr');
|
||
deletedRow.find('td:eq(1)').text("");
|
||
deletedRow.find('td:eq(6)').text("");
|
||
disableInput();
|
||
disableSaveBtn();
|
||
disappearIcon();
|
||
checkPremision();
|
||
}
|
||
|
||
function endDateEdit(element) {
|
||
const deletedRow = $(element).closest('tr');
|
||
deletedRow.find('td:eq(3)').text("");
|
||
deletedRow.find('td:eq(4)').text("");
|
||
disableInput();
|
||
disableSaveBtn();
|
||
disappearIcon();
|
||
checkPremision();
|
||
}
|
||
|
||
$(".edit-date , .edit-icon").on("mouseenter",
|
||
function () {
|
||
vibratingAnimation(this);
|
||
});
|
||
|
||
function employerDiagnose() {
|
||
const positionTitle = $('.value').data('value');
|
||
const setContract = $(".setContract");
|
||
// if (positionTitle == '10' || positionTitle == '16' || positionTitle == '17' || positionTitle == '18') {
|
||
// setContract.prop("checked", false);
|
||
// } else {
|
||
// setContract.prop("checked", true);
|
||
// }
|
||
}
|
||
|
||
function disappearIcon() {
|
||
const activeTabPane = $('.tab-pane.active');
|
||
const table = activeTabPane.find('.workDate-table');
|
||
table.find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)').text();
|
||
const rowEndDate = row.find('td:eq(4)').text();
|
||
if (rowStartDate == "") {
|
||
row.find('td:eq(2) a').addClass("d-none");
|
||
} else {
|
||
row.find('td:eq(2) a').removeClass("d-none");
|
||
}
|
||
if (rowEndDate == "") {
|
||
row.find('td:eq(5) a').addClass("d-none");
|
||
} else {
|
||
row.find('td:eq(5) a').removeClass("d-none");
|
||
}
|
||
});
|
||
}
|
||
|
||
function editDate(element) {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
var row = $(element).closest('tr');
|
||
var id = row.attr('data-id');
|
||
var rowIndex = $(element).closest('tr').index();
|
||
var colIndex = $(element).closest('td').index();
|
||
$("#editIndex").val(row.find('td:eq(0)').text());
|
||
if (colIndex == 2) {
|
||
let startDateText = row.find('td:eq(1)').text();
|
||
$("#editStartDate").val(startDateText);
|
||
activeTabPane.find(".input2").val(startDateText).addClass("blinking");
|
||
row.find('td:eq(1)').text("");
|
||
disableInput();
|
||
disableSaveBtn();
|
||
//let activeTabPane = $('.tab-pane.active');
|
||
let editIcon = activeTabPane.find(".edit-icon");
|
||
let deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.addClass("disabled-edit");
|
||
editIcon.addClass("disabled-edit");
|
||
} else if (colIndex == 5) {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
let lastDateText = row.find('td:eq(3)').text();
|
||
let endDateText = row.find('td:eq(4)').text();
|
||
var id = row.attr('data-id');
|
||
// console.log(id);
|
||
if (id != "0" && id != 'undefined') {
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '/Admin/Company/Employees?handler=CheckEditLeftWorkInsurance',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": endDateText, "type": 2 },
|
||
success: function (response) {
|
||
// console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
$("#editLeftDate").val(lastDateText);
|
||
$("#editEndDate").val(endDateText);
|
||
activeTabPane.find(".input3").val(lastDateText).addClass("blinking");
|
||
activeTabPane.find(".input4").val(endDateText).addClass("blinking");
|
||
row.find('td:eq(3)').text("");
|
||
row.find('td:eq(4)').text("");
|
||
disableInput();
|
||
disableSaveBtn();
|
||
//let activeTabPane = $('.tab-pane.active');
|
||
const editIcon = activeTabPane.find(".edit-icon");
|
||
const deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.addClass("disabled-edit");
|
||
editIcon.addClass("disabled-edit");
|
||
} else {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
swal({
|
||
title: "امکان ویرایش ترک کار این پرسنل وجود ندارد. ",
|
||
text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
const tr = $(activeTabPane).find('.workDate-table tbody tr');
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else {
|
||
$("#editLeftDate").val(lastDateText);
|
||
$("#editEndDate").val(endDateText);
|
||
activeTabPane.find(".input3").val(lastDateText).addClass("blinking");
|
||
activeTabPane.find(".input4").val(endDateText).addClass("blinking");
|
||
row.find('td:eq(3)').text("");
|
||
row.find('td:eq(4)').text("");
|
||
disableInput();
|
||
disableSaveBtn();
|
||
// let activeTabPane = $('.tab-pane.active');
|
||
let editIcon = activeTabPane.find(".edit-icon");
|
||
let deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.addClass("disabled-edit");
|
||
editIcon.addClass("disabled-edit");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
$(".edit-icon").unbind('click').on("click",
|
||
function (e) {
|
||
editDate(this);
|
||
});
|
||
|
||
$(function () {
|
||
$('#result-modal [data-parent-modal]').on('click',
|
||
function (e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
const parentModalId = $(this).data('parent-modal');
|
||
$(parentModalId).modal('hide');
|
||
});
|
||
});
|
||
handleCompanyScroll();
|
||
//this code checks the rows, if there are empty rows,they will be filled, and if there is none, a new row will be added
|
||
let addRow = (date1, date2, date3) => {
|
||
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
$("#editStartDate").val('');
|
||
$("#editLeftDate").val('');
|
||
$("#editEndDate").val('');
|
||
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let table = activeTabPane.find('.workDate-table');
|
||
let tableRow = table.find('tbody tr');
|
||
let conflictFound = false;
|
||
tableRow.each(function (rowIndex) {
|
||
let row = $(this);
|
||
let iconShown = row.find('td:eq(2) a').hasClass("d-none");
|
||
let rowStartDate = row.find('td:eq(1)').text(); // Get the start date of the row
|
||
let rowEndDate = row.find('td:eq(4)').text(); // Get the end date of the row
|
||
const $existingDate1 = row.find(`td:eq(1):contains("${date1}")`);
|
||
|
||
var index = '';
|
||
if ($("#deleteIndex").val() != '') {
|
||
index = $("#deleteIndex").val();
|
||
} else if ($("#editIndex").val() != '')
|
||
index = $("#editIndex").val();
|
||
else {
|
||
index = rowIndex + 1;
|
||
}
|
||
|
||
// console.log(index);
|
||
|
||
|
||
let trNumber = table.find(`tr:eq(${index})`);
|
||
let firstTd = trNumber.find('td:eq(1)').text();
|
||
let lastTd = trNumber.find('td:eq(4)').text();
|
||
|
||
if (date1 != '' && $existingDate1.length > 0) {
|
||
//$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
swal({
|
||
title: `تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
const $existingDate2 = row.find(`td:eq(4):contains("${date1}")`);
|
||
if (date1 != '' && $existingDate2.length > 0) {
|
||
//$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
swal({
|
||
title: `تاریخ شروع با تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
const $existingDate3 = row.find(`td:eq(4):contains("${date3}")`);
|
||
if (date3 != '' && $existingDate3.length > 0) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
swal({
|
||
title: `تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
const $existingDate4 = row.find(`td:eq(1):contains("${date3}")`);
|
||
if (date3 != '' && $existingDate4.length > 0) {
|
||
//$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
swal({
|
||
title: `تاریخ پایان با تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#endDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
const $existingDate5 = row.find(`td:eq(1):contains("${date2}")`);
|
||
if (date2 != '' && $existingDate5.length > 0) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ آخرین روز کاری با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
swal({
|
||
title: `تاریخ پایان با تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
if (rowStartDate != '' && date3 != '' && date3 > rowStartDate && date3 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
console.log(11);
|
||
swal({
|
||
title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
|
||
if (rowStartDate != '' && date3 != '' && rowEndDate == '' && date3 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
console.log(22);
|
||
swal({
|
||
title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
console.log(33);
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
console.log(44);
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) {
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) {
|
||
swal({
|
||
title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) {
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
swal({
|
||
title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
});
|
||
if (!conflictFound) {
|
||
//let emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
var index = '';
|
||
if ($("#editIndex").val() != '') {
|
||
index = $("#editIndex").val();
|
||
} else if ($("#deleteIndex").val() != '') {
|
||
index = $("#deleteIndex").val();
|
||
}
|
||
|
||
let emptyRow = null;
|
||
if (index == '')
|
||
emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
else
|
||
emptyRow = table.find(`tr:eq(${index})`);
|
||
|
||
if (emptyRow.length > 0) {
|
||
if (date1 != '') {
|
||
emptyRow.children('td:eq(1)').text(date1);
|
||
}
|
||
if (date2 != '') {
|
||
emptyRow.children('td:eq(3)').text(date2);
|
||
}
|
||
if (date3 != '') {
|
||
emptyRow.children('td:eq(4)').text(date3);
|
||
}
|
||
emptyRow.children('td:eq(6)').text("_");
|
||
// disappearIcon(); checkPremision();
|
||
activeTabPane.find(".date").removeClass("blinking");
|
||
}
|
||
if (emptyRow.length === 0 && !conflictFound) {
|
||
let rowCount = table.find("tbody tr").length;
|
||
let newRow = `<tr data-id="0"><td>${rowCount + 1}</td><td>${date1
|
||
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class="edit-date first-edit permission-removeDate"><i class="fa fa-trash trash trash-icon" aria-hidden="true"></i></a><a href="#" class="edit-icon permission-editDate"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td>${date2}</td><td>${date3
|
||
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class=" edit-date second-edit permission-removeDate"><i class="fa fa-trash trash trash-icon" aria-hidden="true"></i></a><a href="#" class="edit-icon permission-editDate"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td>_</td></tr>`;
|
||
table.find("tbody").append(newRow);
|
||
disableInput();
|
||
disableSaveBtn();
|
||
$('#startDate1').val("");
|
||
$('#lastDay1').val("");
|
||
$('#endDate1').val("");
|
||
}
|
||
disappearIcon();
|
||
checkPremision();
|
||
let editIcon = activeTabPane.find(".edit-icon");
|
||
let deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
$("#editIndex").val('');
|
||
$("#deleteIndex").val('');
|
||
$(".edit-date , .edit-icon").on("mouseenter",
|
||
function () {
|
||
vibratingAnimation(this);
|
||
});
|
||
sortDates();
|
||
updateRowNumbers();
|
||
|
||
|
||
}
|
||
|
||
};
|
||
|
||
//this code is like addRow for the tabs except the first tab
|
||
let addRow2 = (counter, date1, date2, date3) => {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let table = activeTabPane.find('.workDate-table');
|
||
let tableRow = table.find('tbody tr');
|
||
let emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
let startDate = activeTabPane.find('.input2');
|
||
let lastDay = activeTabPane.find('.input3');
|
||
let endDate = activeTabPane.find('.input4');
|
||
let conflictFound = false;
|
||
tableRow.each(function (rowIndex) {
|
||
let row = $(this);
|
||
let iconShown = row.find('td:eq(2) a').hasClass("d-none");
|
||
let rowStartDate = row.find('td:eq(1)').text();
|
||
let rowEndDate = row.find('td:eq(4)').text();
|
||
var index = '';
|
||
if ($("#deleteIndex").val() != '') {
|
||
index = $("#deleteIndex").val();
|
||
} else if ($("#editIndex").val() != '')
|
||
index = $("#editIndex").val();
|
||
else {
|
||
index = rowIndex + 1;
|
||
}
|
||
|
||
let trNumber = table.find(`tr:eq(${index})`);
|
||
let firstTd = trNumber.find('td:eq(1)').text();
|
||
let lastTd = trNumber.find('td:eq(4)').text();
|
||
|
||
const $existingDate1 = row.find(`td:eq(1):contains("${date1}")`);
|
||
if (date1 != '' && $existingDate1.length > 0) {
|
||
//$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
swal({
|
||
title: `تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
const $existingDate2 = row.find(`td:eq(4):contains("${date1}")`);
|
||
if (date1 != '' && $existingDate2.length > 0) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
swal({
|
||
title: `تاریخ شروع با تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
|
||
const $existingDate3 = row.find(`td:eq(4):contains("${date2}")`);
|
||
if (date2 != '' && $existingDate3.length > 0) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
swal({
|
||
title: `تاریخ پایان در ردیف${row.find('td:eq(0)').text()} وارد شده است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
lastDay.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
const $existingDate4 = row.find(`td:eq(1):contains("${date2}")`);
|
||
if (date2 != '' && $existingDate4.length > 0) {
|
||
swal({
|
||
title: `تاریخ آخرین روز کاری با تاریخ شروع در ردیف${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
//$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ آخرین روز کاری با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
lastDay.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
const $existingDate5 = row.find(`td:eq(1):contains("${date3}")`);
|
||
if (date3 != '' && $existingDate5.length > 0) {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
swal({
|
||
title: `تاریخ پایان با تاریخ شروع در ردیف${row.find('td:eq(0)').text()} برابر است.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
endDate.addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
if (rowStartDate != '' && date2 != '' && date2 > rowStartDate && date2 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
swal({
|
||
title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
lastDay.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date2 != '' && rowEndDate == '' && date2 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
swal({
|
||
title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
lastDay.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
swal({
|
||
title: `تاریخ شروع با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') {
|
||
console.log(44);
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) {
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) {
|
||
swal({
|
||
title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) {
|
||
swal({
|
||
title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
lastDay.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) {
|
||
swal({
|
||
title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
lastDay.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
});
|
||
if (!conflictFound) {
|
||
var index = '';
|
||
if ($("#editIndex").val() != '')
|
||
index = $("#editIndex").val();
|
||
else if ($("#deleteIndex").val() != '')
|
||
index = $("#deleteIndex").val();
|
||
|
||
// let emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
let emptyRow = null;
|
||
if (index == '')
|
||
emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
else
|
||
emptyRow = table.find(`tr:eq(${index})`);
|
||
|
||
|
||
if (emptyRow.length > 0) {
|
||
if (date1 != '')
|
||
emptyRow.children('td:eq(1)').text(date1);
|
||
if (date2 != '')
|
||
emptyRow.children('td:eq(3)').text(date2);
|
||
if (date3 != '')
|
||
emptyRow.children('td:eq(4)').text(date3);
|
||
emptyRow.children('td:eq(6)').text("_");
|
||
// disappearIcon(); checkPremision();
|
||
activeTabPane.find(".date").removeClass("blinking");
|
||
|
||
}
|
||
if (emptyRow.length === 0) {
|
||
let rowCount = table.find("tbody tr").length;
|
||
let newRow = `<tr><td>${rowCount + 1}</td><td>${date1
|
||
}</td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date first-edit permission-removeDate"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td>${date2}</td><td>${date3
|
||
}</td><td style="border-right-width: 0;" class="permision"><a onclick=deleteDate(this,"",0,"last") href="#" class=" edit-date second-edit permission-removeDate"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td>_</td></tr>`;
|
||
table.find("tbody").append(newRow);
|
||
disableInput();
|
||
disableSaveBtn();
|
||
// disappearIcon(); checkPremision();
|
||
|
||
}
|
||
disappearIcon();
|
||
checkPremision();
|
||
let editIcon = activeTabPane.find(".edit-icon");
|
||
let deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
$(".edit-date , .edit-icon").on("mouseenter",
|
||
function () {
|
||
vibratingAnimation(this);
|
||
});
|
||
sortDates();
|
||
updateRowNumbers();
|
||
$("#editIndex").val('');
|
||
$("#deleteIndex").val('');
|
||
|
||
}
|
||
|
||
};
|
||
|
||
//this code checks the row number
|
||
let updateRowNumbers = () => {
|
||
|
||
const activeTabPane = $('.tab-pane.active');
|
||
const rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
rows.each(function (index) {
|
||
$(this).find("td:first-child").text(index + 1);
|
||
});
|
||
};
|
||
|
||
//this code sorts the table based on the second date column in descending order
|
||
function sortDates() {
|
||
const activeTabPane = $('.tab-pane.active');
|
||
const table = activeTabPane.find('.workDate-table');
|
||
const rows = table.find('tr:gt(0)').toArray();
|
||
rows.sort(function (a, b) {
|
||
const date1a = new Date($(a).find('td:eq(1)').text().replace(/\//g, '-'));
|
||
const date1b = new Date($(b).find('td:eq(1)').text().replace(/\//g, '-'));
|
||
return date1b - date1a;
|
||
});
|
||
for (let i = 0; i < rows.length; i++) {
|
||
table.append(rows[i]);
|
||
}
|
||
}
|
||
|
||
//date keyup for tab-1
|
||
$(".date").keyup(function () {
|
||
const value = $(this).val();
|
||
const lengthValue = value.length;
|
||
const id = $(this).attr('id');
|
||
|
||
|
||
if (lengthValue == 10) {
|
||
if (!dateValidCheck(this)) {
|
||
$(this).addClass("errored");
|
||
} else {
|
||
$(this).removeClass("errored");
|
||
|
||
if (id == 'lastDay1') {
|
||
setDate(value, 'lastDay1', 'endDate1', true);
|
||
} else if (id == 'endDate1') {
|
||
setDate(value, 'endDate1', 'lastDay1', false);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
//date keyup for tab-except1
|
||
$(".date").keyup(function () {
|
||
const value = $(this).val();
|
||
const lengthValue = value.length;
|
||
const activeTabPane = $('.tab-pane.active');
|
||
const startDate = activeTabPane.find('.input2');
|
||
const lastDay = activeTabPane.find('.input3');
|
||
const endDate = activeTabPane.find('.input4');
|
||
const endDateId = endDate.attr('id');
|
||
const lastDateId = lastDay.attr('id');
|
||
const id = $(this).attr('id');
|
||
|
||
|
||
if (lengthValue == 10) {
|
||
if (!dateValidCheck(this)) {
|
||
$(this).addClass("errored");
|
||
} else {
|
||
$(this).removeClass("errored");
|
||
|
||
if (id == lastDateId) {
|
||
setDate(value, lastDateId, endDateId, true);
|
||
} else if (id == endDateId) {
|
||
setDate(value, endDateId, lastDateId, false);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
function setDate(value, fieldIdInput, fieldIdResult, islastDay) {
|
||
|
||
let urlPost = '';
|
||
|
||
if (islastDay == true) {
|
||
urlPost = '@Url.Page("/Company/Employees/Index", "AfterDate")';
|
||
} else {
|
||
urlPost = '@Url.Page("/Company/Employees/Index", "BeforeDate")';
|
||
}
|
||
$.ajax({
|
||
/* contentType: 'charset=utf-8',*/
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: urlPost,
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "date": value },
|
||
success: function (response) {
|
||
|
||
|
||
$(`#${fieldIdResult}`).val(response.resultDate);
|
||
},
|
||
failure: function (response) {
|
||
//console.log(5, response);
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
|
||
$("#btnSaveData").click(function () {
|
||
$(".input-send-data").remove();
|
||
|
||
$(".tab-pane").each(function (i) {
|
||
var workshopid = $(this).attr("data-workshopid");
|
||
var workshopName = $(this).attr("data-workshopName");
|
||
var employeeId = @Model.EmployeeId;
|
||
const personnelCode = $(this).find('input.position-code');
|
||
var jobId = $(this).find('.ul-search').find('span.value').attr('data-value');
|
||
var includeStatus = $(this).find('input[type=checkbox]').is(":checked");
|
||
//console.log(workshopid);
|
||
//console.log(jobId);
|
||
//console.log($("#select-"+workshopid).val());
|
||
|
||
const haspersonelcode = personnelCode.attr("data-haspersonelcode");
|
||
|
||
if (haspersonelcode.toLowerCase() != "true") {
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].HasPersonelCode" id="PersonnelCode_${i
|
||
}__HasPersonelCode" value="false" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkshopId" id="PersonnelCode_${i
|
||
}__WorkshopId" value="${workshopid}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].EmployeeId" id="PersonnelCode_${i
|
||
}__EmployeeId" value="${employeeId}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].PersonnelCode" id="PersonnelCode_${i
|
||
}__PersonnelCode" value="${personnelCode.val()}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkShopName" id="PersonnelCode_${i
|
||
}__WorkShopName" value="${workshopName}" />`);
|
||
} else {
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].HasPersonelCode" id="PersonnelCode_${i
|
||
}__HasPersonelCode" value="true" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkshopId" id="PersonnelCode_${i
|
||
}__WorkshopId" value="0" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].EmployeeId" id="PersonnelCode_${i
|
||
}__EmployeeId" value="0" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].PersonnelCode" id="PersonnelCode_${i
|
||
}__PersonnelCode" value="0" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkShopName" id="PersonnelCode_${i
|
||
}__WorkShopName" value="" />`);
|
||
}
|
||
var index2 = 0;
|
||
$(this).find('table tr').each(function (x) {
|
||
const leftWorkDate = $(this).find('td:eq(4)').text().trim();
|
||
const startWorkDate = $(this).find('td:eq(1)').text().trim();
|
||
const id = $(this).attr("data-id");
|
||
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i
|
||
}].WorkshopId" id="LeftWorkInsuranceGroups_${i}__WorkshopId" value="${workshopid}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i
|
||
}].WorkshopName" id="LeftWorkInsuranceGroups_${i}__WorkshopName" value="${workshopName}" />`);
|
||
|
||
if (startWorkDate != '') {
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].WorkshopId" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__WorkshopId" value="${workshopid}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].Id" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__Id" value="${id}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].EmployeeId" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__EmployeeId" value="${employeeId}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].WorkshopName" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__WorkshopName" value="${workshopName
|
||
}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].StartWorkDate" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__StartWorkDate" value="${startWorkDate
|
||
}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].LeftWorkDate" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__LeftWorkDate" value="${leftWorkDate
|
||
}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].JobId" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__JobId" value="${jobId}" />`);
|
||
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups[${i}].LeftworkInsuranceViewModels[${index2
|
||
}].IncludeStatus" id="LeftWorkInsuranceGroups_${i}__LeftworkInsuranceViewModels_${index2}__IncludeStatus" value="${includeStatus
|
||
}" />`);
|
||
//$("#divAppendData").append('<input type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+x+'].EmployeeFullName" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+x+'__EmployeeFullName" value="'+leftWorkDate+'" />');
|
||
index2 = index2 + 1;
|
||
}
|
||
});
|
||
});
|
||
let conflictFound = false;
|
||
$('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText == '' && rowEndDateText != '') {
|
||
rowStartDate.addClass("emptyStart");
|
||
conflictFound = true;
|
||
}
|
||
});
|
||
if (!conflictFound) {
|
||
$("#employee").submit();
|
||
}
|
||
|
||
//$('#sendData').click();
|
||
//$("#employee").submit();
|
||
});
|
||
|
||
|
||
$('#employee').submit(function (e) {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
$.ajax({
|
||
async: false,
|
||
type: "POST",
|
||
url: $(this).attr('action'),
|
||
data: $(this).serialize(),
|
||
success: function (response) {
|
||
console.log(response);
|
||
if (response.flag == 'list') {
|
||
let result = '<ul>';
|
||
for (let i = 0; i < response.endResult.length; i++) {
|
||
if (response.endResult[i].isSuccedded == true) {
|
||
result = result + '<li ><div class="alert alert-success">' + response.endResult[i].message + '</div></li>';
|
||
} else {
|
||
result = result + '<li><div class="alert alert-danger">' + response.endResult[i].message + '</div></li>';
|
||
}
|
||
}
|
||
result = result + '</ul>';
|
||
$("#resultdiv").html(result);
|
||
$("#result-modal").modal('show');
|
||
} else {
|
||
if (response.endResult.isSuccedded == true) {
|
||
//$.Notification.autoHideNotify('success', 'top right', response.endResult.message);
|
||
swal({
|
||
title: response.endResult.message,
|
||
text: "",
|
||
type: "success",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
confirmButtonText: "بستن",
|
||
//cancelButtonText: "خیر",
|
||
closeOnConfirm: true,
|
||
customClass: "successSwall"
|
||
});
|
||
} else {
|
||
// $.Notification.autoHideNotify('error', 'top right', response.endResult.message);
|
||
swal({
|
||
title: response.endResult.message,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
});
|
||
return false;
|
||
});
|
||
|
||
|
||
function checkcountRow() {
|
||
|
||
$(".tab-pane").each(function () {
|
||
const tab = $(this);
|
||
const table = $(this).find('table');
|
||
table.find('tr').each(function (x) {
|
||
const leftWorkDate = $(this).find('td:eq(4)').text().trim();
|
||
const startWorkDate = $(this).find('td:eq(1)').text().trim();
|
||
disableInput();
|
||
disableSaveBtn();
|
||
|
||
});
|
||
|
||
const trCount = $(this).find('table tr').length - 1;
|
||
const newRowNumber = 5 - trCount;
|
||
if (trCount < 5) {
|
||
for (let index = 0; index < newRowNumber; index++) {
|
||
const newRow = `<tr><td>${trCount + index + 1
|
||
}</td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class="edit-date d-none first-edit permission-removeDate"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td><td></td><td style="border-right-width: 0;" class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class="edit-date d-none second-edit permission-removeDate"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i style="color: #f9792bf7;" class="fa fa-edit"></i></a></td><td></td></tr>`;
|
||
table.find("tbody").append(newRow);
|
||
disappearIcon();
|
||
//checkPremision();
|
||
}
|
||
}
|
||
});
|
||
sortDates();
|
||
handleScroll();
|
||
checkPremision();
|
||
}
|
||
|
||
//this function handles the show or hide of the scrollbar
|
||
function handleScroll() {
|
||
const activeTabPane = $('.tab-pane.active');
|
||
const rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
const rowCount = rows.length;
|
||
const content = activeTabPane.find('.table-content');
|
||
if (rowCount > 5) {
|
||
content.removeClass('hide-scrollbar');
|
||
} else {
|
||
content.addClass('hide-scrollbar');
|
||
}
|
||
}
|
||
|
||
//this function handles the show or hide of the scrollbar of the company titles
|
||
function handleCompanyScroll() {
|
||
if ($('.nav-tabs a').length <= 4) {
|
||
$('.nav-tabs').addClass('hide-scrollbar');
|
||
} else {
|
||
$('.nav-tabs').removeClass('hide-scrollbar');
|
||
}
|
||
}
|
||
|
||
// this function disable/enable the input fields based on the data in the table
|
||
function disableSaveBtn() {
|
||
const activeTabPane = $('.tab-pane');
|
||
const table = activeTabPane.find(".workDate-table tbody").get(0);
|
||
const navLink = $('.nav-link');
|
||
const navTitle = navLink.find('.nav-title');
|
||
const firstColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[1].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
const secondColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[3].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
const thirdColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[4].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
$("#save1").removeClass("buttonDeactived");
|
||
} else if (firstColumnData.length > secondColumnData.length) {
|
||
$("#save1").addClass("buttonDeactived");
|
||
} else if (firstColumnData.length == 0 && secondColumnData.length == 0) {
|
||
$("#save1").addClass("buttonDeactived");
|
||
} else {
|
||
$("#save1").removeClass("buttonDeactived");
|
||
}
|
||
}
|
||
|
||
function disableInput() {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let table = activeTabPane.find(".workDate-table tbody").get(0);
|
||
let navLink = $('.nav-link');
|
||
let navTitle = navLink.find('.nav-title');
|
||
|
||
|
||
let firstColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[1].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
|
||
|
||
let secondColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[3].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
|
||
|
||
let thirdColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[4].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
|
||
|
||
// console.log(firstColumnData.length);
|
||
// console.log(secondColumnData.length);
|
||
//console.log(thirdColumnData.length);
|
||
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
disabledJob();
|
||
activeTabPane.find('.input2').prop('disabled', true);
|
||
activeTabPane.find('.input3').prop('disabled', true);
|
||
activeTabPane.find('.input4').prop('disabled', true);
|
||
if (!activeTabPane.find('.input2').hasClass('blinking')) {
|
||
activeTabPane.find('.input2').val('');
|
||
} else if (!activeTabPane.find('.input3').hasClass('blinking')) {
|
||
activeTabPane.find('.input3').val('');
|
||
} else if (!activeTabPane.find('.input4').hasClass('blinking')) {
|
||
activeTabPane.find('.input4').val('');
|
||
}
|
||
activeTabPane.find('.position-name').prop('disabled', true);
|
||
//$('.position-code').prop('disabled', true);
|
||
activeTabPane.find('.setContract').prop('disabled', true);
|
||
//$("#save1").removeClass("buttonDeactived");
|
||
} else if (firstColumnData.length > secondColumnData.length) {
|
||
removeDisabledJob();
|
||
activeTabPane.find('.input2').prop('disabled', true);
|
||
activeTabPane.find('.input2').val('');
|
||
activeTabPane.find('.input3').prop('disabled', false);
|
||
activeTabPane.find('.input4').prop('disabled', false);
|
||
} else {
|
||
removeDisabledJob();
|
||
activeTabPane.find('.input3').val('');
|
||
activeTabPane.find('.input4').val('');
|
||
activeTabPane.find('.input2').prop('disabled', false);
|
||
activeTabPane.find('.input3').prop('disabled', true);
|
||
activeTabPane.find('.input4').prop('disabled', true);
|
||
activeTabPane.find('.position-name').prop('disabled', false);
|
||
//$("#save1").removeClass("buttonDeactived");
|
||
activeTabPane.find('.setContract').prop('disabled', false);
|
||
}
|
||
var haspersonelcode = activeTabPane.find('input.position-code').attr("data-haspersonelcode");
|
||
if (haspersonelcode.toLowerCase() == "true" || haspersonelcode == '') {
|
||
activeTabPane.find('input.position-code').prop('disabled', true);
|
||
} else {
|
||
activeTabPane.find('input.position-code').prop('disabled', false);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
// tooltip for when the title of the tabs are long
|
||
$(function () {
|
||
$('.nav-title').tooltip({
|
||
container: 'body',
|
||
fontFamily: 'IranSans',
|
||
background: 'grey',
|
||
placement: 'top',
|
||
offset: { x: 150, y: 20 },
|
||
trigger: 'hover',
|
||
html: true,
|
||
title: function () {
|
||
return `<span style="font-family: IranSans, sans-serif;">${$(this).text()}</span>`;
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
function deleteLeftwork(element, workshopId) {
|
||
swal({
|
||
title: "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.",
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
confirmButtonText: "بله",
|
||
cancelButtonText: "خیر",
|
||
closeOnConfirm: false,
|
||
closeOnCancel: true
|
||
},
|
||
function (isConfirm) {
|
||
if (isConfirm) {
|
||
|
||
const newItem = $(element).attr('newitem');
|
||
var result = false;
|
||
if (newItem == null) {
|
||
$("#IsDelete").val('true');
|
||
//result=deleteWorkshop(workshopId);
|
||
deleteWorkshop(workshopId).then(function (res) {
|
||
result = res;
|
||
afterDeleteWorkshop(element, workshopId, result, newItem);
|
||
}).catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
} else {
|
||
afterDeleteWorkshop(element, workshopId, result, newItem);
|
||
}
|
||
disableInput();
|
||
disableSaveBtn();
|
||
// disappearIcon(); checkPremision();
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function getPersonelCode(workshopId) {
|
||
//console.log(workshopId);
|
||
const employeeId = @Model.EmployeeId;
|
||
// var workshopId=$("#input1").val();
|
||
|
||
$.ajax({
|
||
/* contentType: 'charset=utf-8',*/
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "GetPersonelCode")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": Number(workshopId), "employeeId": Number(employeeId) },
|
||
success: function (response) {
|
||
|
||
const inputCode = $(`div[data-workshopid|='${workshopId}']`).find("input.position-code");
|
||
// var inputCode = $('.tab-pane').find(`[data-workshopid='${workshopId}']`).find("input.position-code");
|
||
//var inputClass=inputCode.attr("class");
|
||
inputCode.val(response.personnelCode);
|
||
if (response.hasPersonelCode) {
|
||
disableInput();
|
||
inputCode.prop("disabled", true);
|
||
inputCode.attr("data-haspersonelcode", "true");
|
||
} else {
|
||
inputCode.prop("disabled", false);
|
||
inputCode.attr("data-haspersonelcode", "false");
|
||
}
|
||
|
||
disableSaveBtn();
|
||
},
|
||
failure: function (response) {
|
||
// console.log(5, response);
|
||
}
|
||
});
|
||
}
|
||
|
||
var timerLeftWorkInsurance = null;
|
||
$('body').on('keyup',
|
||
'.select2-search__field',
|
||
function () {
|
||
//clearTimeout(timerLeftWorkInsurance);
|
||
//timerLeftWorkInsurance = setTimeout(jobListByText, 1000);
|
||
jobListByText();
|
||
});
|
||
|
||
lockLeftWorkInsurance = false;
|
||
lastValueLeftWorkInsurance = '';
|
||
|
||
function jobListByText() {
|
||
const this_ = $(".select2-search__field");
|
||
var text = $(this_).val();
|
||
var selectItem = $('.tab-pane.active').find('.select-city');
|
||
const workshopid = $('.tab-pane.active').attr('data-workshopid');
|
||
|
||
const selectControls = $(this_).attr("aria-controls");
|
||
if (text != "" && selectControls != "select2-input1-results") {
|
||
if (!lockLeftWorkInsurance) {
|
||
lockLeftWorkInsurance = true;
|
||
lastValueLeftWorkInsurance = text;
|
||
} else {
|
||
return;
|
||
}
|
||
$.ajax({
|
||
async: false,
|
||
/* contentType: 'charset=utf-8',*/
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "JobListByText")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "textSearch": text, "workshopId": workshopid },
|
||
success: function (response) {
|
||
lockLeftWorkInsurance = false;
|
||
$.each(response.jobList,
|
||
function (i, item) {
|
||
if (selectItem.find(`option[value='${item.id}']`).length == 0) {
|
||
const newOption = new Option((item.jobName + ' | ' + item.jobCode), item.id, true, true);
|
||
selectItem.append(newOption);
|
||
}
|
||
selectItem.val('0');
|
||
});
|
||
if (text != lastValueLeftWorkInsurance) {
|
||
//console.log(100);
|
||
jobListByText($(".select2-search__field"));
|
||
}
|
||
},
|
||
failure: function (response) {
|
||
lockLeftWorkInsurance = false;
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else {
|
||
//console.log(10);
|
||
}
|
||
}
|
||
|
||
function getJobByWorkshopId(workshopId) {
|
||
$.ajax({
|
||
async: false,
|
||
/* contentType: 'charset=utf-8',*/
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "JobListByWorkshopId")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId },
|
||
success: function (response) {
|
||
// console.log(response);
|
||
$.each(response.jobList,
|
||
function (i, item) {
|
||
const newOption = new Option((item.jobName + ' | ' + item.jobCode), item.id, true, true);
|
||
$(`#select-${workshopId}`).append(newOption);
|
||
});
|
||
$(`#select-${workshopId}`).val('0');
|
||
},
|
||
failure: function (response) {
|
||
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
}
|
||
|
||
function checkPremision() {
|
||
if (list.indexOf(10420) == -1) {
|
||
$(".permission-removeDate").addClass("d-none");
|
||
}
|
||
if (list.indexOf(10425) == -1) {
|
||
$(".permission-editDate").addClass("d-none");
|
||
}
|
||
if (list.indexOf(10419) == -1) {
|
||
$('.delworkshop').remove();
|
||
}
|
||
}
|
||
|
||
function deleteWorkshop(id) {
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
return new Promise(function (resolve, reject) {
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "DeleteLeftWorkInsuranceWorkshop")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": id, "employeeId": @Model.EmployeeId },
|
||
success: function (response) {
|
||
console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
if (response.message != null) {
|
||
swal({
|
||
title: response.message,
|
||
text: "",
|
||
type: "success",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
confirmButtonText: "بستن",
|
||
//cancelButtonText: "خیر",
|
||
closeOnConfirm: true,
|
||
customClass: "successSwall"
|
||
});
|
||
}
|
||
resolve(true);
|
||
} else {
|
||
//$.Notification.autoHideNotify('error', 'top right', response.message);
|
||
|
||
swal({
|
||
title: response.message,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
closeOnCancel: true,
|
||
customClass: "errorSwall"
|
||
});
|
||
resolve(false);
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
reject(response);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
function afterDeleteWorkshop(element, workshopId, result, newItem) {
|
||
const navLink = $(element).closest('.nav-link');
|
||
const navTitle = navLink.find('.nav-title');
|
||
|
||
if ((workshopId != 0 && result == true) || newItem == "true") {
|
||
|
||
if ($(element).closest('.nav-link').index() === 0 && $('.nav-tabs a').length === 1) {
|
||
navTitle.text('نام شرکت');
|
||
navTitle.addClass("disactive");
|
||
const activeTabPane = $('.tab-pane.active');
|
||
activeTabPane.find("input.position-code").val("");
|
||
activeTabPane.find(".position-name").val(0);
|
||
const rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
const rowCount = rows.length;
|
||
if (rowCount === 6) {
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
}
|
||
rows.each(function () {
|
||
if (rowCount <= 5) {
|
||
$(this).find('td:eq(6)').text("");
|
||
//$(this).find('td:eq(5)').text("");
|
||
$(this).find('td:eq(4)').text("");
|
||
$(this).find('td:eq(3)').text("");
|
||
// $(this).find('td:eq(2)').text("");
|
||
$(this).find('td:eq(1)').text("");
|
||
disappearIcon();
|
||
|
||
}
|
||
if (rowCount > 5) {
|
||
$(this).remove();
|
||
updateRowNumbers();
|
||
}
|
||
});
|
||
} else {
|
||
const href_ = $(element).closest('.nav-link').attr("href");
|
||
|
||
const tabId = href_.replace('#', '');
|
||
|
||
|
||
$(element).closest('.nav-link').remove();
|
||
handleCompanyScroll();
|
||
$(`#${tabId}`).remove();
|
||
|
||
if ($(element).closest('.nav-link').hasClass('active')) {
|
||
$('.nav-tabs a:first-child').trigger('click');
|
||
}
|
||
}
|
||
swal({
|
||
title: "عملیات با موفقیت حذف شد.",
|
||
text: "",
|
||
type: "success",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
confirmButtonText: "بستن",
|
||
//cancelButtonText: "خیر",
|
||
closeOnConfirm: true,
|
||
customClass: "successSwall"
|
||
});
|
||
}
|
||
checkPremision();
|
||
}
|
||
|
||
function deleteDate(element, date, workshopId, type) {
|
||
const deletedRow = $(element).closest('tr');
|
||
const endDate = deletedRow.find('td:eq(3)').text();
|
||
$("#deleteIndex").val(deletedRow.find('td:eq(0)').text());
|
||
|
||
$('.sweet-alert').removeClass("successSwall");
|
||
$('.sweet-alert').removeClass("errorSwall");
|
||
|
||
if (type == "first" && endDate != "") {
|
||
swal({
|
||
title: "لطفا برای حذف تاریخ شروع به کار، ابتدا تاریخ ترک کار را حذف کنید.",
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
} else if (workshopId != 0 && date != '') {
|
||
const hasInsuranceList = deletedRow.attr("data-hasInsuranceList");
|
||
//console.log(hasInsuranceList);
|
||
if (type == "first" && hasInsuranceList.toLowerCase() == "true")
|
||
$("#deleteStartDate").val(date);
|
||
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckDeleteLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": date, "type": (type == "first" ? 1 : 2) },
|
||
success: function (response) {
|
||
//console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
if (type == "first")
|
||
startDateEdit(element);
|
||
else
|
||
endDateEdit(element);
|
||
} else {
|
||
//$.Notification.autoHideNotify('error', 'top right', response.message);
|
||
swal({
|
||
title: response.message, //response.endResult.message,
|
||
text: "",
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
|
||
const tr = $(element).parent().parent();
|
||
if (type == "first") {
|
||
tr.find('td:eq(1)').addClass("emptyStart");
|
||
} else {
|
||
tr.find('td:eq(3)').addClass("emptyStart");
|
||
tr.find('td:eq(4)').addClass("emptyStart");
|
||
}
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else if (workshopId == 0 || date == '') {
|
||
if (type == "first")
|
||
startDateEdit(element);
|
||
else
|
||
endDateEdit(element);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
function removeDisabledJob() {
|
||
const activeTabPane = $('.tab-pane.active');
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
|
||
if (activeTabPane.find(".dadmehr-select-search").hasClass('disabled')) {
|
||
activeTabPane.find(".custom-select").removeClass('disabled');
|
||
activeTabPane.find(".dadmehr-select-search").removeClass('disabled');
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
|
||
activeTabPane.find(".custom-select").html(
|
||
`<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobListByText")"><li> <input onkeyup=searchTextLeftWorkInsurance(event,this,"@Url.Page("/Company/Employees/Index", "JobListByText")",${workshopId}) class= "text-right input-text" /> </li></ul><ul class= "result options text-right" ></ul>`
|
||
);
|
||
}
|
||
}
|
||
|
||
function disabledJob() {
|
||
|
||
const activeTabPane = $('.tab-pane.active');
|
||
activeTabPane.find(".custom-select").addClass('disabled');
|
||
activeTabPane.find(".dadmehr-select-search").addClass('disabled');
|
||
const workshopId = activeTabPane.attr("data-workshopid");
|
||
|
||
activeTabPane.find(".custom-select").html(
|
||
`<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobListByText")"><li> <input onkeyup=searchTextLeftWorkInsurance(event,this,"@Url.Page("/Company/Employees/Index", "JobListByText")",${workshopId}) class= "text-right input-text" /> </li></ul><ul class= "result options text-right" ></ul>`
|
||
);
|
||
activeTabPane.find('.ul-search').html('');
|
||
}
|
||
|
||
function saveData() {
|
||
$("#editStartDate").val('');
|
||
$("#editLeftDate").val('');
|
||
$("#editEndDate").val('');
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let editIcon = activeTabPane.find(".edit-icon");
|
||
let deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
activeTabPane.find(".date").removeClass("blinking");
|
||
let startDate = activeTabPane.find('.input2');
|
||
let lastDay = activeTabPane.find('.input3');
|
||
let endDate = activeTabPane.find('.input4');
|
||
let startValue = startDate.val();
|
||
let lastValue = lastDay.val();
|
||
let endValue = endDate.val();
|
||
let dateId = startDate.attr('id');
|
||
let number = dateId.match(/\d+/)[0];
|
||
|
||
if (startValue != '' && !checkLength(startDate.val(), 10)) {
|
||
if (!dateValidCheckByValue(startDate)) {
|
||
startDate.addClass("errored");
|
||
} else {
|
||
startDate.removeClass("errored");
|
||
}
|
||
}
|
||
if (lastValue != '' && !checkLength(lastDay.val(), 10)) {
|
||
if (!dateValidCheckByValue(startDate)) {
|
||
lastDay.addClass("errored");
|
||
} else {
|
||
lastDay.removeClass("errored");
|
||
}
|
||
}
|
||
if (endValue != '' && !checkLength(endDate.val(), 10)) {
|
||
if (!dateValidCheckByValue(endDate)) {
|
||
endDate.addClass("errored");
|
||
} else {
|
||
endDate.removeClass("errored");
|
||
}
|
||
|
||
}
|
||
|
||
if (!activeTabPane.find('.date').hasClass('errored')) {
|
||
|
||
|
||
var editable = false;
|
||
if (startDate != '' && !activeTabPane.find('.date').hasClass('errored') && $("#editStartDate").val() != '') {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": startValue, "type": 1 },
|
||
success: function (response) {
|
||
// console.log(response);
|
||
if (response.isSuccedded == true) {
|
||
if (!startDate.hasClass('errored') && !endDate.hasClass('errored') && !lastDay.hasClass('errored')) {
|
||
addRow2(number, startValue, lastValue, endValue);
|
||
activeTabPane.find('.input2').val('');
|
||
disableInput();
|
||
disableSaveBtn();
|
||
handleScroll();
|
||
|
||
const editIcon = activeTabPane.find(".edit-icon");
|
||
const deleteIcon = activeTabPane.find(".edit-date");
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
activeTabPane.find(".date").removeClass("blinking");
|
||
}
|
||
$('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ویرایش ثبت شروع به کار وجود ندارد.",
|
||
text: response.message,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
// var tr = $(activeTabPane).find('.workDate-table tbody tr');
|
||
// tr.find('td:eq(1)').text($("#editStartDate").val());
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
} else {
|
||
if (!activeTabPane.find('.date').hasClass('errored')) {
|
||
if ($("#deleteStartDate").val() != '') {
|
||
swal({
|
||
title: "امکان حذف تاریخ وجود ندارد.",
|
||
text: ` به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ثبت تاریخ جدید قبل از تاریخ ${$("#deleteStartDate").val()}امکان پذیر می باشد. `,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": date1, "type": 1 },
|
||
success: function (response) {
|
||
if (response.isSuccedded == true) {
|
||
if (!startDate.hasClass('errored') && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) {
|
||
$("#deleteStartDate").val('');
|
||
|
||
addRow2(number, startValue, lastValue, endValue);
|
||
disableInput();
|
||
disableSaveBtn();
|
||
handleScroll();
|
||
activeTabPane.find('.input2').val('');
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
if ($("#editLeftDate").val() != '') {
|
||
swal({
|
||
title: "امکان ثبت تاریخ شروع به کار وجود ندارد",
|
||
text: response.message,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ثبت تاریخ ترک کار وجود ندارد",
|
||
text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
}
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
|
||
|
||
} else {
|
||
var workshopId = activeTabPane.attr("data-workshopid");
|
||
if (lastValue != '' && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) {
|
||
//check edit for endDate
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")',
|
||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": endValue, "type": 2 },
|
||
success: function (response) {
|
||
if (response.isSuccedded == true) {
|
||
if (!startDate.hasClass('errored') && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) {
|
||
$("#deleteStartDate").val('');
|
||
|
||
addRow2(number, startValue, lastValue, endValue);
|
||
disableInput();
|
||
disableSaveBtn();
|
||
handleScroll();
|
||
activeTabPane.find('.input2').val('');
|
||
}
|
||
activeTabPane.find('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
} else {
|
||
if ($("#editLeftDate").val() != '') {
|
||
swal({
|
||
title: "امکان ویرایش تاریخ ترک کار وجود ندارد",
|
||
text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
} else {
|
||
swal({
|
||
title: "امکان ثبت تاریخ ترک کار وجود ندارد",
|
||
text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `,
|
||
type: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#DD6B55",
|
||
//confirmButtonText: "بستن",
|
||
cancelButtonText: "بستن",
|
||
closeOnConfirm: false,
|
||
customClass: "errorSwall"
|
||
});
|
||
}
|
||
deleteIcon.removeClass("disabled-edit");
|
||
editIcon.removeClass("disabled-edit");
|
||
|
||
}
|
||
},
|
||
error: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
|
||
} else if (startDate.val() != '' && !startDate.hasClass('errored')) {
|
||
addRow2(number, startValue, lastValue, endValue);
|
||
activeTabPane.find('.input2').val('');
|
||
disableInput();
|
||
disableSaveBtn();
|
||
handleScroll();
|
||
}
|
||
}
|
||
}
|
||
$('.workDate-table').find("tbody tr").each(function () {
|
||
const row = $(this);
|
||
const rowStartDate = row.find('td:eq(1)');
|
||
const rowEndDate = row.find('td:eq(4)');
|
||
const rowStartDateText = row.find('td:eq(1)').text();
|
||
const rowEndDateText = row.find('td:eq(4)').text();
|
||
if (rowStartDateText != '') {
|
||
rowStartDate.removeClass("emptyStart");
|
||
}
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
// $('.workDate-table').find("tbody tr").each(function () {
|
||
// let row = $(this);
|
||
// let rowStartDate = row.find('td:eq(1)');
|
||
// let rowEndDate = row.find('td:eq(4)');
|
||
// let rowStartDateText = row.find('td:eq(1)').text();
|
||
// let rowEndDateText = row.find('td:eq(4)').text();
|
||
// if (rowStartDateText != '') {
|
||
// rowStartDate.removeClass("emptyStart");
|
||
// }
|
||
// });
|
||
}
|
||
</script> |