5182 lines
185 KiB
JavaScript
5182 lines
185 KiB
JavaScript
var map = null;
|
||
var map2 = null;
|
||
var table;
|
||
var startAbrarMarker = null;
|
||
var isSetStartAbrarMarker = false;
|
||
var endAbrarMarker = null;
|
||
var isSetEndAbrarMarker = false;
|
||
var progressAbrarMarker = null;
|
||
var isSetprogressAbrarMarker = false;
|
||
var mapshow = null;
|
||
var startAbrarMarkershow = null;
|
||
var isSetStartAbrarMarkershow = false;
|
||
var endAbrarMarkershow = null;
|
||
var isSetEndAbrarMarkershow = false;
|
||
var staticMap = null;
|
||
|
||
var ekipAbrarMarkerJustShow = null;
|
||
var isSetEkipAbrarMarkerJustShow = false;
|
||
var startAbrarMarkerJustShow = null;
|
||
var isSetStartAbrarMarkerJustShow = false;
|
||
var endAbrarMarkerJustShow = null;
|
||
var isSetEndAbrarMarkerJustShow = false;
|
||
var list_province = [];
|
||
var list_citys = [];
|
||
var array_hold = [];
|
||
var array_hold_String = "";
|
||
var array_hold_String_edited;
|
||
var data_select_sec;
|
||
var array_hold_Axis_type = [];
|
||
var data_select_Axis_type;
|
||
var String_hold_Axis_type = "";
|
||
var String_edited_Axis_type;
|
||
|
||
var array_geted_date = [];
|
||
var hold_Data_p1 = "";
|
||
var pooriapo;
|
||
var edited_end_date;
|
||
var hold_Data_city1;
|
||
var city1_array = [];
|
||
var city1_String = "";
|
||
var city1_String_edited = "";
|
||
var hold_Data_city2;
|
||
var city2_array = [];
|
||
var city2_String = "";
|
||
var city2_String_edited = "";
|
||
var hold_Data_city3;
|
||
var city3_array = [];
|
||
var city3_String = "";
|
||
var city3_String_edited = "";
|
||
var hold_Data_province1;
|
||
var hold_Data_province2;
|
||
var hold_Data_province3;
|
||
var array_geted_date = [];
|
||
var edited_end_date;
|
||
var routeControls = [];
|
||
var routeControlsPath = [];
|
||
var popupArrays = [];
|
||
var popupArraysPath = [];
|
||
var polylinePath = null;
|
||
|
||
var startLatlng;
|
||
var endLatlng;
|
||
var progressLatlng;
|
||
|
||
var edit;
|
||
var idEdit;
|
||
var cost;
|
||
var mapCenterLat = null;
|
||
var mapCenterLng = null;
|
||
var tablesecond;
|
||
var hasError = false;
|
||
var province,
|
||
town,
|
||
axisName,
|
||
axisType,
|
||
projectTitle,
|
||
contractor,
|
||
consultant,
|
||
contractDate,
|
||
contractPrice,
|
||
contractDatePicker;
|
||
var provinces = [];
|
||
var towns = [];
|
||
var projectDistance = {};
|
||
var editProjectDistance = null;
|
||
var projectDistanceLastUpdate = null;
|
||
var projectDistanceLastUpdatestatus = null;
|
||
var projectDefaultDistances = null;
|
||
var project_distance_edit = {};
|
||
var project_title = "";
|
||
var rowId = 0;
|
||
var historyId = 0;
|
||
var sliderImages = null;
|
||
var slideIndexlayer = 1;
|
||
var idkol;
|
||
var objectshow = {};
|
||
var status;
|
||
var locationStartLatLng, locationEndLatLng;
|
||
var boundingbox;
|
||
var tooltipjson;
|
||
var max1 = null;
|
||
var max2 = null;
|
||
var max3 = null;
|
||
var max4 = null;
|
||
var max5 = null;
|
||
var max6 = null;
|
||
var max7 = null;
|
||
var max8 = null;
|
||
var max9 = null;
|
||
var max10 = null;
|
||
var max11 = null;
|
||
var max12 = null;
|
||
var max13 = null;
|
||
|
||
var min1 = null;
|
||
var min2 = null;
|
||
var min3 = null;
|
||
var min4 = null;
|
||
var min5 = null;
|
||
var min6 = null;
|
||
var min7 = null;
|
||
var min8 = null;
|
||
var min9 = null;
|
||
var min10 = null;
|
||
var min11 = null;
|
||
var min12 = null;
|
||
var min13 = null;
|
||
|
||
var progres1 = null;
|
||
var progres2 = null;
|
||
var progres3 = null;
|
||
var progres4 = null;
|
||
var progres5 = null;
|
||
var progres6 = null;
|
||
var progres7 = null;
|
||
var progres8 = null;
|
||
var progres9 = null;
|
||
var progres10 = null;
|
||
var progres11 = null;
|
||
var progres12 = null;
|
||
var progres13 = null;
|
||
|
||
var canSubmit;
|
||
|
||
var projectupdateimage = [];
|
||
var startAbrarDivIcon = 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 endAbrarDivIcon = 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 progressAbrarDivIcon = L.divIcon({
|
||
html: `
|
||
<div id="pin-marker-progress" 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 projectEditId = null;
|
||
var projectEditData = [];
|
||
var abrarProjectSlider = null;
|
||
var datatable2 = [
|
||
{
|
||
1: ["0"],
|
||
2: ["0"],
|
||
3: ["0"],
|
||
4: ["0"],
|
||
5: ["0"],
|
||
6: ["0"],
|
||
7: ["0"],
|
||
8: ["0"],
|
||
9: ["0"],
|
||
10: ["0"],
|
||
11: ["0"],
|
||
12: ["0"],
|
||
13: ["0"],
|
||
},
|
||
];
|
||
var tablethird;
|
||
function showLoaderScreen() {
|
||
$(".starter-loader-container").css("display", "flex").hide().fadeIn();
|
||
}
|
||
|
||
function hideLoaderScreen() {
|
||
$(".starter-loader-container").fadeOut();
|
||
}
|
||
fromDateCamp = $("#datepickfromdate").persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
autoClose: true,
|
||
initialValue: false,
|
||
});
|
||
$(document).bind('click', function (e) {
|
||
const clicked = $(e.target);
|
||
if (clicked.parents('.select2-selection__choice').length != 0 || clicked.parents('.datepicker-container').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");
|
||
}
|
||
});
|
||
|
||
|
||
$(document).ready(function () {
|
||
getProvinces();
|
||
|
||
table = $("#example").DataTable({
|
||
dom: "<flB<t>p>",
|
||
pagingType: "simple_numbers",
|
||
scrollX: 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, "asc"][(1, "asc")], [2, "desc"], [3, "desc"], [4, "desc"]],
|
||
order: [[0, "asc"]],
|
||
processing: true,
|
||
select: true,
|
||
destroy: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/api/camp/all",
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
return json.data;
|
||
},
|
||
},
|
||
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: "blockage_cause_fa" },
|
||
|
||
{ data: "blockage_length" },
|
||
{ data: "blockage_damage_higher_6_count" },
|
||
{ data: "blockage_damage_lower_6_count" },
|
||
{ data: "blockage_damage_count" },
|
||
{ data: "active_cars_count" },
|
||
{ data: "active_rahdar_count" },
|
||
{ data: "block_axis_desc" },
|
||
{ data: "blockage_damage_money" },
|
||
{
|
||
data: "submited_at",
|
||
},
|
||
{ data: "prediction_time_fa" },
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
return data.is_open_at + data.is_open_type_fa;
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data.is_open_at == null) {
|
||
return `
|
||
<div class="d-flex justify-content-center parent-btn">
|
||
<button id="editButton${data.id}" class="btn-dataTable editor details-control" title="ویرایش"><i class="fa fa-edit icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable location-button" title="مشاهده مکانی پروژه" ><i class="fa fa-eye icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable image-show" title="مشاهده عکس ها" ><i class="fa fa-image icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable deletsubmit" title=" حذف " ><i class="fa fa-trash icon-btnTable"></i></button>
|
||
</div>
|
||
`;
|
||
} else {
|
||
return `
|
||
<div class="d-flex justify-content-center parent-btn">
|
||
<button id="editButton${data.id}" class="btn-dataTable editor details-control" title="ویرایش" disabled><i class="fa fa-edit icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable location-button" title="مشاهده مکانی پروژه" ><i class="fa fa-eye icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable image-show" title="مشاهده عکس ها" ><i class="fa fa-image icon-btnTable"></i></button>
|
||
<div class="line-btn-table"></div>
|
||
<button class="btn-dataTable deletsubmit" title=" حذف " disabled><i class="fa fa-trash icon-btnTable"></i></button>
|
||
</div>
|
||
`;
|
||
}
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data.is_open_at == null) {
|
||
return `
|
||
<button class="btn btn-sm btn-success finalsubmit" title=" بازگشایی " ><i class="fa fa-check"></i></button>
|
||
`;
|
||
} else {
|
||
return `
|
||
<button class="btn btn-sm btn-success finalsubmit" title=" بازگشایی " disabled ><i class="fa fa-check"></i></button>
|
||
`;
|
||
}
|
||
},
|
||
},
|
||
],
|
||
columnDefs: [
|
||
],
|
||
buttons: [
|
||
{
|
||
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) {
|
||
if ($(".parent-filter").css("display") == "none") {
|
||
$(".parent-filter").css("display", "block");
|
||
} else if ($(".parent-filter").css("display") != "none") {
|
||
$(".parent-filter").css("display", "none");
|
||
}
|
||
},
|
||
},
|
||
|
||
{
|
||
extend: "excelHtml5",
|
||
title: "Excel",
|
||
text:
|
||
'<div class="d-flex flex-column"><i class="fa mb-2 fa-book icon-color"></i>خروجی به اکسل</div>',
|
||
messageTop: "روکش آسفالت (نگهداری راه)",
|
||
exportOptions: {
|
||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||
},
|
||
customize: function (xlsx) {
|
||
var sheet = xlsx.xl.worksheets["sheet1.xml"];
|
||
$('row c[r^="M"]', sheet).each(function () {
|
||
|
||
$(this).attr("s", "52");
|
||
});
|
||
$('row c[r^="N"]', sheet).each(function () {
|
||
|
||
$(this).attr("s", "52");
|
||
});
|
||
},
|
||
},
|
||
|
||
],
|
||
initComplete: function () {
|
||
$("body").find(".dataTables_scrollBody").addClass("scrollbar");
|
||
},
|
||
});
|
||
});
|
||
function createLeafletMap(startP, endP, update) {
|
||
let bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
let mapName;
|
||
|
||
if (!update) {
|
||
|
||
map = new L.map("abrar-map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView(startP, 9);
|
||
mapName = map;
|
||
} else {
|
||
|
||
map2 = new L.map("abrar-map-2", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView(startP, 9);
|
||
mapName = map2;
|
||
}
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
mapName
|
||
);
|
||
|
||
if (update) {
|
||
startAbrarMarker = new L.marker(startP, {
|
||
icon: startAbrarDivIcon,
|
||
draggable: false,
|
||
}).addTo(mapName);
|
||
} else {
|
||
startAbrarMarker = new L.marker(startP, {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(mapName);
|
||
}
|
||
|
||
if (!edit) {
|
||
endAbrarMarker = new L.marker(endP, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: true,
|
||
});
|
||
} else {
|
||
isSetStartAbrarMarker = true;
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
if (update) {
|
||
mapName = map2;
|
||
if (endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng(endP);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
checkMarkersAndDrawPath(update);
|
||
} else if (!endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker = new L.marker(endP, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: false,
|
||
});
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
checkMarkersAndDrawPath(update);
|
||
} else if (endAbrarMarker && endP[0] == "NaN") {
|
||
endAbrarMarker.remove();
|
||
}
|
||
|
||
progressAbrarMarker = new L.marker(
|
||
[parseFloat(startP[0]), parseFloat(startP[1]) + 1],
|
||
{
|
||
icon: progressAbrarDivIcon,
|
||
draggable: true,
|
||
}
|
||
).addTo(mapName);
|
||
|
||
progressAbrarMarker.on("click", function () {
|
||
if (!isSetprogressAbrarMarker) {
|
||
progressAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
isSetprogressAbrarMarker = true;
|
||
|
||
$("#pin-marker-progress")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
|
||
}
|
||
});
|
||
|
||
mapName.on("move", function () {
|
||
if (!isSetprogressAbrarMarker) {
|
||
progressAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-progress").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
mapName.on("moveend", function () {
|
||
if (!isSetprogressAbrarMarker) {
|
||
progressAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-progress").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
|
||
progressAbrarMarker.on("drag", function () {
|
||
$("#pin-marker-progress").addClass("pin-move");
|
||
});
|
||
|
||
progressAbrarMarker.on("dragend", function () {
|
||
$("#pin-marker-progress").removeClass("pin-move");
|
||
|
||
if (
|
||
$("#pin-marker-progress").hasClass("pin-set") ||
|
||
isSetprogressAbrarMarker
|
||
) {
|
||
|
||
$("#pin-marker-progress").addClass("pin-set");
|
||
} else {
|
||
mapName.setView(progressAbrarMarker.getLatLng());
|
||
}
|
||
});
|
||
} else {
|
||
mapName = map;
|
||
|
||
if (endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng(endP);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
checkMarkersAndDrawPath(update);
|
||
} else if (!endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker = new L.marker(endP, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: true,
|
||
});
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
// console.log(endP);
|
||
checkMarkersAndDrawPath(update);
|
||
} else if (endAbrarMarker && endP[0] == "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng([
|
||
parseFloat(startP[0]),
|
||
parseFloat(startP[1]) + 1,
|
||
]);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = false;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn pin-set");
|
||
} else {
|
||
endAbrarMarker = new L.marker(
|
||
[parseFloat(startP[0]), parseFloat(startP[1]) + 1],
|
||
{
|
||
icon: endAbrarDivIcon,
|
||
draggable: true,
|
||
}
|
||
);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = false;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn pin-set");
|
||
}
|
||
}
|
||
}
|
||
|
||
mapName.on("move", function () {
|
||
if (!isSetStartAbrarMarker && !isSetEndAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
|
||
if (isSetStartAbrarMarker && !isSetEndAbrarMarker && !update) {
|
||
endAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-end").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
mapName.on("moveend", function () {
|
||
if (!isSetStartAbrarMarker && !isSetEndAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
|
||
if (isSetStartAbrarMarker && !isSetEndAbrarMarker && !update) {
|
||
endAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
|
||
startAbrarMarker.on("click", function () {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start")
|
||
.removeClass("pin-move pin-warn")
|
||
.addClass("pin-set");
|
||
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
mapName.setView(markerLatLng);
|
||
endAbrarMarker.setLatLng(markerLatLng);
|
||
endAbrarMarker.addTo(mapName);
|
||
}
|
||
});
|
||
|
||
if (endAbrarMarker) {
|
||
endAbrarMarker.on("click", function () {
|
||
if (!isSetEndAbrarMarker) {
|
||
endAbrarMarker.setLatLng(L.latLng(mapName.getCenter()));
|
||
isSetEndAbrarMarker = true;
|
||
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").val(
|
||
endAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
endAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
checkMarkersAndDrawPath(update);
|
||
}
|
||
});
|
||
|
||
endAbrarMarker.on("drag", function () {
|
||
$("#pin-marker-end").addClass("pin-move");
|
||
checkMarkersAndDrawPath(update);
|
||
});
|
||
|
||
endAbrarMarker.on("dragend", function () {
|
||
$("#pin-marker-end").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-end").hasClass("pin-set") || isSetEndAbrarMarker) {
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").val(
|
||
endAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
endAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
).removeClass("is-invalid-input");
|
||
$("#pin-marker-end").addClass("pin-set");
|
||
checkMarkersAndDrawPath(update);
|
||
} else {
|
||
mapName.setView(endAbrarMarker.getLatLng());
|
||
}
|
||
});
|
||
}
|
||
|
||
startAbrarMarker.on("drag", function () {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
checkMarkersAndDrawPath(update);
|
||
});
|
||
|
||
startAbrarMarker.on("dragend", function () {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartAbrarMarker) {
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).removeClass("is-invalid-input");
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
checkMarkersAndDrawPath(update);
|
||
} else {
|
||
mapName.setView(startAbrarMarker.getLatLng());
|
||
}
|
||
});
|
||
}
|
||
$("#example").on("click", "button.image-show", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
let formData = new FormData();
|
||
formData.append("id", idkol);
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/camp/get",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
// console.log(result.data.files.length);
|
||
if (result.data.files.length != 0) {
|
||
// var images = row.data().images
|
||
// hideLoaderScreen();
|
||
opensliderforeachrow(result.data, 1);
|
||
}
|
||
},
|
||
});
|
||
});
|
||
function opensliderforeachrow(row, main) {
|
||
// let row = table.row(tr);
|
||
sliderImages = row.files;
|
||
let updated_at;
|
||
// updated_at = row.data().last_history.last_updated_at;
|
||
// updated_at = row.data().updated_at;
|
||
let dataLength = sliderImages.length;
|
||
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
|
||
for (let index = 0; index < sliderImages.length; index++) {
|
||
var imageUrl;
|
||
var updateDate;
|
||
if (main == 0) {
|
||
imageUrl = sliderImages[index];
|
||
updateDate = row.submited_at;
|
||
} else {
|
||
imageUrl =
|
||
"https://rms.rmto.ir/storage" +
|
||
sliderImages[index].path.slice(6);
|
||
// console.log("hasman", row.updated_at);
|
||
|
||
updateDate = row.submited_at;
|
||
}
|
||
var test = index + 1;
|
||
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="' +
|
||
imageUrl +
|
||
'"><div class="textt"> تصویر ' +
|
||
test +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updateDate +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + test + ')"></span>'
|
||
);
|
||
}
|
||
|
||
if (dataLength > 0) {
|
||
slideindex = 1;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
function openSlidershowbutton(row, main) {
|
||
sliderImages = row.data().images;
|
||
let updated_at;
|
||
let dataLength = sliderImages.length;
|
||
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
|
||
for (let index = 0; index < sliderImages.length; index++) {
|
||
var imageUrl;
|
||
var updateDate;
|
||
if (main == 1) {
|
||
imageUrl = sliderImages[index];
|
||
updateDate = row.data().images_dates[index];
|
||
} else {
|
||
imageUrl =
|
||
"https://rms.rmto.ir/storage" +
|
||
sliderImages[index].path.slice(6);
|
||
// console.log("hasman", row.data().updated_at);
|
||
|
||
updateDate = row.data().updated_at;
|
||
}
|
||
var test = index + 1;
|
||
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="' +
|
||
imageUrl +
|
||
'"><div class="textt"> تصویر ' +
|
||
test +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updateDate +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + test + ')"></span>'
|
||
);
|
||
}
|
||
|
||
if (dataLength > 0) {
|
||
slideindex = 1;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
|
||
function createLeafletMapshow(startP, endP) {
|
||
var latapi1 = startP[0];
|
||
var lngapi1 = startP[1];
|
||
var latapi2 = endP[0];
|
||
var lngapi2 = endP[1];
|
||
let bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
mapshow = new L.map("abrarshow-map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([latapi1, lngapi1], 9);
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
mapshow
|
||
);
|
||
|
||
startAbrarMarkershow = new L.marker(L.latLng(latapi1, lngapi1), {
|
||
icon: startAbrarDivIcon,
|
||
}).addTo(mapshow);
|
||
|
||
endAbrarMarkershow = new L.marker(L.latLng(latapi2, lngapi2), {
|
||
icon: endAbrarDivIcon,
|
||
}).addTo(mapshow);
|
||
|
||
isSetStartAbrarMarkershow = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
|
||
isSetEndAbrarMarkershow = true;
|
||
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
|
||
checkMarkersAndDrawPathshow();
|
||
}
|
||
function setmapshow(startp, endp) {
|
||
var latapi1 = startp[0];
|
||
var lngapi1 = startp[1];
|
||
var latapi2 = endp[0];
|
||
var lngapi2 = endp[1];
|
||
mapshow.removeLayer(startAbrarMarkershow);
|
||
mapshow.removeLayer(endAbrarMarkershow);
|
||
mapshow.setView([latapi1, lngapi1], 9);
|
||
|
||
startAbrarMarkershow = new L.marker(L.latLng(latapi1, lngapi1), {
|
||
icon: startAbrarDivIcon,
|
||
}).addTo(mapshow);
|
||
endAbrarMarkershow = new L.marker(L.latLng(latapi2, lngapi2), {
|
||
icon: endAbrarDivIcon,
|
||
}).addTo(mapshow);
|
||
isSetStartAbrarMarkershow = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
|
||
isSetEndAbrarMarkershow = true;
|
||
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
|
||
checkMarkersAndDrawPathshow();
|
||
}
|
||
|
||
function initialField() {
|
||
$("#axis-name-id").val("");
|
||
$("#axis-type-id").val("0");
|
||
$("#project-title-id").val("");
|
||
$("#yearshown").val("13");
|
||
$("#contractor-id").val("");
|
||
$("#consultant-id").val("");
|
||
$("#contract-date-id").val("");
|
||
$("#contract-price-id").val("");
|
||
$("#tool-id").val("");
|
||
$("#milion").val("");
|
||
$("#polhabig").val("");
|
||
$("#polhasmall").val("");
|
||
$("#polha").val("");
|
||
$("#machinery").val("");
|
||
$("#activerahdar").val("");
|
||
$("#tozihat").val("");
|
||
$("#predict-type-id").val("0");
|
||
$("#dicc-type-id").val("0");
|
||
$("#inputFile1").val("");
|
||
$("#inputFile2").val("");
|
||
$("#inputFile3").val("");
|
||
$("#image_upload_second").empty();
|
||
$("#thirdshow").css("display", "block");
|
||
$("#image_upload_first").css("display", "none");
|
||
|
||
$("#firstshow").css("display", "block");
|
||
$("#image_upload_second").css("display", "none");
|
||
|
||
$("#secondshow").css("display", "block");
|
||
$("#image_upload_third").css("display", "none");
|
||
|
||
$("#province-id").removeClass("is-invalid-input");
|
||
$("#axis-name-id").removeClass("is-invalid-input");
|
||
$("#axis-type-id").removeClass("is-invalid-input");
|
||
$("#project-title-id").removeClass("is-invalid-input");
|
||
$("#yearshown").removeClass("is-invalid-input");
|
||
$("#contractor-id").removeClass("is-invalid-input");
|
||
$("#consultant-id").removeClass("is-invalid-input");
|
||
$("#contract-date-id").removeClass("is-invalid-input");
|
||
$("#contract-price-id").removeClass("is-invalid-input");
|
||
$("#dicc-type-id").removeClass("is-invalid-input");
|
||
$("#tool-id").removeClass("is-invalid-input");
|
||
$("#milion").removeClass("is-invalid-input");
|
||
$("#polhabig").removeClass("is-invalid-input");
|
||
$("#polhasmall").removeClass("is-invalid-input");
|
||
$("#polha").removeClass("is-invalid-input");
|
||
$("#machinery").removeClass("is-invalid-input");
|
||
$("#activerahdar").removeClass("is-invalid-input");
|
||
$("#tozihat").removeClass("is-invalid-input");
|
||
$("#predict-type-id").removeClass("is-invalid-input");
|
||
}
|
||
|
||
function initialMarkerMapValue(latP, lngP) {
|
||
|
||
if (isSetStartAbrarMarker) {
|
||
endAbrarMarker.remove();
|
||
}
|
||
|
||
isSetEndAbrarMarker = false;
|
||
map.setView([latP, lngP], 9);
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
isSetStartAbrarMarker = false;
|
||
|
||
removeStartToEndPath(0);
|
||
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").val("");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").val("");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
|
||
function initialMarkerMapValueEdit(startP, endP, update) {
|
||
|
||
// console.log(endAbrarMarker);
|
||
// console.log("endP", endP);
|
||
|
||
startAbrarMarker.setLatLng(startP);
|
||
isSetStartAbrarMarker = true;
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
|
||
if (update) {
|
||
mapName = map2;
|
||
removeStartToEndPath(1);
|
||
|
||
if (endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng(endP);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
} else if (!endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker = new L.marker(endP, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: false,
|
||
});
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
} else if (endAbrarMarker && endP[0] == "NaN") {
|
||
endAbrarMarker.remove();
|
||
}
|
||
} else {
|
||
mapName = map;
|
||
removeStartToEndPath(0);
|
||
|
||
if (endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng(endP);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = true;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
} else if (!endAbrarMarker && endP[0] != "NaN") {
|
||
endAbrarMarker = new L.marker(endP, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: true,
|
||
});
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = false;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn pin-set");
|
||
} else if (endAbrarMarker && endP[0] == "NaN") {
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng([
|
||
parseFloat(startP[0]),
|
||
parseFloat(startP[1]) + 1,
|
||
]);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = false;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn pin-set");
|
||
} else {
|
||
endAbrarMarker = new L.marker(
|
||
[parseFloat(startP[0]), parseFloat(startP[1]) + 1],
|
||
{
|
||
icon: endAbrarDivIcon,
|
||
draggable: true,
|
||
}
|
||
);
|
||
endAbrarMarker.addTo(mapName);
|
||
isSetEndAbrarMarker = false;
|
||
$("#pin-marker-end").removeClass("pin-move pin-warn pin-set");
|
||
}
|
||
}
|
||
}
|
||
|
||
function initialMarkerMapValueEditshow(startP, endP) {
|
||
|
||
// console.log(!endAbrarMarker);
|
||
|
||
removeStartToEndPath(0);
|
||
endAbrarMarker.remove();
|
||
endAbrarMarker.setLatLng(endP);
|
||
endAbrarMarker.addTo(map);
|
||
|
||
startAbrarMarker.setLatLng(startP);
|
||
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move pin-warn").addClass("pin-set");
|
||
|
||
isSetEndAbrarMarker = true;
|
||
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
|
||
checkMarkersAndDrawPath(0);
|
||
|
||
avrLat = (parseFloat(startP[0]) + parseFloat(endP[0])) / 2;
|
||
avrLng = (parseFloat(startP[1]) + parseFloat(endP[1])) / 2;
|
||
|
||
map.setView([avrLat, avrLng], 6);
|
||
}
|
||
$("#add-project-button").on("click", function () {
|
||
$("#tool-main").css("display", "none");
|
||
$("#update-table").css("display", "none");
|
||
$("#submitNewRow").attr("disabled", false);
|
||
|
||
edit = false;
|
||
showModal(0);
|
||
initialField();
|
||
prepareImageModal();
|
||
if (map == null) {
|
||
setTimeout(() => {
|
||
createLeafletMap([35.6892, 51.389], [35.6892, 51.389], 0);
|
||
}, 200);
|
||
} else {
|
||
initialMarkerMapValue(35.6892, 51.389);
|
||
}
|
||
$("#province-id").empty();
|
||
$("#province-id").append('<option value="0">انتخاب اداره کل</option>');
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#province-id").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
});
|
||
$("#example").on("click", "tbody tr", function () {
|
||
if ($(this).hasClass("selected")) {
|
||
$(this).removeClass("selected");
|
||
$(this).css("color", "");
|
||
$(this).find("i").css("color", "");
|
||
} else {
|
||
table.$("tr.selected").find("i").css("color", "");
|
||
table.$("tr.selected").css("color", "");
|
||
table.$("tr.selected").removeClass("selected");
|
||
$(this).addClass("selected");
|
||
$(this).css("color", "white");
|
||
$(this).find("i").css("color", "white");
|
||
}
|
||
});
|
||
|
||
function scrolldown() {
|
||
$("html, body").animate(
|
||
{
|
||
scrollTop: $(".up").offset().top,
|
||
},
|
||
50
|
||
);
|
||
}
|
||
function scrolldowntable() {
|
||
$("html, body").animate(
|
||
{
|
||
scrollTop: $(".upnext").offset().top + 1000,
|
||
},
|
||
50
|
||
);
|
||
}
|
||
$("#example").on("click", "button.location-button", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
window.open("https://rms.rmto.ir/camp/map/" + idkol);
|
||
});
|
||
$("#example").on("click", "button.projectdistance", function () {
|
||
$("#update-table").css("display", "none");
|
||
$("#tool-main").css("display", "block");
|
||
scrolldown();
|
||
$("#distance-title").empty();
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
status = row.data().status;
|
||
// console.log(row.data().id);
|
||
var projectTitle = row.data().project_name;
|
||
var axisType = row.data().axis_name;
|
||
var titlecard =
|
||
"طول پروژه" +
|
||
" " +
|
||
projectTitle +
|
||
" " +
|
||
"محور" +
|
||
" " +
|
||
axisType +
|
||
" " +
|
||
"به کیلومتر";
|
||
var note = '<h3 class="card-title">' + titlecard + "</h3>";
|
||
$("#distance-title").append(note);
|
||
tablesecond = $("#exampletool").DataTable({
|
||
dom: "Bfrti",
|
||
destroy: true,
|
||
pagingType: "simple_numbers",
|
||
searching: 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: [[0, "asc"][(1, "asc")], [2, "desc"], [3, "desc"], [4, "desc"]],
|
||
order: [[0, "desc"]],
|
||
processing: true,
|
||
ajax: {
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/get-distance",
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
// console.log(json.data[0].project_distance[key][0])
|
||
// console.log(json.data);
|
||
if (json.data.length != 0) {
|
||
return json.data;
|
||
} else return datatable2; // to do table
|
||
},
|
||
},
|
||
columns: [
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[1] != undefined) {
|
||
return data[1][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
|
||
if (data[2] != undefined) {
|
||
return data[2][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[3] != undefined) {
|
||
return data[3][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[4] != undefined) {
|
||
return data[4][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[5] != undefined) {
|
||
return data[5][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[6] != undefined) {
|
||
return data[6][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[7] != undefined) {
|
||
return data[7][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[8] != undefined) {
|
||
return data[8][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[9] != undefined) {
|
||
return data[9][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[10] != undefined) {
|
||
return data[10][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[11] != undefined) {
|
||
return data[11][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[12] != undefined) {
|
||
return data[12][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
if (data[13] != undefined) {
|
||
return data[13][0];
|
||
} else return "0";
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
orderable: false,
|
||
data: null,
|
||
render: function (data, type, row) {
|
||
/////// i delete disabled milad
|
||
|
||
if (status == 2) {
|
||
return `
|
||
<button class="btn btn-sm btn-success edittool" >ویرایش و ثبت </button>
|
||
`;
|
||
} else
|
||
return `<button class="btn btn-danger btn-sm edittool">ثبت و ویرایش<div></div></button>
|
||
`;
|
||
},
|
||
},
|
||
],
|
||
|
||
buttons: [
|
||
// extend: "excelHtml5",
|
||
// text: "خروجی به اکسل",
|
||
// exportOptions: {
|
||
// },
|
||
],
|
||
});
|
||
});
|
||
$("#exampletool").on("click", "button.edittool", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = tablesecond.row(tr);
|
||
objectshow = row.data();
|
||
|
||
if (objectshow[1] != undefined) {
|
||
$("#project-distance-input-1").val(objectshow[1]);
|
||
}
|
||
if (objectshow[2] != undefined) {
|
||
$("#project-distance-input-2").val(objectshow[2]);
|
||
}
|
||
if (objectshow[3] != undefined) {
|
||
$("#project-distance-input-3").val(objectshow[3]);
|
||
}
|
||
if (objectshow[4] != undefined) {
|
||
$("#project-distance-input-4").val(objectshow[4]);
|
||
}
|
||
if (objectshow[5] != undefined) {
|
||
$("#project-distance-input-5").val(objectshow[5]);
|
||
}
|
||
if (objectshow[6] != undefined) {
|
||
$("#project-distance-input-6").val(objectshow[6]);
|
||
}
|
||
if (objectshow[7] != undefined) {
|
||
$("#project-distance-input-7").val(objectshow[7]);
|
||
}
|
||
if (objectshow[8] != undefined) {
|
||
$("#project-distance-input-8").val(objectshow[8]);
|
||
}
|
||
if (objectshow[9] != undefined) {
|
||
$("#project-distance-input-9").val(objectshow[9]);
|
||
}
|
||
if (objectshow[10] != undefined) {
|
||
$("#project-distance-input-10").val(objectshow[10]);
|
||
}
|
||
if (objectshow[11] != undefined) {
|
||
$("#project-distance-input-11").val(objectshow[11]);
|
||
}
|
||
if (objectshow[12] != undefined) {
|
||
$("#project-distance-input-12").val(objectshow[12]);
|
||
}
|
||
if (objectshow[12] != undefined) {
|
||
$("#project-distance-input-13").val(objectshow[13]);
|
||
}
|
||
|
||
$("#show-projecttool").modal("show");
|
||
});
|
||
$("#submitoolfinal").on("click", function () {
|
||
var objectedit = {};
|
||
var project1 = $("#project-distance-input-1").val();
|
||
var project2 = $("#project-distance-input-2").val();
|
||
var project3 = $("#project-distance-input-3").val();
|
||
var project4 = $("#project-distance-input-4").val();
|
||
var project5 = $("#project-distance-input-5").val();
|
||
var project6 = $("#project-distance-input-6").val();
|
||
var project7 = $("#project-distance-input-7").val();
|
||
var project8 = $("#project-distance-input-8").val();
|
||
var project9 = $("#project-distance-input-9").val();
|
||
var project10 = $("#project-distance-input-10").val();
|
||
var project11 = $("#project-distance-input-11").val();
|
||
var project12 = $("#project-distance-input-12").val();
|
||
var project13 = $("#project-distance-input-13").val();
|
||
if (project1 !== "" && project1 !== "0") {
|
||
objectedit[1] = [project1];
|
||
}
|
||
if (project2 !== "" && project2 !== "0") {
|
||
objectedit[2] = [project2];
|
||
}
|
||
if (project3 !== "" && project3 !== "0") {
|
||
objectedit[3] = [project3];
|
||
}
|
||
if (project4 !== "" && project4 !== "0") {
|
||
objectedit[4] = [project4];
|
||
}
|
||
if (project5 !== "" && project5 !== "0") {
|
||
objectedit[5] = [project5];
|
||
}
|
||
if (project6 !== "" && project6 !== "0") {
|
||
objectedit[6] = [project6];
|
||
}
|
||
if (project7 !== "" && project7 !== "0") {
|
||
objectedit[7] = [project7];
|
||
}
|
||
if (project8 !== "" && project8 !== "0") {
|
||
objectedit[8] = [project8];
|
||
}
|
||
if (project9 !== "" && project9 !== "0") {
|
||
objectedit[9] = [project9];
|
||
}
|
||
if (project10 !== "" && project10 !== "0") {
|
||
objectedit[10] = [project10];
|
||
}
|
||
if (project11 !== "" && project11 !== "0") {
|
||
objectedit[11] = [project11];
|
||
}
|
||
if (project12 !== "" && project12 !== "0") {
|
||
objectedit[12] = [project12];
|
||
}
|
||
if (project13 !== "" && project13 !== "0") {
|
||
objectedit[13] = [project13];
|
||
}
|
||
Object.size = function (obj) {
|
||
var size = 0,
|
||
key;
|
||
for (key in obj) {
|
||
if (obj.hasOwnProperty(key)) size++;
|
||
}
|
||
return size;
|
||
};
|
||
|
||
for (i = 1; i < 14; i++) {
|
||
if (
|
||
$("#project-distance-input-" + i)
|
||
.val()
|
||
.slice(0, 1) == 0 &&
|
||
$("#project-distance-input-" + i).val().length > 1 &&
|
||
$("#project-distance-input-" + i)
|
||
.val()
|
||
.slice(1, 2) != "."
|
||
) {
|
||
$("#project-distance-input-" + i).addClass("is-invalid");
|
||
} else {
|
||
$("#project-distance-input-" + i).removeClass("is-invalid");
|
||
}
|
||
}
|
||
if ($("#show-projecttool").find(".is-invalid").length) {
|
||
} else {
|
||
var size = Object.size(objectedit);
|
||
if (size != 0) {
|
||
let formData = new FormData();
|
||
let project_distance = JSON.stringify(objectedit);
|
||
formData.append("project-distance", project_distance);
|
||
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/edit-distance",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
$("#show-projecttool").modal("hide");
|
||
ajaxcalltablefirsttool(idkol);
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
// // location.reload()
|
||
// });
|
||
},
|
||
error: function (error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "لطفا حداقل یکی از فیلدهای مرتبط را پر کنید.",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
$("#example").on("click", "button.finalsubmit", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
var buttonsprev = $("<div>")
|
||
.append(
|
||
createButton(
|
||
"بازگشایی بصورت موقت می باشد (خسارت ها رفع نشده اند )",
|
||
"temp",
|
||
function () {
|
||
swal.close();
|
||
}
|
||
)
|
||
)
|
||
.append(
|
||
createButton(
|
||
"بازگشایی همراه با رفع خسارت های وارد شده می باشد ",
|
||
"final",
|
||
function () {
|
||
swal.close();
|
||
}
|
||
)
|
||
);
|
||
|
||
$("#modalshowopen").modal("show");
|
||
let formData = new FormData();
|
||
formData.append("id", idkol);
|
||
});
|
||
$("#notopen").on("click", function () {
|
||
let formData = new FormData();
|
||
formData.append("id", idkol);
|
||
formData.append("is-open-type", 1);
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/camp/update",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
|
||
hideLoaderScreen();
|
||
$("#modalshowopen").modal("hide");
|
||
ajaxcalltablegharar();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
|
||
|
||
// });
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
});
|
||
$("#opencomp").on("click", function () {
|
||
let formData = new FormData();
|
||
formData.append("id", idkol);
|
||
formData.append("is-open-type", 2);
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/camp/update",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
|
||
$("#modalshowopen").modal("hide");
|
||
hideLoaderScreen();
|
||
ajaxcalltablegharar();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
|
||
|
||
// });
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
});
|
||
function createButton(text, id, cb) {
|
||
cb();
|
||
return $('<button id="' + id + '">' + text + "</button>").on("click", cb);
|
||
}
|
||
$("#example").on("click", "button.deletsubmit", function () {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
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/camp/delete",
|
||
type: "POST",
|
||
data: formData,
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
ajaxcalltablegharar();
|
||
// showLoaderScreen();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
// location.reload();
|
||
// });
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
|
||
function getProvinces() {
|
||
let reqUrl =
|
||
"https://rms.rmto.ir/public/contents/provinces";
|
||
$.ajax({
|
||
url: reqUrl,
|
||
type: "GET",
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
provinces = result.data;
|
||
$("#filter-province").empty();
|
||
$("#filter-province").append('<option value="0">انتخاب اداره کل</option>');
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#filter-province").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
|
||
},
|
||
error: function (error) {
|
||
//console.log(error);
|
||
},
|
||
});
|
||
}
|
||
|
||
function getTowns(id, num, val, defaultVal) {
|
||
let reqUrl =
|
||
"https://rms.rmto.ir/public/contents/provinces/" +
|
||
id;
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: reqUrl,
|
||
type: "GET",
|
||
success: function (result) {
|
||
hideLoaderScreen();
|
||
towns = result.data;
|
||
if (num == 1) {
|
||
setTownSelect("", val[0]);
|
||
} else if (num == 2) {
|
||
setTownSelect("", val[0]);
|
||
setTownSelect("1", val[1]);
|
||
} else {
|
||
setTownSelect("", val[0]);
|
||
setTownSelect("1", val[1]);
|
||
setTownSelect("2", val[2]);
|
||
}
|
||
|
||
if (!edit || !defaultVal) {
|
||
if (towns.length) {
|
||
let provinceIndex = provinces.findIndex(function (entry) {
|
||
return entry.id == towns[0].province_id;
|
||
});
|
||
|
||
if (provinceIndex != -1) {
|
||
map.flyTo(
|
||
[
|
||
provinces[provinceIndex].center_lat,
|
||
provinces[provinceIndex].center_long,
|
||
],
|
||
10
|
||
);
|
||
}
|
||
initialMarkerMapValue(
|
||
provinces[provinceIndex].center_lat,
|
||
provinces[provinceIndex].center_long
|
||
);
|
||
}
|
||
}
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
},
|
||
complete: function () { },
|
||
});
|
||
}
|
||
|
||
function setTownSelect(box, selectedId) {
|
||
$("#town-id" + box).empty();
|
||
$("#town-id" + box).append('<option value="0">انتخاب شهرستان</option>');
|
||
|
||
for (let index = 0; index < towns.length; index++) {
|
||
if (selectedId == towns[index].id) {
|
||
$("#town-id" + box).append(
|
||
"\
|
||
<option value=" +
|
||
towns[index].id +
|
||
" selected>" +
|
||
towns[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
} else {
|
||
$("#town-id" + box).append(
|
||
"\
|
||
<option value=" +
|
||
towns[index].id +
|
||
">" +
|
||
towns[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
$("#province-id").change(function () {
|
||
let boxNum = $("#subTown").children().length;
|
||
if ($(this).val() > 0) {
|
||
if (boxNum == 1) {
|
||
getTowns($(this).val(), 1, [0], false);
|
||
} else if (boxNum == 2) {
|
||
getTowns($(this).val(), 2, [0, 0], false);
|
||
} else {
|
||
getTowns($(this).val(), 3, [0, 0, 0], false);
|
||
}
|
||
} else {
|
||
if (boxNum == 1) {
|
||
$("#town-id").empty();
|
||
$("#town-id").append('<option value="0">انتخاب شهرستان</option>');
|
||
} else if (boxNum == 2) {
|
||
$("#town-id").empty();
|
||
$("#town-id").append('<option value="0">انتخاب شهرستان</option>');
|
||
$("#town-id1").empty();
|
||
$("#town-id1").append('<option value="0">انتخاب شهرستان</option>');
|
||
} else {
|
||
$("#town-id").empty();
|
||
$("#town-id").append('<option value="0">انتخاب شهرستان</option>');
|
||
$("#town-id1").empty();
|
||
$("#town-id1").append('<option value="0">انتخاب شهرستان</option>');
|
||
$("#town-id2").empty();
|
||
$("#town-id2").append('<option value="0">انتخاب شهرستان</option>');
|
||
}
|
||
}
|
||
});
|
||
|
||
$("#example").on("click", "button.details-control", function () {
|
||
$("#thirdshow").css("display", "block");
|
||
$("#image_upload_first").css("display", "none");
|
||
|
||
$("#firstshow").css("display", "block");
|
||
$("#image_upload_second").css("display", "none");
|
||
|
||
$("#secondshow").css("display", "block");
|
||
$("#image_upload_third").css("display", "none");
|
||
edit = true;
|
||
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idEdit = row.data().id;
|
||
|
||
startLatlng = row.data().start_latlng;
|
||
endLatlng = row.data().end_latlng;
|
||
$("#yearshown").val(row.data().contract_date);
|
||
|
||
if (map == null) {
|
||
setTimeout(() => {
|
||
createLeafletMap(startLatlng, endLatlng, 0);
|
||
}, 200);
|
||
} else {
|
||
initialMarkerMapValueEdit(startLatlng, endLatlng, 0);
|
||
}
|
||
showModal(row.data().id);
|
||
// if (row.data().status==2){
|
||
// $("#submitNewRow").attr("disabled", true);
|
||
// else {
|
||
|
||
|
||
$("#province-id").empty();
|
||
$("#province-id").append('<option value="0">انتخاب اداره کل</option>');
|
||
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#province-id").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
|
||
var provinceid = row.data().province_id;
|
||
var townMap = row.data().cities_id;
|
||
var townsArray = Object.keys(townMap);
|
||
var townsArrayValue = Object.values(townMap);
|
||
|
||
if (townsArray.length == 1) {
|
||
getTowns(row.data().province_id, 1, [townsArray[0]], true);
|
||
} else if (townsArray.length == 2) {
|
||
$("#subTown div").append(
|
||
`<div class="input-group mb-3">
|
||
|
||
<input type ="text" class="form-control" id="mosharekat1" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
|
||
</div>
|
||
`
|
||
);
|
||
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id1"
|
||
>
|
||
<option value="0" style="font-size:10px">انتخاب شهرستان</option>
|
||
</select>
|
||
<div class="input-group mb-3">
|
||
|
||
<input type ="text" class="form-control" id="mosharekat2" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>`);
|
||
|
||
getTowns(row.data().province_id, 2, [townsArray[0], townsArray[1]], true);
|
||
|
||
$("#mosharekat1").val(townsArrayValue[0]);
|
||
$("#mosharekat2").val(townsArrayValue[1]);
|
||
} else if (townsArray.length == 3) {
|
||
$("#subTown div").append(
|
||
`<div class="input-group mb-3">
|
||
|
||
<input type ="text" class="form-control" id="mosharekat1" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
|
||
</div>
|
||
`
|
||
);
|
||
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id1"
|
||
>
|
||
<option value="0" style="font-size:10px">انتخاب شهرستان</option>
|
||
</select>
|
||
<div class="input-group mb-3">
|
||
|
||
<input type ="text" class="form-control" id="mosharekat2" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>`);
|
||
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id2"
|
||
>
|
||
<option value="0" style="font-size:10px">انتخاب شهرستان</option>
|
||
</select>
|
||
<div class="input-group mb-3">
|
||
|
||
<input type ="text" class="form-control" id="mosharekat3" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>`);
|
||
|
||
getTowns(
|
||
row.data().province_id,
|
||
3,
|
||
[townsArray[0], townsArray[1], townsArray[2]],
|
||
true
|
||
);
|
||
|
||
$("#mosharekat1").val(townsArrayValue[0]);
|
||
$("#mosharekat2").val(townsArrayValue[1]);
|
||
$("#mosharekat3").val(townsArrayValue[2]);
|
||
}
|
||
|
||
$("[data-mask]").inputmask();
|
||
|
||
var Roadaxis = row.data().axis_name;
|
||
var axisName_type = row.data().axis_type;
|
||
var blockagecause = row.data().blockage_cause;
|
||
var blockagetype = row.data().blockage_type;
|
||
var blockagetool = row.data().blockage_length;
|
||
var blockage_damage_money = row.data().blockage_damage_money;
|
||
var blockage_damage_count = row.data().blockage_damage_count;
|
||
var active_cars_count = row.data().active_cars_count;
|
||
var active_rahdar_count = row.data().active_rahdar_count;
|
||
var block_axis_desc = row.data().block_axis_desc;
|
||
var under6 = row.data().blockage_damage_lower_6_count;
|
||
var over6 = row.data().blockage_damage_higher_6_count;
|
||
var prediction = row.data().prediction_time;
|
||
|
||
$("#dicc-type-id").val(blockagecause);
|
||
$("#block-type").val(blockagetype);
|
||
$("#tool-id").val(blockagetool);
|
||
$("#milion").val(blockage_damage_money);
|
||
$("#polha").val(blockage_damage_count);
|
||
$("#machinery").val(active_cars_count);
|
||
$("#activerahdar").val(active_rahdar_count);
|
||
$("#tozihat").val(block_axis_desc);
|
||
$("#polhasmall").val(under6);
|
||
$("#polhabig").val(over6);
|
||
$("#predict-type-id").val(prediction);
|
||
|
||
onLocationChange();
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").val(
|
||
parseFloat(startLatlng[0]).toFixed(6) +
|
||
parseFloat(startLatlng[1]).toFixed(6)
|
||
);
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").val(
|
||
parseFloat(endLatlng[0]).toFixed(6) + parseFloat(endLatlng[1]).toFixed(6)
|
||
);
|
||
|
||
$("#province-id").val(provinceid);
|
||
$("#axis-name-id").val(Roadaxis);
|
||
$("#axis-type-id").val(axisName_type);
|
||
});
|
||
|
||
function showModal(id) {
|
||
$("#stepModalmaintenance").modal("show");
|
||
|
||
$("[data-mask]").inputmask();
|
||
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").on(
|
||
"keyup",
|
||
function () {
|
||
checkStartMarkerValidation();
|
||
}
|
||
);
|
||
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").on(
|
||
"keyup",
|
||
function () {
|
||
checkEndMarkerValidation();
|
||
}
|
||
);
|
||
|
||
function checkStartMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let startLatLngVal = $(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
if (isNaN(startLatLng[0])) {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).removeClass("is-invalid-input");
|
||
} else {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).addClass("is-invalid-input");
|
||
}
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").val("");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-start]").attr(
|
||
"placeholder",
|
||
"(شروع) => (طول جغرافیایی) - (عرض جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!startLatLng == 2 ||
|
||
!reg.test(startLatLng[0]) ||
|
||
!reg.test(startLatLng[1])
|
||
) {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).addClass("is-invalid-input");
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
startAbrarMarker.setLatLng(startLatLng);
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
startAbrarMarker.setLatLng(startLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
|
||
if (!isSetEndAbrarMarker) {
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
endAbrarMarker.setLatLng(markerLatLng);
|
||
|
||
if (!isSetStartAbrarMarker) {
|
||
endAbrarMarker.addTo(map);
|
||
}
|
||
}
|
||
|
||
isSetStartAbrarMarker = true;
|
||
} else {
|
||
projectEditData["project-start-latlng"] = [
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6),
|
||
];
|
||
}
|
||
|
||
checkMarkersAndDrawPath(0);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function checkEndMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let endLatLngVal = $(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let endLatLng = endLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
|
||
if (isNaN(endLatLng[0])) {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
).removeClass("is-invalid-input");
|
||
} else {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
).addClass("is-invalid-input");
|
||
}
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").val("");
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").attr(
|
||
"placeholder",
|
||
"(پایان) => (طول جغرافیایی) - (عرض جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (
|
||
!endLatLng == 2 ||
|
||
!reg.test(endLatLng[0]) ||
|
||
!reg.test(endLatLng[1])
|
||
) {
|
||
$("#stepModalmaintenance input[name=abrar-project-latlng-end]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-end").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
endAbrarMarker.setLatLng(endLatLng);
|
||
isSetEndAbrarMarker = true;
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
endAbrarMarker.setLatLng(endLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
} else {
|
||
projectEditData["project-end-latlng"] = [
|
||
endAbrarMarker.getLatLng().lat.toFixed(6),
|
||
endAbrarMarker.getLatLng().lng.toFixed(6),
|
||
];
|
||
}
|
||
|
||
checkMarkersAndDrawPath(0);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
$("#subTown").empty();
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id"
|
||
>
|
||
<option value="0">انتخاب شهرستان</option>
|
||
</select>
|
||
|
||
</div>`);
|
||
|
||
$(".cancel").on("click", function () {
|
||
$("#stepModalmaintenance").modal("hide");
|
||
});
|
||
|
||
restrictInputOtherThanArabic($("#axis-name-id"));
|
||
restrictInputOtherThanArabic($("#project-title-id"));
|
||
restrictInputOtherThanArabic($("#contractor-id"));
|
||
restrictInputOtherThanArabic($("#consultant-id"));
|
||
restrictInputOtherThanArabic($("#tozihat"));
|
||
|
||
$("#town-id").on("change", function () {
|
||
if (parseInt($(this).children("option:selected").val()) == 0) {
|
||
$("#town-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
}
|
||
|
||
$("#submitNewRow").on("click", function () {
|
||
let url = "https://rms.rmto.ir/webapi/camp/store";
|
||
|
||
if (edit) {
|
||
url = "https://rms.rmto.ir/webapi/camp/edit";
|
||
}
|
||
|
||
|
||
const p2e = (s) => s.replace(/[۰-۹]/g, (d) => "۰۱۲۳۴۵۶۷۸۹".indexOf(d));
|
||
let startLatLngVal = $(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-start]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
|
||
let endLatLngVal = $(
|
||
"#stepModalmaintenance input[name=abrar-project-latlng-end]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let endLatLng = endLatLngVal.map(function (e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
|
||
let provinceVal = $("#province-id").children("option:selected").val();
|
||
|
||
let axisNameVal = $("#axis-name-id").val();
|
||
|
||
let axisTypeVal = $("#axis-type-id").children("option:selected").val();
|
||
|
||
let town1Val = $("#town-id").children("option:selected").val();
|
||
let mosharekatTown1Val = $("#mosharekat1").val();
|
||
|
||
let town2Val = "";
|
||
let mosharekatTown2Val = "";
|
||
if ($("#town-id1").css("display") != "none") {
|
||
town2Val = $("#town-id1").children("option:selected").val();
|
||
mosharekatTown2Val = $("#mosharekat2").val();
|
||
}
|
||
|
||
let town3Val = "";
|
||
let mosharekatTown3Val = "";
|
||
if ($("#town-id2").css("display") != "none") {
|
||
town3Val = $("#town-id2").children("option:selected").val();
|
||
mosharekatTown3Val = $("#mosharekat3").val();
|
||
}
|
||
let dicctype = $("#dicc-type-id").val();
|
||
let block_type = $("#block-type").val();
|
||
|
||
let milion = $("#milion").val();
|
||
let polha = $("#polha").val();
|
||
let machinery = $("#machinery").val();
|
||
let activerahdar = $("#activerahdar").val();
|
||
let tozihat = $("#tozihat").val();
|
||
let toolensedad = $("#tool-id").val();
|
||
|
||
let predictiontime = $("#predict-type-id").children("option:selected").val();
|
||
let polhabig = $("#polhabig").val();
|
||
let polhasmall = $("#polhasmall").val();
|
||
|
||
if (isNaN(startLatLng[0])) {
|
||
$("input[name='abrar-project-latlng-start']").addClass("is-invalid-input");
|
||
} else {
|
||
$("input[name='abrar-project-latlng-start']").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
|
||
if (isNaN(endLatLng[0])) {
|
||
$("input[name='abrar-project-latlng-end']").addClass("is-invalid-input");
|
||
} else {
|
||
$("input[name='abrar-project-latlng-end']").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (parseInt(provinceVal) == 0) {
|
||
$("#province-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#province-id").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (axisNameVal == "") {
|
||
$("#axis-name-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#axis-name-id").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (parseInt(axisTypeVal) == 0) {
|
||
$("#axis-type-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#axis-type-id").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (parseInt(town1Val) == 0) {
|
||
$("#town-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (parseInt(town2Val) == 0) {
|
||
$("#town-id1").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id1").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (parseInt(town3Val) == 0) {
|
||
$("#town-id2").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id2").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if ($("#town-id2").length) {
|
||
if (mosharekatTown1Val == "") {
|
||
$("#mosharekat1").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat1").removeClass("is-invalid-input");
|
||
}
|
||
if (mosharekatTown2Val == "") {
|
||
$("#mosharekat2").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat2").removeClass("is-invalid-input");
|
||
}
|
||
if (mosharekatTown3Val == "") {
|
||
$("#mosharekat3").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat3").removeClass("is-invalid-input");
|
||
}
|
||
|
||
let mosharekatSum =
|
||
parseInt(mosharekatTown1Val) +
|
||
parseInt(mosharekatTown2Val) +
|
||
parseInt(mosharekatTown3Val);
|
||
|
||
if (mosharekatSum != 100) {
|
||
$("#mosharekat1").addClass("is-invalid-input");
|
||
$("#mosharekat2").addClass("is-invalid-input");
|
||
$("#mosharekat3").addClass("is-invalid-input");
|
||
if ($(".invalid-feedback").length) {
|
||
$(".invalid-feedback").show();
|
||
} else {
|
||
$("#mosharekat1").parent().append(`
|
||
<div class="invalid-feedback">
|
||
مجموع درصد مشارکت ها باید 100 درصد باشد.
|
||
</div>
|
||
`);
|
||
$(".invalid-feedback").show();
|
||
}
|
||
} else {
|
||
if ($(".invalid-feedback").length) $(".invalid-feedback").hide();
|
||
}
|
||
} else if ($("#town-id1").length) {
|
||
if (mosharekatTown1Val == "") {
|
||
$("#mosharekat1").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat1").removeClass("is-invalid-input");
|
||
}
|
||
if (mosharekatTown2Val == "") {
|
||
$("#mosharekat2").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat2").removeClass("is-invalid-input");
|
||
}
|
||
|
||
let mosharekatSum =
|
||
parseInt(mosharekatTown1Val) + parseInt(mosharekatTown2Val);
|
||
|
||
if (mosharekatSum != 100) {
|
||
$("#mosharekat1").addClass("is-invalid-input");
|
||
$("#mosharekat2").addClass("is-invalid-input");
|
||
|
||
if ($(".invalid-feedback").length) {
|
||
$(".invalid-feedback").show();
|
||
} else {
|
||
$("#mosharekat1").parent().append(`
|
||
<div class="invalid-feedback">
|
||
مجموع درصد مشارکت ها باید 100 درصد باشد.
|
||
</div>
|
||
`);
|
||
$(".invalid-feedback").show();
|
||
}
|
||
} else {
|
||
if ($(".invalid-feedback").length) $(".invalid-feedback").hide();
|
||
}
|
||
}
|
||
|
||
if (dicctype == 0) {
|
||
$("#dicc-type-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#dicc-type-id").removeClass("is-invalid-input");
|
||
}
|
||
if (toolensedad == 0) {
|
||
$("#tool-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#tool-id").removeClass("is-invalid-input");
|
||
}
|
||
if (milion == "") {
|
||
$("#milion").addClass("is-invalid-input");
|
||
} else {
|
||
$("#milion").removeClass("is-invalid-input");
|
||
}
|
||
if (predictiontime == 0) {
|
||
$("#predict-type-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#predict-type-id").removeClass("is-invalid-input");
|
||
}
|
||
if (polha == "") {
|
||
$("#polha").addClass("is-invalid-input");
|
||
} else {
|
||
$("#polha").removeClass("is-invalid-input");
|
||
}
|
||
if (polhasmall == "") {
|
||
$("#polhasmall").addClass("is-invalid-input");
|
||
} else {
|
||
$("#polhasmall").removeClass("is-invalid-input");
|
||
}
|
||
if (polhabig == "") {
|
||
$("#polhabig").addClass("is-invalid-input");
|
||
} else {
|
||
$("#polhabig").removeClass("is-invalid-input");
|
||
}
|
||
if (machinery == "") {
|
||
$("#machinery").addClass("is-invalid-input");
|
||
} else {
|
||
$("#machinery").removeClass("is-invalid-input");
|
||
}
|
||
|
||
if (activerahdar == "") {
|
||
$("#activerahdar").addClass("is-invalid-input");
|
||
} else {
|
||
$("#activerahdar").removeClass("is-invalid-input");
|
||
}
|
||
if (tozihat == "") {
|
||
$("#tozihat ").addClass("is-invalid-input");
|
||
} else {
|
||
$("#tozihat ").removeClass("is-invalid-input");
|
||
}
|
||
if ($("#town-id").val() === $("#town-id1").val()) {
|
||
$("#town-id1").addClass("is-invalid-input");
|
||
}
|
||
if ($("#town-id").val() === $("#town-id2").val()) {
|
||
$("#town-id2").addClass("is-invalid-input");
|
||
}
|
||
if ($("#town-id1").val() === $("#town-id2").val()) {
|
||
$("#town-id2").addClass("is-invalid-input");
|
||
}
|
||
if ($("#stepModalmaintenance").find(".is-invalid-input").length) {
|
||
} else if (boundingbox) {
|
||
if (
|
||
boundingbox &&
|
||
parseFloat(startLatLng[0]) >= parseFloat(boundingbox[0]) &&
|
||
parseFloat(startLatLng[0]) <= parseFloat(boundingbox[1]) &&
|
||
parseFloat(startLatLng[1]) >= parseFloat(boundingbox[2]) &&
|
||
parseFloat(startLatLng[1]) <= parseFloat(boundingbox[3]) &&
|
||
parseFloat(endLatLng[0]) >= parseFloat(boundingbox[0]) &&
|
||
parseFloat(endLatLng[0]) <= parseFloat(boundingbox[1]) &&
|
||
parseFloat(endLatLng[1]) >= parseFloat(boundingbox[2]) &&
|
||
parseFloat(endLatLng[1]) <= parseFloat(boundingbox[3])
|
||
) {
|
||
let formData = new FormData();
|
||
|
||
let cities = {};
|
||
if ($("#town-id2").length) {
|
||
cities[town1Val] = mosharekatTown1Val;
|
||
cities[town2Val] = mosharekatTown2Val;
|
||
cities[town3Val] = mosharekatTown3Val;
|
||
} else if ($("#town-id1").length) {
|
||
cities[town1Val] = mosharekatTown1Val;
|
||
cities[town2Val] = mosharekatTown2Val;
|
||
} else {
|
||
cities[town1Val] = 100;
|
||
}
|
||
formData.append("province-id", provinceVal);
|
||
formData.append("cities-id", JSON.stringify(cities));
|
||
formData.append("axis-name", axisNameVal);
|
||
formData.append("axis-type", axisTypeVal);
|
||
formData.append("prediction-time", predictiontime);
|
||
formData.append("blockage-cause", dicctype);
|
||
formData.append("blockage-length", toolensedad);
|
||
formData.append("blockage-damage-money", milion);
|
||
formData.append("blockage-damage-count", polha);
|
||
formData.append("blockage-damage-lower-6-count", polhasmall);
|
||
formData.append("blockage-damage-higher-6-count", polhabig);
|
||
|
||
formData.append("active-cars-count", machinery);
|
||
|
||
formData.append("active-rahdar-count", activerahdar);
|
||
formData.append("start-latlng", startLatLng);
|
||
formData.append("end-latlng", endLatLng);
|
||
formData.append("block-axis-desc", tozihat);
|
||
if ($("input[name=inputFile1]")[0].files[0] != undefined) {
|
||
formData.append("image-1", $("input[name=inputFile1]")[0].files[0]);
|
||
formData.append("name-1", "image-1");
|
||
}
|
||
if ($("input[name=inputFile2]")[0].files[0] != undefined) {
|
||
formData.append("image-2", $("input[name=inputFile2]")[0].files[0]);
|
||
formData.append("name-2", "image-2");
|
||
}
|
||
if ($("input[name=inputFile3]")[0].files[0] != undefined) {
|
||
formData.append("image-3", $("input[name=inputFile3]")[0].files[0]);
|
||
formData.append("name-3", "image-3");
|
||
}
|
||
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ", " + pair[1]);
|
||
}
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: url,
|
||
type: "POST",
|
||
data: formData,
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
mimeType: "multipart/form-data",
|
||
success: function (result) {
|
||
console.log(result);
|
||
$("#stepModalmaintenance").modal("hide");
|
||
ajaxcalltablegharar();
|
||
// setTimeout(function () {
|
||
// }, 2000);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "خطایی رخ داده است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: ". لطفا در محدوده استان موقعیت را ثبت کنید ",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
}
|
||
} else {
|
||
let formData = new FormData();
|
||
|
||
let cities = {};
|
||
if ($("#town-id2").length) {
|
||
cities[town1Val] = mosharekatTown1Val;
|
||
cities[town2Val] = mosharekatTown2Val;
|
||
cities[town3Val] = mosharekatTown3Val;
|
||
} else if ($("#town-id1").length) {
|
||
cities[town1Val] = mosharekatTown1Val;
|
||
cities[town2Val] = mosharekatTown2Val;
|
||
} else {
|
||
cities[town1Val] = 100;
|
||
}
|
||
|
||
formData.append("id", idEdit);
|
||
formData.append("province-id", provinceVal);
|
||
formData.append("cities-id", JSON.stringify(cities));
|
||
formData.append("axis-name", axisNameVal);
|
||
formData.append("axis-type", axisTypeVal);
|
||
formData.append("prediction-time", predictiontime);
|
||
formData.append("blockage-cause", dicctype);
|
||
formData.append("blockage-length", toolensedad);
|
||
formData.append("blockage-damage-money", milion);
|
||
formData.append("blockage-damage-count", polha);
|
||
formData.append("blockage-damage-lower-6-count", polhasmall);
|
||
formData.append("blockage-damage-higher-6-countt", polhabig);
|
||
formData.append("active-cars-count", machinery);
|
||
formData.append("active-rahdar-count", activerahdar);
|
||
formData.append("start-latlng", startLatLng);
|
||
formData.append("end-latlng", endLatLng);
|
||
formData.append("block-axis-desc", tozihat);
|
||
if ($("input[name=inputFile1]")[0].files[0] != undefined) {
|
||
formData.append("image-1", $("input[name=inputFile1]")[0].files[0]);
|
||
formData.append("name-1", "image-1");
|
||
}
|
||
if ($("input[name=inputFile2]")[0].files[0] != undefined) {
|
||
formData.append("image-2", $("input[name=inputFile2]")[0].files[0]);
|
||
formData.append("name-2", "image-2");
|
||
}
|
||
if ($("input[name=inputFile3]")[0].files[0] != undefined) {
|
||
formData.append("image-3", $("input[name=inputFile3]")[0].files[0]);
|
||
formData.append("name-3", "image-3");
|
||
}
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ", " + pair[1]);
|
||
}
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: url,
|
||
type: "POST",
|
||
data: formData,
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
mimeType: "multipart/form-data",
|
||
success: function (result) {
|
||
$("#stepModalmaintenance").modal("hide");
|
||
ajaxcalltablegharar();
|
||
// setTimeout(function () {
|
||
// }, 2000);
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "خطایی رخ داده است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
});
|
||
|
||
function ajaxcalltable() {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/getlist",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
|
||
hideLoaderScreen();
|
||
// icon: "success",
|
||
// text: "اطلاعات اولیه با موفقیت ثبت گردید!",
|
||
// });
|
||
|
||
$("#stepModalmaintenance").modal("hide");
|
||
},
|
||
});
|
||
}
|
||
|
||
function onLocationChange() {
|
||
let lat, lng;
|
||
|
||
let provinceId = $("#province-id").children("option:selected").val();
|
||
let provinceIndex = provinces.findIndex(function (entry) {
|
||
return entry.id == provinceId;
|
||
});
|
||
|
||
if (provinceIndex != -1) {
|
||
lat = provinces[provinceIndex].center_lat;
|
||
lng = provinces[provinceIndex].center_long;
|
||
}
|
||
|
||
$.ajax({
|
||
url:
|
||
"https://rmsmap.rmto.ir/nominatim/reverse.php?format=json" +
|
||
"&lat=" +
|
||
lat +
|
||
"&lon=" +
|
||
lng +
|
||
"&accept-language=fa" +
|
||
"&zoom=5",
|
||
type: "GET",
|
||
success: function (result) {
|
||
boundingbox = result.boundingbox;
|
||
// console.log(boundingbox);
|
||
},
|
||
error: function (error) {
|
||
console.log(error);
|
||
},
|
||
});
|
||
}
|
||
|
||
$("#province-id").on("change", function () {
|
||
if (parseInt($(this).children("option:selected").val()) == 0) {
|
||
$("#province-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#province-id").removeClass("is-invalid-input");
|
||
|
||
onLocationChange();
|
||
}
|
||
});
|
||
|
||
$("#axis-name-id").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#axis-name-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#axis-name-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#yearshown").on("change", function () {
|
||
// $("#yearshown").addClass("is-invalid-input");
|
||
$("#yearshown").removeClass("is-invalid-input");
|
||
});
|
||
|
||
$("#axis-type-id").on("change", function () {
|
||
if (parseInt($(this).children("option:selected").val()) == 0) {
|
||
$("#axis-type-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#axis-type-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#project-title-id").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#project-title-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#project-title-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#contractor-id").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#contractor-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#contractor-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#consultant-id").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#consultant-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#consultant-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#contract-price-id").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#contract-price-id").addClass("is-invalid-input");
|
||
} else {
|
||
$("#contract-price-id").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
function restrictInputOtherThanArabic($field) {
|
||
var arabicCharUnicodeRange = /[\u0600-\u06FF-0-9-45]/;
|
||
|
||
$field.bind("keypress", function (event) {
|
||
var key = event.which;
|
||
// 8 = backspace
|
||
if (key == 8 || key == 0 || key === 32) {
|
||
return true;
|
||
}
|
||
|
||
var str = String.fromCharCode(key);
|
||
if (arabicCharUnicodeRange.test(str)) {
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
});
|
||
}
|
||
|
||
function addTownBox() {
|
||
let childNum = $("#subTown").children().length;
|
||
|
||
if (childNum == 1 && $("#town-id").val() != 0) {
|
||
$("#subTown div").append(
|
||
`
|
||
<div class="input-group mb-3">
|
||
<input type ="text" class="form-control" id="mosharekat1" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
</div>
|
||
`
|
||
);
|
||
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id${childNum}"
|
||
>
|
||
<option value="0" style="font-size:10px">انتخاب شهرستان</option>
|
||
</select>
|
||
<div class="input-group mb-3">
|
||
<input type ="text" class="form-control" id="mosharekat2" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
</div>
|
||
</div>`);
|
||
setTownSelect(childNum);
|
||
} else if (childNum == 2 && $("#town-id1").val() != 0) {
|
||
$("#subTown").append(`<div class="form-group col-md-12">
|
||
<label>
|
||
شهرستان
|
||
</label>
|
||
<select
|
||
class="form-control"
|
||
style="font-size:12px"
|
||
name="town"
|
||
id="town-id${childNum}"
|
||
>
|
||
<option value="0" style="font-size:10px">انتخاب شهرستان</option>
|
||
</select>
|
||
<div class="input-group mb-3">
|
||
<input type ="text" class="form-control" id="mosharekat3" min="1" max="100" data-inputmask="'mask': '99'" data-mask style="margin-top: 5px;" placeholder="درصد مشارکت"></input>
|
||
<div class="input-group-prepend p-0" style="margin-top:5px">
|
||
<span class="input-group-text" id="basic-addon2" style="padding:0px">%</span>
|
||
</div>
|
||
</div>
|
||
</div>`);
|
||
setTownSelect(childNum);
|
||
}
|
||
|
||
$("[data-mask]").inputmask();
|
||
|
||
$("#town-id1").on("change", function () {
|
||
if (parseInt($(this).children("option:selected").val()) == 0) {
|
||
$("#town-id1").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id1").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#town-id2").on("change", function () {
|
||
if (parseInt($(this).children("option:selected").val()) == 0) {
|
||
$("#town-id2").addClass("is-invalid-input");
|
||
} else {
|
||
$("#town-id2").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#mosharekat1").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#mosharekat1").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat1").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#mosharekat2").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#mosharekat2").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat2").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
|
||
$("#mosharekat3").on("change", function () {
|
||
if ($(this).val() == "") {
|
||
$("#mosharekat3").addClass("is-invalid-input");
|
||
} else {
|
||
$("#mosharekat3").removeClass("is-invalid-input");
|
||
}
|
||
});
|
||
}
|
||
|
||
function removeTownBox() {
|
||
let childNum = $("#subTown").children().length;
|
||
|
||
if (childNum == 3) {
|
||
$("#town-id2").parent().remove();
|
||
} else if (childNum == 2) {
|
||
$("#town-id1").parent().remove();
|
||
$("#subTown .input-group").remove();
|
||
}
|
||
}
|
||
|
||
function checkMarkersAndDrawPath(update) {
|
||
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(update);
|
||
} else {
|
||
setTimeout(() => {
|
||
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(update);
|
||
} else {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
mapName = update ? map2 : map;
|
||
mapName.removeControl(control);
|
||
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
// map.removeLayer(polyline);
|
||
}
|
||
}, 20);
|
||
}
|
||
}
|
||
function checkMarkersAndDrawPathshow() {
|
||
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")
|
||
) {
|
||
drawPathshow();
|
||
} else {
|
||
setTimeout(() => {
|
||
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")
|
||
) {
|
||
drawPathshow();
|
||
} else {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
mapshow.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
// map.removeLayer(polyline);
|
||
}
|
||
}, 20);
|
||
}
|
||
}
|
||
function removeStartToEndPath(update) {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
mapName = update ? map2 : map;
|
||
|
||
mapName.removeControl(control);
|
||
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
}
|
||
// if (routeControlsPath.length) {
|
||
// map.removeControl(control);
|
||
// });
|
||
// if (polylinePath != null) {
|
||
// }
|
||
// case "line": {
|
||
// [
|
||
// [dest[0], dest[1]],
|
||
// {
|
||
// opacity: 0.6,
|
||
// }
|
||
// break;
|
||
// case "axis": {
|
||
// `https://rmsmap.rmto.ir/route/v1/driving/${source[1]},${source[0]};${dest[1]},${dest[0]}?overview=false&alternatives=true&steps=true`,
|
||
// routeControlsPath.push(
|
||
// waypoints: [
|
||
// L.latLng(parseFloat(dest[0]), parseFloat(dest[1])),
|
||
// fitSelectedRoutes: false,
|
||
// createMarker: function () {
|
||
// },
|
||
// addWaypoints: false,
|
||
// {
|
||
// opacity: 0.6,
|
||
// },
|
||
// },
|
||
// .on("routesfound", function (e) {
|
||
// if (popupArraysPath[index] !== null) {
|
||
// }
|
||
|
||
// 'maxWidth': '300',
|
||
// 'className': 'customRouteEstimate'
|
||
|
||
// .coordinates
|
||
// 2)].lat,
|
||
// .lng);
|
||
// popup.setLatLng(popupLocation);
|
||
// popupArraysPath.push(popup);
|
||
// })
|
||
// );
|
||
// );
|
||
// $(".leaflet-routing-container-hide").css("display", "none");
|
||
// }
|
||
// }
|
||
|
||
function drawPath(update) {
|
||
mapName = update ? map2 : map;
|
||
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
mapName.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
// L.polyline(
|
||
// L.latLng(
|
||
// parseFloat(startAbrarMarker.getLatLng().lng)
|
||
// L.latLng(
|
||
// parseFloat(endAbrarMarker.getLatLng().lng)
|
||
// ],
|
||
// color: "blue",
|
||
// opacity: 0.5,
|
||
// }
|
||
// );
|
||
|
||
routeControls.push(
|
||
L.Routing.control({
|
||
waypoints: [
|
||
L.latLng(
|
||
parseFloat(startAbrarMarker.getLatLng().lat),
|
||
parseFloat(startAbrarMarker.getLatLng().lng)
|
||
),
|
||
L.latLng(
|
||
parseFloat(endAbrarMarker.getLatLng().lat),
|
||
parseFloat(endAbrarMarker.getLatLng().lng)
|
||
),
|
||
],
|
||
fitSelectedRoutes: false,
|
||
draggableWaypoints: true,
|
||
createMarker: function () {
|
||
return null;
|
||
},
|
||
lineOptions: {
|
||
addWaypoints: false,
|
||
styles: [
|
||
{
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
},
|
||
],
|
||
},
|
||
})
|
||
// var divideBy = 2;
|
||
// map.removeLayer(popupArrays[index]);
|
||
|
||
// maxWidth: "300",
|
||
// className: "customRouteEstimate",
|
||
// var popup = new L.Popup(customOptions);
|
||
// e.routes[0].coordinates[
|
||
// ].lat,
|
||
// parseInt(e.routes[0].coordinates.length / divideBy)
|
||
// );
|
||
// '<span style="color:#FF5630; font-size:11px; font-family: IRANSansFaNum;">مسافت: </span>' +
|
||
// " کیلومتر";
|
||
// parseFloat(e.routes[0].summary.totalDistance / 1000.0).toFixed(2)
|
||
|
||
// popup.setContent(popupContent);
|
||
// map.addLayer(popup);
|
||
// })
|
||
.addTo(mapName)
|
||
);
|
||
$(".leaflet-control-container").css("display", "none");
|
||
$(".leaflet-routing-container-hide").css("display", "none");
|
||
}
|
||
function drawPathshow() {
|
||
if (routeControls.length) {
|
||
$(routeControls).each(function (index, control) {
|
||
mapshow.removeControl(control);
|
||
routeControls.splice(routeControls.indexOf(index), 1);
|
||
});
|
||
}
|
||
// L.polyline(
|
||
// L.latLng(
|
||
// parseFloat(startAbrarMarker.getLatLng().lng)
|
||
// L.latLng(
|
||
// parseFloat(endAbrarMarker.getLatLng().lng)
|
||
// ],
|
||
// color: "blue",
|
||
// opacity: 0.5,
|
||
// }
|
||
// );
|
||
|
||
routeControls.push(
|
||
L.Routing.control({
|
||
waypoints: [
|
||
L.latLng(
|
||
parseFloat(startAbrarMarkershow.getLatLng().lat),
|
||
parseFloat(startAbrarMarkershow.getLatLng().lng)
|
||
),
|
||
L.latLng(
|
||
parseFloat(endAbrarMarkershow.getLatLng().lat),
|
||
parseFloat(endAbrarMarkershow.getLatLng().lng)
|
||
),
|
||
],
|
||
fitSelectedRoutes: false,
|
||
draggableWaypoints: true,
|
||
createMarker: function () {
|
||
return null;
|
||
},
|
||
lineOptions: {
|
||
addWaypoints: false,
|
||
styles: [
|
||
{
|
||
color: "#28a745",
|
||
opacity: 0.8,
|
||
weight: 5,
|
||
},
|
||
],
|
||
},
|
||
})
|
||
// var divideBy = 2;
|
||
// map.removeLayer(popupArrays[index]);
|
||
|
||
// maxWidth: "300",
|
||
// className: "customRouteEstimate",
|
||
// var popup = new L.Popup(customOptions);
|
||
// e.routes[0].coordinates[
|
||
// ].lat,
|
||
// parseInt(e.routes[0].coordinates.length / divideBy)
|
||
// );
|
||
// '<span style="color:#FF5630; font-size:11px; font-family: IRANSansFaNum;">مسافت: </span>' +
|
||
// " کیلومتر";
|
||
// parseFloat(e.routes[0].summary.totalDistance / 1000.0).toFixed(2)
|
||
|
||
// popup.setContent(popupContent);
|
||
// map.addLayer(popup);
|
||
// })
|
||
.addTo(mapshow)
|
||
);
|
||
$(".leaflet-control-container").css("display", "none");
|
||
$(".leaflet-routing-container-hide").css("display", "none");
|
||
}
|
||
|
||
$("#rejectoolfinal").on("click", function () {
|
||
$("#show-projecttool").modal("hide");
|
||
});
|
||
|
||
$("#example").on("click", "button.update-button", function () {
|
||
$("#tool-main").css("display", "none");
|
||
$("#update-table").css("display", "block");
|
||
scrolldowntable();
|
||
$("#title-update").empty();
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
cost = row.data().contract_credit;
|
||
var projecttitle = row.data().project_name;
|
||
var axisname = row.data().axis_name;
|
||
var ostan = row.data().province_fa;
|
||
|
||
startLatlng = row.data().start_latlng;
|
||
endLatlng = row.data().end_latlng;
|
||
|
||
var titleupdate =
|
||
"بروزرسانی آخرین وضعیت پروژه" +
|
||
" " +
|
||
projecttitle +
|
||
" " +
|
||
"محور" +
|
||
" " +
|
||
axisname +
|
||
" " +
|
||
"استان" +
|
||
" " +
|
||
ostan;
|
||
var note = '<h3 class="card-title" >' + titleupdate + "</h3> ";
|
||
$("#title-update").append(note);
|
||
showLoaderScreen();
|
||
tablethird = $("#example-update").DataTable({
|
||
dom: "lfrtip",
|
||
scrollX: true,
|
||
destroy: true,
|
||
pagingType: "simple_numbers",
|
||
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,
|
||
autoWidth: false,
|
||
ajax: {
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/get-distance-update-list",
|
||
type: "GET",
|
||
dataSrc: function (json) {
|
||
tooltipjson = json.data.distance;
|
||
if (json.data.distance_update.length) {
|
||
projectDistanceLastUpdate =
|
||
json.data.distance_update[json.data.distance_update.length - 1];
|
||
projectDistanceLastUpdatestatus =
|
||
projectDistanceLastUpdate.previous_status;
|
||
if (projectDistanceLastUpdatestatus == 0) {
|
||
$("#add-project-update").attr("disabled", true);
|
||
} else {
|
||
$("#add-project-update").attr("disabled", false);
|
||
}
|
||
// "projectDistanceLastUpdate",
|
||
// );
|
||
} else {
|
||
projectDistanceLastUpdate = null;
|
||
projectDefaultDistances = json.data.distance;
|
||
}
|
||
hideLoaderScreen();
|
||
return json.data.distance_update;
|
||
},
|
||
},
|
||
columns: [
|
||
{
|
||
data: null,
|
||
render: function (data, type, row, meta) {
|
||
return meta.row + 1;
|
||
},
|
||
},
|
||
{ data: "updated_at" },
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row, column) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 1;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
// console.log(data[Object.keys(data)[keyIndex]][0]);
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row, column) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 1;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row, column) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 1;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 2;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 2;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 2;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 3;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 3;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 3;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 4;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 4;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 4;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 5;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 5;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 5;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 6;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 6;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 6;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 7;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 7;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 7;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 8;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 8;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 8;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 9;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 9;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 9;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 10;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 10;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 10;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 11;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 11;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 11;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 12;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 12;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 1)
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 12;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 2)
|
||
return data[Object.keys(data)[keyIndex]][2];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 12;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
if (data[Object.keys(data)[keyIndex]].length > 2)
|
||
return data[Object.keys(data)[keyIndex]][3];
|
||
else return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 13;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][0];
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "previous_project_distance_update",
|
||
render: function (data, type, row) {
|
||
let keyIndex = Object.keys(data).findIndex(function (entry) {
|
||
return entry == 13;
|
||
});
|
||
if (keyIndex == -1) {
|
||
return "-";
|
||
} else {
|
||
return data[Object.keys(data)[keyIndex]][1];
|
||
}
|
||
},
|
||
},
|
||
|
||
{
|
||
data: "previous_project_status",
|
||
render: function (data, type, row) {
|
||
if (data == 1) {
|
||
return " در دست برنامه ریزی اولیه";
|
||
} else if (data == 2) {
|
||
return " در دست مطالعه و تهیه اسناد مناقصه";
|
||
} else if (data == 3) {
|
||
return "در دست مناقصه";
|
||
} else if (data == 4) {
|
||
return "در حال تجهیز کارگاه";
|
||
} else if (data == 5) {
|
||
return " در حال اجرا/فعال";
|
||
} else if (data == 6) {
|
||
return "در حال اجرا/متوقف ";
|
||
} else if (data == 7) {
|
||
return " در حال آماده سازی برای افتتاح";
|
||
} else if (data == 8) {
|
||
return " تکمیل و خاتمه یافته و بهره برداری شده";
|
||
} else return "توسط استان بروز رسانی نشده است";
|
||
},
|
||
},
|
||
|
||
{
|
||
data: null,
|
||
render: function (data, type, row, meta) {
|
||
let buttons = "";
|
||
|
||
buttons = ``;
|
||
|
||
|
||
// sliderImages = data.images;
|
||
|
||
buttons =
|
||
`
|
||
<div style="display: flex; flex-direction: row;">
|
||
<button type="button" class="btn btn-primary btn-sm" onclick="showMapModalStatic(` +
|
||
data.previous_team_latlng +
|
||
`)" ><i class="fa fa-globe" aria-hidden="true"></i></button>
|
||
<button class="btn btn-warning btn-sm upload-image-button" title="آپلود عکس" style="margin-right: 5px;" ><i class="fa fa-images"></i></button>
|
||
</div>
|
||
`;
|
||
// } else {
|
||
// <div style="display: flex; flex-direction: row;">
|
||
|
||
// `;
|
||
// }
|
||
// else {
|
||
// <div style="display: flex; flex-direction: row;">
|
||
// </div>
|
||
// }
|
||
|
||
return buttons;
|
||
},
|
||
},
|
||
],
|
||
initComplete: function (settings, json) {
|
||
$("#top-card-title").text(`بروزرسانی آخرین وضعیت پروژه ${project_title}`);
|
||
},
|
||
});
|
||
});
|
||
$("#image-upload-modal").on("click", "button.submit-update", function () {
|
||
// var row = tablethird.row(tr);
|
||
// console.log("history", historyId);
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا برای ثبت مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
historyId +
|
||
"/submit-history",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
location.reload();
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
alert("خطا :(");
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
// var tr = $(this).closest("tr");
|
||
// historyId = row.data().id;
|
||
// let rowImages = row.data().images;
|
||
// console.log("rowImages", rowImages, "sliderImages", sliderImages);
|
||
// // if (rowImages.length >0) {
|
||
|
||
// return entry.path.includes("image-1");
|
||
|
||
// test += `<div class="form-group col-md-3" id="uploadBox1">
|
||
// <div class="file-input-modal">
|
||
// imageIndex1
|
||
// "public",
|
||
// )}" id="image_upload_first" class="zoomimage" alt="your image" />
|
||
// <input class="file-input " id="inputFile1" type="file"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="firstshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_first" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
|
||
|
||
// return entry.path.includes("image-2");
|
||
|
||
// test += `<div class="form-group col-md-3" id="uploadBox2">
|
||
// <div class="file-input-modal">
|
||
// imageIndex2
|
||
// "public",
|
||
// )}" id="image_upload_second" name="" class="zoomimage" alt="your image" />
|
||
// <input class="file-input" type="file" id="inputFile2"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="secondshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_second" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// }
|
||
|
||
// return entry.path.includes("image-3");
|
||
// if (imageIndex3 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(3)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox3">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile3"
|
||
// </label>
|
||
// }
|
||
// return entry.path.includes("image-4");
|
||
// if (imageIndex4 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(4)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox4">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile4"
|
||
// </label>
|
||
// }
|
||
// return entry.path.includes("image-5");
|
||
// if (imageIndex5 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(5)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox5">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile5"
|
||
// </label>
|
||
// }
|
||
// return entry.path.includes("image-6");
|
||
// if (imageIndex6 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(6)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox6">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile6"
|
||
// </label>
|
||
// }
|
||
// return entry.path.includes("image-7");
|
||
// if (imageIndex7 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(7)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox7">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile7"
|
||
// </label>
|
||
// }
|
||
// return entry.path.includes("image-8");
|
||
// if (imageIndex8 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(8)" style="">✕</div>
|
||
// `;
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox8">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile8"
|
||
// </label>
|
||
// }
|
||
// // test += `<div class="form-row">
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="firstshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_first" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="secondshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_second" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="thirdshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_third" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="fourthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_fourth" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="fifthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_fifth" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="sixshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_six" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="sevenshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_seven" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // <label class="file-input-modal-container">
|
||
// // <img id="eightshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// // <img id="image_upload_eight" name="" class="zoomimage" alt="your image"
|
||
// // </div>
|
||
// // accept="image/*">
|
||
// // </div>
|
||
// // `;
|
||
// $("#image-upload-modal .modal-body").empty();
|
||
|
||
// $("#firstshow").css("display", "none");
|
||
// readURL1(this);
|
||
// $("#inputFile2").change(function () {
|
||
// $("#uploadBox3").css("display", "block");
|
||
// });
|
||
// $("#thirdshow").css("display", "none");
|
||
// readURL3(this);
|
||
// $("#inputFile4").change(function () {
|
||
// $("#uploadBox5").css("display", "block");
|
||
// });
|
||
// $("#fifthshow").css("display", "none");
|
||
// readURL5(this);
|
||
// $("#inputFile6").change(function () {
|
||
// $("#uploadBox7").css("display", "block");
|
||
// });
|
||
// $("#sevenshow").css("display", "none");
|
||
// readURL7(this);
|
||
// $("#inputFile8").change(function () {
|
||
// readURL8(this);
|
||
|
||
// });
|
||
|
||
$("#example-update").on("click", "button.upload-image-button", function () {
|
||
// openSlidershowbutton(tr)
|
||
|
||
var tr = $(this).closest("tr");
|
||
var row = tablethird.row(tr);
|
||
var updateDate = row.data().updated_at;
|
||
|
||
if (updateDate == "-") {
|
||
prepareImageModal();
|
||
historyId = row.data().id;
|
||
|
||
$("#image-upload-modal").modal({
|
||
backdrop: "static",
|
||
keyboard: false,
|
||
});
|
||
$("#image-upload-modal").modal("show");
|
||
} else {
|
||
openSlidershowbutton(row, 0);
|
||
}
|
||
// let rowImages = row.data().images;
|
||
// let canUpdate = row.data().updated_at == "-" ? true : false;
|
||
// var test = "";
|
||
|
||
|
||
// return entry.path.includes("image-1");
|
||
|
||
// test += `<div class="form-group col-md-3" id="uploadBox1">
|
||
// <div class="file-input-modal">
|
||
// imageIndex1
|
||
// "public",
|
||
// )}" id="image_upload_first" class="zoomimage" alt="your image" />
|
||
// <input class="file-input " id="inputFile1" type="file"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="firstshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_first" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*" >
|
||
// </div>`;
|
||
|
||
|
||
// return entry.path.includes("image-2");
|
||
|
||
// test += `<div class="form-group col-md-3" id="uploadBox2">
|
||
// <div class="file-input-modal">
|
||
// imageIndex2
|
||
// "public",
|
||
// )}" id="image_upload_second" name="" class="zoomimage" alt="your image" />
|
||
// <input class="file-input" type="file" id="inputFile2"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// test += `<div class="form-group col-md-3" id="uploadBox2">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile2"
|
||
// </label>
|
||
// `;
|
||
// else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="secondshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_second" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*" >
|
||
// </div>
|
||
// }
|
||
// // }
|
||
// return entry.path.includes("image-3");
|
||
// if (imageIndex3 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(3)" style="">✕</div>
|
||
// `;
|
||
// if (imageIndex2 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="thirdshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_third" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
// else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="thirdshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_third" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
|
||
|
||
// return entry.path.includes("image-4");
|
||
// if (imageIndex4 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(4)" style="">✕</div>
|
||
// `;
|
||
// if (imageIndex3 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fourthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fourth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
// else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fourthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fourth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
|
||
|
||
// return entry.path.includes("image-5");
|
||
// if (imageIndex5 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(5)" style="">✕</div>
|
||
// `;
|
||
// if (imageIndex4 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fifthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fifth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
// else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fifthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fifth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
|
||
// let imageIndex6 = rowImages.findIndex(function (entry) {
|
||
// });
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox6">
|
||
// <div class="file-input-modal">
|
||
// imageIndex6
|
||
// "public",
|
||
// )}" id="image_upload_six" name="" class="zoomimage" alt="your image" />
|
||
// <input class="file-input" type="file" id="inputFile6"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox6">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile6"
|
||
// </label>
|
||
// }
|
||
// test += ` <div class="form-group col-md-3" style="display: none;" id="uploadBox6">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile6"
|
||
// </label>
|
||
// }
|
||
|
||
// return entry.path.includes("image-7");
|
||
// if (imageIndex7 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img src="https://rms.rmto.ir/${rowImages[
|
||
// ].path.replace(
|
||
// "storage"
|
||
// </div>
|
||
// accept="image/*">
|
||
// <div class="remove-image-container501" onclick="removeImage(7)" style="">✕</div>
|
||
// `;
|
||
// if (imageIndex6 != -1) {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="sevenshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_seven" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
// else {
|
||
// <label class="file-input-modal-container">
|
||
// <img id="sevenshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_seven" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>`;
|
||
|
||
// let imageIndex8 = rowImages.findIndex(function (entry) {
|
||
// });
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox8">
|
||
// <div class="file-input-modal">
|
||
// imageIndex8
|
||
// "public",
|
||
// )}" id="image_upload_eight" name="" class="zoomimage" alt="your image" />
|
||
// <input class="file-input" type="file" id="inputFile8"
|
||
// </label>
|
||
// </div>
|
||
// } else {
|
||
// test += ` <div class="form-group col-md-3" id="uploadBox8">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile8"
|
||
// </label>
|
||
// }
|
||
// test += ` <div class="form-group col-md-3" style="display: none;" id="uploadBox8">
|
||
// <div class="file-input-modal">
|
||
// style="height: 20px; margin-top: 5px;" />
|
||
// style=" display: none" />
|
||
// <input class="file-input" type="file" id="inputFile8"
|
||
// </label>
|
||
// }
|
||
|
||
// test += `<div class="form-row">
|
||
// <label class="file-input-modal-container">
|
||
// <img id="firstshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_first" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="secondshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_second" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="thirdshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_third" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fourthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fourth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="fifthshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_fifth" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="sixshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_six" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="sevenshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_seven" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// <label class="file-input-modal-container">
|
||
// <img id="eightshow" src="../dist/images/icons/add-image.svg" alt="your image"
|
||
// <img id="image_upload_eight" name="" class="zoomimage" alt="your image"
|
||
// </div>
|
||
// accept="image/*">
|
||
// </div>
|
||
// `;
|
||
|
||
// console.log("my name is swwan" , canUpdate)
|
||
// additional = `<hr />
|
||
// ثبت و بروزرسانی
|
||
// }else{
|
||
// <button type="button" class="btn btn-success float-left submit-update" id="add-update-button" disabled>
|
||
// </button>`
|
||
|
||
// $("#image-upload-modal .modal-body").append(test);
|
||
|
||
// $("#firstshow").css("display", "none");
|
||
// readURL1(this);
|
||
// $("#inputFile2").change(function () {
|
||
// $("#uploadBox3").css("display", "block");
|
||
// });
|
||
// $("#thirdshow").css("display", "none");
|
||
// readURL3(this);
|
||
// $("#inputFile4").change(function () {
|
||
// $("#uploadBox5").css("display", "block");
|
||
// });
|
||
// $("#fifthshow").css("display", "none");
|
||
// readURL5(this);
|
||
// $("#inputFile6").change(function () {
|
||
// $("#uploadBox7").css("display", "block");
|
||
// });
|
||
// $("#sevenshow").css("display", "none");
|
||
// readURL7(this);
|
||
// $("#inputFile8").change(function () {
|
||
// $("#uploadBox9").css("display", "block");
|
||
// });
|
||
});
|
||
|
||
function readURL1(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_first").css("display", "block");
|
||
$("#image_upload_first").attr("src", e.target.result);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL2(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_second").css("display", "block");
|
||
$("#image_upload_second").attr("src", e.target.result);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL3(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_third").css("display", "block");
|
||
$("#image_upload_third").attr("src", e.target.result);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL4(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_fourth").css("display", "block");
|
||
$("#image_upload_fourth").attr("src", e.target.result);
|
||
uploadUpdateImage(4, input);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL5(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_fifth").css("display", "block");
|
||
$("#image_upload_fifth").attr("src", e.target.result);
|
||
uploadUpdateImage(5, input);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL6(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_six").css("display", "block");
|
||
$("#image_upload_six").attr("src", e.target.result);
|
||
uploadUpdateImage(6, input);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL7(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_seven").css("display", "block");
|
||
$("#image_upload_seven").attr("src", e.target.result);
|
||
uploadUpdateImage(7, input);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function readURL8(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
$("#image_upload_eight").css("display", "block");
|
||
$("#image_upload_eight").attr("src", e.target.result);
|
||
uploadUpdateImage(8, input);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
function removeImage(index) {
|
||
let formData = new FormData();
|
||
formData.append("history-id", historyId);
|
||
formData.append("name", "image-" + index);
|
||
// console.log(value);
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا برای ثبت مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: `https://rms.rmto.ir/rahdari/road-maintenance-project/history-images/delete-image`,
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
$("#image-upload-modal").modal("hide");
|
||
ajaxcalltablethird2(idkol);
|
||
},
|
||
error: function (error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
function uploadUpdateImage(index, input) {
|
||
let formData = new FormData();
|
||
formData.append("history-id", historyId);
|
||
formData.append("image", input.files[0]);
|
||
formData.append("name", "image-" + index);
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ", " + pair[1]);
|
||
}
|
||
// console.log(value);
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: `https://rms.rmto.ir/rahdari/road-maintenance-project/history-images/upload`,
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (result) {
|
||
console.log(result);
|
||
ajaxcalltablethird3(idkol);
|
||
$("#deleteIcon" + index).css("display", "block");
|
||
},
|
||
error: function (error) {
|
||
hideLoaderScreen();
|
||
alert("خطا در آپلود تصویر :(");
|
||
},
|
||
});
|
||
}
|
||
|
||
function openSlider(tr) {
|
||
let row = tablethird.row(tr);
|
||
sliderImages = row.data().images;
|
||
let updated_at = row.data().updated_at;
|
||
let dataLength = sliderImages.length;
|
||
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
|
||
for (let index = 0; index < sliderImages.length; index++) {
|
||
if (sliderImages[index].path.includes("image-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
"1" +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 1 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 2 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-3")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 3 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-4")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 4 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-5")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 5 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-6")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 6 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-7")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 7 + ')"></span>'
|
||
);
|
||
}
|
||
if (sliderImages[index].path.includes("image-8")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
sliderImages.length +
|
||
'</div><img src="https://rms.rmto.ir/' +
|
||
sliderImages[index].path.replace("public", "storage") +
|
||
'"><div class="textt"> تصویر ' +
|
||
(index + 1) +
|
||
":" +
|
||
" " +
|
||
"تاریخ :" +
|
||
updated_at +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 8 + ')"></span>'
|
||
);
|
||
}
|
||
}
|
||
|
||
if (dataLength > 0) {
|
||
slideindex = 1;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
|
||
function layerslidershow(n) {
|
||
let slides = $("#slideroverlay #slideshow-slide .mySlides");
|
||
let dots = $("#slideroverlay #slideshow-dot .dot");
|
||
|
||
if (n > slides.length) {
|
||
slideIndexlayer = 1;
|
||
}
|
||
if (n < 1) {
|
||
slideIndexlayer = slides.length;
|
||
}
|
||
|
||
$(slides).each(function () {
|
||
$(this).css("display", "none");
|
||
});
|
||
$(dots).each(function () {
|
||
$(this).removeClass("active");
|
||
});
|
||
|
||
$(slides[slideIndexlayer - 1]).css("display", "block");
|
||
$(dots[slideIndexlayer - 1]).addClass("active");
|
||
}
|
||
|
||
$("#slideroverlay .close").on("click", function () {
|
||
$(this).parent().parent().css("display", "none");
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
});
|
||
|
||
$("#slideroverlay #slideshow-slide .prev").on("click", function () {
|
||
layerslidershow((slideIndexlayer -= 1));
|
||
});
|
||
|
||
$("#slideroverlay #slideshow-slide .next").on("click", function () {
|
||
layerslidershow((slideIndexlayer += 1));
|
||
});
|
||
|
||
function currentphotoshow(slideIndex) {
|
||
layerslidershow((slideIndexlayer = slideIndex));
|
||
}
|
||
|
||
function ajaxcalltablesec(idkol) {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/get-distance",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#exampletool").dataTable().fnClearTable();
|
||
$("#exampletool").dataTable().fnAddData(result.data);
|
||
hideLoaderScreen();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablefirst() {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/getlist",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
hideLoaderScreen();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablefirsttool(idkol) {
|
||
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/getlist",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
ajaxcalltablesec(idkol);
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablefirstupdate(idkol) {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/getlist",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
ajaxcalltablethird2(idkol);
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablethird2(idkol) {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/get-distance-update-list",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example-update").dataTable().fnClearTable();
|
||
$("#example-update").dataTable().fnAddData(result.data.distance_update);
|
||
hideLoaderScreen();
|
||
$("#image-upload-modal").modal("hide");
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablethird3(idkol) {
|
||
$.ajax({
|
||
url:
|
||
"https://rms.rmto.ir/rahdari/road-maintenance-project/" +
|
||
idkol +
|
||
"/get-distance-update-list",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example-update").dataTable().fnClearTable();
|
||
$("#example-update").dataTable().fnAddData(result.data.distance_update);
|
||
hideLoaderScreen();
|
||
},
|
||
});
|
||
}
|
||
function ajaxcalltablegharar() {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/camp/all",
|
||
type: "GET",
|
||
success: function (result) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
hideLoaderScreen();
|
||
// icon: "success",
|
||
// confirmButtonText: "بستن",
|
||
},
|
||
});
|
||
}
|
||
function showprojecttype() {
|
||
$("#stepModalprojecttype").modal("show");
|
||
}
|
||
$("#approveprojecttype").on("click", function () {
|
||
|
||
if ($("#roadmaintanace").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-maintenance-project"
|
||
);
|
||
} else if ($("#reviewdangerpoint").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-danger-prevention"
|
||
);
|
||
} else if ($("#improveroad").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-upgrade-safety"
|
||
);
|
||
} else if ($("#faniproject").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-technical-building"
|
||
);
|
||
} else if ($("#rahdarkhane").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-tollhouse-management"
|
||
);
|
||
} else if ($("#projectbuild").is(":checked")) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-construction-rural"
|
||
);
|
||
}
|
||
$("#stepModalprojecttype").modal("hide");
|
||
});
|
||
|
||
function showprojecttest(index) {
|
||
if (index == 1) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-maintenance-project"
|
||
);
|
||
} else if (index == 2) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-danger-prevention"
|
||
);
|
||
} else if (index == 3) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-upgrade-safety"
|
||
);
|
||
} else if (index == 4) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-technical-building"
|
||
);
|
||
} else if (index == 5) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-tollhouse-management"
|
||
);
|
||
} else if (index == 6) {
|
||
window.open(
|
||
"https://rms.rmto.ir/road-construction-rural"
|
||
);
|
||
}
|
||
}
|
||
|
||
function showMapModalStatic(lat, lng) {
|
||
$("#exampleModalCenterStatic").modal("show");
|
||
|
||
if (staticMap == null) {
|
||
setTimeout(() => {
|
||
createLeafletMapStatic();
|
||
setNewView(lat, lng);
|
||
}, 500);
|
||
} else {
|
||
setNewView(lat, lng);
|
||
}
|
||
}
|
||
|
||
function createLeafletMapStatic() {
|
||
let bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
staticMap = new L.map("abrar-map-static", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([32.4279, 53.688], 9);
|
||
staticMap.dragging.disable();
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
staticMap
|
||
);
|
||
|
||
ekipAbrarMarkerJustShow = new L.marker(L.latLng(staticMap.getCenter()), {
|
||
icon: progressAbrarDivIcon,
|
||
draggable: false,
|
||
}).addTo(staticMap);
|
||
startAbrarMarkerJustShow = new L.marker(startLatlng, {
|
||
icon: startAbrarDivIcon,
|
||
draggable: false,
|
||
}).addTo(staticMap);
|
||
endAbrarMarkerJustShow = new L.marker(endLatlng, {
|
||
icon: endAbrarDivIcon,
|
||
draggable: false,
|
||
}).addTo(staticMap);
|
||
}
|
||
|
||
function setNewView(lat, lng) {
|
||
staticMap.setView(new L.LatLng(lat, lng), 9);
|
||
// startAbrarMarker = new L.marker(L.latLng(staticMap.getCenter()), {
|
||
// draggable: false
|
||
// } else {
|
||
ekipAbrarMarkerJustShow.setLatLng([lat, lng]);
|
||
startAbrarMarkerJustShow.setLatLng(startLatlng);
|
||
endAbrarMarkerJustShow.setLatLng(endLatlng);
|
||
}
|
||
|
||
function prepareImageModal() {
|
||
$("#inputFile1").change(function () {
|
||
$("#firstshow").css("display", "none");
|
||
$("#uploadBox2").css("display", "block");
|
||
|
||
readURL1(this);
|
||
});
|
||
$("#inputFile2").change(function () {
|
||
$("#secondshow").css("display", "none");
|
||
$("#uploadBox3").css("display", "block");
|
||
readURL2(this);
|
||
});
|
||
$("#inputFile3").change(function () {
|
||
$("#thirdshow").css("display", "none");
|
||
$("#uploadBox4").css("display", "block");
|
||
readURL3(this);
|
||
});
|
||
$("#inputFile4").change(function () {
|
||
$("#fourthshow").css("display", "none");
|
||
$("#uploadBox5").css("display", "block");
|
||
readURL4(this);
|
||
});
|
||
$("#inputFile5").change(function () {
|
||
$("#fifthshow").css("display", "none");
|
||
$("#uploadBox6").css("display", "block");
|
||
readURL5(this);
|
||
});
|
||
$("#inputFile6").change(function () {
|
||
$("#sixshow").css("display", "none");
|
||
$("#uploadBox7").css("display", "block");
|
||
readURL6(this);
|
||
});
|
||
$("#inputFile7").change(function () {
|
||
$("#sevenshow").css("display", "none");
|
||
$("#uploadBox8").css("display", "block");
|
||
readURL7(this);
|
||
});
|
||
$("#inputFile8").change(function () {
|
||
$("#eightshow").css("display", "none");
|
||
$("#uploadBox9").css("display", "block");
|
||
readURL8(this);
|
||
});
|
||
}
|
||
$(document).on("load", function () {
|
||
$(window).bind("resize", checkPosition);
|
||
});
|
||
|
||
function checkPosition() {
|
||
if ($(window).width() < 1100) {
|
||
$("#example_wrapper").css("margin-top", "50px");
|
||
} else {
|
||
$("#example_wrapper").css("margin-top", "");
|
||
}
|
||
if ($(window).width() < 555) {
|
||
$(".content-center-dataTable").css("width", "260px");
|
||
} else {
|
||
$(".content-center-dataTable").css("width", "");
|
||
}
|
||
if ($(window).width() < 440) {
|
||
$(".dataTables_filter input").css("width", "94px");
|
||
$(".dataTables_filter").css("margin-bottom", "10px");
|
||
$(".dt-buttons").addClass("d-flex");
|
||
$(".dt-buttons").addClass("justify-content-center");
|
||
$(".dt-buttons button").css("font-size", "10px");
|
||
} else {
|
||
$(".dataTables_filter input").css("width", "");
|
||
$(".dataTables_filter").css("margin-bottom", "");
|
||
$(".dt-buttons").removeClass("d-flex");
|
||
$(".dt-buttons button").css("font-size", "");
|
||
$(".dt-buttons").removeClass("justify-content-center");
|
||
}
|
||
}
|
||
|
||
// filter camp
|
||
$("#btn_filter_show").on("click", function () {
|
||
var filterCamp = ""
|
||
var provinceFiletr
|
||
var blockage
|
||
var axisType
|
||
var CampStartTime
|
||
var timeVal
|
||
|
||
provinceFiletr = $("#filter-province").val()
|
||
blockage = $("#blockage").val()
|
||
axisType = $("#axis_type").val()
|
||
timeVal = $("#datepickfromdate").val()
|
||
|
||
CampStartTime = moment(
|
||
fromDateCamp.getState().selected.year +
|
||
"/" +
|
||
fromDateCamp.getState().selected.month +
|
||
"/" +
|
||
fromDateCamp.getState().selected.date,
|
||
"jYYYY/jM/jD"
|
||
);
|
||
filterCamp = `?province=${provinceFiletr}`;
|
||
filterCamp +=
|
||
timeVal != "" ? `&blockage_date=${CampStartTime.locale("fa").format("YYYY-MM-DD")}` : ``;
|
||
filterCamp +=
|
||
blockage != 0 ? `&blockage=${blockage}` : ``;
|
||
filterCamp +=
|
||
axisType != 0 ? `&axis_type=${axisType}` : ``;
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/camp/all" + filterCamp,
|
||
type: "GET",
|
||
success: function (result) {
|
||
if (result.data.length != 0) {
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
}
|
||
else {
|
||
$("#example").dataTable().fnClearTable();
|
||
|
||
}
|
||
|
||
},
|
||
error: function (error) {
|
||
console.log("eroor")
|
||
|
||
},
|
||
});
|
||
})
|