6122 lines
206 KiB
JavaScript
6122 lines
206 KiB
JavaScript
var mapUrl = "https://rmsmap.rmto.ir/141map/";
|
||
var addMap = null;
|
||
var editMap = null;
|
||
|
||
var startMarkerAdd = null;
|
||
var endMarkerAdd = null;
|
||
|
||
var startMarkerEdit = null;
|
||
var endMarkerEdit = null;
|
||
|
||
var routeControls = [];
|
||
|
||
var excelDatepickerFirstTable = {};
|
||
|
||
var isSetStartMarkerAdd = false;
|
||
var isSetEndMarkerAdd = false;
|
||
|
||
var isSetStartMarkerEdit = false;
|
||
var isSetEndMarkerEdit = false;
|
||
|
||
var contractRowId;
|
||
var addDatepicker;
|
||
var editDatepicker;
|
||
|
||
var titlecontract;
|
||
var provinceIdForSub;
|
||
var statusIdForSub;
|
||
var ProTypeChoose = 1;
|
||
var historyTable;
|
||
var arrAddOprationsDisable = [0, 0, 0, 0];
|
||
var arrEditOprationsDisable = [0, 0, 0, 0];
|
||
var updateId;
|
||
var addNewSubitemStatus = "true";
|
||
var queryParemsExcel = [];
|
||
var PERMISSIONS = [];
|
||
var isReloadAjax = false;
|
||
var subcontract_nature = 0;
|
||
var operation_res;
|
||
|
||
$("[data-mask]").inputmask();
|
||
var startDivIcon = L.divIcon({
|
||
html: `
|
||
<div id="pin-marker-start" class="pin-marker">
|
||
<div class="map-pin-marker">
|
||
<div class="pin-main-circle"></div>
|
||
<div class="pin-white-circle"></div>
|
||
<div class="pin-title-circle">
|
||
<span class="title-circle-text">شروع</span>
|
||
</div>
|
||
<div class="pin-main-line"></div>
|
||
</div>
|
||
<div class="pin-main-shadow">
|
||
<div class="shadow-dot">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,
|
||
iconSize: [55, 75],
|
||
iconAnchor: [33, 64],
|
||
});
|
||
|
||
var endDivIcon = L.divIcon({
|
||
html: `
|
||
<div id="pin-marker-end" class="pin-marker">
|
||
<div class="map-pin-marker">
|
||
<div class="pin-main-circle"></div>
|
||
<div class="pin-white-circle"></div>
|
||
<div class="pin-title-circle">
|
||
<span class="title-circle-text">پایان</span>
|
||
</div>
|
||
<div class="pin-main-line"></div>
|
||
</div>
|
||
<div class="pin-main-shadow">
|
||
<div class="shadow-dot">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,
|
||
iconSize: [55, 75],
|
||
iconAnchor: [33, 64],
|
||
});
|
||
|
||
var startDivIconEdit = L.divIcon({
|
||
html: `
|
||
<div id="edit_pin-marker-start" class="pin-marker">
|
||
<div class="map-pin-marker">
|
||
<div class="pin-main-circle"></div>
|
||
<div class="pin-white-circle"></div>
|
||
<div class="pin-title-circle">
|
||
<span class="title-circle-text">شروع</span>
|
||
</div>
|
||
<div class="pin-main-line"></div>
|
||
</div>
|
||
<div class="pin-main-shadow">
|
||
<div class="shadow-dot">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,
|
||
iconSize: [55, 75],
|
||
iconAnchor: [33, 64],
|
||
});
|
||
|
||
var endDivIconEdit = L.divIcon({
|
||
html: `
|
||
<div id="edit_pin-marker-end" class="pin-marker">
|
||
<div class="map-pin-marker">
|
||
<div class="pin-main-circle"></div>
|
||
<div class="pin-white-circle"></div>
|
||
<div class="pin-title-circle">
|
||
<span class="title-circle-text">پایان</span>
|
||
</div>
|
||
<div class="pin-main-line"></div>
|
||
</div>
|
||
<div class="pin-main-shadow">
|
||
<div class="shadow-dot">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,
|
||
iconSize: [55, 75],
|
||
iconAnchor: [33, 64],
|
||
});
|
||
|
||
excelDatepickerFirstTable.from = $(
|
||
"#datapicker-from-excel-table"
|
||
).persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
autoClose: true,
|
||
onSelect: function (unix) {
|
||
excelDatepickerFirstTable.from.touched = true;
|
||
|
||
$("#datapicker-to-excel-table").prop("disabled", "");
|
||
|
||
if (
|
||
excelDatepickerFirstTable.from.getState().selected.unixDate >=
|
||
excelDatepickerFirstTable.to.getState().selected.unixDate
|
||
) {
|
||
excelDatepickerFirstTable.to.setDate(
|
||
excelDatepickerFirstTable.from.getState().selected.unixDate
|
||
);
|
||
}
|
||
|
||
if (
|
||
excelDatepickerFirstTable.to &&
|
||
excelDatepickerFirstTable.to.options &&
|
||
excelDatepickerFirstTable.to.options.minDate != unix
|
||
) {
|
||
let cachedValue =
|
||
excelDatepickerFirstTable.to.getState().selected.unixDate;
|
||
|
||
excelDatepickerFirstTable.to.options = { minDate: unix };
|
||
|
||
if (excelDatepickerFirstTable.from.touched) {
|
||
excelDatepickerFirstTable.to.setDate(cachedValue);
|
||
}
|
||
}
|
||
},
|
||
});
|
||
|
||
excelDatepickerFirstTable.to = $(
|
||
"#datapicker-to-excel-table"
|
||
).persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
autoClose: true,
|
||
onSelect: function (unix) {
|
||
excelDatepickerFirstTable.to.touched = true;
|
||
},
|
||
});
|
||
|
||
function showLoaderScreen() {
|
||
$(".divloader").css("display", "flex").hide().fadeIn();
|
||
}
|
||
|
||
function hideLoaderScreen() {
|
||
$(".divloader").fadeOut();
|
||
}
|
||
|
||
$(document).ready(function () {
|
||
// PERMISSIONS
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/user/get-permission",
|
||
type: "GET",
|
||
cache: false,
|
||
async: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
PERMISSIONS = result.data;
|
||
},
|
||
error: function () {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت سطح دسترسی",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
},
|
||
});
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/operation",
|
||
type: "GET",
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (res) {
|
||
operation_res = res;
|
||
$.each(operation_res, function (key, value) {
|
||
$("#select_project_type_excel").append(
|
||
"<option value='" + value.en_name + "'>" + value.farsi + "</option>"
|
||
);
|
||
});
|
||
$.each(operation_res, function (key, value) {
|
||
$(".project-type").append(
|
||
"<option value='" + value.id + "'>" + value.farsi + "</option>"
|
||
);
|
||
});
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در در دریافت ماهیت پروژه",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
|
||
/// [start] contract_show_province_filter-word
|
||
if (
|
||
$.inArray("word-export-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("word-export-province", PERMISSIONS) != -1
|
||
) {
|
||
$.ajax({
|
||
//// [start] contract_add_province_url-word
|
||
url: `https://rms.rmto.ir/webapi/getuser/province-perm${$.inArray("word-export-contract", PERMISSIONS) != -1 ? "?type=all" : ""
|
||
}`,
|
||
//// [end] contract_add_province_url-word
|
||
type: "GET",
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
const provinces = result.data;
|
||
$("#select-province-word").empty();
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#select-province-word").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت استان ها",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
/// [end] contract_show_province_filter-word
|
||
|
||
/// [start] contract_show_province_filter
|
||
if (
|
||
$.inArray("show-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("show-contract-province", PERMISSIONS) != -1
|
||
) {
|
||
$.ajax({
|
||
//// [start] contract_add_province_url
|
||
url: `https://rms.rmto.ir/webapi/getuser/province-perm${$.inArray("show-contract", PERMISSIONS) != -1 ? "?type=all" : ""
|
||
}`,
|
||
//// [end] contract_add_province_url
|
||
type: "GET",
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
const provinces = result.data;
|
||
$("#select-province").empty();
|
||
$("#select-province-excel").append(
|
||
'<option value="0">انتخاب استان</option>'
|
||
);
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#select-province-excel").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
$("#select-province").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت استان ها",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
/// [end] contract_show_province_filter
|
||
|
||
/// [START] add-contract-btn
|
||
if (
|
||
!(
|
||
$.inArray("add-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("add-contract-province", PERMISSIONS) != -1
|
||
)
|
||
)
|
||
$(".add-contract-btn").remove();
|
||
/// [END] add-contract-btn
|
||
|
||
/// [start] contract_add_province
|
||
if (
|
||
$.inArray("add-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("add-contract-province", PERMISSIONS) != -1
|
||
) {
|
||
$.ajax({
|
||
//// [start] contract_add_province_url
|
||
url: `https://rms.rmto.ir/webapi/getuser/province-perm${$.inArray("add-contract", PERMISSIONS) != -1 ? "?type=all" : ""
|
||
}`,
|
||
//// [end] contract_add_province_url
|
||
type: "GET",
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
const provinces = result.data;
|
||
$("#add-contract-province").empty();
|
||
$("#add-contract-province").append(
|
||
'<option value="0">انتخاب استان</option>'
|
||
);
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#add-contract-province").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت استان ها",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
/// [end] contract_add_province
|
||
|
||
/// [start] contract_edit_province
|
||
if (
|
||
$.inArray("edit-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("edit-contract-province", PERMISSIONS) != -1
|
||
) {
|
||
$.ajax({
|
||
/// [start] contract_edit_province_url
|
||
url: `https://rms.rmto.ir/webapi/getuser/province-perm${$.inArray("edit-contract", PERMISSIONS) != -1 ? "?type=all" : ""
|
||
}`,
|
||
/// [end] contract_edit_province_url
|
||
type: "GET",
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
const provinces = result.data;
|
||
|
||
$("#edit-contract-province").empty();
|
||
$("#edit-contract-province").append(
|
||
'<option value="0">انتخاب استان</option>'
|
||
);
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#edit-contract-province").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت استان ها",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
/// [end] contract_edit_province
|
||
|
||
// PERMISSIONS
|
||
|
||
$("#datapicker-from-excel-table").prop(
|
||
"disabled",
|
||
$.inArray(
|
||
$("#select_project_type_excel").val(),
|
||
$("#select_project_type_excel").data("activeDate")
|
||
) != -1
|
||
);
|
||
$("#datapicker-to-excel-table").prop(
|
||
"disabled",
|
||
$.inArray(
|
||
$("#select_project_type_excel").val(),
|
||
$("#select_project_type_excel").data("activeDate")
|
||
) != -1
|
||
);
|
||
|
||
$("#add-contract-Plan-num").select2({
|
||
multiple: true,
|
||
theme: "bootstrap4",
|
||
language: {
|
||
noResults: function () {
|
||
return "نتیجه ای یافت نشد";
|
||
},
|
||
},
|
||
});
|
||
$("#edit-contract-Plan-num").select2({
|
||
multiple: true,
|
||
theme: "bootstrap4",
|
||
language: {
|
||
noResults: function () {
|
||
return "نتیجه ای یافت نشد";
|
||
},
|
||
},
|
||
});
|
||
$("#select-province").select2({
|
||
placeholder: "انتخاب استان ",
|
||
multiple: true,
|
||
dir: "rtl",
|
||
});
|
||
|
||
$(".last_statusfilter").select2({
|
||
placeholder: "انتخاب وضعیت ",
|
||
multiple: true,
|
||
dir: "rtl",
|
||
});
|
||
|
||
$(".project-type").select2({
|
||
placeholder: "ماهیت پروژه ",
|
||
multiple: true,
|
||
dir: "rtl",
|
||
});
|
||
appendYearFilter();
|
||
// end main page table
|
||
showLoaderScreen();
|
||
table = $("#main-table-contract").DataTable({
|
||
serverSide: true,
|
||
dom: "<lB<t>p>",
|
||
pagingType: "simple_numbers",
|
||
filter: true,
|
||
language: {
|
||
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
||
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
||
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
||
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
||
sInfoPostFix: "",
|
||
sInfoThousands: ",",
|
||
sLengthMenu: "نمایش _MENU_ ردیف",
|
||
sLoadingRecords: "در حال بارگزاری...",
|
||
sProcessing: "در حال پردازش...",
|
||
sSearch: "جستجو: ",
|
||
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
||
oPaginate: {
|
||
sFirst: "برگهی نخست",
|
||
sLast: "برگهی آخر",
|
||
sNext: "بعدی",
|
||
sPrevious: "قبلی",
|
||
},
|
||
oAria: {
|
||
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
||
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
||
},
|
||
},
|
||
order: [
|
||
[0, "desc"]
|
||
],
|
||
processing: true,
|
||
select: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/contracts/index",
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
if (json.can_submit == 0) {
|
||
$('#point-add').prop('disabled', true)
|
||
}
|
||
canSubmit = json.can_submit
|
||
return json.data;
|
||
},
|
||
},
|
||
columns: [
|
||
{
|
||
className: "text-center align-middle",
|
||
data: "unique_id",
|
||
name: {
|
||
name: 'unique_id',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "province_fa",
|
||
name: {
|
||
name: 'contracts.province_fa',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "office_fa",
|
||
name: {
|
||
name: 'office_fa',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "title",
|
||
name: {
|
||
name: 'title',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "status_fa",
|
||
name: {
|
||
name: 'status_fa',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contract_date',
|
||
type: 'date_between'
|
||
},
|
||
render: function (data) {
|
||
if (data.contract_date != null) {
|
||
return data.contract_date.replace(/-/g, "/");
|
||
}
|
||
return "";
|
||
},
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "contract_peymankar",
|
||
name: {
|
||
name: 'contract_peymankar',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "contract_moshaver_tarahi",
|
||
name: {
|
||
name: 'contracts.contract_moshaver_tarahi',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "contract_moshaver_nezarat",
|
||
name: {
|
||
name: 'contracts.contract_moshaver_nezarat',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: "contract_number",
|
||
name: {
|
||
name: 'contract_number',
|
||
type: 'text'
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'national_credit_license',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
if (data.national_credit_license == 1) {
|
||
return `<i class="fa fa-check"></i>`;
|
||
} else {
|
||
return `-`;
|
||
}
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'province_credit_license',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
if (data.province_credit_license == 1) {
|
||
return `<i class="fa fa-check"></i>`;
|
||
} else {
|
||
return `-`;
|
||
}
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'headquarter_issued_license',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
if (data.headquarter_issued_license == 1) {
|
||
return `<i class="fa fa-check"></i>`;
|
||
} else {
|
||
return `-`;
|
||
}
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'province_issued_license',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
if (data.province_issued_license == 1) {
|
||
return `<i class="fa fa-check"></i>`;
|
||
} else {
|
||
return `-`;
|
||
}
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contract_tarh_array',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
var datashown = "";
|
||
if (data.contract_tarh_array != null) {
|
||
var nameArr = data.contract_tarh_array.split(",");
|
||
|
||
for (var i = 0; i < nameArr.length; i++) {
|
||
datashown = datashown + nameArr[i] + "<br>";
|
||
}
|
||
return datashown;
|
||
}
|
||
return "";
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contract_credit_province',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
const contractCreditProvince = parseFloat(
|
||
data.contract_credit_province != null
|
||
? data.contract_credit_province
|
||
: 0
|
||
).toLocaleString("en");
|
||
return contractCreditProvince;
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contract_credit_national',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
const contractCreditNational = parseFloat(
|
||
data.contract_credit_national != null
|
||
? data.contract_credit_national
|
||
: 0
|
||
).toLocaleString("en");
|
||
return contractCreditNational;
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contract_credit',
|
||
type: 'text'
|
||
},
|
||
render: function (data) {
|
||
const contractCredit = parseFloat(
|
||
data.contract_credit != null ? data.contract_credit : 0
|
||
).toLocaleString("en");
|
||
return contractCredit;
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'contracts.created_at',
|
||
type: 'between'
|
||
},
|
||
render: function (data) {
|
||
const createdAtFa = moment(data.created_at).format(
|
||
"HH:mm:ss | jYYYY/jMM/jDD"
|
||
);
|
||
return createdAtFa;
|
||
},
|
||
searchable: true,
|
||
orderable: true,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'option',
|
||
type: 'option'
|
||
},
|
||
render: function (data) {
|
||
return `<div class="setcontent">${data.canEdit == 0
|
||
? '<button disabled class="btn-dataTable" title="ویرایش"><i class="fa fa-edit icon-btnTable"></i></button>'
|
||
: '<button class="btn-dataTable edit-contract-btn" title="ویرایش"><i class="fa fa-edit icon-btnTable"></i></button>'
|
||
}<div class="line-btn-table"></div>
|
||
${data.canDelete == 0
|
||
? '<button disabled class="btn-dataTable" title=" حذف "><i class="fa fa-trash icon-btnTable"></i></button>'
|
||
: '<button class="btn-dataTable delete-contract-btn" title=" حذف "><i class="fa fa-trash icon-btnTable"></i></button>'
|
||
}
|
||
</div>
|
||
`;
|
||
},
|
||
searchable: false,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'option',
|
||
type: 'option'
|
||
},
|
||
render: function (data) {
|
||
return data.canAddProject == 0
|
||
? `<button disabled class="btn-dataTable" title="ثبت اطلاعات زیر پروژه"><i class="fa fa-plus icon-btnTable"></i></button>`
|
||
: `<button class="btn-dataTable how-add-subcontract" title="ثبت اطلاعات زیر پروژه"><i class="fa fa-plus icon-btnTable"></i></button>`;
|
||
},
|
||
searchable: false,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle",
|
||
data: null,
|
||
name: {
|
||
name: 'option',
|
||
type: 'option'
|
||
},
|
||
render: function (data, type, row) {
|
||
return data.canShowProject == 0
|
||
? "-"
|
||
: row.status_rel == 2
|
||
? `<button class="btn-dataTable show-subcontract-btn" title="نمایش زیر پروژه"><i class="far fa-eye icon-btnTable"></i></button><p>${data.subitems_count}</p>`
|
||
: `<button class="btn-dataTable" disabled title="نمایش زیر پروژه"><i class="far fa-eye icon-btnTable"></i></button><p>${data.subitems_count}</p>`;
|
||
},
|
||
searchable: false,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle d-none",
|
||
data: "province_id",
|
||
name: {
|
||
name: 'contracts.province_id',
|
||
type: 'multi_select'
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle d-none",
|
||
data: "status_id",
|
||
name: {
|
||
name: 'status_id',
|
||
type: 'multi_select'
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle d-none",
|
||
data: "status_rel",
|
||
name: {
|
||
name: 'status_rel',
|
||
type: 'select'
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
{
|
||
className: "text-center sorting align-middle d-none",
|
||
data: "status_rel",
|
||
name: {
|
||
name: 'project_type_id',
|
||
type: 'relation.multi_select'
|
||
},
|
||
searchable: true,
|
||
orderable: false,
|
||
},
|
||
],
|
||
buttons: [
|
||
{
|
||
className: "static-btn-cta",
|
||
text: '<div class="btn-table-excel"><div class="d-flex flex-column"><i class="fa mb-2 fa-book icon-color"></i>گزارش آماری</div></div>',
|
||
action: function (e, dt, node, config) {
|
||
$(".parent-excel").css("display", "block");
|
||
},
|
||
},
|
||
{
|
||
className: "excel-btn-cta",
|
||
text: '<div class="btn-table-excel"><div class="d-flex flex-column"><i class="fa fa-check-circle mb-2 icon-color"></i>خروجی قرارداد</div></div>',
|
||
action: function (e, dt, node, config) {
|
||
const url = `https://rms.rmto.ir/reports/contracts${queryParemsExcel.length != 0 ? `?${queryParemsExcel.join("&")}` : ""
|
||
}`;
|
||
window.open(url, "_blank");
|
||
},
|
||
},
|
||
{
|
||
className: "word-btn-cta",
|
||
text: '<div class="btn-table-word"><div class="d-flex flex-column"><i class="fas fa-file-pdf mb-2 icon-color"></i>خروجی به PDF</div></div>',
|
||
action: function (e, dt, node, config) {
|
||
$(".parent-word").css("display", "block");
|
||
},
|
||
},
|
||
|
||
{
|
||
text: '<div class="btn-table-filter"><div class="d-flex flex-column"><i class="fa mb-2 fa-filter icon-color"></i> فیلترینگ پیشرفته</div></div>',
|
||
action: function (e, dt, node, config) {
|
||
$(".parent-filter").css("display", "block");
|
||
},
|
||
},
|
||
|
||
{
|
||
text: "<div class='d-flex flex-column'><i class='fa mb-2 fa-download icon-color'></i>دانلود فیلم راهنما</div>",
|
||
action: function (e, dt, node, config) {
|
||
window.open("/storage/2021-07-03_13-24-331_1.mp4", "_blank");
|
||
},
|
||
},
|
||
],
|
||
initComplete: function () {
|
||
$("body").find(".dataTables_scrollBody").addClass("scrollbar");
|
||
if (
|
||
!(
|
||
$.inArray("word-export-contract", PERMISSIONS) != -1 ||
|
||
$.inArray("word-export-province", PERMISSIONS) != -1
|
||
)
|
||
)
|
||
$(".word-btn-cta").prop("disabled", true);
|
||
if (!($.inArray("excel-export-statistics", PERMISSIONS) != -1))
|
||
$(".static-btn-cta").prop("disabled", true);
|
||
if (!($.inArray("excel-export-contract", PERMISSIONS) != -1))
|
||
$(".excel-btn-cta").prop("disabled", true);
|
||
|
||
hideLoaderScreen();
|
||
},
|
||
});
|
||
|
||
});
|
||
|
||
//(add)
|
||
$(document).on("click", ".add-contract-btn", function () {
|
||
$("#add-contract-cta").prop("disabled", false);
|
||
//clear data (add)
|
||
$(".select-add-contract").val(0);
|
||
$(".select-add-contract").removeClass("validity-checker");
|
||
$(".select2-add-contract").empty();
|
||
$(".select2-selection").removeClass("validity-checker");
|
||
$(".input-add-contract").val("");
|
||
$(".input-add-contract").removeClass("validity-checker");
|
||
$(".add-contract-span").text("0");
|
||
$(".checkbox-for-convening").prop("checked", false);
|
||
$(".tripple-amount").css("display", "none");
|
||
|
||
planNumber();
|
||
});
|
||
$(document).on("click", "#add-contract-cta", function () {
|
||
var addContractPlanNum = [];
|
||
$("#add-contract-cta").prop("disabled", true);
|
||
// validity
|
||
const parent = $(this).parents("#add-contract-modal");
|
||
parent.find(".input-add-contract").each(function () {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".select-add-contract").each(function () {
|
||
if ($(this).val() != 0) {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
|
||
parent.find(".checkbox-contracts").each(function () {
|
||
const checkboxFlag = $(this).attr("checkboxFlag");
|
||
if (!$(this).prop("checked")) {
|
||
parent
|
||
.find(`.${checkboxFlag} .input-add-contract`)
|
||
.removeClass("validity-checker");
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.removeClass("validity-checker");
|
||
} else {
|
||
if (parent.find(".select2-add-contract").val() != "") {
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.removeClass("validity-checker");
|
||
} else {
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.addClass("validity-checker");
|
||
}
|
||
}
|
||
});
|
||
// end validity
|
||
|
||
// giving all values
|
||
const addContractAdministrationId = $("#add-contract-administration").val();
|
||
const addContractAdministrationFa = $("#add-contract-administration")
|
||
.children("option:selected")
|
||
.text();
|
||
const addContractProvinceId = $("#add-contract-province").val();
|
||
const addContractProvinceFa = $("#add-contract-province")
|
||
.children("option:selected")
|
||
.text();
|
||
const addContractTitle = $("#add-contract-title").val();
|
||
const addContractConditionId = $("#add-contract-Condition").val();
|
||
const addContractConditionFa = $("#add-contract-Condition")
|
||
.children("option:selected")
|
||
.text();
|
||
const addContractConveningDate = moment(
|
||
addDatepicker.getState().selected.unixDate
|
||
).format("jYYYY-jMM-jDD");
|
||
const addContractContractorName = $("#add-contract-Contractor-name").val();
|
||
const addContractConsultantDesign = $(
|
||
"#add-contract-Consultant-design"
|
||
).val();
|
||
const addContractConsultantMonitoring = $(
|
||
"#add-contract-Consultant-Monitoring"
|
||
).val();
|
||
const contract_number = $(
|
||
"#add-contract-contract-number"
|
||
).val();
|
||
const addContractAllcontractAmount = $(
|
||
"#add-contract-allcontract-amount"
|
||
).val();
|
||
let addContractCommunicatedNationalAmount = "";
|
||
let addContractCommunicatedProvinceAmount = "";
|
||
let addContractHeadquartersCertificateAmount = "";
|
||
let valid_license = false;
|
||
let nationalCreditLicense = 0;
|
||
let provinceCreditLicense = 0;
|
||
let headquarterIssuedLicense = 0;
|
||
let provinceIssuedLicense = 0;
|
||
|
||
let formData = new FormData();
|
||
if ($("#add-contract-Communicated-Credit-National").is(":checked")) {
|
||
nationalCreditLicense = 1;
|
||
valid_license = true;
|
||
addContractCommunicatedNationalAmount = $(
|
||
"#add-contract-Communicated-national-amount"
|
||
).val();
|
||
$("#add-contract-Plan-num")
|
||
.select2("data")
|
||
.forEach((element) => {
|
||
addContractPlanNum.push(element.text);
|
||
});
|
||
}
|
||
if ($("#add-contract-Communicated-credit-province").is(":checked")) {
|
||
provinceCreditLicense = 1;
|
||
valid_license = true;
|
||
addContractCommunicatedProvinceAmount = $(
|
||
"#add-contract-Communicated-province-amount"
|
||
).val();
|
||
}
|
||
if ($("#add-contract-headquarters-certificate").is(":checked")) {
|
||
headquarterIssuedLicense = 1;
|
||
valid_license = true;
|
||
addContractHeadquartersCertificateAmount = $(
|
||
"#add-contract-headquarters-certificate-amount"
|
||
).val();
|
||
}
|
||
if ($("#add-contract-Communicated-province-certificate").is(":checked")) {
|
||
provinceIssuedLicense = 1;
|
||
valid_license = true;
|
||
}
|
||
formData.append("national_credit_license", nationalCreditLicense);
|
||
formData.append("province_credit_license", provinceCreditLicense);
|
||
formData.append("province_issued_license", provinceIssuedLicense);
|
||
formData.append("headquarter_issued_license", headquarterIssuedLicense);
|
||
|
||
formData.append(
|
||
"contract_credit_national",
|
||
addContractCommunicatedNationalAmount
|
||
);
|
||
formData.append(
|
||
"contract_credit_province",
|
||
addContractCommunicatedProvinceAmount
|
||
);
|
||
formData.append(
|
||
"contract_credit_headquarter",
|
||
addContractHeadquartersCertificateAmount
|
||
);
|
||
|
||
formData.append("contract_tarh_array", addContractPlanNum);
|
||
|
||
formData.append("contract_credit", addContractAllcontractAmount);
|
||
// end giving all values
|
||
formData.append("office_id", addContractAdministrationId);
|
||
formData.append("office_fa", addContractAdministrationFa);
|
||
formData.append("province_id", addContractProvinceId);
|
||
formData.append("province_fa", addContractProvinceFa);
|
||
formData.append("title", addContractTitle);
|
||
formData.append("status_fa", addContractConditionFa);
|
||
formData.append("status_id", addContractConditionId);
|
||
formData.append("contract_date", addContractConveningDate);
|
||
formData.append("contract_peymankar", addContractContractorName);
|
||
formData.append("contract_moshaver_tarahi", addContractConsultantDesign);
|
||
formData.append("contract_moshaver_nezarat", addContractConsultantMonitoring);
|
||
formData.append("contract_number", contract_number);
|
||
if (!valid_license) {
|
||
$("#add-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "حداقل یکی از مجوز های انعقاد قرارداد را انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else if ($("#add-contract-modal").find(".validity-checker").length != 0) {
|
||
$("#add-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "مقادیر مشخص شده را پر کنید",
|
||
text: "اگر همچنان با این اخطار مواجه شدید با پشتیبانی تماس بگیرید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/contracts/store-dev",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
$("#add-contract-modal").modal("hide");
|
||
$("#add-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "success",
|
||
text: "قرارداد با موفقیت ثبت شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
isReloadAjax = true;
|
||
table.ajax.reload(null, false);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
$("#add-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
});
|
||
//(end add)
|
||
|
||
// lisence warning hider and shower
|
||
$(".checkbox-for-convening").change(function () {
|
||
if ($(".checkbox-for-convening").is(":checked")) {
|
||
$(".add-warning-lisence").fadeOut(300);
|
||
} else {
|
||
$(".add-warning-lisence").fadeIn(300);
|
||
}
|
||
});
|
||
$(".checkbox-for-convening-edit").change(function () {
|
||
if ($(".checkbox-for-convening-edit").is(":checked")) {
|
||
$(".edit-warning-lisence").fadeOut(300);
|
||
} else {
|
||
$(".edit-warning-lisence").fadeIn(300);
|
||
}
|
||
});
|
||
// end lisence warning hider and shower
|
||
|
||
//(edit)
|
||
$(document).on("click", ".edit-contract-btn", function () {
|
||
$("#edit-contract-Condition option").prop("disabled", false);
|
||
//clear data (edit)
|
||
$(".select-edit-contract").val(0);
|
||
$(".select-edit-contract").removeClass("validity-checker");
|
||
$(".select2-edit-contract").empty();
|
||
$(".select2-selection").removeClass("validity-checker");
|
||
$(".input-edit-contract").val("");
|
||
$(".input-edit-contract").removeClass("validity-checker");
|
||
$(".edit-contract-span").text("0");
|
||
$(".checkbox-for-convening-edit").prop("checked", false);
|
||
$(".tripple-amount-edit").css("display", "none");
|
||
$("#edit-contract-province").prop("disabled", true);
|
||
|
||
// giving data from table
|
||
const tr = $(this).closest("tr");
|
||
const row = table.row(tr);
|
||
contractRowId = row.data().id;
|
||
const officeId = row.data().office_id;
|
||
const provinceId = row.data().province_id;
|
||
const statusId = row.data().status_id;
|
||
const title = row.data().title;
|
||
|
||
const contractPeymankar = row.data().contract_peymankar;
|
||
const contractMoshaverTarahi = row.data().contract_moshaver_tarahi;
|
||
const contractMoshaverNezarat = row.data().contract_moshaver_nezarat;
|
||
const contract_number = row.data().contract_number;
|
||
|
||
const nationalCreditLicense = row.data().national_credit_license;
|
||
const provinceCreditLicense = row.data().province_credit_license;
|
||
const provinceIssuedLicense = row.data().province_issued_license;
|
||
const headquarterIssuedLicense = row.data().headquarter_issued_license;
|
||
|
||
const contractTarhArray =
|
||
row.data().contract_tarh_array == null
|
||
? []
|
||
: row.data().contract_tarh_array.split(",");
|
||
|
||
const contractCreditNational = row.data().contract_credit_national;
|
||
const contractCreditProvince = row.data().contract_credit_province;
|
||
const contractCreditHeadquarter = row.data().contract_credit_headquarter;
|
||
|
||
const contractCredit = row.data().contract_credit;
|
||
|
||
// giving data from table
|
||
|
||
// appending data
|
||
|
||
$("#edit-contract-administration").val(officeId);
|
||
$("#edit-contract-province").val(provinceId);
|
||
$("#edit-contract-title").val(title);
|
||
$("#edit-contract-Condition").val(statusId);
|
||
$("#edit-contract-convening-date").val(moment(row.data().contract_date).format("YYYY/MM/DD"));
|
||
$("#edit-contract-Contractor-name").val(contractPeymankar);
|
||
$("#edit-contract-Consultant-design").val(contractMoshaverTarahi);
|
||
$("#edit-contract-Consultant-Monitoring").val(contractMoshaverNezarat);
|
||
$("#edit-contract-contract-number").val(contract_number);
|
||
$("#edit-contract-Communicated-national-amount").val(contractCreditNational);
|
||
$("#edit-contract-Communicated-national-amount-span").text(
|
||
parseFloat(
|
||
contractCreditNational != null ? contractCreditNational : 0
|
||
).toLocaleString("en")
|
||
);
|
||
$("#edit-contract-Communicated-province-amount").val(contractCreditProvince);
|
||
$("#edit-contract-Communicated-province-amount-span").text(
|
||
parseFloat(
|
||
contractCreditProvince != null ? contractCreditProvince : 0
|
||
).toLocaleString("en")
|
||
);
|
||
$("#edit-contract-headquarters-certificate-amount").val(
|
||
contractCreditHeadquarter
|
||
);
|
||
$("#edit-contract-headquarters-certificate-amount-span").text(
|
||
parseFloat(
|
||
contractCreditHeadquarter != null ? contractCreditHeadquarter : 0
|
||
).toLocaleString("en")
|
||
);
|
||
$("#edit-contract-allcontract-amount").val(contractCredit);
|
||
$("#edit-contract-allcontract-amount-span").text(
|
||
parseFloat(contractCredit != null ? contractCredit : 0).toLocaleString("en")
|
||
);
|
||
|
||
// checkboxes
|
||
if (nationalCreditLicense == 1) {
|
||
$("#edit-contract-Communicated-Credit-National").prop("checked", true);
|
||
$(".checkbox-national-edit").slideDown("300");
|
||
}
|
||
if (provinceCreditLicense == 1) {
|
||
$("#edit-contract-Communicated-credit-province").prop("checked", true);
|
||
$(".checkbox-province-edit").slideDown("300");
|
||
}
|
||
if (headquarterIssuedLicense == 1) {
|
||
$("#edit-contract-headquarters-certificate").prop("checked", true);
|
||
$(".checkbox-headquarters-edit").slideDown("300");
|
||
}
|
||
if (provinceIssuedLicense == 1) {
|
||
$("#edit-contract-Communicated-province-certificate").prop("checked", true);
|
||
}
|
||
// checkboxes
|
||
|
||
// lisence warning hider and shower
|
||
if (
|
||
nationalCreditLicense == 1 ||
|
||
provinceCreditLicense == 1 ||
|
||
headquarterIssuedLicense == 1 ||
|
||
provinceIssuedLicense == 1
|
||
) {
|
||
$(".edit-warning-lisence").fadeOut(300);
|
||
} else {
|
||
$(".edit-warning-lisence").fadeIn(300);
|
||
}
|
||
// end lisence warning hider and shower
|
||
|
||
// appending data
|
||
|
||
// sorting conditon
|
||
const sortingValue = $("#edit-contract-Condition option:selected").index();
|
||
$(`#edit-contract-Condition option:lt(${sortingValue})`).prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
|
||
planNumberedit(contractTarhArray);
|
||
});
|
||
$(document).on("click", "#edit-contract-cta", function () {
|
||
let editContractPlanNum = [];
|
||
// validity
|
||
const parent = $(this).parents("#edit-contract-modal");
|
||
parent.find(".input-edit-contract").each(function () {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".select-edit-contract").each(function () {
|
||
if ($(this).val() != 0) {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".checkbox-contracts-edit").each(function () {
|
||
const checkboxFlag = $(this).attr("checkboxFlag");
|
||
if (!$(this).prop("checked")) {
|
||
parent
|
||
.find(`.${checkboxFlag} .input-edit-contract`)
|
||
.removeClass("validity-checker");
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.removeClass("validity-checker");
|
||
} else {
|
||
if (parent.find(".select2-edit-contract").val() != "") {
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.removeClass("validity-checker");
|
||
} else {
|
||
parent
|
||
.find(`.${checkboxFlag} .select2-selection`)
|
||
.addClass("validity-checker");
|
||
}
|
||
}
|
||
});
|
||
// end validity
|
||
|
||
// sending data
|
||
|
||
// giving all values
|
||
const editContractAdministrationId = $("#edit-contract-administration").val();
|
||
const editContractAdministrationFa = $("#edit-contract-administration")
|
||
.children("option:selected")
|
||
.text();
|
||
const editContractProvinceId = $("#edit-contract-province").val();
|
||
const editContractProvinceFa = $("#edit-contract-province")
|
||
.children("option:selected")
|
||
.text();
|
||
const editContractTitle = $("#edit-contract-title").val();
|
||
const editContractConditionId = $("#edit-contract-Condition").val();
|
||
const editContractConditionFa = $("#edit-contract-Condition")
|
||
.children("option:selected")
|
||
.text();
|
||
const editContractConveningDate = moment(
|
||
editDatepicker.getState().selected.unixDate
|
||
).format("jYYYY-jMM-jDD");
|
||
const editContractContractorName = $("#edit-contract-Contractor-name").val();
|
||
const editContractConsultantDesign = $(
|
||
"#edit-contract-Consultant-design"
|
||
).val();
|
||
const contract_number = $(
|
||
"#edit-contract-contract-number"
|
||
).val();
|
||
const editContractConsultantMonitoring = $(
|
||
"#edit-contract-Consultant-Monitoring"
|
||
).val();
|
||
const editContractAllcontractAmount = $(
|
||
"#edit-contract-allcontract-amount"
|
||
).val();
|
||
let editContractCommunicatedNationalAmount = "";
|
||
let editContractCommunicatedProvinceAmount = "";
|
||
let editContractHeadquartersCertificateAmount = "";
|
||
let valid_license = false;
|
||
let nationalCreditLicense = 0;
|
||
let provinceCreditLicense = 0;
|
||
let headquarterIssuedLicense = 0;
|
||
let provinceIssuedLicense = 0;
|
||
|
||
let formData = new FormData();
|
||
if ($("#edit-contract-Communicated-Credit-National").is(":checked")) {
|
||
nationalCreditLicense = 1;
|
||
valid_license = true;
|
||
editContractCommunicatedNationalAmount = $(
|
||
"#edit-contract-Communicated-national-amount"
|
||
).val();
|
||
$("#edit-contract-Plan-num")
|
||
.select2("data")
|
||
.forEach((element) => {
|
||
editContractPlanNum.push(element.text);
|
||
});
|
||
}
|
||
if ($("#edit-contract-Communicated-credit-province").is(":checked")) {
|
||
provinceCreditLicense = 1;
|
||
valid_license = true;
|
||
editContractCommunicatedProvinceAmount = $(
|
||
"#edit-contract-Communicated-province-amount"
|
||
).val();
|
||
}
|
||
if ($("#edit-contract-headquarters-certificate").is(":checked")) {
|
||
headquarterIssuedLicense = 1;
|
||
valid_license = true;
|
||
editContractHeadquartersCertificateAmount = $(
|
||
"#edit-contract-headquarters-certificate-amount"
|
||
).val();
|
||
}
|
||
if ($("#edit-contract-Communicated-province-certificate").is(":checked")) {
|
||
provinceIssuedLicense = 1;
|
||
valid_license = true;
|
||
}
|
||
formData.append("national_credit_license", nationalCreditLicense);
|
||
formData.append("province_credit_license", provinceCreditLicense);
|
||
formData.append("province_issued_license", provinceIssuedLicense);
|
||
formData.append("headquarter_issued_license", headquarterIssuedLicense);
|
||
|
||
formData.append(
|
||
"contract_credit_national",
|
||
editContractCommunicatedNationalAmount
|
||
);
|
||
formData.append(
|
||
"contract_credit_province",
|
||
editContractCommunicatedProvinceAmount
|
||
);
|
||
formData.append(
|
||
"contract_credit_headquarter",
|
||
editContractHeadquartersCertificateAmount
|
||
);
|
||
|
||
formData.append("contract_tarh_array", editContractPlanNum);
|
||
|
||
formData.append("contract_credit", editContractAllcontractAmount);
|
||
// end giving all values
|
||
formData.append("office_id", editContractAdministrationId);
|
||
formData.append("office_fa", editContractAdministrationFa);
|
||
formData.append("province_id", editContractProvinceId);
|
||
formData.append("province_fa", editContractProvinceFa);
|
||
formData.append("title", editContractTitle);
|
||
formData.append("status_fa", editContractConditionFa);
|
||
formData.append("status_id", editContractConditionId);
|
||
formData.append("contract_date", editContractConveningDate);
|
||
formData.append("contract_peymankar", editContractContractorName);
|
||
formData.append("contract_moshaver_tarahi", editContractConsultantDesign);
|
||
formData.append("contract_number", contract_number);
|
||
formData.append("contract_moshaver_nezarat", editContractConsultantMonitoring);
|
||
if (!valid_license) {
|
||
$("#edit-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "حداقل یکی از مجوز های انعقاد قرارداد را انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else if ($("#edit-contract-modal").find(".validity-checker").length != 0) {
|
||
$("#edit-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "مقادیر مشخص شده را پر کنید",
|
||
text: "اگر همچنان با این اخطار مواجه شدید با پشتیبانی تماس بگیرید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/contracts/update-dev/" + contractRowId,
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
$("#edit-contract-modal").modal("hide");
|
||
$("#edit-contract-cta").prop("disabled", false);
|
||
isReloadAjax = true;
|
||
table.ajax.reload(null, false);
|
||
hideLoaderScreen();
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
$("#edit-contract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
// sending data
|
||
});
|
||
//(end edit)
|
||
|
||
//(howaddSub)
|
||
$(document).on("click", ".how-add-subcontract", function () {
|
||
let tr = $(this).closest("tr");
|
||
let row = table.row(tr);
|
||
titlecontract = row.data().title;
|
||
provinceIdForSub = row.data().province_id;
|
||
statusIdForSub = row.data().status_id;
|
||
contractRowId = row.data().id;
|
||
const selectedRowContractData = row.data();
|
||
$(".how-add-subcontract-modal-title").text(selectedRowContractData.unique_id);
|
||
$(".add-subcontract-modal-title").text(selectedRowContractData.unique_id);
|
||
$("#add-subcontract-nature").empty();
|
||
$("#add-subcontract-nature").append(
|
||
`<option value="0">انتخاب ماهیت پروژه</option>`
|
||
);
|
||
getSubcontractNature();
|
||
$("#how-add-subcontract-modal").modal("show");
|
||
});
|
||
//(end howaddSub)
|
||
|
||
//(addSub)
|
||
|
||
$(document).on("click", "#add_new_subcontract", function () {
|
||
addNewSubitemStatus = "true";
|
||
var positions = null;
|
||
// clear all data
|
||
$(".attent_num").css("display", "");
|
||
$("#add-subcontract-modal").find("tfoot").addClass("d-none");
|
||
$(".show-city-past").addClass("d-none");
|
||
$(".show-axisName-past").addClass("d-none");
|
||
$(".show-axisTypeFa-past").addClass("d-none");
|
||
$(".select-add-subcontract").val(0);
|
||
$(".select-add-subcontract").removeClass("validity-checker");
|
||
$("#add_project_start_map").val("");
|
||
$("#add_project_end_map").val("");
|
||
$(".input-map-project").removeClass("validity-checker");
|
||
$(".input-add-subcontract").val("");
|
||
$(".input-add-subcontract").removeClass("validity-checker");
|
||
$(".span-add-subcontract").text("0");
|
||
$("#add-Supervisor-number").val("09");
|
||
$("#add-Supervisor-number").removeClass("validity-checker");
|
||
$(".map-endplace-title").addClass("d-none");
|
||
$("#limit_percentage").addClass("d-none");
|
||
$(".add-subcontract-action-type-all").empty();
|
||
$(".add-subcontract-action-type-all").prop("disabled", true);
|
||
$(".add-subcontract-action-type-show-all").text("");
|
||
$(".add-subcontract-action-type-unit-all").text("-");
|
||
$(".add-subcontract-type-unit-show-all").text("-");
|
||
$(".add-subcontract-action-type-amount-all").prop("disabled", true);
|
||
$(".add-subcontract-type-amount-show-all").text("");
|
||
$(".tonaj").addClass("d-none");
|
||
$(".add-subcontract-action-type-progress-all").prop("disabled", true);
|
||
// clear image part
|
||
$("#add-subcontract-modal").find(".img-preview").removeAttr("src", "");
|
||
$("#add-subcontract-modal").find(".img-title").css("display", "");
|
||
$("#add-subcontract-modal").find(".btn-delete-img").prop("disabled", true);
|
||
$(".imgbox").removeClass("validity-checker");
|
||
$("#add-subcontract-nature").prop("disabled", false);
|
||
$("#deviceImg1load").css("display", "none");
|
||
$("#deviceImg2load").css("display", "none");
|
||
// clear image part
|
||
|
||
// end clear all data
|
||
if (addMap == null) {
|
||
setTimeout(() => {
|
||
createAddMap(positions);
|
||
}, 400);
|
||
} else {
|
||
setTimeout(() => {
|
||
clearAddMap(positions);
|
||
}, 400);
|
||
}
|
||
// giving needed data from contract
|
||
showSubProvince();
|
||
$("#add-subcontract-title").val(titlecontract);
|
||
if (statusIdForSub == 1) {
|
||
$("#add-subcontract-last-project-position").val(0);
|
||
$("#add-subcontract-last-project-position").prop("disabled", false);
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", false);
|
||
} else if (statusIdForSub == 2) {
|
||
$("#add-subcontract-last-project-position").val(4);
|
||
$("#add-subcontract-last-project-position").prop("disabled", true);
|
||
$("#add-subcontract-progress-mainpercent").val("5");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
} else if (statusIdForSub == 3) {
|
||
$("#add-subcontract-last-project-position").val(3);
|
||
$("#add-subcontract-last-project-position").prop("disabled", true);
|
||
$("#add-subcontract-progress-mainpercent").val("100");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
}
|
||
// giving needed data from contract
|
||
|
||
$("#add-subcontract-modal").modal("show");
|
||
});
|
||
//(end addSub)
|
||
//getSubcontractNature
|
||
function getSubcontractNature() {
|
||
$.each(operation_res, function (key, value) {
|
||
const limitAmount =
|
||
key == 1 || key == 3 || key == 6 ? "limitAmount" : "notlimit";
|
||
$("#add-subcontract-nature").append(
|
||
"<option isline='" +
|
||
value.is_line +
|
||
"' class='" +
|
||
limitAmount +
|
||
"' value='" +
|
||
value.id +
|
||
"'>" +
|
||
value.farsi +
|
||
"</option>"
|
||
);
|
||
});
|
||
}
|
||
|
||
// btn for poor data
|
||
$(document).on("click", ".without-Contractor-name", function () {
|
||
poorInfoParent = $(this).parents(".input-group");
|
||
poorInfoParent = $(poorInfoParent).find("input");
|
||
$(poorInfoParent).val("امانی");
|
||
});
|
||
$(document).on("click", ".without-advisor-name", function () {
|
||
poorInfoParent = $(this).parents(".input-group");
|
||
poorInfoParent = $(poorInfoParent).find("input");
|
||
$(poorInfoParent).val("ندارد");
|
||
});
|
||
// btn for poor data
|
||
$(document).on("change", ".checkbox-for-convening", function () {
|
||
const parent = $(this).parents(".modal");
|
||
const checkboxFlag = $(this).attr("checkboxFlag");
|
||
parent.find(`.${checkboxFlag}`).slideToggle(300);
|
||
});
|
||
|
||
$(document).on("change", ".checkbox-for-convening-edit", function () {
|
||
const parent = $(this).parents(".modal");
|
||
const checkboxFlag = $(this).attr("checkboxFlag");
|
||
parent.find(`.${checkboxFlag}`).slideToggle(300);
|
||
});
|
||
|
||
// add contract convening date start
|
||
addDatepicker = $("input[name=add-contract-convening-date]").persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
initialValue: false,
|
||
autoClose: true,
|
||
initialValueType: "persian",
|
||
});
|
||
editDatepicker = $(
|
||
"input[name=edit-contract-convening-date]"
|
||
).persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
initialValue: false,
|
||
autoClose: true,
|
||
initialValueType: "persian",
|
||
});
|
||
// end add contract convening date start
|
||
|
||
// delete row of main table
|
||
$("#main-table-contract").on("click", ".delete-contract-btn", function () {
|
||
let tr = $(this).closest("tr");
|
||
let row = table.row(tr);
|
||
let row_id = row.data().id;
|
||
let formData = new FormData();
|
||
formData.append("id", row_id);
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا برای حذف مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، حذف میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/contracts/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
isReloadAjax = true;
|
||
table.ajax.reload(null, false);
|
||
$("#show_subcontract_table").css("display", "none");
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در برقراری ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
// end delete row of main table
|
||
|
||
// phone number validity
|
||
function phone_checker() {
|
||
if ($(".number-validity").val().length == 11) {
|
||
$(".attent_num").fadeOut("100");
|
||
} else {
|
||
$(".attent_num").fadeIn("100");
|
||
}
|
||
}
|
||
|
||
function edit_phone_checker() {
|
||
if ($(".edit-number-validity").val().length == 11) {
|
||
$(".edit-attent_num").fadeOut("100");
|
||
} else {
|
||
$(".edit-attent_num").fadeIn("100");
|
||
}
|
||
}
|
||
// end phone number validity
|
||
|
||
// uploading file input
|
||
$(document).on("change", ".img-input", function () {
|
||
var input = this;
|
||
var parent = $(input).parents(".img-box");
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
reader.onload = function (e) {
|
||
parent.find(".img-title").css("display", "none");
|
||
parent.find(".btn-delete-img").removeAttr("disabled");
|
||
parent.find(".img-preview").attr("src", e.target.result);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
});
|
||
|
||
$(".btn-delete-img").on("click", function () {
|
||
var parent = $(this).parents(".img-box");
|
||
parent.find(".img-input").val("");
|
||
parent.find(".img-preview").removeAttr("src");
|
||
parent.find(".img-title").css("display", "");
|
||
$(this).attr("disabled", "disabled");
|
||
});
|
||
// end uploading file input
|
||
// modal cancel btn
|
||
$(".cancel").on("click", function () {
|
||
var ghostParent = $(this).parents(".modal");
|
||
ghostParent.modal("hide");
|
||
});
|
||
// modal cancel btn
|
||
// persian value limit text input
|
||
restrictInputOtherThanArabic($("input[type=text]"));
|
||
|
||
function restrictInputOtherThanArabic($field) {
|
||
var arabicCharUnicodeRange = /[\u0600-\u06FF-0-9-45]/;
|
||
|
||
$field.bind("keypress", function (event) {
|
||
var key = event.which;
|
||
if (key == 8 || key == 0 || key === 32) {
|
||
return true;
|
||
}
|
||
|
||
var str = String.fromCharCode(key);
|
||
if (arabicCharUnicodeRange.test(str)) {
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
});
|
||
}
|
||
// persian value limit text input
|
||
|
||
// seprate money amount
|
||
$('input[type="number"]').on("input", function () {
|
||
var parent = $(this).closest(".align-items-center");
|
||
if ($(this).val() == "") {
|
||
parent.find("span").text("0");
|
||
return false;
|
||
}
|
||
parent.find("span").text(parseFloat($(this).val()).toLocaleString("en"));
|
||
});
|
||
// end seprate money amount
|
||
// contract plan number
|
||
function planNumber() {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/contracts/eblagh",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
success: function (data) {
|
||
hideLoaderScreen();
|
||
var tarhnum = data.data;
|
||
var arrayeblagh = [];
|
||
for (let index = 0; index < tarhnum.length; index++) {
|
||
arrayeblagh.push(tarhnum[index].tarh_number);
|
||
}
|
||
var arraykol = [];
|
||
arraykol = cleanarray(arrayeblagh);
|
||
for (let index = 0; index < arraykol.length; index++) {
|
||
$("#add-contract-Plan-num").append(
|
||
"\
|
||
<option value=" +
|
||
index +
|
||
">" +
|
||
arraykol[index] +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
$("#add-contract-modal").modal("show");
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت شماره طرح",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
|
||
function planNumberedit(dataArray) {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/contracts/eblagh",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
success: function (data) {
|
||
hideLoaderScreen();
|
||
var tarhnum = data.data;
|
||
var arrayeblagh = [];
|
||
for (let index = 0; index < tarhnum.length; index++) {
|
||
arrayeblagh.push(tarhnum[index].tarh_number);
|
||
}
|
||
var arraykol = [];
|
||
arraykol = cleanarray(arrayeblagh);
|
||
for (let index = 0; index < arraykol.length; index++) {
|
||
if ($.inArray(arraykol[index], dataArray) != -1) {
|
||
$("#edit-contract-Plan-num").append(
|
||
"\
|
||
<option selected value=" +
|
||
index +
|
||
">" +
|
||
arraykol[index] +
|
||
"</option>\
|
||
"
|
||
);
|
||
} else {
|
||
$("#edit-contract-Plan-num").append(
|
||
"\
|
||
<option value=" +
|
||
index +
|
||
">" +
|
||
arraykol[index] +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
}
|
||
$("#edit-contract-modal").modal("show");
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت شماره طرح",
|
||
confirmButtonText: "بروزرسانی صفحه",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
// end contract plan number
|
||
// array cleaner
|
||
function cleanarray(list) {
|
||
var result = [];
|
||
$.each(list, function (i, e) {
|
||
if ($.inArray(e, result) == -1) result.push(e);
|
||
});
|
||
return result;
|
||
}
|
||
// end array cleaner
|
||
|
||
// project action type finder
|
||
$(document).on("change", "#add-subcontract-nature", function () {
|
||
clearAddMap();
|
||
const addSubcontractNature = $("#add-subcontract-nature").val();
|
||
showLoaderScreen();
|
||
$(".add-subcontract-action-type-amount-all").removeClass("validity-checker");
|
||
$(".add-subcontract-action-type-amount-all").attr("disabled", true);
|
||
$(".add-subcontract-action-type-all").empty();
|
||
$(".add-subcontract-action-type-amount-all").val("");
|
||
$(".add-subcontract-action-type-unit-all").text("-");
|
||
$(".add-subcontract-action-type-show-all").text("");
|
||
$(".add-subcontract-type-unit-show-all").text("-");
|
||
$(".add-subcontract-type-amount-show-all").text("");
|
||
$(".add-subcontract-action-type-progress-all").val("");
|
||
$(".add-subcontract-action-type-progress-all").removeClass(
|
||
"validity-checker"
|
||
);
|
||
$(".add-subcontract-action-type-progress-all").attr("disabled", true);
|
||
$(".add-subcontract-action-type-tonaj-all").val("");
|
||
$(".add-subcontract-action-type-tonaj-all").removeClass("validity-checker");
|
||
$(".add-subcontract-action-type-tonaj-all").attr("disabled", true);
|
||
$(".map-endplace-title").removeClass("d-none");
|
||
if (addSubcontractNature == 1) {
|
||
$(".tonaj").removeClass("d-none");
|
||
} else {
|
||
$(".tonaj").addClass("d-none");
|
||
}
|
||
if (addSubcontractNature == 0) {
|
||
$(".map-endplace-title").addClass("d-none");
|
||
hideLoaderScreen();
|
||
$(".add-subcontract-action-type-all").attr("disabled", true);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "لطفا نوع عملیات خود را به درستی انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
$(".add-subcontract-action-type-all").attr("disabled", false);
|
||
$(".add-subcontract-action-type-all").append(
|
||
"<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>"
|
||
);
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/operation/" + addSubcontractNature,
|
||
type: "GET",
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (res) {
|
||
$.each(res, function (key, value) {
|
||
const unit = value.unit != "" ? value.unit : "-";
|
||
const amountable = value.amountable;
|
||
$(".add-subcontract-action-type-all").append(
|
||
"<option amountable='" +
|
||
amountable +
|
||
"' unit='" +
|
||
unit +
|
||
"' value='" +
|
||
key +
|
||
"'>" +
|
||
value.farsi +
|
||
"</option>"
|
||
);
|
||
});
|
||
hideLoaderScreen();
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت نوع عملیات",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
});
|
||
|
||
$(document).on("change", "#edit-subcontract-nature", function () {
|
||
const editSubcontractNature = $("#edit-subcontract-nature").val();
|
||
$(".input-map-project").removeClass("validity-checker");
|
||
showLoaderScreen();
|
||
$(".edit-subcontract-action-type-amount-all").removeClass("validity-checker");
|
||
$(".edit-subcontract-action-type-amount-all").attr("disabled", true);
|
||
$(".edit-subcontract-action-type-all").empty();
|
||
$(".edit-subcontract-action-type-amount-all").val("");
|
||
$(".edit-subcontract-action-type-unit-all").text("-");
|
||
$(".edit-subcontract-action-type-show-all").text("");
|
||
$(".edit-subcontract-type-unit-show-all").text("-");
|
||
$(".edit-subcontract-type-amount-show-all").text("");
|
||
$(".edit-subcontract-action-type-progress-all").val("");
|
||
$(".edit-subcontract-action-type-progress-all").removeClass(
|
||
"validity-checker"
|
||
);
|
||
$(".edit-subcontract-action-type-progress-all").attr("disabled", true);
|
||
$(".edit-subcontract-action-type-tonaj-all").val("");
|
||
$(".edit-subcontract-action-type-tonaj-all").removeClass("validity-checker");
|
||
$(".edit-subcontract-action-type-tonaj-all").attr("disabled", true);
|
||
$(".map-endplace-title").removeClass("d-none");
|
||
if (editSubcontractNature == 1) {
|
||
$(".tonaj").removeClass("d-none");
|
||
} else {
|
||
$(".tonaj").addClass("d-none");
|
||
}
|
||
if (editSubcontractNature == 0) {
|
||
$(".map-endplace-title").addClass("d-none");
|
||
hideLoaderScreen();
|
||
$(".edit-subcontract-action-type-all").attr("disabled", true);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "لطفا نوع عملیات خود را به درستی انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
$(".edit-subcontract-action-type-all").attr("disabled", false);
|
||
$(".edit-subcontract-action-type-all").append(
|
||
"<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>"
|
||
);
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/operation/" + editSubcontractNature,
|
||
type: "GET",
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (res) {
|
||
$.each(res, function (key, value) {
|
||
const unit = value.unit != "" ? value.unit : "-";
|
||
const amountable = value.amountable;
|
||
$(".edit-subcontract-action-type-all").append(
|
||
"<option amountable='" +
|
||
amountable +
|
||
"' unit='" +
|
||
unit +
|
||
"' value='" +
|
||
key +
|
||
"'>" +
|
||
value.farsi +
|
||
"</option>"
|
||
);
|
||
});
|
||
hideLoaderScreen();
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت نوع عملیات",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
});
|
||
|
||
$(document).on("change", ".add-subcontract-action-type-all", function () {
|
||
const modal = $(this).parents("#add-subcontract-modal");
|
||
const boxIndex = $(this).parents("tr").data("boxIndex");
|
||
const trParent = $(this).closest("tr");
|
||
trParent.find(".add-subcontract-action-type-amount-all").val("");
|
||
let unit = $(this).find("option:selected").attr("unit");
|
||
let amountable = $(this).find("option:selected").attr("amountable");
|
||
trParent.find(".add-subcontract-action-type-unit-all").text(unit);
|
||
const opration = {
|
||
value: $(this).val(),
|
||
};
|
||
|
||
if (arrAddOprationsDisable[boxIndex] != opration.value)
|
||
arrAddOprationsDisable[boxIndex] = opration.value;
|
||
|
||
modal.find(".add-subcontract-action-type-all option").prop("disabled", false);
|
||
for (let i = 0; i < arrAddOprationsDisable.length; i++) {
|
||
if (arrAddOprationsDisable[i] != 0)
|
||
modal
|
||
.find(
|
||
`.add-subcontract-action-type-all option[value=${arrAddOprationsDisable[i]}]`
|
||
)
|
||
.prop("disabled", true);
|
||
}
|
||
|
||
$("#add-subcontract-action-type-unit-first-show").text(
|
||
$("#add-subcontract-action-type-unit-first").text()
|
||
);
|
||
$("#add-subcontract-action-type-unit-second-show").text(
|
||
$("#add-subcontract-action-type-unit-second").text()
|
||
);
|
||
$("#add-subcontract-action-type-unit-third-show").text(
|
||
$("#add-subcontract-action-type-unit-third").text()
|
||
);
|
||
$("#add-subcontract-action-type-unit-forth-show").text(
|
||
$("#add-subcontract-action-type-unit-forth").text()
|
||
);
|
||
$("#add-subcontract-action-type-amount-first-show").text(
|
||
$("#add-subcontract-action-type-amount-first").val()
|
||
);
|
||
$("#add-subcontract-action-type-amount-second-show").text(
|
||
$("#add-subcontract-action-type-amount-second").val()
|
||
);
|
||
$("#add-subcontract-action-type-amount-third-show").text(
|
||
$("#add-subcontract-action-type-amount-third").val()
|
||
);
|
||
$("#add-subcontract-action-type-amount-forth-show").text(
|
||
$("#add-subcontract-action-type-amount-forth").val()
|
||
);
|
||
|
||
if (amountable == 0) {
|
||
trParent
|
||
.find(".add-subcontract-action-type-amount-all")
|
||
.attr("disabled", true);
|
||
} else if (amountable == 1) {
|
||
trParent
|
||
.find(".add-subcontract-action-type-amount-all")
|
||
.attr("disabled", false);
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 1) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#add-subcontract-action-type-first-show").text("");
|
||
$("#add-subcontract-action-type-progress-first").val("");
|
||
$("#add-subcontract-action-type-tonaj-first").val("");
|
||
$("#add-subcontract-action-type-progress-first").attr("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-first").attr("disabled", true);
|
||
} else {
|
||
$("#add-subcontract-action-type-first-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#add-subcontract-action-type-progress-first").attr("disabled", false);
|
||
$("#add-subcontract-action-type-tonaj-first").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 2) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#add-subcontract-action-type-second-show").text("");
|
||
$("#add-subcontract-action-type-progress-second").val("");
|
||
$("#add-subcontract-action-type-tonaj-second").val("");
|
||
$("#add-subcontract-action-type-progress-second").attr("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-second").attr("disabled", true);
|
||
} else {
|
||
$("#add-subcontract-action-type-second-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#add-subcontract-action-type-progress-second").attr("disabled", false);
|
||
$("#add-subcontract-action-type-tonaj-second").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 3) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#add-subcontract-action-type-third-show").text("");
|
||
$("#add-subcontract-action-type-progress-third").val("");
|
||
$("#add-subcontract-action-type-tonaj-third").val("");
|
||
$("#add-subcontract-action-type-progress-third").attr("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-third").attr("disabled", true);
|
||
} else {
|
||
$("#add-subcontract-action-type-third-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#add-subcontract-action-type-progress-third").attr("disabled", false);
|
||
$("#add-subcontract-action-type-tonaj-third").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 4) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#add-subcontract-action-type-forth-show").text("");
|
||
$("#add-subcontract-action-type-progress-forth").val("");
|
||
$("#add-subcontract-action-type-tonaj-forth").val("");
|
||
$("#add-subcontract-action-type-progress-forth").attr("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-forth").attr("disabled", true);
|
||
} else {
|
||
$("#add-subcontract-action-type-forth-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#add-subcontract-action-type-progress-forth").attr("disabled", false);
|
||
$("#add-subcontract-action-type-tonaj-forth").attr("disabled", false);
|
||
}
|
||
}
|
||
if ($("#add-subcontract-action-type-first option:selected").val() == 113) {
|
||
$("#add-subcontract-action-type-tonaj-first").prop("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-first").val("")
|
||
}
|
||
|
||
if ($("#add-subcontract-action-type-second option:selected").val() == 113) {
|
||
$("#add-subcontract-action-type-tonaj-second").prop("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-second").val("")
|
||
}
|
||
|
||
if ($("#add-subcontract-action-type-third option:selected").val() == 113) {
|
||
$("#add-subcontract-action-type-tonaj-third").prop("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-third").val("")
|
||
}
|
||
|
||
if ($("#add-subcontract-action-type-forth option:selected").val() == 113) {
|
||
$("#add-subcontract-action-type-tonaj-forth").prop("disabled", true);
|
||
$("#add-subcontract-action-type-tonaj-forth").val("");
|
||
}
|
||
});
|
||
|
||
$(document).on("change", ".edit-subcontract-action-type-all", function () {
|
||
const modal = $(this).parents("#edit-subcontract-modal");
|
||
const boxIndex = $(this).parents("tr").data("boxIndex");
|
||
const trParent = $(this).closest("tr");
|
||
trParent.find(".edit-subcontract-action-type-amount-all").val("");
|
||
let unit = $(this).find("option:selected").attr("unit");
|
||
let amountable = $(this).find("option:selected").attr("amountable");
|
||
trParent.find(".edit-subcontract-action-type-unit-all").text(unit);
|
||
const opration = {
|
||
value: $(this).val(),
|
||
};
|
||
|
||
if (arrEditOprationsDisable[boxIndex] != opration.value)
|
||
arrEditOprationsDisable[boxIndex] = opration.value;
|
||
|
||
modal
|
||
.find(".edit-subcontract-action-type-all option")
|
||
.prop("disabled", false);
|
||
|
||
for (let i = 0; i < arrEditOprationsDisable.length; i++) {
|
||
if (arrEditOprationsDisable[i] != 0)
|
||
modal
|
||
.find(
|
||
`.edit-subcontract-action-type-all option[value=${arrEditOprationsDisable[i]}]`
|
||
)
|
||
.prop("disabled", true);
|
||
}
|
||
|
||
$("#edit-subcontract-action-type-unit-first-show").text(
|
||
$("#edit-subcontract-action-type-unit-first").text()
|
||
);
|
||
$("#edit-subcontract-action-type-unit-second-show").text(
|
||
$("#edit-subcontract-action-type-unit-second").text()
|
||
);
|
||
$("#edit-subcontract-action-type-unit-third-show").text(
|
||
$("#edit-subcontract-action-type-unit-third").text()
|
||
);
|
||
$("#edit-subcontract-action-type-unit-forth-show").text(
|
||
$("#edit-subcontract-action-type-unit-forth").text()
|
||
);
|
||
$("#edit-subcontract-action-type-amount-first-show").text(
|
||
$("#edit-subcontract-action-type-amount-first").val()
|
||
);
|
||
$("#edit-subcontract-action-type-amount-second-show").text(
|
||
$("#edit-subcontract-action-type-amount-second").val()
|
||
);
|
||
$("#edit-subcontract-action-type-amount-third-show").text(
|
||
$("#edit-subcontract-action-type-amount-third").val()
|
||
);
|
||
$("#edit-subcontract-action-type-amount-forth-show").text(
|
||
$("#edit-subcontract-action-type-amount-forth").val()
|
||
);
|
||
|
||
if (amountable == 0) {
|
||
trParent
|
||
.find(".edit-subcontract-action-type-amount-all")
|
||
.attr("disabled", true);
|
||
} else if (amountable == 1) {
|
||
trParent
|
||
.find(".edit-subcontract-action-type-amount-all")
|
||
.attr("disabled", false);
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 1) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#edit-subcontract-action-type-first-show").text("");
|
||
$("#edit-subcontract-action-type-progress-first").val("");
|
||
$("#edit-subcontract-action-type-tonaj-first").val("");
|
||
$("#edit-subcontract-action-type-progress-first").attr("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-first").attr("disabled", true);
|
||
} else {
|
||
$("#edit-subcontract-action-type-first-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#edit-subcontract-action-type-progress-first").attr("disabled", false);
|
||
$("#edit-subcontract-action-type-tonaj-first").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 2) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#edit-subcontract-action-type-second-show").text("");
|
||
$("#edit-subcontract-action-type-progress-second").val("");
|
||
$("#edit-subcontract-action-type-tonaj-second").val("");
|
||
$("#edit-subcontract-action-type-progress-second").attr("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-second").attr("disabled", true);
|
||
} else {
|
||
$("#edit-subcontract-action-type-second-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#edit-subcontract-action-type-progress-second").attr(
|
||
"disabled",
|
||
false
|
||
);
|
||
$("#edit-subcontract-action-type-tonaj-second").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 3) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#edit-subcontract-action-type-third-show").text("");
|
||
$("#edit-subcontract-action-type-progress-third").val("");
|
||
$("#edit-subcontract-action-type-tonaj-third").val("");
|
||
$("#edit-subcontract-action-type-progress-third").attr("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-third").attr("disabled", true);
|
||
} else {
|
||
$("#edit-subcontract-action-type-third-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#edit-subcontract-action-type-progress-third").attr("disabled", false);
|
||
$("#edit-subcontract-action-type-tonaj-third").attr("disabled", false);
|
||
}
|
||
}
|
||
|
||
if ($(this).data("subcontractAction") == 4) {
|
||
if ($(this).find("option:selected").val() == 0) {
|
||
$("#edit-subcontract-action-type-forth-show").text("");
|
||
$("#edit-subcontract-action-type-progress-forth").val("");
|
||
$("#edit-subcontract-action-type-tonaj-forth").val("");
|
||
$("#edit-subcontract-action-type-progress-forth").attr("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-forth").attr("disabled", true);
|
||
} else {
|
||
$("#edit-subcontract-action-type-forth-show").text(
|
||
$(this).find("option:selected").text()
|
||
);
|
||
$("#edit-subcontract-action-type-progress-forth").attr("disabled", false);
|
||
$("#edit-subcontract-action-type-tonaj-forth").attr("disabled", false);
|
||
}
|
||
}
|
||
if ($("#edit-subcontract-action-type-first option:selected").val() == 113) {
|
||
$("#edit-subcontract-action-type-tonaj-first").prop("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-first").val("")
|
||
}
|
||
|
||
if ($("#edit-subcontract-action-type-second option:selected").val() == 113) {
|
||
$("#edit-subcontract-action-type-tonaj-second").prop("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-second").val("")
|
||
}
|
||
|
||
if ($("#edit-subcontract-action-type-third option:selected").val() == 113) {
|
||
$("#edit-subcontract-action-type-tonaj-third").prop("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-third").val("")
|
||
}
|
||
|
||
if ($("#edit-subcontract-action-type-forth option:selected").val() == 113) {
|
||
$("#edit-subcontract-action-type-tonaj-forth").prop("disabled", true);
|
||
$("#edit-subcontract-action-type-tonaj-forth").val("");
|
||
}
|
||
});
|
||
|
||
$(document).on("click", "#add-subcontract-cta", function () {
|
||
var end_lat = null;
|
||
var end_lng = null;
|
||
let actionChecker = false;
|
||
$("#add-subcontract-cta").prop("disabled", true);
|
||
// checking validity
|
||
const parent = $(this).parents("#add-subcontract-modal");
|
||
parent.find(".input-map-project").each(function () {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
if ($("#add-Supervisor-number").val().length != 11) {
|
||
$("#add-Supervisor-number").addClass("validity-checker");
|
||
} else {
|
||
$("#add-Supervisor-number").removeClass("validity-checker");
|
||
}
|
||
parent.find(".input-add-subcontract").each(function () {
|
||
if (!$(this).prop("disabled")) {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
} else {
|
||
$(this).removeClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".add-subcontract-action-type-tonaj-all").each(function () {
|
||
if ($("#add-subcontract-nature").val() == 1) {
|
||
if (!$(this).prop("disabled")) {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
} else {
|
||
$(this).removeClass("validity-checker");
|
||
}
|
||
}
|
||
});
|
||
parent.find(".select-add-subcontract").each(function () {
|
||
if ($(this).val() != 0) {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".img-preview").each(function () {
|
||
if ($(this).prop("src") == "") {
|
||
$(this).parents(".imgbox").addClass("validity-checker");
|
||
} else {
|
||
$(this).parents(".imgbox").removeClass("validity-checker");
|
||
}
|
||
});
|
||
if ($("#add-subcontract-last-project-position").val() == 2) {
|
||
if ($("#add-subcontract-progress-mainpercent").val().length <= 1) {
|
||
$("#add-subcontract-progress-mainpercent").addClass("validity-checker");
|
||
} else {
|
||
$("#add-subcontract-progress-mainpercent").removeClass(
|
||
"validity-checker"
|
||
);
|
||
}
|
||
}
|
||
// checking validity
|
||
const project_title = $("#add-subcontract-title").val();
|
||
const project_type_id = $("#add-subcontract-nature").val();
|
||
const project_type_fa = $("#add-subcontract-nature option:selected").text();
|
||
|
||
const operation_type_id1 = $(
|
||
"#add-subcontract-action-type-first option:selected"
|
||
).val();
|
||
const operation_type_amount1 = $(
|
||
"#add-subcontract-action-type-amount-first"
|
||
).val();
|
||
const operation_type_progress1 = $(
|
||
"#add-subcontract-action-type-progress-first"
|
||
).val();
|
||
const operation_type_tonaj1 = $(
|
||
"#add-subcontract-action-type-tonaj-first"
|
||
).val();
|
||
|
||
const operation_type_id2 = $(
|
||
"#add-subcontract-action-type-second option:selected"
|
||
).val();
|
||
const operation_type_amount2 = $(
|
||
"#add-subcontract-action-type-amount-second"
|
||
).val();
|
||
const operation_type_progress2 = $(
|
||
"#add-subcontract-action-type-progress-second"
|
||
).val();
|
||
const operation_type_tonaj2 = $(
|
||
"#add-subcontract-action-type-tonaj-second"
|
||
).val();
|
||
|
||
const operation_type_id3 = $(
|
||
"#add-subcontract-action-type-third option:selected"
|
||
).val();
|
||
const operation_type_amount3 = $(
|
||
"#add-subcontract-action-type-amount-third"
|
||
).val();
|
||
const operation_type_progress3 = $(
|
||
"#add-subcontract-action-type-progress-third"
|
||
).val();
|
||
const operation_type_tonaj3 = $(
|
||
"#add-subcontract-action-type-tonaj-third"
|
||
).val();
|
||
|
||
const operation_type_id4 = $(
|
||
"#add-subcontract-action-type-forth option:selected"
|
||
).val();
|
||
const operation_type_amount4 = $(
|
||
"#add-subcontract-action-type-amount-forth"
|
||
).val();
|
||
const operation_type_progress4 = $(
|
||
"#add-subcontract-action-type-progress-forth"
|
||
).val();
|
||
const operation_type_tonaj4 = $(
|
||
"#add-subcontract-action-type-tonaj-forth"
|
||
).val();
|
||
|
||
const operator_name = $("#add-Supervisor-name").val();
|
||
const operator_phone = $("#add-Supervisor-number").val();
|
||
|
||
const priority_project = $("#add-subcontract-importance-degree").val();
|
||
const priority_project_fa = $(
|
||
"#add-subcontract-importance-degree option:selected"
|
||
).text();
|
||
const followup_priority_project_id = $(
|
||
"#add-subcontract-monitoring-degree"
|
||
).val();
|
||
const followup_priority_project = $(
|
||
"#add-subcontract-monitoring-degree option:selected"
|
||
).text();
|
||
|
||
const city_id = $("#add-subcontract-province").val();
|
||
const city_fa = $("#add-subcontract-province option:selected").text();
|
||
|
||
const axis_name_fa = $("#add-subcontract-axisName").val();
|
||
const axis_type_id = $("#add-subcontract-axisType").val();
|
||
const axis_type_fa = $("#add-subcontract-axisType option:selected").text();
|
||
|
||
const last_status_id = $("#add-subcontract-last-project-position").val();
|
||
const last_status_fa = $(
|
||
"#add-subcontract-last-project-position option:selected"
|
||
).text();
|
||
const progress_project = $("#add-subcontract-progress-mainpercent").val();
|
||
|
||
const last_digit_project = $(
|
||
"#add-subcontract-last-riali-digit-project"
|
||
).val();
|
||
const last_function_operator = $(
|
||
"#add-subcontract-last-amount-worker-function"
|
||
).val();
|
||
const last_payable_operator = $(
|
||
"#add-subcontract-last-payable-amount-worker"
|
||
).val();
|
||
const complete_payable = $(
|
||
"#add-subcontract-amount-for-ending-project"
|
||
).val();
|
||
const province_id = provinceIdForSub;
|
||
const contract_id = contractRowId;
|
||
const image1 = $("#deviceImg1").get(0).files[0];
|
||
const image2 = $("#deviceImg2").get(0).files[0];
|
||
const start_lat = startMarkerAdd.getLatLng().lat.toFixed(6);
|
||
const start_lng = startMarkerAdd.getLatLng().lng.toFixed(6);
|
||
end_lat = endMarkerAdd.getLatLng().lat.toFixed(6);
|
||
end_lng = endMarkerAdd.getLatLng().lng.toFixed(6);
|
||
let formData = new FormData();
|
||
if ($("#add-subcontract-action-type-first option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id1", operation_type_id1);
|
||
if ($("#add-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount1", operation_type_amount1);
|
||
}
|
||
formData.append("operation_type_progress1", operation_type_progress1);
|
||
if ($("#add-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj1", operation_type_tonaj1);
|
||
}
|
||
}
|
||
if ($("#add-subcontract-action-type-second option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id2", operation_type_id2);
|
||
if ($("#add-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount2", operation_type_amount2);
|
||
}
|
||
formData.append("operation_type_progress2", operation_type_progress2);
|
||
if ($("#add-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj2", operation_type_tonaj2);
|
||
}
|
||
}
|
||
if ($("#add-subcontract-action-type-third option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id3", operation_type_id3);
|
||
if ($("#add-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount3", operation_type_amount3);
|
||
}
|
||
formData.append("operation_type_progress3", operation_type_progress3);
|
||
if ($("#add-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj3", operation_type_tonaj3);
|
||
}
|
||
}
|
||
if ($("#add-subcontract-action-type-forth option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id4", operation_type_id4);
|
||
if ($("#add-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount4", operation_type_amount4);
|
||
}
|
||
formData.append("operation_type_progress4", operation_type_progress4);
|
||
if ($("#add-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj4", operation_type_tonaj4);
|
||
}
|
||
}
|
||
formData.append("project_title", project_title);
|
||
formData.append("project_type_id", project_type_id);
|
||
formData.append("project_type_fa", project_type_fa);
|
||
formData.append("operator_name", operator_name);
|
||
formData.append("province_id", province_id);
|
||
formData.append("operator_phone", operator_phone);
|
||
formData.append("priority_project", priority_project);
|
||
formData.append("priority_project_fa", priority_project_fa);
|
||
formData.append("followup_priority_project_id", followup_priority_project_id);
|
||
formData.append("followup_priority_project", followup_priority_project);
|
||
formData.append("city_id", city_id);
|
||
formData.append("city_fa", city_fa);
|
||
formData.append("axis_name_fa", axis_name_fa);
|
||
formData.append("axis_type_id", axis_type_id);
|
||
formData.append("axis_type_fa", axis_type_fa);
|
||
formData.append("last_status_id", last_status_id);
|
||
formData.append("last_status_fa", last_status_fa);
|
||
formData.append("progress_project", progress_project);
|
||
formData.append("last_digit_project", last_digit_project);
|
||
formData.append("last_function_operator", last_function_operator);
|
||
formData.append("last_payable_operator", last_payable_operator);
|
||
formData.append("complete_payable", complete_payable);
|
||
formData.append("contract_id", contract_id);
|
||
if (typeof image1 !== "undefined") formData.append("image1", image1);
|
||
if (typeof image2 !== "undefined") formData.append("image2", image2);
|
||
formData.append("start_lat", start_lat);
|
||
formData.append("start_lng", start_lng);
|
||
formData.append("end_lat", end_lat);
|
||
formData.append("end_lng", end_lng);
|
||
formData.append("addNewSubitemStatus", addNewSubitemStatus);
|
||
if (addNewSubitemStatus == "false")
|
||
formData.append(
|
||
"projectData_id",
|
||
$("#pre_distance_choose").data("projectId")
|
||
);
|
||
if (!actionChecker) {
|
||
$("#add-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "حداقل یکی از انواع عملیات را انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else if (
|
||
$("#add-subcontract-modal").find(".validity-checker").length != 0
|
||
) {
|
||
$("#add-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "مقادیر مشخص شده را پر کنید",
|
||
text: "اگر همچنان با این اخطار مواجه شدید با پشتیبانی تماس بگیرید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/store-dev",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
$("#add-subcontract-modal").modal("hide");
|
||
$("#how-add-subcontract-modal").modal("hide");
|
||
$("#choose-project-type-modal").modal("hide");
|
||
$("#add-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "success",
|
||
text: "زیر پروژه با موفقیت ثبت شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
isReloadAjax = true;
|
||
table.ajax.reload(null, false);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
$("#add-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
});
|
||
|
||
function showSubProvince(city_id) {
|
||
$("#add-subcontract-province").empty();
|
||
$("#add-subcontract-province").append(
|
||
'<option value="0">انتخاب شهرستان</option>'
|
||
);
|
||
$("#edit-subcontract-province").empty();
|
||
$("#edit-subcontract-province").append(
|
||
'<option value="0">انتخاب شهرستان</option>'
|
||
);
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/public/contents/provinces/" + provinceIdForSub,
|
||
type: "GET",
|
||
async: "false",
|
||
success: function (data) {
|
||
const list_citys = data.data;
|
||
for (let index = 0; index < list_citys.length; index++) {
|
||
$("#add-subcontract-province").append(
|
||
"<option value=" +
|
||
list_citys[index].id +
|
||
">" +
|
||
list_citys[index].name_fa +
|
||
"</option>"
|
||
);
|
||
$("#edit-subcontract-province").append(
|
||
"<option value=" +
|
||
list_citys[index].id +
|
||
">" +
|
||
list_citys[index].name_fa +
|
||
"</option>"
|
||
);
|
||
hideLoaderScreen();
|
||
}
|
||
$("#edit-subcontract-province").val(city_id);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت شهرستان",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
$(document).on("change", "#add-subcontract-last-project-position", function () {
|
||
if ($(this).val() == 1) {
|
||
$("#add-subcontract-progress-mainpercent").val("10");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#limit_percentage").addClass("d-none");
|
||
} else if ($(this).val() == 2) {
|
||
$("#add-subcontract-progress-mainpercent").val("");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", false);
|
||
$("#limit_percentage").removeClass("d-none");
|
||
} else if ($(this).val() == 3) {
|
||
$("#add-subcontract-progress-mainpercent").val("100");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#limit_percentage").addClass("d-none");
|
||
} else if ($(this).val() == 0) {
|
||
$("#add-subcontract-progress-mainpercent").val("");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", false);
|
||
$("#limit_percentage").addClass("d-none");
|
||
}
|
||
});
|
||
$(document).on(
|
||
"change",
|
||
"#edit-subcontract-last-project-position",
|
||
function () {
|
||
if ($(this).val() == 1) {
|
||
$("#edit-subcontract-progress-mainpercent").val("10");
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#edit_limit_percentage").addClass("d-none");
|
||
} else if ($(this).val() == 2) {
|
||
$("#edit-subcontract-progress-mainpercent").val("");
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", false);
|
||
$("#edit_limit_percentage").removeClass("d-none");
|
||
} else if ($(this).val() == 3) {
|
||
$("#edit-subcontract-progress-mainpercent").val("100");
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#edit_limit_percentage").addClass("d-none");
|
||
} else if ($(this).val() == 0) {
|
||
$("#edit-subcontract-progress-mainpercent").val("");
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", false);
|
||
$("#limit_percentage").addClass("d-none");
|
||
}
|
||
}
|
||
);
|
||
$(".add-subcontract-action-type-amount-all").on("input", function () {
|
||
const onTimeValue = $(this).val();
|
||
if ($(this).data("subcontractAmount") == 1) {
|
||
if (onTimeValue == "")
|
||
return $("#add-subcontract-action-type-amount-first-show").text("");
|
||
return $("#add-subcontract-action-type-amount-first-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 2) {
|
||
if (onTimeValue == "")
|
||
return $("#add-subcontract-action-type-amount-second-show").text("");
|
||
return $("#add-subcontract-action-type-amount-second-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 3) {
|
||
if (onTimeValue == "")
|
||
return $("#add-subcontract-action-type-amount-third-show").text("");
|
||
return $("#add-subcontract-action-type-amount-third-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 4) {
|
||
if (onTimeValue == "")
|
||
return $("#add-subcontract-action-type-amount-forth-show").text("");
|
||
$("#add-subcontract-action-type-amount-forth-show").text(onTimeValue);
|
||
}
|
||
});
|
||
|
||
$(".edit-subcontract-action-type-amount-all").on("input", function () {
|
||
const onTimeValue = $(this).val();
|
||
if ($(this).data("subcontractAmount") == 1) {
|
||
if (onTimeValue == "")
|
||
return $("#edit-subcontract-action-type-amount-first-show").text("");
|
||
return $("#edit-subcontract-action-type-amount-first-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 2) {
|
||
if (onTimeValue == "")
|
||
return $("#edit-subcontract-action-type-amount-second-show").text("");
|
||
return $("#edit-subcontract-action-type-amount-second-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 3) {
|
||
if (onTimeValue == "")
|
||
return $("#edit-subcontract-action-type-amount-third-show").text("");
|
||
return $("#edit-subcontract-action-type-amount-third-show").text(
|
||
onTimeValue
|
||
);
|
||
}
|
||
|
||
if ($(this).data("subcontractAmount") == 4) {
|
||
if (onTimeValue == "")
|
||
return $("#edit-subcontract-action-type-amount-forth-show").text("");
|
||
$("#edit-subcontract-action-type-amount-forth-show").text(onTimeValue);
|
||
}
|
||
});
|
||
|
||
function createAddMap(position) {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
if (position != null) {
|
||
addMap = L.map("add_map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([position.start.lat, position.start.lng], 7);
|
||
} else {
|
||
addMap = L.map("add_map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([35.7065, 51.3477], 7);
|
||
}
|
||
L.tileLayer(`${mapUrl}{z}/{x}/{y}.png`, {}).addTo(addMap);
|
||
setMarkerDefaultAdd(position);
|
||
}
|
||
|
||
function clearAddMap(position) {
|
||
isSetStartMarkerAdd = false;
|
||
isSetEndMarkerAdd = false;
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
addMap.removeLayer(startMarkerAdd);
|
||
if (endMarkerAdd != null) {
|
||
addMap.removeLayer(endMarkerAdd);
|
||
}
|
||
if (position != null) {
|
||
addMap.setView([position.start.lat, position.start.lng], 7);
|
||
} else {
|
||
addMap.setView([35.7065, 51.3477], 7);
|
||
}
|
||
setMarkerDefaultAdd(position);
|
||
}
|
||
|
||
function setMarkerDefaultAdd(position) {
|
||
isSetStartMarkerAdd = false;
|
||
isSetEndMarkerAdd = false;
|
||
$("#pin-marker-end").removeClass("pin-set");
|
||
$("#pin-marker-start").removeClass("pin-set");
|
||
$("#add_project_start_map").val("");
|
||
$("#add_project_end_map").val("");
|
||
if (position != null) {
|
||
if (position.end != undefined) {
|
||
startMarkerAdd = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: startDivIcon,
|
||
draggable: true,
|
||
}).addTo(addMap);
|
||
|
||
endMarkerAdd = new L.marker([position.end.lat, position.end.lng], {
|
||
icon: endDivIcon,
|
||
draggable: true,
|
||
}).addTo(addMap);
|
||
|
||
$("#add_project_start_map").val(position.start.lat + position.start.lng);
|
||
$("#add_project_end_map").val(position.end.lat + position.end.lng);
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
isSetEndMarkerAdd = true;
|
||
isSetStartMarkerAdd = true;
|
||
$("#pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
checkMarkersAndDrawPath();
|
||
} else {
|
||
startMarkerAdd = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: startDivIcon,
|
||
draggable: true,
|
||
}).addTo(addMap);
|
||
|
||
endMarkerAdd = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: endDivIcon,
|
||
draggable: true,
|
||
}).addTo(addMap);
|
||
|
||
$("#add_project_start_map").val(position.start.lat + position.start.lng);
|
||
isSetStartMarkerAdd = true;
|
||
$("#pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
}
|
||
} else {
|
||
startMarkerAdd = new L.marker(L.latLng(addMap.getCenter()), {
|
||
icon: startDivIcon,
|
||
draggable: true,
|
||
}).addTo(addMap);
|
||
|
||
endMarkerAdd = new L.marker(L.latLng(addMap.getCenter()), {
|
||
icon: endDivIcon,
|
||
draggable: true,
|
||
});
|
||
}
|
||
|
||
addMap.on("move", function () {
|
||
if (!isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
||
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
|
||
if (isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
||
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
$("#pin-marker-end").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
addMap.on("moveend", function () {
|
||
if (!isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
||
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
|
||
if (isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
||
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
|
||
startMarkerAdd.on("click", function () {
|
||
if (!isSetStartMarkerAdd) {
|
||
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
||
isSetStartMarkerAdd = true;
|
||
$("#pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
$("#add_project_start_map").val(
|
||
startMarkerAdd.getLatLng().lat.toFixed(6) +
|
||
startMarkerAdd.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#add_project_start_map").removeClass("validity-checker");
|
||
}
|
||
endMarkerAdd.addTo(addMap);
|
||
|
||
$(this).hide();
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
});
|
||
|
||
startMarkerAdd.on("drag", function () {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
|
||
startMarkerAdd.on("dragend", function () {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartMarkerAdd) {
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
$("#add_project_start_map").val(
|
||
startMarkerAdd.getLatLng().lat.toFixed(6) +
|
||
startMarkerAdd.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#add_project_start_map").removeClass("validity-checker");
|
||
checkMarkersAndDrawPath();
|
||
} else {
|
||
addMap.setView(startMarkerAdd.getLatLng());
|
||
}
|
||
});
|
||
|
||
endMarkerAdd.on("click", function () {
|
||
if (!isSetEndMarkerAdd) {
|
||
isSetEndMarkerAdd = true;
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
$("#add_project_end_map").val(
|
||
endMarkerAdd.getLatLng().lat.toFixed(6) +
|
||
endMarkerAdd.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#add_project_end_map").removeClass("validity-checker");
|
||
}
|
||
checkMarkersAndDrawPath();
|
||
});
|
||
|
||
endMarkerAdd.on("drag", function () {
|
||
$("#pin-marker-end").addClass("pin-move");
|
||
checkMarkersAndDrawPath();
|
||
});
|
||
|
||
endMarkerAdd.on("dragend", function () {
|
||
$("#pin-marker-end").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-end").hasClass("pin-set") || isSetEndMarkerAdd) {
|
||
$("#pin-marker-end").addClass("pin-set");
|
||
$("#add_project_end_map").val(
|
||
endMarkerAdd.getLatLng().lat.toFixed(6) +
|
||
endMarkerAdd.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#add_project_end_map").removeClass("validity-checker");
|
||
checkMarkersAndDrawPath();
|
||
} else {
|
||
addMap.setView(endMarkerAdd.getLatLng());
|
||
}
|
||
});
|
||
}
|
||
|
||
function checkMarkersAndDrawPath() {
|
||
if (
|
||
$("#pin-marker-start").hasClass("pin-set") &&
|
||
!$("#pin-marker-start").hasClass("pin-move") &&
|
||
$("#pin-marker-end").hasClass("pin-set") &&
|
||
!$("#pin-marker-end").hasClass("pin-move")
|
||
) {
|
||
drawPath();
|
||
}
|
||
}
|
||
|
||
function drawPath() {
|
||
let subcontractValue = $("#add-subcontract-nature").val();
|
||
if (subcontractValue != 6) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
routeControls.push(
|
||
L.Routing.control({
|
||
waypoints: [
|
||
L.latLng(
|
||
parseFloat(startMarkerAdd.getLatLng().lat),
|
||
parseFloat(startMarkerAdd.getLatLng().lng)
|
||
),
|
||
L.latLng(
|
||
parseFloat(endMarkerAdd.getLatLng().lat),
|
||
parseFloat(endMarkerAdd.getLatLng().lng)
|
||
),
|
||
],
|
||
fitSelectedRoutes: false,
|
||
draggableWaypoints: true,
|
||
createMarker: function () {
|
||
return null;
|
||
},
|
||
lineOptions: {
|
||
addWaypoints: false,
|
||
styles: [
|
||
{
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
},
|
||
],
|
||
},
|
||
}).addTo(addMap)
|
||
);
|
||
$(".leaflet-control-container").css("display", "none");
|
||
$(".leaflet-routing-container-hide").css("display", "none");
|
||
} else {
|
||
var polyline;
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
var latlngs = Array();
|
||
latlngs.push(startMarkerAdd.getLatLng());
|
||
latlngs.push(endMarkerAdd.getLatLng());
|
||
routeControls.push(
|
||
(polyline = L.polyline(latlngs, {
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
}).addTo(addMap))
|
||
);
|
||
}
|
||
}
|
||
|
||
$(document).on("click", ".choose-project-type", function () {
|
||
$("#choose-project-type-modal").modal("show");
|
||
$("#choose_project_type").val(1);
|
||
showLoaderScreen();
|
||
ProTypeChooseTable = $("#choose_pro_type_table").DataTable({
|
||
dom: "<f<t>p>",
|
||
pagingType: "simple_numbers",
|
||
responsive: true,
|
||
pageLength: 6,
|
||
destroy: true,
|
||
language: {
|
||
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
||
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
||
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
||
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
||
sInfoPostFix: "",
|
||
sInfoThousands: ",",
|
||
sLengthMenu: "نمایش _MENU_ ردیف",
|
||
sLoadingRecords: "در حال بارگذاری...",
|
||
sProcessing: "در حال پردازش...",
|
||
sSearch: "جستجو / فیلتر: ",
|
||
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
||
oPaginate: {
|
||
sFirst: "برگهی نخست",
|
||
sLast: "برگهی آخر",
|
||
sNext: "بعدی",
|
||
sPrevious: "قبلی",
|
||
},
|
||
oAria: {
|
||
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
||
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
||
},
|
||
},
|
||
processing: true,
|
||
select: true,
|
||
destroy: true,
|
||
ajax: {
|
||
url:
|
||
"https://rms.rmto.ir/api/finance/maintenance?project_id=" +
|
||
contractRowId,
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
hideLoaderScreen();
|
||
canSubmit = json.can_submit;
|
||
return json.data;
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا در دریافت اطلاعات",
|
||
text: jqXHR.status,
|
||
confirmButtonText: "بستن",
|
||
});
|
||
hideLoaderScreen();
|
||
},
|
||
},
|
||
columns: [
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function (data, type, row, meta) {
|
||
return meta.row + 1;
|
||
},
|
||
},
|
||
{ data: "province_fa" },
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data.city_2_fa != null && data.city_3_fa != null)
|
||
return `${data.city_1_fa}-${data.city_2_fa}-${data.city_3_fa}`;
|
||
else if (data.city_2_fa != null)
|
||
return `${data.city_1_fa}-${data.city_2_fa}`;
|
||
else return `${data.city_1_fa}`;
|
||
},
|
||
},
|
||
{ data: "axis_name" },
|
||
{ data: "axis_type_fa" },
|
||
{ data: "project_name" },
|
||
{ data: "contractor_name" },
|
||
{ data: "contract_date" },
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data.submited_at_fa == null) {
|
||
return "<div class='line-empty-col'></div>";
|
||
} else {
|
||
return data.submited_at_fa;
|
||
}
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return `<div class="d-flex justify-content-center parent-btn"><button class="btn-dataTable" id="addToSubcontract" title="الصاق به زیر پروژه قرارداد"><i class="fa fa-plus icon-btnTable"></i></button></div>`;
|
||
},
|
||
},
|
||
],
|
||
});
|
||
});
|
||
|
||
$(document).on("change", "#choose_project_type", function () {
|
||
showLoaderScreen();
|
||
ProTypeChoose = $(this).val();
|
||
let url;
|
||
if (ProTypeChoose == 1) {
|
||
url =
|
||
"https://rms.rmto.ir/api/finance/maintenance?project_id=" + contractRowId;
|
||
} else if (ProTypeChoose == 2) {
|
||
url = "https://rms.rmto.ir/api/finance/danger?project_id=" + contractRowId;
|
||
} else if (ProTypeChoose == 3) {
|
||
url =
|
||
"https://rms.rmto.ir/api/finance/upgradeSafety?project_id=" +
|
||
contractRowId;
|
||
} else if (ProTypeChoose == 4) {
|
||
url =
|
||
"https://rms.rmto.ir/api/finance/technical?project_id=" + contractRowId;
|
||
} else if (ProTypeChoose == 5) {
|
||
url =
|
||
"https://rms.rmto.ir/api/finance/tollhouse?project_id=" + contractRowId;
|
||
}
|
||
$.ajax({
|
||
url: url,
|
||
type: "GET",
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
$("#choose_pro_type_table").dataTable().fnClearTable();
|
||
$("#choose_pro_type_table").dataTable().fnAddData(result.data);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت اطلاعات جدول",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
});
|
||
$(document).on("click", "#addToSubcontract", function () {
|
||
addNewSubitemStatus = "false";
|
||
const tr = $(this).closest("tr");
|
||
const row = ProTypeChooseTable.row(tr);
|
||
const provinceFaForSub = row.data().province_fa;
|
||
const axisNameForSub = row.data().axis_name;
|
||
const axisTypeFaForSub = row.data().axis_type_fa;
|
||
const currentProjectId = row.data().id;
|
||
let imgUrl_show;
|
||
if ($("#choose_project_type").val() == 1) {
|
||
imgUrl_show =
|
||
"https://rms.rmto.ir/api/finance/maintanance/show?id=" + currentProjectId;
|
||
} else if ($("#choose_project_type").val() == 2) {
|
||
imgUrl_show =
|
||
"https://rms.rmto.ir/api/finance/danger/show?id=" + currentProjectId;
|
||
} else if ($("#choose_project_type").val() == 3) {
|
||
imgUrl_show =
|
||
"https://rms.rmto.ir/api/finance/upgradesafety/show?id=" +
|
||
currentProjectId;
|
||
} else if ($("#choose_project_type").val() == 4) {
|
||
imgUrl_show =
|
||
"https://rms.rmto.ir/api/finance/technical/show?id=" + currentProjectId;
|
||
} else if ($("#choose_project_type").val() == 5) {
|
||
imgUrl_show =
|
||
"https://rms.rmto.ir/api/finance/tollhouse/show?id=" + currentProjectId;
|
||
}
|
||
var positions = {};
|
||
if (row.data().end_latlng != null) {
|
||
positions = {
|
||
start: {
|
||
lat: row.data().start_latlng[0],
|
||
lng: row.data().start_latlng[1],
|
||
},
|
||
end: {
|
||
lat: row.data().end_latlng[0],
|
||
lng: row.data().end_latlng[1],
|
||
},
|
||
};
|
||
} else {
|
||
positions = {
|
||
start: {
|
||
lat: row.data().start_latlng[0],
|
||
lng: row.data().start_latlng[1],
|
||
},
|
||
};
|
||
}
|
||
|
||
showLoaderScreen();
|
||
// clearing data
|
||
$(".attent_num").css("display", "");
|
||
$(".map-endplace-title").removeClass("d-none");
|
||
$("#add-subcontract-modal").find("tfoot").removeClass("d-none");
|
||
$(".show-city-past").removeClass("d-none");
|
||
$(".show-axisName-past").removeClass("d-none");
|
||
$(".show-axisTypeFa-past").removeClass("d-none");
|
||
$(".select-add-subcontract").val(0);
|
||
$(".select-add-subcontract").removeClass("validity-checker");
|
||
$("#add_project_start_map").val("");
|
||
$("#add_project_end_map").val("");
|
||
$(".input-map-project").removeClass("validity-checker");
|
||
$(".input-add-subcontract").val("");
|
||
$(".input-add-subcontract").removeClass("validity-checker");
|
||
$(".span-add-subcontract").text("0");
|
||
$("#add-Supervisor-number").val("09");
|
||
$("#add-Supervisor-number").removeClass("validity-checker");
|
||
$("#limit_percentage").addClass("d-none");
|
||
$(".add-subcontract-action-type-all").empty();
|
||
$(".add-subcontract-action-type-all").attr("disabled", true);
|
||
$(".add-subcontract-action-type-show-all").text("");
|
||
$(".add-subcontract-action-type-unit-all").text("-");
|
||
$(".add-subcontract-type-unit-show-all").text("-");
|
||
$(".add-subcontract-action-type-amount-all").attr("disabled", true);
|
||
$(".add-subcontract-type-amount-show-all").text("");
|
||
$(".add-subcontract-action-type-tonaj-all").val("");
|
||
$(".add-subcontract-action-type-tonaj-all").removeClass("validity-checker");
|
||
$(".add-subcontract-action-type-tonaj-all").prop("disabled", true);
|
||
$(".tonaj").addClass("d-none");
|
||
$(".add-subcontract-action-type-progress-all").attr("disabled", true);
|
||
// clear image part
|
||
$("#add-subcontract-modal").find(".img-preview").removeAttr("src", "");
|
||
$("#add-subcontract-modal").find(".img-title").css("display", "");
|
||
$("#add-subcontract-modal").find(".btn-delete-img").prop("disabled", true);
|
||
$("#add-subcontract-modal").find(".img-input").val("");
|
||
$(".imgbox").removeClass("validity-checker");
|
||
$("#add-subcontract-nature").prop("disabled", true);
|
||
$("#deviceImg1load").css("display", "none");
|
||
$("#deviceImg2load").css("display", "none");
|
||
// clear image part
|
||
|
||
if (addMap == null) {
|
||
setTimeout(() => {
|
||
createAddMap(positions);
|
||
}, 400);
|
||
} else {
|
||
clearAddMap(positions);
|
||
}
|
||
// end clearing data
|
||
|
||
// calling past images
|
||
$.ajax({
|
||
url: imgUrl_show,
|
||
type: "GET",
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
if (result.data[0].images.length != 0) {
|
||
if (result.data[0].images.length > 1) {
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1Preview")
|
||
.attr("src", result.data[0].images[0]);
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1Title")
|
||
.css("display", "none");
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1load")
|
||
.css("display", "");
|
||
$("#add-subcontract-modal")
|
||
.find("#deleteDeviceImg1")
|
||
.removeAttr("disabled");
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg2Preview")
|
||
.attr("src", result.data[0].images[1]);
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg2Title")
|
||
.css("display", "none");
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg2load")
|
||
.css("display", "");
|
||
$("#add-subcontract-modal")
|
||
.find("#deleteDeviceImg2")
|
||
.removeAttr("disabled");
|
||
} else {
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1Preview")
|
||
.attr("src", result.data[0].images[0]);
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1Title")
|
||
.css("display", "none");
|
||
$("#add-subcontract-modal")
|
||
.find("#deviceImg1load")
|
||
.css("display", "");
|
||
$("#add-subcontract-modal")
|
||
.find("#deleteDeviceImg1")
|
||
.removeAttr("disabled");
|
||
}
|
||
}
|
||
},
|
||
});
|
||
// end calling past images
|
||
|
||
// appending needed data
|
||
showSubProvince();
|
||
$("#pre_distance_choose").data("projectId", currentProjectId);
|
||
$("#add-subcontract-title").val(titlecontract);
|
||
$("#add-subcontract-nature").val(ProTypeChoose);
|
||
$(".chooseProTypeTable_city").text(provinceFaForSub);
|
||
$(".chooseProTypeTable_axisName").text(axisNameForSub);
|
||
$(".chooseProTypeTable_axisTypeFa").text(axisTypeFaForSub);
|
||
$("#add-subcontract-axisName").val(axisNameForSub);
|
||
if (statusIdForSub == 1) {
|
||
$("#add-subcontract-last-project-position").val(0);
|
||
$("#add-subcontract-last-project-position").prop("disabled", false);
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", false);
|
||
} else if (statusIdForSub == 2) {
|
||
$("#add-subcontract-last-project-position").val(4);
|
||
$("#add-subcontract-last-project-position").prop("disabled", true);
|
||
$("#add-subcontract-progress-mainpercent").val("5");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
} else if (statusIdForSub == 3) {
|
||
$("#add-subcontract-last-project-position").val(3);
|
||
$("#add-subcontract-last-project-position").prop("disabled", true);
|
||
$("#add-subcontract-progress-mainpercent").val("100");
|
||
$("#add-subcontract-progress-mainpercent").prop("disabled", true);
|
||
}
|
||
if (ProTypeChoose == 1) {
|
||
$(".tonaj").removeClass("d-none");
|
||
} else {
|
||
$(".tonaj").addClass("d-none");
|
||
}
|
||
// appending needed data
|
||
|
||
// action type data giving
|
||
|
||
$(".add-subcontract-action-type-all").attr("disabled", false);
|
||
$(".add-subcontract-action-type-all").append(
|
||
"<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>"
|
||
);
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/csi/operation/" + $("#add-subcontract-nature").val(),
|
||
type: "GET",
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (res) {
|
||
$.each(res, function (key, value) {
|
||
const unit = value.unit != "" ? value.unit : "-";
|
||
const amountable = value.amountable;
|
||
$(".add-subcontract-action-type-all").append(
|
||
"<option amountable='" +
|
||
amountable +
|
||
"' unit='" +
|
||
unit +
|
||
"' value='" +
|
||
key +
|
||
"'>" +
|
||
value.farsi +
|
||
"</option>"
|
||
);
|
||
});
|
||
hideLoaderScreen();
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت نوع عملیات",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
// end action type data giving
|
||
|
||
$("#add-subcontract-modal").modal("show");
|
||
});
|
||
|
||
function scrolldowntable() {
|
||
$("html, body").animate(
|
||
{
|
||
scrollTop: $(".upnext").offset().top + 1000,
|
||
},
|
||
50
|
||
);
|
||
}
|
||
// showTable subcontract
|
||
$(document).on("click", ".show-subcontract-btn", function () {
|
||
let tr = $(this).closest("tr");
|
||
let row = table.row(tr);
|
||
let id = row.data().id;
|
||
provinceIdForSub = row.data().province_id;
|
||
contractRowId = row.data().id;
|
||
statusIdForSub = row.data().status_id;
|
||
$(".edit-subcontract-modal-title").text(row.data().unique_id);
|
||
$("#title_update_unique").text("(" + row.data().unique_id + ")");
|
||
$("#show_subcontract_table").css("display", "block");
|
||
scrolldowntable();
|
||
showLoaderScreen();
|
||
subItemTable = $("#subcontractTable").DataTable({
|
||
dom: "<f<t>p>",
|
||
pagingType: "simple_numbers",
|
||
paging: true,
|
||
searching: false,
|
||
scrollX: true,
|
||
destroy: true,
|
||
responsive: true,
|
||
language: {
|
||
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
||
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
||
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
||
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
||
sInfoPostFix: "",
|
||
sInfoThousands: ",",
|
||
sLengthMenu: "نمایش _MENU_ ردیف",
|
||
sLoadingRecords: "در حال بارگذاری...",
|
||
sProcessing: "در حال پردازش...",
|
||
sSearch: "جستجو: ",
|
||
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
||
oPaginate: {
|
||
sFirst: "برگهی نخست",
|
||
sLast: "برگهی آخر",
|
||
sNext: "بعدی",
|
||
sPrevious: "قبلی",
|
||
},
|
||
oAria: {
|
||
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
||
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
||
},
|
||
},
|
||
order: [[0, "desc"]],
|
||
processing: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/contracts/show/" + id,
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
hideLoaderScreen();
|
||
return json.data;
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا در دریافت اطلاعات",
|
||
text: `کد خطا : ${jqXHR.status}`,
|
||
confirmButtonText: "بروزرسانی",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
location.reload(true);
|
||
},
|
||
});
|
||
$("#show_subcontract_table").css("display", "none");
|
||
hideLoaderScreen();
|
||
},
|
||
},
|
||
initComplete: function () {
|
||
$("body").find(".dataTables_scrollBody").addClass("scrollbar");
|
||
},
|
||
columns: [
|
||
{
|
||
data: "unique_code",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "project_title",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "project_type_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-sm btnSubItemModal_actionType">...</button>';
|
||
},
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "city_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "axis_type_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "axis_name_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "followup_priority_project",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "priority_project_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "progress_project",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: "last_status_fa",
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
className: "text-center text-nowrap",
|
||
data: null,
|
||
render: function (data) {
|
||
const last_digit_project = parseFloat(
|
||
data.last_digit_project != null ? data.last_digit_project : 0
|
||
).toLocaleString("en");
|
||
return last_digit_project;
|
||
},
|
||
},
|
||
{
|
||
className: "text-center text-nowrap",
|
||
data: null,
|
||
render: function (data) {
|
||
const last_function_operator = parseFloat(
|
||
data.last_function_operator != null
|
||
? data.last_function_operator
|
||
: 0
|
||
).toLocaleString("en");
|
||
return last_function_operator;
|
||
},
|
||
},
|
||
{
|
||
className: "text-center text-nowrap",
|
||
data: null,
|
||
render: function (data) {
|
||
const last_payable_operator = parseFloat(
|
||
data.last_payable_operator != null ? data.last_payable_operator : 0
|
||
).toLocaleString("en");
|
||
return last_payable_operator;
|
||
},
|
||
},
|
||
{
|
||
className: "text-center text-nowrap",
|
||
data: null,
|
||
render: function (data) {
|
||
const complete_payable = parseFloat(
|
||
data.complete_payable != null ? data.complete_payable : 0
|
||
).toLocaleString("en");
|
||
return complete_payable;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-sm btnSubItemOpratorModal">...</button>';
|
||
},
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return row.start_lat + ", " + row.start_lng;
|
||
},
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-show-img-subitem"><i class="fas fa-image"></i></button>';
|
||
},
|
||
className: "text-center text-nowrap",
|
||
},
|
||
{
|
||
className: "text-nowrap testshow text-center",
|
||
data: null,
|
||
render: function (data) {
|
||
const updated_at = moment(data.updated_at).format(
|
||
"HH:mm:ss | jYYYY/jMM/jDD"
|
||
);
|
||
return updated_at;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return `<div class="setcontent">${data.canEdit == 0
|
||
? '<button disabled class="btn-dataTable btn-edit-subitem"><i class="fas fa-edit"></i></button>'
|
||
: '<button class="btn-dataTable btn-edit-subitem"><i class="fas fa-edit"></i></button>'
|
||
}<div class="line-btn-table"></div><button class="btn-dataTable btn-history-subitem"><i class="fas fa-history"></i></button><div class="line-btn-table"></div>${data.canDelete == 0
|
||
? '<button disabled class="btn-dataTable btn-delete-subitem"><i class="fa fa-trash"></i></button>'
|
||
: '<button class="btn-dataTable btn-delete-subitem"><i class="fa fa-trash"></i></button>'
|
||
}</div>`;
|
||
},
|
||
className: "text-center text-nowrap",
|
||
},
|
||
],
|
||
});
|
||
});
|
||
// end showTable subcontract
|
||
// modals of subcontract
|
||
// action type modal
|
||
$(document).on("click", ".btnSubItemModal_actionType", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = subItemTable.row(tr);
|
||
|
||
row.data().project_type_id == "1"
|
||
? $(".modal-op-tonaj").removeClass("d-none")
|
||
: $(".modal-op-tonaj").addClass("d-none");
|
||
|
||
$(".input-subcontract-table").val("");
|
||
|
||
$("#subItemModal_type_fa1").val(row.data().operation_type_fa1);
|
||
$("#subItemModal_type_amount1").val(row.data().operation_type_amount1);
|
||
$("#subItemModal_type_unit1").val(row.data().operation_type_unit1);
|
||
$("#subItemModal_type_progress1").val(row.data().operation_type_progress1);
|
||
$("#subItemModal_type_tonaj1").val(row.data().operation_type_tonaj1);
|
||
|
||
$("#subItemModal_type_fa2").val(row.data().operation_type_fa2);
|
||
$("#subItemModal_type_amount2").val(row.data().operation_type_amount2);
|
||
$("#subItemModal_type_unit2").val(row.data().operation_type_unit2);
|
||
$("#subItemModal_type_progress2").val(row.data().operation_type_progress2);
|
||
$("#subItemModal_type_tonaj2").val(row.data().operation_type_tonaj2);
|
||
|
||
$("#subItemModal_type_fa3").val(row.data().operation_type_fa3);
|
||
$("#subItemModal_type_amount3").val(row.data().operation_type_amount3);
|
||
$("#subItemModal_type_unit3").val(row.data().operation_type_unit3);
|
||
$("#subItemModal_type_progress3").val(row.data().operation_type_progress3);
|
||
$("#subItemModal_type_tonaj3").val(row.data().operation_type_tonaj3);
|
||
$("#subItemModal_type_tonaj3").val(row.data().operation_type_tonaj3);
|
||
|
||
$("#subItemModal_type_fa4").val(row.data().operation_type_fa4);
|
||
$("#subItemModal_type_amount4").val(row.data().operation_type_amount4);
|
||
$("#subItemModal_type_unit4").val(row.data().operation_type_unit4);
|
||
$("#subItemModal_type_progress4").val(row.data().operation_type_progress4);
|
||
$("#subItemModal_type_tonaj4").val(row.data().operation_type_tonaj4);
|
||
|
||
$("#subItemModal_actionType").modal("show");
|
||
});
|
||
// end action type modal
|
||
// operator data modal
|
||
$(document).on("click", ".btnSubItemOpratorModal", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = subItemTable.row(tr);
|
||
|
||
$(".input-subcontract-table").val("");
|
||
|
||
$("#subItemOpratorModal_operator_name").val(row.data().operator_name);
|
||
$("#subItemOpratorModal_operator_phone").val(row.data().operator_phone);
|
||
|
||
$("#subItemOpratorModal").modal("show");
|
||
});
|
||
// end operator data modal
|
||
// image modal data
|
||
$(document).on("click", ".btn-show-img-subitem", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = subItemTable.row(tr);
|
||
|
||
$("#imgSubItem1").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + row.data().image_path1
|
||
);
|
||
$("#imgSubItem2").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + row.data().image_path2
|
||
);
|
||
|
||
$("#subItemImgModal").modal("show");
|
||
});
|
||
// end image modal data
|
||
|
||
// previus data of action types
|
||
$("#pre_distance_choose").on("click", function () {
|
||
const currentProjectId = $(this).data("projectId");
|
||
showLoaderScreen();
|
||
const url_distance1 =
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
currentProjectId +
|
||
"/get-distance-update-list";
|
||
const url_distance2 =
|
||
"https://rms.rmto.ir/rahdari/road-danger-prevention/" +
|
||
currentProjectId +
|
||
"/get-distance-update-list";
|
||
const url_distance3 =
|
||
"https://rms.rmto.ir/rahdari/road-upgrade-safety/" +
|
||
currentProjectId +
|
||
"/get-distance-update-list";
|
||
const url_distance4 =
|
||
"https://rms.rmto.ir/rahdari/road-technical-building/" +
|
||
currentProjectId +
|
||
"/get-distance-update-list";
|
||
const url_distance5 =
|
||
"https://rms.rmto.ir/rahdari/road-tollhouse-management/" +
|
||
currentProjectId +
|
||
"/get-distance-update-list";
|
||
if (ProTypeChoose == 1) {
|
||
$(".appendhead").empty();
|
||
$(".appendbody").empty();
|
||
$(".appendheadsecond").empty();
|
||
$.ajax({
|
||
url: url_distance1,
|
||
type: "GET",
|
||
success: function (data) {
|
||
pre_distance = data.data.distance_update;
|
||
appendheadmaintan(pre_distance[0].previous_project_distance_update);
|
||
for (let index = 0; index < pre_distance.length; index++) {
|
||
after_distance = pre_distance[index].previous_project_distance_update;
|
||
appendbodymaintan(after_distance);
|
||
}
|
||
hideLoaderScreen();
|
||
$("#modal_distance").modal("show");
|
||
},
|
||
error: function (error) {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت عملیات های پیشین",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
} else if (ProTypeChoose == 2) {
|
||
$(".appendhead").empty();
|
||
$(".appendbody").empty();
|
||
$(".appendheadsecond").empty();
|
||
|
||
$.ajax({
|
||
url: url_distance2,
|
||
type: "GET",
|
||
success: function (data) {
|
||
pre_distance = data.data.distance_update;
|
||
appendheaddanger(pre_distance[0].previous_project_distance_update);
|
||
for (let index = 0; index < pre_distance.length; index++) {
|
||
after_distance = pre_distance[index].previous_project_distance_update;
|
||
appendbodydanger(after_distance);
|
||
}
|
||
hideLoaderScreen();
|
||
$("#modal_distance").modal("show");
|
||
},
|
||
});
|
||
} else if (ProTypeChoose == 3) {
|
||
$(".appendhead").empty();
|
||
$(".appendbody").empty();
|
||
$(".appendheadsecond").empty();
|
||
$.ajax({
|
||
url: url_distance3,
|
||
type: "GET",
|
||
success: function (data) {
|
||
pre_distance = data.data.distance_update;
|
||
appendheadimeni(
|
||
pre_distance.length,
|
||
pre_distance[0].previous_project_distance_update
|
||
);
|
||
for (let index = 0; index < pre_distance.length; index++) {
|
||
after_distance = pre_distance[index].previous_project_distance_update;
|
||
appendbodyimeni(after_distance);
|
||
}
|
||
hideLoaderScreen();
|
||
$("#modal_distance").modal("show");
|
||
},
|
||
});
|
||
} else if (ProTypeChoose == 4) {
|
||
$(".appendhead").empty();
|
||
$(".appendbody").empty();
|
||
$(".appendheadsecond").empty();
|
||
$.ajax({
|
||
url: url_distance4,
|
||
type: "GET",
|
||
success: function (data) {
|
||
pre_distance = data.data.distance_update;
|
||
appendheadtechnic(pre_distance[0].previous_project_distance_update);
|
||
for (let index = 0; index < pre_distance.length; index++) {
|
||
after_distance = pre_distance[index].previous_project_distance_update;
|
||
appendbodytechnic(after_distance);
|
||
}
|
||
hideLoaderScreen();
|
||
$("#modal_distance").modal("show");
|
||
},
|
||
});
|
||
} else if (ProTypeChoose == 5) {
|
||
$(".appendhead").empty();
|
||
$(".appendbody").empty();
|
||
$(".appendheadsecond").empty();
|
||
$.ajax({
|
||
url: url_distance5,
|
||
type: "GET",
|
||
success: function (data) {
|
||
pre_distance = data.data.distance_update;
|
||
appendheadtoll(pre_distance[0].previous_project_distance_update);
|
||
for (let index = 0; index < pre_distance.length; index++) {
|
||
after_distance = pre_distance[index].previous_project_distance_update;
|
||
appendbodytoll(after_distance);
|
||
}
|
||
hideLoaderScreen();
|
||
$("#modal_distance").modal("show");
|
||
},
|
||
});
|
||
}
|
||
});
|
||
|
||
function appendheadmaintan(obj) {
|
||
showeachtr = "<th>مقدار</th><th>تناژ</th><th>درصد پیشرفت</th>";
|
||
showeachtr2 =
|
||
"<th>مقدار</th><th>متر مربع</th><th>تناژ</th><th>درصد پیشرفت</th>";
|
||
showeachtr3 = "<th>مقدار</th><th>درصد پیشرفت</th>";
|
||
|
||
for (const key in obj) {
|
||
if (key == 12) {
|
||
const showtabeldanger = "<th colspan='4'>لکه گیری </th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr2);
|
||
} else if (key == 13) {
|
||
const showtabeldanger = "<th colspan='2'>درزگیری</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr3);
|
||
} else {
|
||
const showtabeldanger =
|
||
"<th colspan='3'>" + appentableprojecttitlemain(key) + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr);
|
||
}
|
||
}
|
||
}
|
||
|
||
function appendbodymaintan(pp) {
|
||
let test = "";
|
||
let showtabeldanger = "";
|
||
for (const key in pp) {
|
||
if (key == 13) {
|
||
showtabeldanger =
|
||
"<td>" + pp[key][0] + "</td><td>" + pp[key][1] + "</td>";
|
||
test = test + showtabeldanger;
|
||
} else if (key == 12) {
|
||
showtabeldanger =
|
||
"<td>" +
|
||
pp[key][0] +
|
||
"</td><td>" +
|
||
pp[key][2] +
|
||
"</td><td>" +
|
||
pp[key][1] +
|
||
"</td><td>" +
|
||
pp[key][3] +
|
||
"</td>";
|
||
test = test + showtabeldanger;
|
||
} else {
|
||
showtabeldanger =
|
||
"<td>" +
|
||
pp[key][0] +
|
||
"</td><td>" +
|
||
pp[key][1] +
|
||
"</td><td>" +
|
||
pp[key][2] +
|
||
"</td>";
|
||
test = test + showtabeldanger;
|
||
}
|
||
}
|
||
$(".appendbody").append("<tr>" + test + "</tr>");
|
||
}
|
||
|
||
function appentableprojecttitlemain(num) {
|
||
if (num == 1) {
|
||
return "روکش آسفالت";
|
||
} else if (num == 2) {
|
||
return "ماسه آسفالت و رگلاژی";
|
||
} else if (num == 3) {
|
||
return "بازیافت سرد و گرم";
|
||
} else if (num == 4) {
|
||
return "میکروسرفیسینگ";
|
||
} else if (num == 5) {
|
||
return "چیپ سیل";
|
||
} else if (num == 6) {
|
||
return "اسلاری سیل";
|
||
} else if (num == 7) {
|
||
return "اسکراب سیل";
|
||
} else if (num == 8) {
|
||
return "فوگ سیل";
|
||
} else if (num == 9) {
|
||
return "سیل کت";
|
||
} else if (num == 10) {
|
||
return "کیپ سیل";
|
||
} else if (num == 11) {
|
||
return "آسفالت سرد / ردمیکس";
|
||
} else if (num == 12) {
|
||
return "لکه گیری";
|
||
} else if (num == 13) {
|
||
return "درزگیری";
|
||
}
|
||
}
|
||
|
||
function appendheaddanger(obj) {
|
||
showeachtr = "<th>درصد پیشرفت</th>";
|
||
|
||
for (const key in obj) {
|
||
let showtabeldanger = "<th>" + obj[key][1] + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr);
|
||
}
|
||
}
|
||
|
||
function appendbodydanger(pp) {
|
||
let test = "";
|
||
let showtabeldanger = "";
|
||
for (const key in pp) {
|
||
showtabeldanger = "<td>" + pp[key][0] + "</td>";
|
||
test = test + showtabeldanger;
|
||
}
|
||
$(".appendbody").append("<tr>" + test + "</tr>");
|
||
}
|
||
|
||
function appendheadimeni(num, obj) {
|
||
const colspanshow = "";
|
||
showeachtr = "<th>کیلومتر</th><th>درصد پیشرفت</th>";
|
||
showeachtr2 = "<th>درصد پیشرفت</th>";
|
||
for (const key in obj) {
|
||
if (key == 9) {
|
||
const showtabeldanger = "<th colspan='2'>" + obj[key][1] + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr2);
|
||
} else {
|
||
const showtabeldanger = "<th colspan='2'>" + obj[key][2] + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr);
|
||
}
|
||
}
|
||
}
|
||
|
||
function appendbodyimeni(pp) {
|
||
let test = "";
|
||
let showtabeldanger = "";
|
||
for (const key in pp) {
|
||
showtabeldanger = "<td>" + pp[key][0] + "</td><td> " + pp[key][1] + "</td>";
|
||
test = test + showtabeldanger;
|
||
}
|
||
$(".appendbody").append("<tr>" + test + "</tr>");
|
||
}
|
||
|
||
function appendbodytechnic(pp) {
|
||
let test = "";
|
||
let showtabeltechnic = "";
|
||
for (const key in pp) {
|
||
showtabeltechnic = "<td>" + pp[key][0] + "</td>";
|
||
test = test + showtabeltechnic;
|
||
}
|
||
$(".appendbody").append("<tr>" + test + "</tr>");
|
||
}
|
||
|
||
function appendheadtechnic(obj) {
|
||
showeachtr = "<th>درصد پیشرفت</th>";
|
||
|
||
for (const key in obj) {
|
||
const showtabeldanger = "<th>" + obj[key][1] + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr);
|
||
}
|
||
}
|
||
|
||
function appendbodytoll(pp) {
|
||
let test = "";
|
||
let showtabeltoll = "";
|
||
for (let key in pp) {
|
||
showtabeltoll = "<td>" + pp[key][0] + "</td>";
|
||
test = test + showtabeltoll;
|
||
}
|
||
$(".appendbody").append("<tr>" + test + "</tr>");
|
||
}
|
||
|
||
function appendheadtoll(obj) {
|
||
showeachtr = "<th>درصد پیشرفت</th>";
|
||
|
||
for (const key in obj) {
|
||
const showtabeldanger = "<th>" + obj[key][1] + "</th>";
|
||
$(".appendhead").append(showtabeldanger);
|
||
$(".appendheadsecond").append(showeachtr);
|
||
}
|
||
}
|
||
// previus data of action types
|
||
|
||
//deleting subcontract
|
||
$(document).on("click", ".btn-delete-subitem", function () {
|
||
let tr = $(this).closest("tr");
|
||
let row = subItemTable.row(tr);
|
||
let idkol = row.data().id;
|
||
let formData = new FormData();
|
||
formData.append("id", idkol);
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا برای حذف مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، حذف میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
beforeSend: function () {
|
||
showLoaderScreen();
|
||
},
|
||
success: function (result) {
|
||
isReloadAjax = true;
|
||
subItemTable.ajax.reload(null, false);
|
||
table.ajax.reload(null, false);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در برقراری ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
// end deleting subcontract
|
||
// history of subcontact table
|
||
$(document).on("click", ".btn-history-subitem", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = subItemTable.row(tr);
|
||
var ths = $("#subcontractTable .th-head");
|
||
$(".internal-table").remove();
|
||
internalTable(tr, "history_subcontract_table", 20).then((onResolved) => {
|
||
showLoaderScreen();
|
||
historyTable = $("#history_subcontract_table").DataTable({
|
||
dom: "<f<t>p>",
|
||
pagingType: "simple_numbers",
|
||
paging: false,
|
||
searching: false,
|
||
scrollX: true,
|
||
destroy: true,
|
||
responsive: true,
|
||
autoWidth: false,
|
||
language: {
|
||
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
||
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
||
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
||
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
||
sInfoPostFix: "",
|
||
sInfoThousands: ",",
|
||
sLengthMenu: "نمایش _MENU_ ردیف",
|
||
sLoadingRecords: "در حال بارگذاری...",
|
||
sProcessing: "در حال پردازش...",
|
||
sSearch: "جستجو: ",
|
||
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
||
oPaginate: {
|
||
sFirst: "برگهی نخست",
|
||
sLast: "برگهی آخر",
|
||
sNext: "بعدی",
|
||
sPrevious: "قبلی",
|
||
},
|
||
oAria: {
|
||
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
||
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
||
},
|
||
},
|
||
order: [[18, "desc"]],
|
||
processing: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/csi/history/" + row.data().id,
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
hideLoaderScreen();
|
||
return json.data;
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا در دریافت اطلاعات",
|
||
text: jqXHR.status,
|
||
confirmButtonText: "بستن",
|
||
});
|
||
hideLoaderScreen();
|
||
},
|
||
},
|
||
columns: [
|
||
{
|
||
data: "unique_code",
|
||
className: "text-center",
|
||
width: ths.eq(0).css("width"),
|
||
},
|
||
{
|
||
data: "project_title",
|
||
className: "text-center",
|
||
width: ths.eq(1).css("width"),
|
||
},
|
||
{
|
||
data: "project_type_fa",
|
||
className: "text-center",
|
||
width: ths.eq(2).css("width"),
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-sm btnSubItemHistoryModal" style="color: #fff;">...</button>';
|
||
},
|
||
className: "text-center",
|
||
width: ths.eq(3).css("width"),
|
||
},
|
||
{
|
||
data: "city_fa",
|
||
className: "text-center",
|
||
width: ths.eq(4).css("width"),
|
||
},
|
||
{
|
||
data: "axis_type_fa",
|
||
className: "text-center",
|
||
width: ths.eq(5).css("width"),
|
||
},
|
||
{
|
||
data: "axis_name_fa",
|
||
className: "text-center",
|
||
width: ths.eq(6).css("width"),
|
||
},
|
||
{
|
||
data: "followup_priority_project",
|
||
className: "text-center",
|
||
width: ths.eq(7).css("width"),
|
||
},
|
||
{
|
||
data: "priority_project",
|
||
className: "text-center",
|
||
width: ths.eq(8).css("width"),
|
||
},
|
||
{
|
||
data: "progress_project",
|
||
className: "text-center",
|
||
width: ths.eq(9).css("width"),
|
||
},
|
||
{
|
||
data: "last_status_fa",
|
||
className: "text-center",
|
||
width: ths.eq(10).css("width"),
|
||
},
|
||
{
|
||
data: "last_digit_project",
|
||
className: "text-center",
|
||
width: ths.eq(11).css("width"),
|
||
},
|
||
{
|
||
data: "last_function_operator",
|
||
className: "text-center",
|
||
width: ths.eq(12).css("width"),
|
||
},
|
||
{
|
||
data: "last_payable_operator",
|
||
className: "text-center",
|
||
width: ths.eq(13).css("width"),
|
||
},
|
||
{
|
||
data: "complete_payable",
|
||
className: "text-center",
|
||
width: ths.eq(14).css("width"),
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-sm btnSubItemOpratorHistoryModal" style="color: #fff;">...</button>';
|
||
},
|
||
className: "text-center",
|
||
width: ths.eq(15).css("width"),
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return row.start_lat + ", " + row.start_lng;
|
||
},
|
||
className: "text-center",
|
||
width: ths.eq(16).css("width"),
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return '<button class="btn-dataTable btn-show-img-history-subitem"><i class="fas fa-image" style="color: white;"></i></button>';
|
||
},
|
||
className: "text-center",
|
||
width: ths.eq(17).css("width"),
|
||
},
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function (data) {
|
||
const updated_at = moment(data.updated_at).format(
|
||
"HH:mm:ss | jYYYY/jMM/jDD"
|
||
);
|
||
return updated_at;
|
||
},
|
||
width: ths.eq(18).css("width"),
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return "-";
|
||
},
|
||
className: "text-center",
|
||
width: ths.eq(19).css("width"),
|
||
},
|
||
],
|
||
});
|
||
});
|
||
});
|
||
|
||
// giving width of header
|
||
function internalTable(tr, id, column) {
|
||
let ths = "";
|
||
let initTable;
|
||
for (let i = 1; i <= column; i++) {
|
||
ths += '<th style="background-color: #fff"></th>';
|
||
}
|
||
initTable = `<tr class="internal-table">
|
||
<td class = "p-0 pb-2 bg-white" style="border-width:0px;"
|
||
colspan = "${column}">
|
||
<table table class = "table"
|
||
style = "background-color: #84b6de; color:#fff"
|
||
id = "${id}"
|
||
style = "width: 100%;">
|
||
<thead style="height:0px">
|
||
<tr>
|
||
${ths}
|
||
</tr>
|
||
</thead>
|
||
</table>
|
||
</td>
|
||
</tr>`;
|
||
$(initTable).insertAfter(tr);
|
||
|
||
return Promise.resolve("Success");
|
||
}
|
||
// end giving width of header
|
||
// end history of subcontract table
|
||
|
||
// history action type modal
|
||
$(document).on("click", ".btnSubItemHistoryModal", function () {
|
||
const tr = $(this).closest("tr");
|
||
const row = historyTable.row(tr);
|
||
|
||
row.data().project_type_id == "1"
|
||
? $(".modal-op-tonaj").removeClass("d-none")
|
||
: $(".modal-op-tonaj").addClass("d-none");
|
||
|
||
$(".input-subcontract-table").val("");
|
||
|
||
$("#subItemModal_type_fa1").val(row.data().operation_type_fa1);
|
||
$("#subItemModal_type_amount1").val(row.data().operation_type_amount1);
|
||
$("#subItemModal_type_unit1").val(row.data().operation_type_unit1);
|
||
$("#subItemModal_type_progress1").val(row.data().operation_type_progress1);
|
||
$("#subItemModal_type_tonaj1").val(row.data().operation_type_tonaj1);
|
||
|
||
$("#subItemModal_type_fa2").val(row.data().operation_type_fa2);
|
||
$("#subItemModal_type_amount2").val(row.data().operation_type_amount2);
|
||
$("#subItemModal_type_unit2").val(row.data().operation_type_unit2);
|
||
$("#subItemModal_type_progress2").val(row.data().operation_type_progress2);
|
||
$("#subItemModal_type_tonaj2").val(row.data().operation_type_tonaj2);
|
||
|
||
$("#subItemModal_type_fa3").val(row.data().operation_type_fa3);
|
||
$("#subItemModal_type_amount3").val(row.data().operation_type_amount3);
|
||
$("#subItemModal_type_unit3").val(row.data().operation_type_unit3);
|
||
$("#subItemModal_type_progress3").val(row.data().operation_type_progress3);
|
||
$("#subItemModal_type_tonaj3").val(row.data().operation_type_tonaj3);
|
||
|
||
$("#subItemModal_type_fa4").val(row.data().operation_type_fa4);
|
||
$("#subItemModal_type_amount4").val(row.data().operation_type_amount4);
|
||
$("#subItemModal_type_unit4").val(row.data().operation_type_unit4);
|
||
$("#subItemModal_type_progress4").val(row.data().operation_type_progress4);
|
||
$("#subItemModal_type_tonaj4").val(row.data().operation_type_tonaj4);
|
||
|
||
$("#subItemModal_actionType").modal("show");
|
||
});
|
||
// end history action type modal
|
||
// history operator data modal
|
||
$(document).on("click", ".btnSubItemOpratorHistoryModal", function () {
|
||
const tr = $(this).closest("tr");
|
||
const row = historyTable.row(tr);
|
||
|
||
$("#subItemOpratorModal_operator_name").val("");
|
||
$("#subItemOpratorModal_operator_phone").val("");
|
||
|
||
$("#subItemOpratorModal_operator_name").val(row.data().operator_name);
|
||
$("#subItemOpratorModal_operator_phone").val(row.data().operator_phone);
|
||
|
||
$("#subItemOpratorModal").modal("show");
|
||
});
|
||
// end history operator data modal
|
||
// history image modal data
|
||
$(document).on("click", ".btn-show-img-history-subitem", function () {
|
||
const tr = $(this).closest("tr");
|
||
const row = historyTable.row(tr);
|
||
|
||
$("#imgSubItem1").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + row.data().image_path1
|
||
);
|
||
$("#imgSubItem2").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + row.data().image_path2
|
||
);
|
||
|
||
$("#subItemImgModal").modal("show");
|
||
});
|
||
// end history image modal data
|
||
|
||
// end modals of subcontract
|
||
|
||
// edit subcontract modal
|
||
$(document).on("click", ".btn-edit-subitem", function () {
|
||
arrEditOprationsDisable = [0, 0, 0, 0];
|
||
// clear all data
|
||
$(".edit-attent_num").css("display", "");
|
||
$(".select-edit-subcontract").val(0);
|
||
$(".select-edit-subcontract").removeClass("validity-checker");
|
||
$("#edit_project_start_map").val("");
|
||
$("#edit_project_end_map").val("");
|
||
$(".input-map-project").removeClass("validity-checker");
|
||
$(".input-edit-subcontract").val("");
|
||
$(".input-edit-subcontract").removeClass("validity-checker");
|
||
$(".span-edit-subcontract").text("0");
|
||
$("#edit-Supervisor-number").val("09");
|
||
$("#edit-Supervisor-number").removeClass("validity-checker");
|
||
$(".map-endplace-title").addClass("d-none");
|
||
$("#limit_percentage").addClass("d-none");
|
||
$(".edit-subcontract-action-type-all").empty();
|
||
$(".edit-subcontract-action-type-all").attr("disabled", true);
|
||
$(".edit-subcontract-action-type-show-all").text("");
|
||
$(".edit-subcontract-action-type-unit-all").text("-");
|
||
$(".edit-subcontract-type-unit-show-all").text("-");
|
||
$(".edit-subcontract-action-type-amount-all").attr("disabled", true);
|
||
$(".edit-subcontract-type-amount-show-all").text("");
|
||
$(".tonaj").addClass("d-none");
|
||
$(".edit-subcontract-action-type-progress-all").attr("disabled", true);
|
||
$(".edit-subcontract-action-type-tonaj-all").prop("disabled", true);
|
||
$(".edit-subcontract-action-type-tonaj-all").removeClass("validity-checker");
|
||
// clear image part
|
||
$("#edit-subcontract-modal").find(".img-preview").removeAttr("src", "");
|
||
$("#edit-subcontract-modal").find(".img-title").css("display", "");
|
||
$("#edit-subcontract-modal").find(".btn-delete-img").prop("disabled", true);
|
||
$("#edit-subcontract-nature").prop("disabled", false);
|
||
$("#edit-subcontract-nature").prop("disabled", true);
|
||
$("#edit-subcontract-modal").find(".img-preview").removeAttr("src", "");
|
||
$("#edit-subcontract-modal").find(".img-title").css("display", "");
|
||
$("#edit-subcontract-modal").find(".img-input").val("");
|
||
$("#edit-subcontract-modal").find(".btn-delete-img").prop("disabled", true);
|
||
$("#edit-subcontract-modal").find(".imgbox").removeClass("validity-checker");
|
||
// clear image part
|
||
|
||
// end clear all data
|
||
|
||
// appending data
|
||
const tr = $(this).closest("tr");
|
||
const row = subItemTable.row(tr);
|
||
const allData = row.data();
|
||
updateId = allData.id;
|
||
const project_title = allData.project_title;
|
||
const project_type_id = allData.project_type_id;
|
||
const operation_type_id1 = allData.operation_type_id1;
|
||
const operation_type_id2 = allData.operation_type_id2;
|
||
const operation_type_id3 = allData.operation_type_id3;
|
||
const operation_type_id4 = allData.operation_type_id4;
|
||
const operation_type_amount1 = allData.operation_type_amount1;
|
||
const operation_type_amount2 = allData.operation_type_amount2;
|
||
const operation_type_amount3 = allData.operation_type_amount3;
|
||
const operation_type_amount4 = allData.operation_type_amount4;
|
||
const operation_type_progress1 = allData.operation_type_progress1;
|
||
const operation_type_progress2 = allData.operation_type_progress2;
|
||
const operation_type_progress3 = allData.operation_type_progress3;
|
||
const operation_type_progress4 = allData.operation_type_progress4;
|
||
const operation_type_tonaj1 = allData.operation_type_tonaj1;
|
||
const operation_type_tonaj2 = allData.operation_type_tonaj2;
|
||
const operation_type_tonaj3 = allData.operation_type_tonaj3;
|
||
const operation_type_tonaj4 = allData.operation_type_tonaj4;
|
||
var positions = {};
|
||
if (allData.start_lat != null) {
|
||
if (allData.end_lat != null) {
|
||
positions = {
|
||
start: {
|
||
lat: allData.start_lat,
|
||
lng: allData.start_lng,
|
||
},
|
||
end: {
|
||
lat: allData.end_lat,
|
||
lng: allData.end_lng,
|
||
},
|
||
};
|
||
} else {
|
||
positions = {
|
||
start: {
|
||
lat: allData.start_lat,
|
||
lng: allData.start_lng,
|
||
},
|
||
};
|
||
}
|
||
} else {
|
||
positions = null;
|
||
}
|
||
|
||
const operator_name = allData.operator_name;
|
||
const operator_phone = allData.operator_phone;
|
||
const priority_project = allData.priority_project;
|
||
const followup_priority_project_id = allData.followup_priority_project_id;
|
||
const city_id = allData.city_id;
|
||
const axis_name_fa = allData.axis_name_fa;
|
||
const axis_type_id = allData.axis_type_id;
|
||
const last_status_id = allData.last_status_id;
|
||
const progress_project = allData.progress_project;
|
||
|
||
const image_path1 = allData.image_path1;
|
||
const image_path2 = allData.image_path2;
|
||
|
||
const last_digit_project = allData.last_digit_project;
|
||
const last_function_operator = allData.last_function_operator;
|
||
const last_payable_operator = allData.last_payable_operator;
|
||
const complete_payable = allData.complete_payable;
|
||
|
||
if (last_status_id == 1) {
|
||
$("#edit_limit_percentage").addClass("d-none");
|
||
$("#edit-subcontract-last-project-position").prop("disabled", false);
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#edit-subcontract-progress-mainpercent").val("10");
|
||
} else if (last_status_id == 2) {
|
||
$("#edit_limit_percentage").removeClass("d-none");
|
||
$("#edit-subcontract-last-project-position").prop("disabled", false);
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", false);
|
||
$("#edit-subcontract-progress-mainpercent").val(progress_project);
|
||
} else if (last_status_id == 3) {
|
||
$("#edit_limit_percentage").addClass("d-none");
|
||
$("#edit-subcontract-last-project-position").prop("disabled", true);
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#edit-subcontract-progress-mainpercent").val("100");
|
||
} else if (last_status_id == 4) {
|
||
$("#edit_limit_percentage").addClass("d-none");
|
||
$("#edit-subcontract-last-project-position").prop("disabled", false);
|
||
$("#edit-subcontract-progress-mainpercent").prop("disabled", true);
|
||
$("#edit-subcontract-progress-mainpercent").val("5");
|
||
}
|
||
|
||
$("#edit-subcontract-title").val(project_title);
|
||
$("#edit-subcontract-nature").val(project_type_id);
|
||
subcontract_nature = project_type_id;
|
||
$("#edit-subcontract-action-type-amount-first").val(operation_type_amount1);
|
||
$("#edit-subcontract-action-type-amount-second").val(operation_type_amount2);
|
||
$("#edit-subcontract-action-type-amount-third").val(operation_type_amount3);
|
||
$("#edit-subcontract-action-type-amount-forth").val(operation_type_amount4);
|
||
|
||
$("#edit-subcontract-action-type-progress-first").val(
|
||
operation_type_progress1
|
||
);
|
||
$("#edit-subcontract-action-type-progress-second").val(
|
||
operation_type_progress2
|
||
);
|
||
$("#edit-subcontract-action-type-progress-third").val(
|
||
operation_type_progress3
|
||
);
|
||
$("#edit-subcontract-action-type-progress-forth").val(
|
||
operation_type_progress4
|
||
);
|
||
|
||
$("#edit-subcontract-action-type-tonaj-first").val(operation_type_tonaj1);
|
||
$("#edit-subcontract-action-type-tonaj-second").val(operation_type_tonaj2);
|
||
$("#edit-subcontract-action-type-tonaj-third").val(operation_type_tonaj3);
|
||
$("#edit-subcontract-action-type-tonaj-forth").val(operation_type_tonaj4);
|
||
|
||
$("#edit-subcontract-last-riali-digit-project").val(last_digit_project);
|
||
$("#edit-subcontract-last-riali-digit-project-span").text(
|
||
parseFloat(last_digit_project).toLocaleString("en")
|
||
);
|
||
$("#edit-subcontract-last-amount-worker-function").val(
|
||
last_function_operator
|
||
);
|
||
$("#edit-subcontract-last-amount-worker-function-span").text(
|
||
parseFloat(last_function_operator).toLocaleString("en")
|
||
);
|
||
$("#edit-subcontract-last-payable-amount-worker").val(last_payable_operator);
|
||
$("#edit-subcontract-last-payable-amount-worker-span").text(
|
||
parseFloat(last_payable_operator).toLocaleString("en")
|
||
);
|
||
$("#edit-subcontract-amount-for-ending-project").val(complete_payable);
|
||
$("#edit-subcontract-amount-for-ending-project-span").text(
|
||
parseFloat(complete_payable).toLocaleString("en")
|
||
);
|
||
|
||
if (editMap == null) {
|
||
setTimeout(() => {
|
||
createEditMap(positions);
|
||
}, 400);
|
||
} else {
|
||
setTimeout(() => {
|
||
clearEditMap(positions);
|
||
}, 400);
|
||
}
|
||
|
||
$("#edit-Supervisor-name").val(operator_name);
|
||
$("#edit-Supervisor-number").val(operator_phone);
|
||
if ($("#edit-Supervisor-number").val().length == 11) {
|
||
$(".edit-attent_num").fadeOut(300);
|
||
}
|
||
$("#edit-subcontract-importance-degree").val(priority_project);
|
||
$("#edit-subcontract-monitoring-degree").val(followup_priority_project_id);
|
||
showSubProvince(city_id);
|
||
$("#edit-subcontract-axisName").val(axis_name_fa);
|
||
$("#edit-subcontract-axisType").val(axis_type_id);
|
||
$("#edit-subcontract-last-project-position").val(last_status_id);
|
||
|
||
if (image_path1 != null) {
|
||
$("#edit-deviceImg1Preview").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + image_path1
|
||
);
|
||
$("#edit-deviceImg1Title").css("display", "none");
|
||
$("#edit-deleteDeviceImg1").prop("disabled", false);
|
||
}
|
||
if (image_path2 != null) {
|
||
$("#edit-deviceImg2Preview").attr(
|
||
"src",
|
||
"https://rms.rmto.ir/" + image_path2
|
||
);
|
||
$("#edit-deviceImg2Title").css("display", "none");
|
||
$("#edit-deleteDeviceImg2").prop("disabled", false);
|
||
}
|
||
|
||
if (project_type_id == 1) {
|
||
$(".tonaj").removeClass("d-none");
|
||
} else {
|
||
$(".tonaj").addClass("d-none");
|
||
}
|
||
|
||
if (project_type_id == 0) {
|
||
$(".map-endplace-title").addClass("d-none");
|
||
hideLoaderScreen();
|
||
$(".edit-subcontract-action-type-all").attr("disabled", true);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "لطفا نوع عملیات خود را به درستی انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
$(".edit-subcontract-action-type-all").attr("disabled", false);
|
||
$(".edit-subcontract-action-type-all").append(
|
||
"<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>"
|
||
);
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/operation/" + project_type_id,
|
||
type: "GET",
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (res) {
|
||
$.each(res, function (key, value) {
|
||
const unit = value.unit != "" ? value.unit : "-";
|
||
const amountable = value.amountable;
|
||
$(".edit-subcontract-action-type-all").append(
|
||
"<option amountable='" +
|
||
amountable +
|
||
"' unit='" +
|
||
unit +
|
||
"' value='" +
|
||
key +
|
||
"'>" +
|
||
value.farsi +
|
||
"</option>"
|
||
);
|
||
});
|
||
|
||
if (operation_type_id1 == null || operation_type_id1 == 0) {
|
||
$("#edit-subcontract-action-type-first").val(0);
|
||
$("#edit-subcontract-action-type-amount-first").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-progress-first").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-unit-first").text(
|
||
$("#edit-subcontract-action-type-first option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-first-show").text(
|
||
$("#edit-subcontract-action-type-first option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-first").val(operation_type_id1);
|
||
arrEditOprationsDisable[0] = operation_type_id1;
|
||
if (
|
||
$("#edit-subcontract-action-type-first option:selected").attr(
|
||
"amountable"
|
||
) == 1
|
||
) {
|
||
$("#edit-subcontract-action-type-amount-first").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
$("#edit-subcontract-action-type-amount-first-show").text(
|
||
$("#edit-subcontract-action-type-amount-first").val()
|
||
);
|
||
}
|
||
if ($("#edit-subcontract-action-type-first").val() == 0) {
|
||
$("#edit-subcontract-action-type-progress-first").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-progress-first").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
}
|
||
if (project_type_id == 1) {
|
||
$("#edit-subcontract-action-type-tonaj-first").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-tonaj-first").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
}
|
||
$("#edit-subcontract-action-type-unit-first").text(
|
||
$("#edit-subcontract-action-type-first option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-first-show").text(
|
||
$("#edit-subcontract-action-type-first option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-first-show").text(
|
||
$("#edit-subcontract-action-type-first option:selected").text()
|
||
);
|
||
}
|
||
|
||
if (operation_type_id2 == null || operation_type_id2 == 0) {
|
||
$("#edit-subcontract-action-type-second").val(0);
|
||
$("#edit-subcontract-action-type-amount-second").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-progress-second").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-unit-second").text(
|
||
$("#edit-subcontract-action-type-second option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-second-show").text(
|
||
$("#edit-subcontract-action-type-second option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-second").val(operation_type_id2);
|
||
arrEditOprationsDisable[1] = operation_type_id2;
|
||
if (
|
||
$("#edit-subcontract-action-type-second option:selected").attr(
|
||
"amountable"
|
||
) == 1
|
||
) {
|
||
$("#edit-subcontract-action-type-amount-second").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
$("#edit-subcontract-action-type-amount-second-show").text(
|
||
$("#edit-subcontract-action-type-amount-second").val()
|
||
);
|
||
}
|
||
if ($("#edit-subcontract-action-type-second").val() == 0) {
|
||
$("#edit-subcontract-action-type-progress-second").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-progress-second").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
}
|
||
if (project_type_id == 1) {
|
||
$("#edit-subcontract-action-type-tonaj-second").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-tonaj-second").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
}
|
||
$("#edit-subcontract-action-type-unit-second").text(
|
||
$("#edit-subcontract-action-type-second option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-second-show").text(
|
||
$("#edit-subcontract-action-type-second option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-second-show").text(
|
||
$("#edit-subcontract-action-type-second option:selected").text()
|
||
);
|
||
}
|
||
|
||
if (operation_type_id3 == null || operation_type_id3 == 0) {
|
||
$("#edit-subcontract-action-type-third").val(0);
|
||
$("#edit-subcontract-action-type-amount-third").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-progress-third").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-unit-third").text(
|
||
$("#edit-subcontract-action-type-third option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-third-show").text(
|
||
$("#edit-subcontract-action-type-third option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-third").val(operation_type_id3);
|
||
arrEditOprationsDisable[2] = operation_type_id3;
|
||
if (
|
||
$("#edit-subcontract-action-type-third option:selected").attr(
|
||
"amountable"
|
||
) == 1
|
||
) {
|
||
$("#edit-subcontract-action-type-amount-third").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
$("#edit-subcontract-action-type-amount-third-show").text(
|
||
$("#edit-subcontract-action-type-amount-third").val()
|
||
);
|
||
}
|
||
if ($("#edit-subcontract-action-type-third").val() == 0) {
|
||
$("#edit-subcontract-action-type-progress-third").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-progress-third").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
}
|
||
if (project_type_id == 1) {
|
||
$("#edit-subcontract-action-type-tonaj-third").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-tonaj-third").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
}
|
||
$("#edit-subcontract-action-type-unit-third").text(
|
||
$("#edit-subcontract-action-type-third option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-third-show").text(
|
||
$("#edit-subcontract-action-type-third option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-third-show").text(
|
||
$("#edit-subcontract-action-type-third option:selected").text()
|
||
);
|
||
}
|
||
|
||
if (operation_type_id4 == null || operation_type_id4 == 0) {
|
||
$("#edit-subcontract-action-type-forth").val(0);
|
||
$("#edit-subcontract-action-type-amount-forth").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-progress-forth").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
$("#edit-subcontract-action-type-unit-forth").text(
|
||
$("#edit-subcontract-action-type-forth option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-forth-show").text(
|
||
$("#edit-subcontract-action-type-forth option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-forth").val(operation_type_id4);
|
||
arrEditOprationsDisable[3] = operation_type_id4;
|
||
if (
|
||
$("#edit-subcontract-action-type-forth option:selected").attr(
|
||
"amountable"
|
||
) == 1
|
||
) {
|
||
$("#edit-subcontract-action-type-amount-forth").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
$("#edit-subcontract-action-type-amount-forth-show").text(
|
||
$("#edit-subcontract-action-type-amount-forth").val()
|
||
);
|
||
}
|
||
if ($("#edit-subcontract-action-type-forth").val() == 0) {
|
||
$("#edit-subcontract-action-type-progress-forth").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-progress-forth").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
}
|
||
if (project_type_id == 1) {
|
||
$("#edit-subcontract-action-type-tonaj-forth").prop(
|
||
"disabled",
|
||
false
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-action-type-tonaj-forth").prop(
|
||
"disabled",
|
||
true
|
||
);
|
||
}
|
||
$("#edit-subcontract-action-type-unit-forth").text(
|
||
$("#edit-subcontract-action-type-forth option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-unit-forth-show").text(
|
||
$("#edit-subcontract-action-type-forth option:selected").attr(
|
||
"unit"
|
||
)
|
||
);
|
||
$("#edit-subcontract-action-type-forth-show").text(
|
||
$("#edit-subcontract-action-type-forth option:selected").text()
|
||
);
|
||
}
|
||
hideLoaderScreen();
|
||
for (let i = 0; i < arrEditOprationsDisable.length; i++) {
|
||
if (arrEditOprationsDisable[i] != 0)
|
||
$("#edit-subcontract-modal")
|
||
.find(
|
||
`.edit-subcontract-action-type-all option[value=${arrEditOprationsDisable[i]}]`
|
||
)
|
||
.prop("disabled", true);
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در دریافت نوع عملیات",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
// end appending data
|
||
|
||
$("#edit-subcontract-modal").modal("show");
|
||
});
|
||
// end edit subcontract modal
|
||
// edit map
|
||
function drawPathEdit() {
|
||
if (subcontract_nature != 6) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
editMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
routeControls.push(
|
||
L.Routing.control({
|
||
waypoints: [
|
||
L.latLng(
|
||
parseFloat(startMarkerEdit.getLatLng().lat),
|
||
parseFloat(startMarkerEdit.getLatLng().lng)
|
||
),
|
||
L.latLng(
|
||
parseFloat(endMarkerEdit.getLatLng().lat),
|
||
parseFloat(endMarkerEdit.getLatLng().lng)
|
||
),
|
||
],
|
||
fitSelectedRoutes: false,
|
||
draggableWaypoints: true,
|
||
createMarker: function () {
|
||
return null;
|
||
},
|
||
lineOptions: {
|
||
addWaypoints: false,
|
||
styles: [
|
||
{
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
},
|
||
],
|
||
},
|
||
}).addTo(editMap)
|
||
);
|
||
$(".leaflet-control-container").css("display", "none");
|
||
$(".leaflet-routing-container-hide").css("display", "none");
|
||
} else {
|
||
var polyline;
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
editMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
var latlngs = Array();
|
||
latlngs.push(startMarkerEdit.getLatLng());
|
||
latlngs.push(endMarkerEdit.getLatLng());
|
||
routeControls.push(
|
||
(polyline = L.polyline(latlngs, {
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
}).addTo(editMap))
|
||
);
|
||
}
|
||
}
|
||
|
||
function createEditMap(position) {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
if (position != null) {
|
||
editMap = L.map("edit_map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([position.start.lat, position.start.lng], 7);
|
||
} else {
|
||
editMap = L.map("edit_map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([35.7065, 51.3477], 7);
|
||
}
|
||
L.tileLayer(`${mapUrl}{z}/{x}/{y}.png`, {}).addTo(editMap);
|
||
setMarkerDefaultEdit(position);
|
||
}
|
||
|
||
function clearEditMap(position) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
editMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
editMap.removeLayer(startMarkerEdit);
|
||
if (endMarkerEdit != null) {
|
||
editMap.removeLayer(endMarkerEdit);
|
||
}
|
||
|
||
if (position != null) {
|
||
editMap.setView([position.start.lat, position.start.lng], 7);
|
||
} else {
|
||
editMap.setView([35.7065, 51.3477], 7);
|
||
}
|
||
setMarkerDefaultEdit(position);
|
||
}
|
||
|
||
function setMarkerDefaultEdit(position) {
|
||
isSetStartMarkerEdit = false;
|
||
isSetEndMarkerEdit = false;
|
||
$("#edit_pin-marker-end").removeClass("pin-set");
|
||
$("#edit_pin-marker-start").removeClass("pin-set");
|
||
$("#edit_project_start_map").val("");
|
||
$("#edit_project_end_map").val("");
|
||
|
||
if (position != null) {
|
||
if (position.end != undefined) {
|
||
isSetStartMarkerEdit = true;
|
||
isSetEndMarkerEdit = true;
|
||
|
||
startMarkerEdit = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: startDivIconEdit,
|
||
draggable: true,
|
||
}).addTo(editMap);
|
||
|
||
endMarkerEdit = new L.marker([position.end.lat, position.end.lng], {
|
||
icon: endDivIconEdit,
|
||
draggable: true,
|
||
}).addTo(editMap);
|
||
|
||
$("#edit_pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
$("#edit_project_start_map").val(position.start.lat + position.start.lng);
|
||
$("#edit_pin-marker-end")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
$("#edit_project_end_map").val(position.end.lat + position.end.lng);
|
||
drawPathEdit();
|
||
} else {
|
||
isSetStartMarkerEdit = true;
|
||
isSetEndMarkerEdit = false;
|
||
|
||
startMarkerEdit = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: startDivIconEdit,
|
||
draggable: true,
|
||
}).addTo(editMap);
|
||
|
||
endMarkerEdit = new L.marker([position.start.lat, position.start.lng], {
|
||
icon: endDivIconEdit,
|
||
draggable: true,
|
||
}).addTo(editMap);
|
||
|
||
$("#edit_pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
|
||
$("#edit_project_start_map").val(position.start.lat + position.start.lng);
|
||
|
||
$("#edit_project_end_map").val("");
|
||
}
|
||
} else {
|
||
isSetStartMarkerEdit = false;
|
||
isSetEndMarkerEdit = false;
|
||
|
||
startMarkerEdit = new L.marker(L.latLng(addMap.getCenter()), {
|
||
icon: startDivIconEdit,
|
||
draggable: true,
|
||
}).addTo(editMap);
|
||
|
||
endMarkerEdit = new L.marker(L.latLng(addMap.getCenter()), {
|
||
icon: endDivIconEdit,
|
||
draggable: true,
|
||
});
|
||
|
||
$("#edit_pin-marker-start").removeClass("pin-set");
|
||
$("#edit_pin-marker-end").removeClass("pin-set");
|
||
|
||
$("#edit_project_start_map").val("");
|
||
|
||
$("#edit_project_end_map").val();
|
||
}
|
||
|
||
editMap.on("move", function () {
|
||
if (!isSetStartMarkerEdit && !isSetEndMarkerEdit) {
|
||
startMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
$("#edit-pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
|
||
if (isSetStartMarkerEdit && !isSetEndMarkerEdit) {
|
||
endMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
$("#edit-pin-marker-end").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
editMap.on("moveend", function () {
|
||
if (!isSetStartMarkerEdit && !isSetEndMarkerEdit) {
|
||
startMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
$("#edit-pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
|
||
if (isSetStartMarkerEdit && !isSetEndMarkerEdit) {
|
||
endMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
$("#edit-pin-marker-end").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
startMarkerEdit.on("click", function () {
|
||
if (!isSetStartMarkerEdit) {
|
||
startMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
endMarkerEdit.setLatLng(L.latLng(editMap.getCenter()));
|
||
isSetStartMarkerEdit = true;
|
||
$("#edit-pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
$("#edit_project_start_map").val(
|
||
startMarkerEdit.getLatLng().lat.toFixed(6) +
|
||
startMarkerEdit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#edit_project_start_map").removeClass("validity-checker");
|
||
}
|
||
endMarkerEdit.addTo(editMap);
|
||
|
||
$(this).hide();
|
||
$("#edit-pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
});
|
||
|
||
startMarkerEdit.on("drag", function () {
|
||
$("#edit_pin-marker-start").addClass("pin-move");
|
||
});
|
||
|
||
startMarkerEdit.on("dragend", function () {
|
||
$("#edit_pin-marker-start").removeClass("pin-move");
|
||
if (
|
||
$("#edit_pin-marker-start").hasClass("pin-set") ||
|
||
isSetStartMarkerEdit
|
||
) {
|
||
$("#edit_pin-marker-start").addClass("pin-set");
|
||
$("#edit_project_start_map").val(
|
||
startMarkerEdit.getLatLng().lat.toFixed(6) +
|
||
startMarkerEdit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#edit_project_start_map").removeClass("validity-checker");
|
||
drawPathEdit();
|
||
} else {
|
||
editMap.setView(startMarkerEdit.getLatLng());
|
||
}
|
||
});
|
||
|
||
endMarkerEdit.on("click", function () {
|
||
if (!isSetEndMarkerEdit) {
|
||
isSetEndMarkerEdit = true;
|
||
$("#edit_pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
$("#edit_project_end_map").val(
|
||
endMarkerEdit.getLatLng().lat.toFixed(6) +
|
||
endMarkerEdit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#edit_project_end_map").removeClass("validity-checker");
|
||
}
|
||
drawPathEdit();
|
||
});
|
||
|
||
endMarkerEdit.on("drag", function () {
|
||
$("#edit_pin-marker-end").addClass("pin-move");
|
||
});
|
||
|
||
endMarkerEdit.on("dragend", function () {
|
||
$("#edit_pin-marker-end").removeClass("pin-move");
|
||
|
||
if ($("#edit_pin-marker-end").hasClass("pin-set") || isSetEndMarkerEdit) {
|
||
$("#edit_pin-marker-end").addClass("pin-set");
|
||
$("#edit_project_end_map").val(
|
||
endMarkerEdit.getLatLng().lat.toFixed(6) +
|
||
endMarkerEdit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$("#edit_project_end_map").removeClass("validity-checker");
|
||
drawPathEdit();
|
||
} else {
|
||
editMap.setView(endMarkerEdit.getLatLng());
|
||
}
|
||
});
|
||
}
|
||
// end edit map
|
||
|
||
//drag marker with lat lng in add
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").on(
|
||
"keyup",
|
||
function () {
|
||
checkStartMarkerValidation();
|
||
}
|
||
);
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").on(
|
||
"keyup",
|
||
function () {
|
||
checkEndMarkerValidation();
|
||
}
|
||
);
|
||
|
||
function checkStartMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let startLatLngVal = $(
|
||
"#add-subcontract-modal input[name=add_project_start_map]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
if (isNaN(startLatLng[0])) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
if (!forSaveData) {
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
} else {
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").val("");
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").attr(
|
||
"placeholder",
|
||
"(شروع) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!startLatLng == 2 ||
|
||
!reg.test(startLatLng[0]) ||
|
||
!reg.test(startLatLng[1])
|
||
) {
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$("#add-subcontract-modal input[name=add_project_start_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
startMarkerAdd.setLatLng(startLatLng);
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
startMarkerAdd.setLatLng(startLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
if (!isSetEndMarkerAdd) {
|
||
let markerLatLng = [
|
||
startMarkerAdd.getLatLng().lat,
|
||
startMarkerAdd.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
addMap.setView(markerLatLng);
|
||
endMarkerAdd.setLatLng(markerLatLng);
|
||
|
||
if (!isSetStartMarkerAdd) {
|
||
endMarkerAdd.addTo(addMap);
|
||
}
|
||
}
|
||
isSetStartMarkerAdd = true;
|
||
}
|
||
checkMarkersAndDrawPath();
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function checkEndMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let endLatLngVal = $("#add-subcontract-modal input[name=add_project_end_map]")
|
||
.val()
|
||
.split(" - ");
|
||
let endLatLng = endLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
|
||
if (isNaN(endLatLng[0])) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
if (!forSaveData) {
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
} else {
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").val("");
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").attr(
|
||
"placeholder",
|
||
"(پایان) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!endLatLng == 2 ||
|
||
!reg.test(endLatLng[0]) ||
|
||
!reg.test(endLatLng[1])
|
||
) {
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$("#add-subcontract-modal input[name=add_project_end_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
endMarkerAdd.setLatLng(endLatLng);
|
||
isSetEndMarkerAdd = true;
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
endMarkerAdd.setLatLng(endLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
}
|
||
|
||
checkMarkersAndDrawPath();
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
//drag marker with lat lng in add
|
||
|
||
//drag marker with lat lng in edit
|
||
$("#edit-subcontract-modal input[name=edit_project_start_map]").on(
|
||
"keyup",
|
||
function () {
|
||
checkStartMarkerValidationEdit();
|
||
}
|
||
);
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").on(
|
||
"keyup",
|
||
function () {
|
||
checkEndMarkerValidationEdit();
|
||
}
|
||
);
|
||
|
||
function checkStartMarkerValidationEdit(
|
||
forSaveData = false,
|
||
pageOnLoad = false
|
||
) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let startLatLngVal = $(
|
||
"#edit-subcontract-modal input[name=edit_project_start_map]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
if (isNaN(startLatLng[0])) {
|
||
if (!forSaveData) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
$(
|
||
"#edit-subcontract-modal input[name=edit_project_start_map]"
|
||
).removeClass("is-invalid-input");
|
||
} else {
|
||
$("#edit-subcontract-modal input[name=edit_project_start_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
$("#edit-pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#edit-subcontract-modal input[name=edit_project_start_map]").val("");
|
||
$("#edit-subcontract-modal input[name=edit_project_start_map]").attr(
|
||
"placeholder",
|
||
"(شروع) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!startLatLng == 2 ||
|
||
!reg.test(startLatLng[0]) ||
|
||
!reg.test(startLatLng[1])
|
||
) {
|
||
$("#edit-subcontract-modal input[name=edit_project_start_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#edit-pin-marker-start").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#edit-subcontract-modal input[name=edit_project_start_map]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
startMarkerEdit.setLatLng(startLatLng);
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#edit-pin-marker-start")
|
||
.removeClass("pin-move")
|
||
.addClass("pin-set");
|
||
startMarkerEdit.setLatLng(startLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#edit-pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
if (!isSetEndMarkerEdit) {
|
||
let markerLatLng = [
|
||
startMarkerEdit.getLatLng().lat,
|
||
startMarkerEdit.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
editMap.setView(markerLatLng);
|
||
endMarkerEdit.setLatLng(markerLatLng);
|
||
|
||
if (!isSetStartMarkerEdit) {
|
||
endMarkerAdd.addTo(addMap);
|
||
}
|
||
}
|
||
|
||
isSetStartMarkerEdit = true;
|
||
}
|
||
drawPathEdit();
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function checkEndMarkerValidationEdit(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let endLatLngVal = $(
|
||
"#edit-subcontract-modal input[name=edit_project_end_map]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let endLatLng = endLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
|
||
if (isNaN(endLatLng[0])) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
addMap.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
if (!forSaveData) {
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
} else {
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
$("#edit-pin-marker-end").removeClass("pin-move pin-set");
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").val("");
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").attr(
|
||
"placeholder",
|
||
"(پایان) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!endLatLng == 2 ||
|
||
!reg.test(endLatLng[0]) ||
|
||
!reg.test(endLatLng[1])
|
||
) {
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#edit-pin-marker-end").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$("#edit-subcontract-modal input[name=edit_project_end_map]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
endMarkerEdit.setLatLng(endLatLng);
|
||
isSetEndMarkerEdit = true;
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#edit-pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
endMarkerEdit.setLatLng(endLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#edit-pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
}
|
||
|
||
drawPathEdit();
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
//drag marker with lat lng in edit
|
||
$(document).on("click", "#edit-subcontract-cta", function () {
|
||
let actionChecker = false;
|
||
$("#edit-subcontract-cta").prop("disabled", true);
|
||
// checking validity
|
||
const parent = $(this).parents("#edit-subcontract-modal");
|
||
parent.find(".input-map-project").each(function () {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
if ($("#edit-Supervisor-number").val().length != 11) {
|
||
$("#edit-Supervisor-number").addClass("validity-checker");
|
||
} else {
|
||
$("#edit-Supervisor-number").removeClass("validity-checker");
|
||
}
|
||
parent.find(".input-edit-subcontract").each(function () {
|
||
if (!$(this).prop("disabled")) {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
} else {
|
||
$(this).removeClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".edit-subcontract-action-type-tonaj-all").each(function () {
|
||
if ($("#edit-subcontract-nature").val() == 1) {
|
||
if (!$(this).prop("disabled")) {
|
||
if ($(this).val() != "") {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
} else {
|
||
$(this).removeClass("validity-checker");
|
||
}
|
||
}
|
||
});
|
||
parent.find(".select-edit-subcontract").each(function () {
|
||
if ($(this).val() != 0) {
|
||
$(this).removeClass("validity-checker");
|
||
} else {
|
||
$(this).addClass("validity-checker");
|
||
}
|
||
});
|
||
parent.find(".img-preview").each(function () {
|
||
if ($(this).prop("src") == "") {
|
||
$(this).parents(".imgbox").addClass("validity-checker");
|
||
} else {
|
||
$(this).parents(".imgbox").removeClass("validity-checker");
|
||
}
|
||
});
|
||
if ($("#edit-subcontract-last-project-position").val() == 2) {
|
||
if ($("#edit-subcontract-progress-mainpercent").val().length <= 1) {
|
||
$("#edit-subcontract-progress-mainpercent").addClass("validity-checker");
|
||
} else {
|
||
$("#edit-subcontract-progress-mainpercent").removeClass(
|
||
"validity-checker"
|
||
);
|
||
}
|
||
}
|
||
// checking validity
|
||
|
||
// ************ edit data part should be checked *************
|
||
const project_title = $("#edit-subcontract-title").val();
|
||
const project_type_id = $("#edit-subcontract-nature").val();
|
||
const project_type_fa = $("#edit-subcontract-nature option:selected").text();
|
||
|
||
const operation_type_id1 = $(
|
||
"#edit-subcontract-action-type-first option:selected"
|
||
).val();
|
||
const operation_type_amount1 = $(
|
||
"#edit-subcontract-action-type-amount-first"
|
||
).val();
|
||
const operation_type_progress1 = $(
|
||
"#edit-subcontract-action-type-progress-first"
|
||
).val();
|
||
const operation_type_tonaj1 = $(
|
||
"#edit-subcontract-action-type-tonaj-first"
|
||
).val();
|
||
|
||
const operation_type_id2 = $(
|
||
"#edit-subcontract-action-type-second option:selected"
|
||
).val();
|
||
const operation_type_amount2 = $(
|
||
"#edit-subcontract-action-type-amount-second"
|
||
).val();
|
||
const operation_type_progress2 = $(
|
||
"#edit-subcontract-action-type-progress-second"
|
||
).val();
|
||
const operation_type_tonaj2 = $(
|
||
"#edit-subcontract-action-type-tonaj-second"
|
||
).val();
|
||
|
||
const operation_type_id3 = $(
|
||
"#edit-subcontract-action-type-third option:selected"
|
||
).val();
|
||
const operation_type_amount3 = $(
|
||
"#edit-subcontract-action-type-amount-third"
|
||
).val();
|
||
const operation_type_progress3 = $(
|
||
"#edit-subcontract-action-type-progress-third"
|
||
).val();
|
||
const operation_type_tonaj3 = $(
|
||
"#edit-subcontract-action-type-tonaj-third"
|
||
).val();
|
||
|
||
const operation_type_id4 = $(
|
||
"#edit-subcontract-action-type-forth option:selected"
|
||
).val();
|
||
const operation_type_amount4 = $(
|
||
"#edit-subcontract-action-type-amount-forth"
|
||
).val();
|
||
const operation_type_progress4 = $(
|
||
"#edit-subcontract-action-type-progress-forth"
|
||
).val();
|
||
const operation_type_tonaj4 = $(
|
||
"#edit-subcontract-action-type-tonaj-forth"
|
||
).val();
|
||
|
||
const operator_name = $("#edit-Supervisor-name").val();
|
||
const operator_phone = $("#edit-Supervisor-number").val();
|
||
|
||
const priority_project = $("#edit-subcontract-importance-degree").val();
|
||
const priority_project_fa = $(
|
||
"#edit-subcontract-importance-degree option:selected"
|
||
).text();
|
||
const followup_priority_project_id = $(
|
||
"#edit-subcontract-monitoring-degree"
|
||
).val();
|
||
const followup_priority_project = $(
|
||
"#edit-subcontract-monitoring-degree option:selected"
|
||
).text();
|
||
|
||
const city_id = $("#edit-subcontract-province").val();
|
||
const city_fa = $("#edit-subcontract-province option:selected").text();
|
||
|
||
const axis_name_fa = $("#edit-subcontract-axisName").val();
|
||
const axis_type_id = $("#edit-subcontract-axisType").val();
|
||
const axis_type_fa = $("#edit-subcontract-axisType option:selected").text();
|
||
|
||
const last_status_id = $("#edit-subcontract-last-project-position").val();
|
||
const last_status_fa = $(
|
||
"#edit-subcontract-last-project-position option:selected"
|
||
).text();
|
||
const progress_project = $("#edit-subcontract-progress-mainpercent").val();
|
||
|
||
const last_digit_project = $(
|
||
"#edit-subcontract-last-riali-digit-project"
|
||
).val();
|
||
const last_function_operator = $(
|
||
"#edit-subcontract-last-amount-worker-function"
|
||
).val();
|
||
const last_payable_operator = $(
|
||
"#edit-subcontract-last-payable-amount-worker"
|
||
).val();
|
||
const complete_payable = $(
|
||
"#edit-subcontract-amount-for-ending-project"
|
||
).val();
|
||
const province_id = provinceIdForSub;
|
||
const contract_id = contractRowId;
|
||
const image1 = $("#edit-deviceImg1").get(0).files[0];
|
||
const image2 = $("#edit-deviceImg2").get(0).files[0];
|
||
|
||
const start_lat = startMarkerEdit.getLatLng().lat.toFixed(6);
|
||
const start_lng = startMarkerEdit.getLatLng().lng.toFixed(6);
|
||
const end_lat = endMarkerEdit.getLatLng().lat.toFixed(6);
|
||
const end_lng = endMarkerEdit.getLatLng().lng.toFixed(6);
|
||
let formData = new FormData();
|
||
if ($("#edit-subcontract-action-type-first option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id1", operation_type_id1);
|
||
if ($("#edit-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount1", operation_type_amount1);
|
||
}
|
||
formData.append("operation_type_progress1", operation_type_progress1);
|
||
if ($("#edit-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj1", operation_type_tonaj1);
|
||
}
|
||
}
|
||
if ($("#edit-subcontract-action-type-second option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id2", operation_type_id2);
|
||
if ($("#edit-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount2", operation_type_amount2);
|
||
}
|
||
formData.append("operation_type_progress2", operation_type_progress2);
|
||
if ($("#edit-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj2", operation_type_tonaj2);
|
||
}
|
||
}
|
||
if ($("#edit-subcontract-action-type-third option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id3", operation_type_id3);
|
||
if ($("#edit-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount3", operation_type_amount3);
|
||
}
|
||
formData.append("operation_type_progress3", operation_type_progress3);
|
||
if ($("#edit-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj3", operation_type_tonaj3);
|
||
}
|
||
}
|
||
if ($("#edit-subcontract-action-type-forth option:selected").val() != 0) {
|
||
actionChecker = true;
|
||
formData.append("operation_type_id4", operation_type_id4);
|
||
if ($("#edit-subcontract-nature option:selected").hasClass("limitAmount")) {
|
||
formData.append("operation_type_amount4", operation_type_amount4);
|
||
}
|
||
formData.append("operation_type_progress4", operation_type_progress4);
|
||
if ($("#edit-subcontract-nature").val() == 1) {
|
||
formData.append("operation_type_tonaj4", operation_type_tonaj4);
|
||
}
|
||
}
|
||
formData.append("project_title", project_title);
|
||
formData.append("project_type_id", project_type_id);
|
||
formData.append("project_type_fa", project_type_fa);
|
||
formData.append("operator_name", operator_name);
|
||
formData.append("province_id", province_id);
|
||
formData.append("operator_phone", operator_phone);
|
||
formData.append("priority_project", priority_project);
|
||
formData.append("priority_project_fa", priority_project_fa);
|
||
formData.append("followup_priority_project_id", followup_priority_project_id);
|
||
formData.append("followup_priority_project", followup_priority_project);
|
||
formData.append("city_id", city_id);
|
||
formData.append("city_fa", city_fa);
|
||
formData.append("axis_name_fa", axis_name_fa);
|
||
formData.append("axis_type_id", axis_type_id);
|
||
formData.append("axis_type_fa", axis_type_fa);
|
||
formData.append("last_status_id", last_status_id);
|
||
formData.append("last_status_fa", last_status_fa);
|
||
formData.append("progress_project", progress_project);
|
||
formData.append("last_digit_project", last_digit_project);
|
||
formData.append("last_function_operator", last_function_operator);
|
||
formData.append("last_payable_operator", last_payable_operator);
|
||
formData.append("complete_payable", complete_payable);
|
||
formData.append("contract_id", contract_id);
|
||
if (typeof image1 !== "undefined") formData.append("image1", image1);
|
||
if (typeof image2 !== "undefined") formData.append("image2", image2);
|
||
formData.append("start_lat", start_lat);
|
||
formData.append("start_lng", start_lng);
|
||
formData.append("end_lat", end_lat);
|
||
formData.append("end_lng", end_lng);
|
||
if (!actionChecker) {
|
||
$("#edit-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "حداقل یکی از انواع عملیات را انتخاب کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else if (
|
||
$("#edit-subcontract-modal").find(".validity-checker").length != 0
|
||
) {
|
||
$("#edit-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "مقادیر مشخص شده را پر کنید",
|
||
text: "اگر همچنان با این اخطار مواجه شدید با پشتیبانی تماس بگیرید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
} else {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/csi/update-dev/" + updateId,
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
$("#edit-subcontract-modal").modal("hide");
|
||
$("#edit-subcontract-cta").prop("disabled", false);
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "success",
|
||
text: "زیر پروژه با موفقیت ویرایش شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
subItemTable.ajax.reload(null, false);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
$("#edit-subcontract-cta").prop("disabled", false);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "مشکل در ارتباط با سرور",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
// ************ edit data part should be checked *************
|
||
});
|
||
|
||
$(document).bind("click", function (e) {
|
||
const clicked = $(e.target);
|
||
if (clicked.parents(".toolbox").length != 0) return false;
|
||
if (clicked.parents(".datepicker-grid-view").length != 0) return false;
|
||
if (clicked.parents(".datepicker-navigator").length != 0) return false;
|
||
if (clicked.parents(".datepicker-container").length != 0) return false;
|
||
if (clicked.parents(".select2-selection__choice").length != 0) return false;
|
||
if (
|
||
clicked.closest(".btn-table-filter").length == 0 &&
|
||
clicked.closest(".parent-filter").length == 0 &&
|
||
$(".parent-filter").css("display") != "none"
|
||
) {
|
||
$(".parent-filter").css("display", "none");
|
||
}
|
||
if (
|
||
clicked.closest(".btn-table-excel").length == 0 &&
|
||
clicked.closest(".parent-excel").length == 0 &&
|
||
$(".parent-excel").css("display") != "none"
|
||
) {
|
||
$(".parent-excel").css("display", "none");
|
||
}
|
||
if (
|
||
clicked.closest(".btn-table-word").length == 0 &&
|
||
clicked.closest(".parent-word").length == 0 &&
|
||
$(".parent-word").css("display") != "none"
|
||
) {
|
||
$(".parent-word").css("display", "none");
|
||
}
|
||
});
|
||
|
||
$("#btn_filter_show").on("click", function () {
|
||
_table = table
|
||
var currentDate = {};
|
||
province_val = $("#select-province").val().join(",");
|
||
status_val = $(".last_statusfilter").val().join(",");
|
||
status_rel_val = $(".contain_project").val();
|
||
currentFilterYear = $('select[name="yearfilter"]').val();
|
||
id_search = $('.id_search').val();
|
||
title_search = $('.title_search').val();
|
||
contract_peymankar_search = $('.contract_peymankar_search').val();
|
||
project_type = $('.project-type').val().join(",");
|
||
currentDate.from = moment(currentFilterYear, "jYYYY");
|
||
currentFilterQueryfrom = currentDate.from.locale("fa").format("YYYY-MM-DD");
|
||
currentDate.to = moment(currentFilterYear, "jYYYY");
|
||
currentDate.to.add(1, "year");
|
||
currentFilterQueryto = currentDate.to.locale("fa").format("YYYY-MM-DD");
|
||
if (id_search != '') {
|
||
_table = _table.column(0).search(id_search);
|
||
} else {
|
||
_table = _table.column(0).search('');
|
||
}
|
||
if (title_search != '') {
|
||
_table = _table.column(3).search(title_search);
|
||
} else {
|
||
_table = _table.column(3).search('');
|
||
}
|
||
if (contract_peymankar_search != '') {
|
||
_table = _table.column(6).search(contract_peymankar_search);
|
||
} else {
|
||
_table = _table.column(6).search('');
|
||
}
|
||
if (province_val != 0) {
|
||
_table = _table.column(22).search(province_val);
|
||
} else {
|
||
_table = _table.column(22).search('');
|
||
}
|
||
if (status_val != 0) {
|
||
_table = _table.column(23).search(status_val);
|
||
} else {
|
||
_table = _table.column(23).search('');
|
||
}
|
||
if (status_rel_val != 0) {
|
||
_table = _table.column(24).search(status_rel_val);
|
||
} else {
|
||
_table = _table.column(24).search('');
|
||
}
|
||
if (currentFilterYear != 0) {
|
||
_table = _table.column(4).search(`${currentFilterQueryfrom}&${currentFilterQueryto}`);
|
||
} else {
|
||
_table = _table.column(4).search('');
|
||
}
|
||
if (project_type != 0) {
|
||
_table = _table.column(25).search(project_type);
|
||
} else {
|
||
_table = _table.column(25).search('');
|
||
}
|
||
|
||
_table.draw();
|
||
});
|
||
$("#btn_excel-download").on("click", function () {
|
||
let currentDate = {};
|
||
let queryParems = [];
|
||
const project_type = $('select[name="select-project-type-excel"]').val();
|
||
const province = $('select[name="select-province-excel"]').val();
|
||
if (
|
||
!(
|
||
$("#datapicker-from-excel-table").is(":disabled") &&
|
||
$("#datapicker-to-excel-table").is(":disabled")
|
||
)
|
||
) {
|
||
if (
|
||
excelDatepickerFirstTable.from != "" &&
|
||
excelDatepickerFirstTable.to != ""
|
||
) {
|
||
currentDate.from = moment(
|
||
excelDatepickerFirstTable.from.getState().selected.year +
|
||
"/" +
|
||
excelDatepickerFirstTable.from.getState().selected.month +
|
||
"/" +
|
||
excelDatepickerFirstTable.from.getState().selected.date,
|
||
"jYYYY/jM/jD"
|
||
).format("YYYY-MM-DD");
|
||
|
||
currentDate.to = moment(
|
||
excelDatepickerFirstTable.to.getState().selected.year +
|
||
"/" +
|
||
excelDatepickerFirstTable.to.getState().selected.month +
|
||
"/" +
|
||
excelDatepickerFirstTable.to.getState().selected.date,
|
||
"jYYYY/jM/jD"
|
||
).format("YYYY-MM-DD");
|
||
|
||
queryParems.push(`fromDate=${currentDate.from}`);
|
||
queryParems.push(`toDate=${currentDate.to}`);
|
||
}
|
||
}
|
||
if (province != 0) queryParems.push(`province=${province}`);
|
||
const url = `https://rms.rmto.ir/reports/${project_type}${queryParems.length != 0 ? `?${queryParems.join("&")}` : ""
|
||
}`;
|
||
window.open(url, "_blank");
|
||
});
|
||
$(document).on("click", "#btn_word_download", function () {
|
||
const provinceWordVal = $("#select-province-word option:selected").val();
|
||
window.open(
|
||
"https://rms.rmto.ir/contracts/document?province=" +
|
||
provinceWordVal +
|
||
"&type=1",
|
||
"_blank"
|
||
);
|
||
// pdf part
|
||
// showPrintPDF();
|
||
});
|
||
function appendYearFilter() {
|
||
var current_year;
|
||
$(".yearfilter").append(`<option value="0">انتخاب سال </option>`);
|
||
current_year = new persianDate().year();
|
||
for (let i = 1396; i <= current_year; i++) {
|
||
$(".yearfilter").append(
|
||
"\
|
||
<option value=" + i + ">" + i.toString() + "</option>\
|
||
"
|
||
);
|
||
}
|
||
}
|
||
$(document).on(
|
||
"input",
|
||
".add-subcontract-action-type-progress-all",
|
||
function () {
|
||
if ($(this).val() > 100) {
|
||
$(this).val(100);
|
||
} else if ($(this).val() < 0) {
|
||
$(this).val(0);
|
||
}
|
||
}
|
||
);
|
||
$(document).on(
|
||
"input",
|
||
".edit-subcontract-action-type-progress-all",
|
||
function () {
|
||
if ($(this).val() > 100) {
|
||
$(this).val(100);
|
||
} else if ($(this).val() < 0) {
|
||
$(this).val(0);
|
||
}
|
||
}
|
||
);
|
||
$(document).on("input", ".add-subcontract-action-type-amount-all", function () {
|
||
if ($(this).val() <= 0) {
|
||
$(this).val("");
|
||
}
|
||
});
|
||
$(document).on(
|
||
"input",
|
||
".edit-subcontract-action-type-amount-all",
|
||
function () {
|
||
if ($(this).val() <= 0) {
|
||
$(this).val("");
|
||
}
|
||
}
|
||
);
|
||
$(document).on("input", ".add-subcontract-action-type-tonaj-all", function () {
|
||
if ($(this).val() <= 0) {
|
||
$(this).val("");
|
||
}
|
||
});
|
||
$(document).on("input", ".edit-subcontract-action-type-tonaj-all", function () {
|
||
if ($(this).val() < 0) {
|
||
$(this).val("");
|
||
}
|
||
});
|
||
|
||
$("#select_project_type_excel").on("change", function () {
|
||
$("#datapicker-from-excel-table").prop(
|
||
"disabled",
|
||
$.inArray($(this).val(), $(this).data("activeDate")) != -1
|
||
);
|
||
|
||
$("#datapicker-to-excel-table").prop(
|
||
"disabled",
|
||
$.inArray($(this).val(), $(this).data("activeDate")) != -1
|
||
);
|
||
});
|
||
|
||
$("table").on("click", "tbody tr", function () {
|
||
const parent = $(this).parents("table");
|
||
parent.find("tr.selected").find("i").css("color", "");
|
||
parent.find("tr.selected").css("color", "");
|
||
parent.find("tr.selected").removeClass("selected");
|
||
|
||
$(this).addClass("selected");
|
||
$(this).css("color", "white");
|
||
$(this).find("i").css("color", "white");
|
||
}); |