1537 lines
72 KiB
Plaintext
1537 lines
72 KiB
Plaintext
@model CompanyManagment.App.Contracts.LeftWorkInsurance.LeftworkInsuranceDividedList
|
||
|
||
@*adding bime*@
|
||
|
||
<link href="@Href("~/DadmehrSelect/dad-mehr-select.css")" rel="stylesheet" />
|
||
<link href="@Href("~/ClientTheme/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.WorkshopName (@Model.EmployeeName)</legend>
|
||
@* <form autocomplete="off">
|
||
|
||
</form>*@
|
||
<div class="col-md-12 col-12 col-sm-12 fdiv">
|
||
<label class="first-label">افزودن کارگاه</label>
|
||
<div class="d-flex">
|
||
<div class="col-lg-11 col-md-11 col-sm-11 col-xs-9">
|
||
<select class="form-control select-city input" id="input1" asp-items='@Model.Workshops'>
|
||
<option value="0">انتخاب کارگاه</option>
|
||
</select>
|
||
</div>
|
||
|
||
<button class="btn save col-lg-1 col-md-1 col-sm-1 col-xs-3" id="save1">ثبت</button>
|
||
</div>
|
||
</div>
|
||
<div class="tabbed-navigation col-md-12 col-12 col-sm-12">
|
||
<div class="nav-tabs hide-scrollbar">
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
int index = 1;
|
||
@foreach (var item in @Model.LeftWorkInsuranceGroups)
|
||
{
|
||
<a href="#tab-@index" class="@(index==1?"active":"") nav-link"> <span class="del-com"><i class="fa fa-trash trash-icon" aria-hidden="true" style="color: white;"></i></span><span 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 class="fa fa-trash trash-icon" aria-hidden="true" style="color: white;"></i></span><span class="nav-title" id="nav-title1">@Model.WorkshopName</span></a>
|
||
}
|
||
|
||
</div>
|
||
<div class="tab-content">
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
int 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="container">
|
||
<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)">
|
||
<div class="custom-select text-right">
|
||
|
||
<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobByTextSearch")">
|
||
@if (item.LeftworkInsuranceViewModels != null && item.LeftworkInsuranceViewModels.Count > 0 && item.LeftworkInsuranceViewModels[0].JobId != 0)
|
||
{
|
||
<li onclick="openSearchResultByCodeLeftWorkInsurance(this,@Model.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>
|
||
}
|
||
</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" data-haspersonelcode="@(item.HasPersonelCode == true ? true : false)" disabled="disabled" placeholder="شماره پرسنلی">
|
||
</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 checked="@item.LeftworkInsuranceViewModels[0].IncludeStatus" type="checkbox" class="setContract">
|
||
}
|
||
else
|
||
{
|
||
<input type="checkbox" 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">ثبت</button>
|
||
</div>
|
||
}
|
||
</div>
|
||
<div class="table-content row">
|
||
<table class="table table-bordered table-striped workDate-table" @((index == 1) ? "id='modal-table'" : "")>
|
||
<colgroup>
|
||
<col style="width: 20px;">
|
||
<col style="width: 140px;">
|
||
<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>تاریخ شروع بکار</th>
|
||
<th>تاریخ آخرین روز کاری</th>
|
||
<th>تاریخ ترک کار</th>
|
||
<th></th>
|
||
<th class="text-small">روزهای کارکرد</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@if (item.LeftworkInsuranceViewModels != null)
|
||
{
|
||
var leftworkInsuranceViewModelList = item.LeftworkInsuranceViewModels;
|
||
for (int i = 0; i < leftworkInsuranceViewModelList.Count; i++)
|
||
{
|
||
<tr>
|
||
<td>@(i + 1)</td>
|
||
<td>@leftworkInsuranceViewModelList[i].StartWorkDate</td>
|
||
<td>@leftworkInsuranceViewModelList[i].EndWorkDate</td>
|
||
<td>@leftworkInsuranceViewModelList[i].LeftWorkDate</td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true"></i></td>
|
||
<td>_</td>
|
||
</tr>
|
||
}
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</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="container">
|
||
<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)" >
|
||
<div class="custom-select text-right">
|
||
|
||
<ul class="ul-search single text-right" data-url="@Url.Page("/Company/Employees/Index", "JobByTextSearch")">
|
||
<li> <input onkeyup="searchTextLeftWorkInsurance(event,this,'@Url.Page("/Company/Employees/Index", "JobByTextSearch")',@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" placeholder="شماره پرسنلی">
|
||
</div>
|
||
<div class="third-col-content">
|
||
<div class="d-flex position-check">
|
||
<span class="position-type"> مشمول مزایا </span>
|
||
<div class="checkbox-wrapper">
|
||
<input type="checkbox" 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 row">
|
||
<table class="table table-bordered table-striped workDate-table" id="modal-table">
|
||
<colgroup>
|
||
<col style="width: 20px;">
|
||
<col style="width: 140px;">
|
||
<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>تاریخ شروع بکار</th>
|
||
<th>تاریخ آخرین روز کاری</th>
|
||
<th>تاریخ ترک کار</th>
|
||
<th></th>
|
||
<th class="text-small">روزهای کارکرد</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
|
||
<tr>
|
||
<td>1</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td></td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i></td>
|
||
<td></td>
|
||
</tr>
|
||
<tr>
|
||
<td>2</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td></td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true"></i></td>
|
||
<td></td>
|
||
</tr>
|
||
<tr>
|
||
<td>3</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td></td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i></td>
|
||
<td></td>
|
||
</tr>
|
||
<tr>
|
||
<td>4</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td></td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i></td>
|
||
<td></td>
|
||
</tr>
|
||
<tr>
|
||
<td>5</td>
|
||
<td></td>
|
||
<td></td>
|
||
<td></td>
|
||
<td><i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i></td>
|
||
<td></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-footer">
|
||
<a class="btn btn-rounded waves-effect waves-light bg-white" id="close" data-dismiss="modal">بستن</a>
|
||
<a href="#" id="btnSaveData" class="btn btn-rounded">ذخیره</a>
|
||
</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="divAppendDataLeftWorkInsurance">
|
||
<input type="hidden" asp-for="EmployeeId" value="@Model.EmployeeId"/>
|
||
<input type="hidden" asp-for="IsDelete" />
|
||
</div>
|
||
</form>
|
||
<script src="~/DadmehrSelect/dadmehr-select.js?v=1.2"></script>
|
||
<script src="~/ClientTheme/js/insurance-list.js?v=1"></script>
|
||
<script>
|
||
$(document).ready(function () {
|
||
handleScroll();
|
||
//handleCompanyScroll();
|
||
saveLeftwork();
|
||
});
|
||
$("#close , .close").on('click', function () {
|
||
$(".datepicker-container").hide();
|
||
});
|
||
|
||
$(".persianDateInput").on('keyup', function () {
|
||
if (event.which !== 8 && event.which !== 46) {
|
||
let value = $(this).val();
|
||
let lengthValue = value.length;
|
||
if (lengthValue === 4) {
|
||
value += '/'
|
||
}
|
||
if (lengthValue === 7) {
|
||
value += '/'
|
||
}
|
||
$(this).val(value);
|
||
}
|
||
});
|
||
|
||
$(".persianDateInput").on('blur', function () {
|
||
let value = $(this).val();
|
||
let lengthValue = value.length;
|
||
if (!dateValidCheck(this)) {
|
||
$(this).addClass("errored");
|
||
}
|
||
else {
|
||
$(this).removeClass("errored");
|
||
}
|
||
});
|
||
// employerDiagnose();
|
||
let navTitle = $('.nav-title');
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
navTitle.addClass("disactive");
|
||
}
|
||
|
||
$(function () {
|
||
var previousText = $('.value').text();
|
||
var previousDataValue = $('.value').data('value');
|
||
var currentText = $('.value').text();
|
||
if (currentText !== previousText) {
|
||
previousText = currentText;
|
||
employerDiagnose();
|
||
}
|
||
});
|
||
|
||
//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)...
|
||
|
||
|
||
//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');
|
||
|
||
//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.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 $existingTitle = $('.nav-title:contains("' + newTitle + '")');
|
||
if ($existingTitle.length > 0) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'شرکت انتخاب شده در لیست وجود دارد.');
|
||
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 class="fa fa-trash trash-icon" style = "color: white;">' + '</i>' + '</span>' + '<span 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: 'YekanBold',
|
||
background: 'grey',
|
||
placement: 'top',
|
||
offset: { x: 300, y: 20 },
|
||
trigger: 'hover',
|
||
html: true,
|
||
title: function () {
|
||
return '<span style="font-family: YekanBold;">' + $(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');
|
||
disableInput();
|
||
employerDiagnose();
|
||
});
|
||
newTabLink.trigger('click');
|
||
var selectItem = $('.tab-pane.active').find('.select-city');
|
||
selectItem.select2();
|
||
}
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
$('#input1').val('0').trigger('change');
|
||
};
|
||
}
|
||
|
||
handleScroll();
|
||
$('.del-com').click(function () {
|
||
let navLink = $(this).closest('.nav-link');
|
||
let navTitle = navLink.find('.nav-title');
|
||
|
||
if ($(this).closest('.nav-link').index() === 0 && $('.nav-tabs a').length === 1) {
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
<text>$("#IsDelete").val('true');</text>
|
||
}
|
||
|
||
|
||
navTitle.text('نام شرکت');
|
||
navTitle.addClass("disactive");
|
||
let activeTabPane = $('.tab-pane.active');
|
||
activeTabPane.find("input.position-code").val("");
|
||
activeTabPane.find(".position-name").val(0);
|
||
let rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
let rowCount = rows.length;
|
||
if (rowCount === 6) {
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
}
|
||
rows.each(function () {
|
||
if (rowCount <= 5) {
|
||
$(this).find('td:eq(5)').text("");
|
||
$(this).find('td:eq(3)').text("");
|
||
$(this).find('td:eq(2)').text("");
|
||
$(this).find('td:eq(1)').text("");
|
||
}
|
||
if (rowCount > 5) {
|
||
$(this).remove();
|
||
updateRowNumbers();
|
||
}
|
||
});
|
||
} else {
|
||
|
||
var href_ = $(this).closest('.nav-link').attr("href");
|
||
|
||
var tabId = href_.replace('#', '');
|
||
|
||
$(this).closest('.nav-link').remove();
|
||
$("#" + tabId).remove();
|
||
|
||
if ($('.nav-tabs a').length <= 4) {
|
||
$('.nav-tabs').addClass('hide-scrollbar');
|
||
} else {
|
||
$('.nav-tabs').removeClass('hide-scrollbar');
|
||
} if ($(this).closest('.nav-link').hasClass('active')) {
|
||
$('.nav-tabs a:first-child').trigger('click');
|
||
}
|
||
}
|
||
disableInput();
|
||
|
||
});
|
||
$(".workDate-table .trash-icon").on("mouseenter", function () {
|
||
$(this).animate({ left: "-2px" }, 50)
|
||
.animate({ left: "2px" }, 50)
|
||
.animate({ left: "0px" }, 50);
|
||
});
|
||
});
|
||
|
||
});
|
||
|
||
//this code handles the second button(for adding data in the first tabs table)
|
||
$(function () {
|
||
$('#save').on('click', function (e) {
|
||
console.log($('.setContract').prop("checked"));
|
||
e.preventDefault();
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let date1 = $('#startDate1').val();
|
||
let date2 = $('#lastDay1').val();
|
||
let date3 = $('#endDate1').val();
|
||
let positionCode = $('.position-code').val();
|
||
let positionName = $(".position-name").val();
|
||
if (positionCode == "") {
|
||
$('.position-code').addClass("errored");
|
||
} else {
|
||
$('.position-code').removeClass("errored");
|
||
}
|
||
if (positionName == 0) {
|
||
$('.position-name').addClass("errored");
|
||
} else {
|
||
$('.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");
|
||
}
|
||
}
|
||
if(!$('.date').hasClass('errored')){
|
||
addRow(date1, date2 , date3);
|
||
handleScroll();
|
||
disableInput();
|
||
}
|
||
});
|
||
});
|
||
// 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');
|
||
|
||
var selectItem = $('.tab-pane.active').find('.select-city');
|
||
selectItem.select2();
|
||
handleScroll();
|
||
disableInput();
|
||
employerDiagnose();
|
||
});
|
||
|
||
//checkPremision();
|
||
|
||
|
||
//this code handles the first button(for adding new tabs)
|
||
function saveLeftwork() {
|
||
var counter = 1; // start counter from 2 since we already have one tab
|
||
// $('#save1').on('click', function (e) {
|
||
// e.preventDefault();
|
||
var workshopId = @Model.WorkshopId;
|
||
if (workshopId != '0') {
|
||
|
||
$("#IsDelete").val('false');
|
||
// var workshopId=$('#input1').val();
|
||
var workshopname = '@Model.WorkshopName'//$('#input1 option:selected').text();
|
||
|
||
|
||
let navLink = $('.nav-link');
|
||
let navTitle = navLink.find('.nav-title');
|
||
|
||
//if there was only one tab...
|
||
|
||
$('#tab-1').attr("data-workshopId", workshopId);
|
||
$('#tab-1').attr("data-workshopname", workshopname);
|
||
navTitle.text(workshopname);
|
||
navTitle.removeClass("disactive");
|
||
navTitle.addClass("active");
|
||
// $('#input1').val('0').trigger('change');
|
||
getPersonelCode(workshopId);
|
||
}
|
||
|
||
handleScroll();
|
||
|
||
$(".workDate-table .trash-icon").on("mouseenter", function () {
|
||
$(this).animate({ left: "-2px" }, 50)
|
||
.animate({ left: "2px" }, 50)
|
||
.animate({ left: "0px" }, 50);
|
||
});
|
||
//});
|
||
|
||
}
|
||
|
||
//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) => {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let table = activeTabPane.find('.workDate-table');
|
||
let conflictFound = false;
|
||
|
||
table.find("tbody tr").each(function () {
|
||
let row = $(this);
|
||
let rowStartDate = row.find('td:eq(1)').text(); // Get the start date of the row
|
||
let rowEndDate = row.find('td:eq(3)').text(); // Get the end date of the row
|
||
|
||
|
||
|
||
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() + ' وارد شده است.');
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
const $existingDate2 = row.find('td:eq(3):contains("' + date1 + '")');
|
||
if (date1 != '' && $existingDate2.length > 0) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
|
||
const $existingDate3 = row.find('td:eq(3):contains("' + date3 + '")');
|
||
if (date3 != '' && $existingDate3.length > 0) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
$('#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() + ' برابر است.');
|
||
$('#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() + ' برابر است.');
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
if (rowStartDate != '' && date3 != '' && date3 > rowStartDate && date3 < rowEndDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date3 != '' && rowEndDate == '' && date3 < rowStartDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
$('#lastDay1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
$('#startDate1').addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
|
||
});
|
||
if (!conflictFound) {
|
||
let emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
if (emptyRow.length > 0) {
|
||
|
||
if (date1 != ''){
|
||
emptyRow.children('td:eq(1)').text(date1);
|
||
}
|
||
|
||
if (date2 != ''){
|
||
emptyRow.children('td:eq(2)').text(date2);
|
||
}
|
||
|
||
if (date3 != ''){
|
||
emptyRow.children('td:eq(3)').text(date3);
|
||
}
|
||
|
||
emptyRow.children('td:eq(5)').text("_");
|
||
}
|
||
if (emptyRow.length === 0 && !conflictFound) {
|
||
let rowCount = table.find("tbody tr").length;
|
||
let newRow = '<tr>' +
|
||
'<td>' + (rowCount + 1) + '</td>' +
|
||
'<td>' + date1 + '</td>' +
|
||
'<td>' + date2 + '</td>' +
|
||
'<td>' + date3 + '</td>' +
|
||
'<td>' + '<i class="fa fa-trash trash trash-icon" aria-hidden="true"></i>' + '</td>' +
|
||
'<td>' + "_" + '</td>' +
|
||
'</tr>';
|
||
table.find("tbody").append(newRow);
|
||
disableInput();
|
||
|
||
|
||
}
|
||
sortDates();
|
||
updateRowNumbers();
|
||
|
||
$('#startDate1').val("");
|
||
$('#lastDay1').val("");
|
||
$('#endDate1').val("");
|
||
}
|
||
|
||
}
|
||
|
||
//this code is like addRow for the tabs except the first tab
|
||
let addRow2 = (counter, date1, date2, date3) => {
|
||
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 () {
|
||
let row = $(this);
|
||
let rowStartDate = row.find('td:eq(1)').text();
|
||
let rowEndDate = row.find('td:eq(3)').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() + ' وارد شده است.');
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
const $existingDate2 = row.find('td:eq(3):contains("' + date1 + '")');
|
||
if (date1 != '' && $existingDate2.length > 0) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.');
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
|
||
const $existingDate3 = row.find('td:eq(3):contains("' + date2 + '")');
|
||
if (date2 != '' && $existingDate3.length > 0) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.');
|
||
lastDay.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
const $existingDate4 = row.find('td:eq(1):contains("' + date2 + '")');
|
||
if (date2 != '' && $existingDate4.length > 0) {
|
||
$.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() + ' برابر است.');
|
||
endDate.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return;
|
||
}
|
||
|
||
if (rowStartDate != '' && date2 != '' && date2 > rowStartDate && date2 < rowEndDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
lastDay.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
startDate.addClass("errored");
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
if (rowStartDate != '' && date2 != '' && rowEndDate == '' && date2 < rowStartDate) {
|
||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.');
|
||
lastDay.addClass("errored");
|
||
|
||
conflictFound = true;
|
||
return false;
|
||
}
|
||
|
||
});
|
||
if (!conflictFound) {
|
||
let emptyRow = table.find("tbody tr td:empty:first").closest('tr');
|
||
|
||
if (emptyRow.length > 0) {
|
||
if (date1 != '')
|
||
emptyRow.children('td:eq(1)').text(date1);
|
||
if (date2 != '')
|
||
emptyRow.children('td:eq(2)').text(date2);
|
||
if (date3 != '')
|
||
emptyRow.children('td:eq(3)').text(date3);
|
||
emptyRow.children('td:eq(5)').text("_");
|
||
|
||
}
|
||
if (emptyRow.length === 0) {
|
||
let rowCount = table.find("tbody tr").length;
|
||
let newRow = '<tr>' +
|
||
'<td>' + (rowCount + 1) + '</td>' +
|
||
'<td>' + date1 + '</td>' +
|
||
'<td>' + date2 + '</td>' +
|
||
'<td>' + date3 + '</td>' +
|
||
'<td>' + '<i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i>' + '</td>' +
|
||
'<td>' + "_" + '</td>' +
|
||
'</tr>';
|
||
table.find("tbody").append(newRow);
|
||
disableInput();
|
||
|
||
}
|
||
|
||
sortDates();
|
||
updateRowNumbers();
|
||
}
|
||
$('.trash').click(function () {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
let rowCount = rows.length;
|
||
if (rowCount === 6) {
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
}
|
||
if (rowCount <= 5) {
|
||
let deletedRow = $(this).closest('tr');
|
||
deletedRow.find('td:eq(5)').text("");
|
||
deletedRow.find('td:eq(3)').text("");
|
||
deletedRow.find('td:eq(2)').text("");
|
||
deletedRow.find('td:eq(1)').text("");
|
||
}
|
||
if (rowCount > 5) {
|
||
$(this).closest('tr').fadeOut(200, function () {
|
||
$(this).remove();
|
||
updateRowNumbers();
|
||
});
|
||
}
|
||
|
||
});
|
||
|
||
|
||
|
||
}
|
||
|
||
//this code checks the row number
|
||
let updateRowNumbers = () => {
|
||
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let 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() {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let table = activeTabPane.find('.workDate-table');
|
||
var rows = table.find('tr:gt(0)').toArray();
|
||
rows.sort(function (a, b) {
|
||
var date1a = new Date($(a).find('td:eq(1)').text().replace(/\//g, '-'));
|
||
var date1b = new Date($(b).find('td:eq(1)').text().replace(/\//g, '-'));
|
||
return date1b - date1a;
|
||
});
|
||
for (var i = 0; i < rows.length; i++) {
|
||
table.append(rows[i]);
|
||
}
|
||
}
|
||
|
||
//date keyup for tab-1
|
||
$(".date").keyup(function(){
|
||
let value= $(this).val();
|
||
let lengthValue = value.length;
|
||
let 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 () {
|
||
let value = $(this).val();
|
||
let lengthValue = value.length;
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let startDate = activeTabPane.find('.input2');
|
||
let lastDay = activeTabPane.find('.input3');
|
||
let endDate = activeTabPane.find('.input4');
|
||
|
||
let endDateId = endDate.attr('id');
|
||
let lastDateId = lastDay.attr('id');
|
||
let 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',*/
|
||
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;
|
||
var 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(jobId);
|
||
//console.log(includeStatus);
|
||
|
||
var haspersonelcode= personnelCode.attr("data-haspersonelcode");
|
||
|
||
if(haspersonelcode.toLowerCase()!="true"){
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="PersonnelCode['+i+'].HasPersonelCode" id="PersonnelCode_'+i+'__HasPersonelCode" value="true" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="PersonnelCode['+i+'].WorkshopId" id="PersonnelCode_'+i+'__WorkshopId" value="'+workshopid+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="PersonnelCode['+i+'].EmployeeId" id="PersonnelCode_'+i+'__EmployeeId" value="'+employeeId+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="PersonnelCode['+i+'].PersonnelCode" id="PersonnelCode_'+i+'__PersonnelCode" value="'+personnelCode.val()+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="PersonnelCode['+i+'].WorkShopName" id="PersonnelCode_'+i+'__WorkShopName" value="'+workshopName+'" />');
|
||
}
|
||
var index2=0;
|
||
$(this).find('table tr').each(function(x) {
|
||
var leftWorkDate =$(this).find('td:eq(3)').text().trim();
|
||
var startWorkDate = $(this).find('td:eq(1)').text().trim();
|
||
|
||
if(startWorkDate!=''){
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].WorkshopId" id="LeftWorkInsuranceGroups_'+i+'__WorkshopId" value="'+workshopid+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].WorkshopId" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__WorkshopId" value="'+workshopid+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].EmployeeId" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__EmployeeId" value="'+employeeId+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].WorkshopName" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__WorkshopName" value="'+workshopName+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].StartWorkDate" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__StartWorkDate" value="'+startWorkDate+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].LeftWorkDate" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__LeftWorkDate" value="'+leftWorkDate+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").append('<input class="input-send-data" type="hidden" name="LeftWorkInsuranceGroups['+i+'].LeftworkInsuranceViewModels['+index2+'].JobId" id="LeftWorkInsuranceGroups_'+i+'__LeftworkInsuranceViewModels_'+index2+'__JobId" value="'+jobId+'" />');
|
||
$("#divAppendDataLeftWorkInsurance").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;
|
||
}
|
||
});
|
||
});
|
||
|
||
//$('#sendData').click();
|
||
$("#employee").submit();
|
||
});
|
||
|
||
|
||
$('#employee').submit(function(e){
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
$.ajax({
|
||
type: "POST",
|
||
url: $(this).attr( 'action' ),
|
||
data: $(this).serialize(),
|
||
success: function (response) {
|
||
if (response.isSuccedded == true) {
|
||
$.Notification.autoHideNotify('success', 'top right', response.message);
|
||
$("#MainModal").modal('hide');
|
||
$(".datepicker-container").hide();
|
||
getEmployeeList();
|
||
}
|
||
else{
|
||
$.Notification.autoHideNotify('error', 'top right', response.message);
|
||
}
|
||
}
|
||
});
|
||
return false;
|
||
});
|
||
|
||
|
||
function checkcountRow(){
|
||
|
||
$(".tab-pane").each(function() {
|
||
var tab=$(this);
|
||
var table= $(this).find('table');
|
||
table.find('tr').each(function(x) {
|
||
var leftWorkDate = $(this).find('td:eq(3)').text().trim();
|
||
var startWorkDate = $(this).find('td:eq(1)').text().trim();
|
||
disableInput();
|
||
|
||
});
|
||
|
||
var trCount = $(this).find('table tr').length-1;
|
||
var newRowNumber = 5 - trCount;
|
||
if(trCount<5)
|
||
{
|
||
for(var index=0; index<newRowNumber; index++ ){
|
||
let newRow = '<tr>' +
|
||
'<td>' + (trCount +index+ 1) + '</td>' +
|
||
'<td></td>' +
|
||
'<td></td>' +
|
||
'<td></td>' +
|
||
'<td>' + '<i class="fa fa-trash trash trash-icon" aria-hidden="true" ></i>' + '</td>' +
|
||
'<td></td>' +
|
||
'</tr>';
|
||
table.find("tbody").append(newRow);
|
||
}
|
||
}
|
||
|
||
});
|
||
sortDates();
|
||
handleScroll();
|
||
|
||
}
|
||
|
||
//this function handles the show or hide of the scrollbar
|
||
function handleScroll(){
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
let rowCount = rows.length;
|
||
let 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 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[2].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
|
||
|
||
let thirdColumnData = Array.from(table.rows)
|
||
.map(row => row.cells[2].textContent.trim())
|
||
.filter(cellValue => cellValue !== "");
|
||
|
||
|
||
// console.log(firstColumnData.length);
|
||
// console.log(secondColumnData.length);
|
||
//console.log(thirdColumnData.length);
|
||
|
||
if (navTitle.text().trim() === 'نام شرکت') {
|
||
$('.input2').prop('disabled', true);
|
||
$('.input3').prop('disabled', true);
|
||
$('.input4').prop('disabled', true);
|
||
$('.position-name').prop('disabled', true);
|
||
//$('.position-code').prop('disabled', true);
|
||
$('.setContract').prop('disabled', true);
|
||
$("#save1").removeClass("buttonDeactived");
|
||
}
|
||
|
||
|
||
|
||
else if (firstColumnData.length > secondColumnData.length) {
|
||
$('.input2').prop('disabled', true);
|
||
$('.input3').prop('disabled', false);
|
||
$('.input4').prop('disabled', false);
|
||
$("#save1").addClass("buttonDeactived");
|
||
}
|
||
//else if(firstColumnData.length == 0 && secondColumnData.length == 0){
|
||
// $("#save1").addClass("buttonDeactived");
|
||
//}
|
||
else {
|
||
$('.input2').prop('disabled', false);
|
||
$('.input3').prop('disabled', true);
|
||
$('.input4').prop('disabled', true);
|
||
$('.position-name').prop('disabled', false);
|
||
$("#save1").removeClass("buttonDeactived");
|
||
$('.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: 'YekanBold',
|
||
background: 'grey',
|
||
placement: 'top',
|
||
offset: { x: 150, y: 20 },
|
||
trigger: 'hover',
|
||
html: true,
|
||
title: function () {
|
||
return '<span style="font-family: YekanBold;">' + $(this).text() + '</span>';
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
$('.trash').click(function () {
|
||
let activeTabPane = $('.tab-pane.active');
|
||
let rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
let rowCount = rows.length;
|
||
if (rowCount === 6) {
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
}
|
||
if (rowCount <= 5) {
|
||
let deletedRow = $(this).closest('tr');
|
||
deletedRow.find('td:eq(5)').text("");
|
||
deletedRow.find('td:eq(3)').text("");
|
||
deletedRow.find('td:eq(2)').text("");
|
||
deletedRow.find('td:eq(1)').text("");
|
||
}
|
||
if (rowCount > 5) {
|
||
$(this).closest('tr').fadeOut(200, function () {
|
||
$(this).remove();
|
||
updateRowNumbers();
|
||
});
|
||
}
|
||
disableInput();
|
||
|
||
});
|
||
|
||
//this code controls the trash icon
|
||
$(".workDate-table .trash-icon").on("mouseenter", function () {
|
||
$(this).animate({ left: "-2px" }, 50)
|
||
.animate({ left: "2px" }, 50)
|
||
.animate({ left: "0px" }, 50);
|
||
});
|
||
|
||
$('.del-com .trash-icon').click(function () {
|
||
let navLink = $(this).closest('.nav-link');
|
||
let navTitle = navLink.find('.nav-title');
|
||
|
||
if ($(this).closest('.nav-link').index() === 0 && $('.nav-tabs a').length === 1) {
|
||
|
||
@if (Model.LeftWorkInsuranceGroups != null && Model.LeftWorkInsuranceGroups.Count > 0)
|
||
{
|
||
<text>$("#IsDelete").val('true');</text>
|
||
}
|
||
navTitle.text('نام شرکت');
|
||
navTitle.addClass("disactive");
|
||
let activeTabPane = $('.tab-pane.active');
|
||
activeTabPane.find("input.position-code").val("");
|
||
activeTabPane.find(".position-name").val(0);
|
||
let rows = activeTabPane.find(".workDate-table tbody").find("tr");
|
||
let rowCount = rows.length;
|
||
if (rowCount === 6) {
|
||
$('.table-content').addClass('hide-scrollbar');
|
||
}
|
||
rows.each(function() {
|
||
if (rowCount <= 5) {
|
||
$(this).find('td:eq(5)').text("");
|
||
$(this).find('td:eq(3)').text("");
|
||
$(this).find('td:eq(2)').text("");
|
||
$(this).find('td:eq(1)').text("");
|
||
}
|
||
if (rowCount > 5) {
|
||
$(this).remove();
|
||
updateRowNumbers();
|
||
}
|
||
});
|
||
} else {
|
||
var href_ = $(this).closest('.nav-link').attr("href");
|
||
|
||
var tabId = href_.replace('#', '');
|
||
|
||
$(this).closest('.nav-link').remove();
|
||
//handleCompanyScroll();
|
||
$("#" + tabId).remove();
|
||
|
||
if ($(this).closest('.nav-link').hasClass('active')) {
|
||
$('.nav-tabs a:first-child').trigger('click');
|
||
}
|
||
}
|
||
disableInput();
|
||
});
|
||
|
||
//the save button in the new tab...
|
||
$('.save').click(function (e) {
|
||
e.preventDefault();
|
||
saveData();
|
||
});
|
||
|
||
function saveData(){
|
||
let activeTabPane = $('.tab-pane.active');
|
||
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 (!$('.date').hasClass('errored')) {
|
||
addRow2(number, startValue, lastValue, endValue);
|
||
disableInput();
|
||
handleScroll();
|
||
|
||
startDate.val("");
|
||
lastDay.val("");
|
||
endDate.val("");
|
||
|
||
}
|
||
}
|
||
|
||
function employerDiagnose(){
|
||
let positionTitle = $('.value').data('value');
|
||
if (positionTitle == '10' || positionTitle == '16' || positionTitle == '17' || positionTitle == '18') {
|
||
$(".setContract").prop("checked", false);
|
||
} else {
|
||
$(".setContract").prop("checked", true);
|
||
}
|
||
//if ($(".setContract").is(":checked")) {
|
||
// $(".setContract").prop("disabled", true);
|
||
//}
|
||
}
|
||
|
||
// $('body').on('keyup', '.select2-search__field', function() {
|
||
// var text=$(this).val()
|
||
// var selectItem=$('.tab-pane.active').find('.select-city');
|
||
// var selectControls=$(this).attr("aria-controls");
|
||
// if(text!="" && selectControls!="select2-input1-results")
|
||
// {
|
||
// $.ajax({
|
||
// /* contentType: 'charset=utf-8',*/
|
||
// dataType: 'json',
|
||
// type: 'POST',
|
||
// url: '@Url.Page("/Company/InsuranceJob/Index", "JobListByText")',
|
||
// headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||
// data: { "textSearch": text },
|
||
// success: function (response) {
|
||
// // selectItem.find('option:not(:first-child)').remove();
|
||
// $.each(response.jobList, function (i, item) {
|
||
// console.log(selectItem.find("option[value='" + item.id + "']").length);
|
||
// if (selectItem.find("option[value='" + item.id + "']").length==0) {
|
||
// // selectItem.val(item.id).trigger('change');
|
||
// //} else {
|
||
// var newOption = new Option((item.jobName+' | '+item.jobCode), item.id, true, true);
|
||
// selectItem.append(newOption).trigger('change');
|
||
// }
|
||
// // selectItem.append('<option value="'+item.id+'">'+item.jobName+' | '+item.jobCode+'</option>');
|
||
// });
|
||
// },
|
||
// failure: function (response) {
|
||
// console.log(5, response);
|
||
// }
|
||
// });
|
||
// }
|
||
// else
|
||
// {
|
||
// //.click();
|
||
// console.log(10);
|
||
// // var value = selectItem.val();
|
||
// // var text = selectItem.find(":selected").text();
|
||
// // selectItem.empty().append("<option value='0'>سمت</option><option selected value='"+value+"'>"+text+"</option>");
|
||
// // selectItem.select2({
|
||
// //allowClear: true
|
||
// //});
|
||
// //$('.tab-pane.active').find(".select2-results").find('li.select2-results__option').html('');
|
||
// }
|
||
//});
|
||
|
||
function getPersonelCode(workshopId){
|
||
//console.log(workshopId);
|
||
var employeeId=@Model.EmployeeId;
|
||
// var workshopId=$("#input1").val();
|
||
|
||
$.ajax({
|
||
/* contentType: 'charset=utf-8',*/
|
||
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) {
|
||
//console.log(response);
|
||
//console.log(response.hasPersonelCode);
|
||
var inputCode=$('.tab-pane.active').find("input.position-code");
|
||
//var inputClass=inputCode.attr("class");
|
||
inputCode.val(response.personnelCode);
|
||
if(response.hasPersonelCode){
|
||
|
||
//inputCode.attr("disabled","disabled");
|
||
inputCode.attr("data-haspersonelcode","true");
|
||
}
|
||
else
|
||
{ //inputCode.attr("disabled","");
|
||
inputCode.attr("data-haspersonelcode","false");
|
||
}
|
||
disableInput();
|
||
},
|
||
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() {
|
||
var this_ = $(".select2-search__field");
|
||
var text = $(this_).val();
|
||
var selectItem = $('.tab-pane.active').find('.select-city');
|
||
var workshopid = $('.tab-pane.active').attr('data-workshopid');
|
||
|
||
var selectControls = $(this_).attr("aria-controls");
|
||
if (text != "" && selectControls != "select2-input1-results") {
|
||
if (!lockLeftWorkInsurance) {
|
||
lockLeftWorkInsurance = true;
|
||
lastValueLeftWorkInsurance = text;
|
||
}
|
||
else {
|
||
return;
|
||
}
|
||
$.ajax({
|
||
/* 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) {
|
||
var 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({
|
||
/* 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) {
|
||
var 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 alert(){
|
||
console.log("yes");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</script>
|
||
|
||
|