var map = null;
var map2 = null;
var dataUrl = null;
var resultData = null;
var startAbrarMarker = null;
var isSetStartAbrarMarker = false;
var endAbrarMarker = null;
var isSetEndAbrarMarker = false;
var startpos = []
var endpos = []
var routeControls = [];
var sliderImages = [];
var updated_at;
var slideIndexlayer = 1;
var tooleproject;
var projectType;
var towns;
var tableDistance;
var tableUpdate;
var rateUrlCom;
var startAbrarDivIcon = L.divIcon({
html: `
`,
iconSize: [55, 75],
iconAnchor: [33, 64],
});
var endAbrarDivIcon = L.divIcon({
html: `
`,
iconSize: [55, 75],
iconAnchor: [33, 64],
});
$(document).ready(function () {
$("[data-mask]").inputmask();
var starRatingControl = new StarRating('.star-rating',{
maxStars: 3,
showText: false
});
var urlParams = new URLSearchParams(window.location.search);
idkol = urlParams.get('id')
projectType = urlParams.get('p_t')
console.log("hello my friend idkol", idkol)
console.log("hello my friend pt", projectType)
if (projectType == 1) {
$("#projecttypee").append("روکش آسفالت (نگهداری راه ها)")
}
else if (projectType == 2) {
$("#projecttypee").append(" رفع نقاط حادثه خیز /پرتصادف ")
}
else if (projectType == 3) {
$("#projecttypee").append("ارتقای ایمنی راه ")
}
else if (projectType == 4) {
$("#projecttypee").append("ابنیه فنی (نگهداری و ساخت )")
}
else if (projectType == 5) {
$("#projecttypee").append("راهدارخانه ها (بهسازی و نوسازی )")
}
switch (projectType) {
case "1":
dataUrl = "https://rms.rmto.ir/api/public/road-maintenance-project/" + idkol + "/getproject"
rateUrlCom = "road-maintenance-project"
break;
case "2":
dataUrl = "https://rms.rmto.ir/api/public/road-danger-prevention/" + idkol + "/getproject"
rateUrlCom = "road-danger-prevention"
break;
case "3":
dataUrl = "https://rms.rmto.ir/api/public/road-upgrade-safety/" + idkol + "/getproject"
rateUrlCom = "road-upgrade-safety"
break;
case "4":
dataUrl = "https://rms.rmto.ir/api/public/road-technical-building/" + idkol + "/getproject"
rateUrlCom = "road-technical-building"
break;
case "5":
dataUrl = "https://rms.rmto.ir/api/public/road-tollhouse-management/" + idkol + "/getproject"
rateUrlCom = "road-tollhouse-management"
break;
default:
dataUrl = "https://rms.rmto.ir/api/public/road-maintenance-project/" + idkol + "/getproject"
rateUrlCom = "road-maintenance-project"
}
$.ajax({
url:
dataUrl,
type: "GET",
// headers: {
// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
// },
// data: formData,
cache: false,
contentType: false,
processData: false,
success: function (result) {
resultData = result.data[0];
console.log("resulttt" ,resultData )
tooleproject=resultData.project_distance
sliderImages = resultData.images;
for (var i = 0; i < resultData.images.length; i++) {
var test = '\

\
'
$("#imagelistshown").append(test)
}
for (var i = 0; i < resultData.images.length; i++) {
var test =
'\

\
';
$(".imagelistshown2edit").append(test);
}
updated_at = resultData.last_updated_at;
projectDistanceUpdate = resultData.project_distance_update
console.log("resultESH", resultData)
$("#contractdate").append(resultData.submited_at)
if (resultData.images.length!=0) {
$("#lastupdated").append(resultData.last_updated_at)
}
else {
$("#lastupdated").append(" ")
}
if(resultData.project_status==0) {
$("#projectstatus").append("توسط استان بروز رسانی نشده است")
}
else if (resultData.project_status==1){
$("#projectstatus").append("در دست برنامه ریزی اولیه")
}
else if (resultData.project_status==2) {
$("#projectstatus").append("در دست مطالعه و تهیه اسناد مناقصه")
}
else if (resultData.project_status==3) {
$("#projectstatus").append("در دست مناقصه")
}
else if (resultData.project_status==4) {
$("#projectstatus").append("در حال تجهیز کارگاه ")
}
else if (resultData.project_status==5) {
$("#projectstatus").append("در حال اجرا فعال ")
}
else if (resultData.project_status==6) {
$("#projectstatus").append("در حال اجرا متوقف ")
}
else if (resultData.project_status==7) {
$("#projectstatus").append("در حال آماده سازی برای افتتاح ")
}
else if (resultData.project_status==8) {
$("#projectstatus").append("تکمیل و خاتمه یافته و بهره برداری شده ")
}
$("#province").append(resultData.province.name)
startpos = resultData.start_latlng
endpos = resultData.end_latlng
console.log("town length", resultData.cities.length)
towns;
switch (resultData.cities.length) {
case 1:
towns = resultData.cities[0].name
break
case 2:
towns = resultData.cities[0].name + "," + resultData.cities[1].name
break
case 3:
towns = resultData.cities[0].name
towns = resultData.cities[0].name + "," + resultData.cities[1].name + "," + resultData.cities[2].name
break
default:
towns = ""
}
$("#town").append(towns)
$("#axisName").append(resultData.axis_name)
var axisType;
switch (resultData.axis_type) {
case 1:
axisType = "شریانی"
break
case 2:
axisType = "اصلی"
break;
case 3:
axisType = "فرعی"
break
case 4:
axisType = "روستایی"
break
default: axisType = ""
}
$("#axisType").append(axisType)
$("#projectName").append(resultData.project_name)
$("#contractor").append(resultData.contractor_name)
$("#startDate").append(resultData.contract_date)
generateTableshowtool(resultData.project_distance , projectType , resultData)
if (resultData.images.length!=0) {
if (projectDistanceUpdate != null) {
$("#titleupdate").css('display', 'block')
GenerateTablestart(projectDistanceUpdate, 1, projectType)
}
else {
GenerateTablestart(projectDistanceUpdate, 0, projectType)
}
}
if (map == null) {
console.log("startT", startpos);
console.log("endD", endpos);
setTimeout(() => {
createLeafletMap([startpos[0], startpos[1]], [endpos[0], endpos[1]]);
}, 200);
}
// showLoaderScreen()
},
error: function (error) {
// hideLoaderScreen();
console.log(error);
// Swal.fire({
// icon: "error",
// title: "خطا",
// text: "پر کردن صحیح تمامی عناوین خواسته شده الزامی است",
// confirmButtonText: "بستن",
// });
},
});
$(".star-rating").on("change",function(){
let formData = new FormData();
formData.append("id",idkol)
formData.append("rate",$(this).val())
formData.append("rate_desc","")
for (var value of formData.values()) {
console.log("HERE IS",value);
}
// console.log("hello", $(this).val());
$.ajax({
// https://rms.rmto.ir/api/public/road-maintenance-project
url:
"https://rms.rmto.ir/rahdari/"+rateUrlCom+"/submit-rate",
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
// data: formData,
cache: false,
data:formData,
contentType: false,
processData: false,
success: function (result) {
console.log("in piroozi")
},
error: function (error) {
// hideLoaderScreen();
console.log(error);
// Swal.fire({
// icon: "error",
// title: "خطا",
// text: "پر کردن صحیح تمامی عناوین خواسته شده الزامی است",
// confirmButtonText: "بستن",
// });
},
});
})
});
function createLeafletMap(startP, endP) {
console.log("createLeafletMap");
let bounds = [
[42.9130026312, 75.6166317076],
[20.5782370061, 35.5092252948],
];
map = new L.map("abrar-map", {
maxBounds: bounds,
minZoom: 6,
}).setView(startP, 12);
L.tileLayer("https://testmap.141.ir/141map/{z}/{x}/{y}.png", {}).addTo(map);
startAbrarMarker = new L.marker(startP, {
icon: startAbrarDivIcon,
draggable: false,
}).addTo(map);
if(endP[0]!="NaN") {
endAbrarMarker = new L.marker(endP, {
icon: endAbrarDivIcon,
draggable: false,
});
endAbrarMarker.addTo(map);
drawPath(map)
$("input[name=abrar-project-latlng-end]").val(
endAbrarMarker.getLatLng().lat.toFixed(6) +
endAbrarMarker.getLatLng().lng.toFixed(6)
);
console.log("testend", endAbrarMarker.getLatLng().lng.toFixed(6))
endAbrarMarker.on("drag", function () {
$("#pin-marker-end").addClass("pin-move");
checkMarkersAndDrawPath();
});
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
}
$("input[name=abrar-project-latlng-start]").val(
startAbrarMarker.getLatLng().lat.toFixed(6) +
startAbrarMarker.getLatLng().lng.toFixed(6)
);
console.log("teststart", startAbrarMarker.getLatLng().lng.toFixed(6))
startAbrarMarker.on("drag", function () {
$("#pin-marker-start").addClass("pin-move");
checkMarkersAndDrawPath();
});
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
}
function createLeafletMap2(startP, endP) {
console.log("createLeafletMap2");
let bounds = [
[42.9130026312, 75.6166317076],
[20.5782370061, 35.5092252948],
];
map2 = new L.map("abrar-map2", {
maxBounds: bounds,
minZoom: 6,
}).setView(startP, 12);
L.tileLayer("https://testmap.141.ir/141map/{z}/{x}/{y}.png", {}).addTo(map2);
startAbrarMarker = new L.marker(startP, {
icon: startAbrarDivIcon,
draggable: false,
}).addTo(map2);
if(endP[0]!="NaN") {
endAbrarMarker = new L.marker(endP, {
icon: endAbrarDivIcon,
draggable: false,
});
endAbrarMarker.addTo(map2);
drawPath(map2)
$("input[name=abrar-project-latlng-end]").val(
endAbrarMarker.getLatLng().lat.toFixed(6) +
endAbrarMarker.getLatLng().lng.toFixed(6)
);
console.log("testend", endAbrarMarker.getLatLng().lng.toFixed(6))
endAbrarMarker.on("drag", function () {
$("#pin-marker-end").addClass("pin-move");
checkMarkersAndDrawPath();
});
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
}
$("input[name=abrar-project-latlng-start]").val(
startAbrarMarker.getLatLng().lat.toFixed(6) +
startAbrarMarker.getLatLng().lng.toFixed(6)
);
console.log("teststart", startAbrarMarker.getLatLng().lng.toFixed(6))
startAbrarMarker.on("drag", function () {
$("#pin-marker-start").addClass("pin-move");
checkMarkersAndDrawPath();
});
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
}
function initialMarkerMapValue(latP, lngP) {
console.log("initialMarkerMapValue");
if (isSetStartAbrarMarker) {
endAbrarMarker.remove();
}
isSetEndAbrarMarker = false;
map.setView([latP, lngP], 9);
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
isSetStartAbrarMarker = false;
removeStartToEndPath();
$("#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) {
console.log("initialMarkerMapValueEdit");
console.log("hello initial edit");
console.log(!endAbrarMarker);
removeStartToEndPath();
// if(endAbrarMarker){
endAbrarMarker.remove();
endAbrarMarker.setLatLng(endP);
endAbrarMarker.addTo(map);
// }else{
// endAbrarMarker = new L.marker(endP, {
// icon: endAbrarDivIcon,
// draggable: true,
// });
// endAbrarMarker.addTo(map);
// }
// endAbrarMarker.setLatLng(markerLatLng);
// 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();
avrLat = (parseFloat(startP[0]) + parseFloat(endP[0])) / 2;
avrLng = (parseFloat(startP[1]) + parseFloat(endP[1])) / 2;
map.setView([avrLat, avrLng], 6);
}
function initialMarkerMapValueEditshow(startP, endP) {
console.log("initialMarkerMapValueEdit");
console.log("hello initial edit");
console.log(!endAbrarMarker);
removeStartToEndPath();
// if(endAbrarMarker){
endAbrarMarker.remove();
endAbrarMarker.setLatLng(endP);
endAbrarMarker.addTo(map);
// }else{
// endAbrarMarker = new L.marker(endP, {
// icon: endAbrarDivIcon,
// draggable: true,
// });
// endAbrarMarker.addTo(map);
// }
// endAbrarMarker.setLatLng(markerLatLng);
// 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();
avrLat = (parseFloat(startP[0]) + parseFloat(endP[0])) / 2;
avrLng = (parseFloat(startP[1]) + parseFloat(endP[1])) / 2;
map.setView([avrLat, avrLng], 6);
}
function drawPath(mymap) {
if (routeControls.length) {
$(routeControls).each(function (index, control) {
mymap.removeControl(control);
routeControls.splice(routeControls.indexOf(index), 1);
});
}
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,
},
],
},
})
.addTo(mymap)
);
$(".leaflet-control-container").css("display", "none");
$(".leaflet-routing-container-hide").css("display", "none");
}
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();
return true;
}
}
function generateTableshowtool(object ,projectType , datakol ) {
console.log("object" , object)
console.log("p-p" ,projectType)
console.log("pitikoo" , datakol)
//
var customers = new Array();
if (customers != []) {
customers = []
}
if (projectType == "1" || projectType == "3") {
customers.push([" نوع عملیات", "حجم"]);
} else {
customers.push([" نوع عملیات"]);
}
// for (var i = 0; i < item.length; i++) {
// customers.push([i + 1, subshow(item[i]), showcount(item[i], dataitem)]);
// }
$.each(object, function (index, value) {
if (projectType == "1" || projectType == "3") {
customers.push([showname(index, projectType , datakol), showkiloo(index, value, projectType)]);
} else {
customers.push([showname(index, projectType , datakol)]);
}
});
// console.log(customers)
tableDistance = document.createElement("TABLE");
$(tableDistance).attr("width", "100%")
$(tableDistance).addClass("table");
$(tableDistance).addClass("table-bordered");
// $(table).addClass("tablepopup");
tableDistance.border = "1";
//Get the count of columns.
if (customers[0]) {
var columnCount = customers[0].length;
}
//Add the header row.
var row = tableDistance.insertRow(-1);
for (var i = 0; i < columnCount; i++) {
var headerCell = document.createElement("TH");
headerCell.innerHTML = customers[0][i];
row.appendChild(headerCell);
}
//Add the data rows.
for (var i = 1; i < customers.length; i++) {
row = tableDistance.insertRow(-1);
for (var j = 0; j < columnCount; j++) {
var cell = row.insertCell(-1);
cell.innerHTML = customers[i][j];
}
}
var dvTable = document.getElementById("showdistance");
dvTable.innerHTML = "";
// console.log("dvtt",dvTable)
dvTable.appendChild(tableDistance);
}
function showname(index, projectType , datakol) {
if (projectType == "1") {
if (index==1) {
return "روکش آسفالت"
}
if (index==2) {
return "ماسه آسفالت "
}
if(index==3){
return "بازیافت سرد و گرم "
}
if (index==4) {
return "میکروسرفیسینگ"
}
if (index==5) {
return "چیپ سیل"
}
if (index==6) {
return "اسلاری سیل "
}
if (index==7) {
return "اسکراب سیل"
}
if (index==8) {
return "فوگ سیل "
}
if (index==9) {
return "سیل کت "
}
if (index==10) {
return "کیپ سیل"
}
if (index==11) {
return "آسفالت سرد/ردمیکس"
}
if (index==12) {
return "لکه گیری "
}
if(index==13) {
return "درز گیری "
}
}
if (projectType == "2") {
if (index == 1) {
return "تعریض و روکش"
}
if (index == 2) {
return "اصلاح قوس"
}
if (index == 3) {
return "تراشه برداری"
}
if (index == 4) {
return "روشنایی نقظه ای"
}
if (index == 5) {
return "احداث تقاطع غیر هم سطح (پل/زیرگذر)"
}
if (index == 6) {
return "ایمن سازی علائم و حفاظ"
}
if (index == 7) {
return "اصلاح ورودی/خروجی"
}
if (index == 8) {
return "تعریض ابنیه فنی"
}
if (index == 9) {
if (datakol.project_description!= null) {
return "سایر اقدامات"+":"+datakol.project_description
}
return "سایر اقدامات "
}
}
if (projectType == "3") {
if (index == 1) {
return " نصب حفاظ بتنی "
}
if (index == 2) {
return " نصب حفاظ فلزی / گاردریل"
}
if (index == 3) {
return " اجرای روشنایی طولی "
}
if (index == 4) {
return " اجرای روشنایی نقطه ای "
}
if (index == 5) {
return " نصب علائم ایمنی (اخباری ) "
}
if (index == 6) {
return "نصب علائم ایمنی (سایر)"
}
if (index == 7) {
return " خط کشی "
}
if (index == 8) {
return " اصلاح شیب شیروانی "
}
if (index == 9) {
return " سایر اقدامات ایمنی راه "
}
}
if (projectType == "4") {
if (index == 1) {
return " تعریض پل / آبرو "
}
if (index == 2) {
return "تعمیرات اساسی پل"
}
if (index == 3) {
return "تعمیرات تونل"
}
if (index == 4) {
return "تعمیر یا احداث دیوار حائل"
}
if (index == 5) {
return "احداث پل جدید"
}
if (index == 6) {
return "احداث کنارگذر پل / تونل"
}
if (index == 7) {
if(datakol.project_description!=null) {
return "سایر اقدامات"+":"+datakol.project_description
}
else {
return "سایر اقدامات"
}
}
}
if (projectType == "5") {
if (index == 1) {
return "احداث راهدارخانه"
}
if (index == 2) {
return "احداث انبار شن و نمک"
}
if (index == 3) {
return "نوسازی و بهسازی راهدارخانه"
}
if (index == 4) {
return "احداث آشیانه ماشین آلات"
}
// if (index == 5) {
// return "احداث پل جدید"
// }
if (index == 6) {
return "محوطه سازی راهدارخانه"
}
if (index == 7) {
if(datakol.project_description!=null) {
return "سایر اقدامات"+":"+datakol.project_description
}
else {
return "سایر اقدامات"
}
}
}
// return index
}
function showkiloo(index , value ,projectType) {
// console.log("valuepitikoo" , index , value , projectType)
console.log("index mored nazar");
console.log(index);
if (projectType==1) {
return value[0]+" "+"(کیلومتر)"
}
else if (projectType==3) {
if(index == 4 || index == 6){
return value[0]+" "+"(تعداد)"
}
else if (index == 5){
return value[0]+" "+"(متر مربع)"
}else if (index == 9){
return value[0]
}
return value[0]+" "+"(کیلومتر)"
}
}
function GenerateTablestart(object, flag, projectType) {
// console.log("obj", object)
// $("#showtabel").empty()
var customers = new Array();
if (customers != []) {
customers = []
}
if (flag) {
if (projectType == "1") {
customers.push([" نوع عملیات", "پیشرفت (درصد)", "کیلومتر"]);
} else {
customers.push([" نوع عملیات", "پیشرفت (درصد)"]);
}
}
// for (var i = 0; i < item.length; i++) {
// customers.push([i + 1, subshow(item[i]), showcount(item[i], dataitem)]);
// }
$.each(object, function (index, value) {
if (projectType == "1") {
customers.push([subshow(index, projectType), showcount(index, value, flag, projectType), showKilo(index, value, flag)]);
} else {
customers.push([subshow(index, projectType), showcount(index, value, flag, projectType)]);
}
});
// console.log(customers)
tableUpdate = document.createElement("TABLE");
$(tableUpdate).attr("width", "100%")
$(tableUpdate).addClass("table");
$(tableUpdate).addClass("table-bordered");
$(tableUpdate).addClass("tablepopup");
tableUpdate.border = "1";
//Get the count of columns.
if (customers[0]) {
var columnCount = customers[0].length;
}
//Add the header row.
var row = tableUpdate.insertRow(-1);
for (var i = 0; i < columnCount; i++) {
var headerCell = document.createElement("TH");
headerCell.innerHTML = customers[0][i];
row.appendChild(headerCell);
}
//Add the data rows.
for (var i = 1; i < customers.length; i++) {
row = tableUpdate.insertRow(-1);
for (var j = 0; j < columnCount; j++) {
var cell = row.insertCell(-1);
cell.innerHTML = customers[i][j];
}
}
var dvTable = document.getElementById("showtable");
dvTable.innerHTML = "";
// console.log("dvtt",dvTable)
dvTable.appendChild(tableUpdate);
}
// function GenerateTableEnd(object, flag) {
// // $("#showtabelend").empty()
// console.log("objend", object)
// var customers = new Array();
// if (customers != []) {
// customers = []
// }
// if(projectType == "2"){
// customers.push([" نوع عملیات", "پیشرفت (درصد)" , "کیلومتر"]);
// }else{
// customers.push([" نوع عملیات", "پیشرفت (درصد)"]);
// }
// // for (var i = 0; i < item.length; i++) {
// // customers.push([i + 1, subshow(item[i]), showcount(item[i], dataitem)]);
// // }
// console.log("imm here" , projectType)
// $.each(object, function (index, value) {
// if(projectType == "2"){
// customers.push([subshow(index ,projectType), showcount(index, value, flag ,projectType), showKilo(index, value, flag ,projectType)]);
// }else{
// customers.push([subshow(index ,projectType), showcount(index, value, flag ,projectType)]);
// }
// });
// // console.log(customers)
// var table = document.createElement("TABLE");
// $(table).attr("width", "100%")
// $(table).addClass("table");
// $(table).addClass("table-bordered");
// $(table).addClass("tablepopup");
// table.border = "1";
// //Get the count of columns.
// if( customers != [] ){
// var columnCount = customers[0].length;
// }
// //Add the header row.
// var row = table.insertRow(-1);
// for (var i = 0; i < columnCount; i++) {
// var headerCell = document.createElement("TH");
// headerCell.innerHTML = customers[0][i];
// row.appendChild(headerCell);
// }
// //Add the data rows.
// for (var i = 1; i < customers.length; i++) {
// row = table.insertRow(-1);
// for (var j = 0; j < columnCount; j++) {
// var cell = row.insertCell(-1);
// cell.innerHTML = customers[i][j];
// }
// }
// var dvTable = document.getElementById("showtabelend");
// dvTable.innerHTML = "";
// // console.log("dvtt",dvTable)
// dvTable.appendChild(table);
// }
function subshow(index, projectType) {
if (projectType == "1") {
if (index==1) {
return "روکش آسفالت"
}
if (index==2) {
return "ماسه آسفالت "
}
if(index==3){
return "بازیافت سرد و گرم "
}
if (index==4) {
return "میکروسرفیسینگ"
}
if (index==5) {
return "چیپ سیل"
}
if (index==6) {
return "اسلاری سیل "
}
if (index==7) {
return "اسکراب سیل"
}
if (index==8) {
return "فوگ سیل "
}
if (index==9) {
return "سیل کت "
}
if (index==10) {
return "کیپ سیل"
}
if (index==11) {
return "آسفالت سرد/ردمیکس"
}
if (index==12) {
return "لکه گیری "
}
if(index==13) {
return "درز گیری "
}
}
if (projectType == "2") {
if (index == 1) {
return "تعریض و روکش"
}
if (index == 2) {
return "اصلاح قوس"
}
if (index == 3) {
return "تراشه برداری"
}
if (index == 4) {
return "روشنایی نقظه ای"
}
if (index == 5) {
return "احداث تقاطع غیر هم سطح (پل/زیرگذر)"
}
if (index == 6) {
return "ایمن سازی علائم و حفاظ"
}
if (index == 7) {
return "اصلاح ورودی/خروجی"
}
if (index == 8) {
return "تعریض ابنیه فنی"
}
if (index == 9) {
return "سایر اقدامات"
}
}
if (projectType == "3") {
if (index == 1) {
return " نصب حفاظ بتنی "
}
if (index == 2) {
return " نصب حفاظ فلزی / گاردریل"
}
if (index == 3) {
return " اجرای روشنایی طولی "
}
if (index == 4) {
return " اجرای روشنایی نقطه ای "
}
if (index == 5) {
return " نصب علائم ایمنی (اخباری ) "
}
if (index == 6) {
return "نصب علائم ایمنی (سایر)"
}
if (index == 7) {
return " خط کشی "
}
if (index == 8) {
return " اصلاح شیب شیروانی "
}
if (index == 9) {
return " سایر اقدامات ایمنی راه "
}
}
if (projectType == "4") {
if (index == 1) {
return " تعریض پل / آبرو "
}
if (index == 2) {
return "تعمیرات اساسی پل"
}
if (index == 3) {
return "تعمیرات تونل"
}
if (index == 4) {
return "تعمیر یا احداث دیوار حائل"
}
if (index == 5) {
return "احداث پل جدید"
}
if (index == 6) {
return "احداث کنارگذر پل / تونل"
}
if (index == 7) {
return "سایر اقدامات"
}
}
if (projectType == "5") {
if (index == 1) {
return "احداث راهدارخانه"
}
if (index == 2) {
return "احداث انبار شن و نمک"
}
if (index == 3) {
return "نوسازی و بهسازی راهدارخانه"
}
if (index == 4) {
return "احداث آشیانه ماشین آلات"
}
// if (index == 5) {
// return "احداث پل جدید"
// }
if (index == 6) {
return "محوطه سازی راهدارخانه"
}
if (index == 7) {
return "سایر"
}
}
// return index
}
function showcount(index, value, flag, projectType) {
let textfile = ""
if (flag == 0) {
return "0"
}
else {
console.log("my name is project type", projectType)
switch (projectType) {
case "1":
if (index == 1) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 2) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 3) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 4) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 5) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 6) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 7) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 9) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 10) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 11) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
if (index == 12) {
for (var i = 0; i < value.length; i++) {
textfile = value[3]
}
}
if (index == 13) {
for (var i = 0; i < value.length; i++) {
textfile = value[2]
}
}
break;
case "5":
case "4":
case "2":
if (index == 1) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 2) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 3) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 4) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 5) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 6) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 7) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 9) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
break;
case "3":
if (index == 1) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 2) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 3) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 4) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 5) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 6) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 7) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[1]
}
}
if (index == 9) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
break;
}
return textfile
}
}
function showKilo(index, value, flag) {
let textfile = ""
if (flag == 0) {
return "0"
}
else {
if (index == 1) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 2) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 3) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 4) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 5) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 6) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 7) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 8) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 9) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 10) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 11) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 12) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
if (index == 13) {
for (var i = 0; i < value.length; i++) {
textfile = value[0]
}
}
return textfile
}
}
function showimagealert(num) {
slideIndexlayer = num+1
console.log("gole nume",num);
console.log("sliderImages", sliderImages)
let dataLength = sliderImages.length;
console.log("datalenght", dataLength)
console.log("update", updated_at)
$("#slideshow-slide").find(".mySlides").remove();
$("#slideshow-dot").find(".dot").remove();
for (let index = 0; index < sliderImages.length; index++) {
console.log("indexxx", index + 1)
var test = index + 1
let divSlide =
'' +
(index + 1) +
" / " +
sliderImages.length +
'

تصویر ' +
test +
":" +
" " +
"تاریخ :" +
updated_at +
"
";
$("#slideshow-slide").append(divSlide);
$("#slideshow-dot").append(
''
);
}
if (dataLength > 0) {
slideindex = 1;
layerslidershow(slideindex);
$("#slideroverlay").css("display", "block");
}
}
$("#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 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");
}
function printbama(){
$("#bamaPreviewModal").modal("show");
console.log("resultData" , resultData);
$("#preview-template-province-name").text(resultData.province.name);
$("#preview-template-town").text(towns);
var projectT;
switch(projectType){
case "1":
projectT = "روکش آسفالت (نگهداری راه ها)"
break;
case "2":
projectT = " رفع نقاط حادثه خیز /پرتصادف "
break;
case "3":
projectT = "ارتقای ایمنی راه "
break;
case "4":
projectT = "ابنیه فنی (نگهداری و ساخت )"
break;
case "5":
projectT = "راهدارخانه ها (بهسازی و نوسازی )"
break;
default:
projectT = ""
}
$("#preview-template-project-type").text(projectT);
$("#preview-template-project-name").text(resultData.project_name);
$("#preview-template-axis-name").text(resultData.axis_name);
var axisType;
switch (resultData.axis_type) {
case 1:
axisType = "شریانی"
break
case 2:
axisType = "اصلی"
break;
case 3:
axisType = "فرعی"
break
case 4:
axisType = "روستایی"
break
default: axisType = ""
}
$("#preview-template-axis-type").text(axisType);
var projectSt;
switch(resultData.project_status){
case 0:
projectSt = "توسط استان بروز رسانی نشده است"
break;
case 1:
projectSt = "در دست برنامه ریزی اولیه"
break;
case 2:
projectSt = "در دست مطالعه و تهیه اسناد مناقصه"
break;
case 3:
projectSt = "در دست مناقصه"
break;
case 4:
projectSt = "در حال تجهیز کارگاه "
console.log("hello mo" ,resultData.project_status );
break;
case 5:
projectSt = "در حال اجرا فعال "
break;
case 6:
projectSt = "در حال اجرا متوقف "
break;
case 7:
projectSt = "در حال آماده سازی برای افتتاح "
break;
case 8:
projectSt = "تکمیل و خاتمه یافته و بهره برداری شده "
break;
}
$("#preview-template-last-status").text(projectSt);
$("#preview-template-last-update").text(resultData.last_updated_at);
$("#preview-template-submit-date").text(resultData.submited_at);
$("#preview-template-contractor").text(resultData.contractor_name);
$("#preview-template-start-date ").text(resultData.contract_date);
if (map2 == null) {
console.log("startT2", startpos);
console.log("endD2", endpos);
setTimeout(() => {
createLeafletMap2([startpos[0], startpos[1]], [endpos[0], endpos[1]]);
}, 400);
}
$("#section-distance").empty();
$("#section-update").empty();
$(tableDistance).clone().appendTo("#section-distance");
$(tableUpdate).clone().appendTo("#section-update");
$("#section-update table").css("margin" , "0px");
// window.print()
}
function showPrintPDF(){
// $("#bamaPreviewModal .modal-body").print();
$("#bamaPreviewModal .modal-body").print();
// .printElement();
// console.log( document.getElementById("bamaPreviewModal").innerHTML)
// var divContents = document.getElementById("bamaPreviewModal").innerHTML;
// console.log("jiioiiiiz",divContents);
// var a = window.open('', '', 'height=595, width=842');
// a.document.write('');
// a.document.write(' Div contents are
');
// a.document.write(divContents);
// a.document.write('');
// a.document.close();
// a.print();
// window.open("https://rms.rmto.ir/webapi/danger-point/" + idkol + "/preview/print", "_blank");
}
// function showimagealert(num) {
// alert(num)
// }