6989 lines
263 KiB
JavaScript
6989 lines
263 KiB
JavaScript
var idkol;
|
||
var canSubmit;
|
||
var table;
|
||
var serialNumberKeep;
|
||
var map = null;
|
||
var mapedit = null;
|
||
var mapshow = null;
|
||
var startAbrarMarker = null;
|
||
var isSetStartAbrarMarker = false;
|
||
var startAbrarMarkeredit = null;
|
||
var isSetStartAbrarMarkeredit = null;
|
||
var startAbrarMarkershow = null;
|
||
var isSetStartAbrarMarkershow = null;
|
||
var provinces = [];
|
||
var latadd = null;
|
||
var lngadd = null;
|
||
var nominlat;
|
||
var nominlng;
|
||
var inputappend = null;
|
||
var idkol;
|
||
var datamainrow;
|
||
var addressnomin;
|
||
var lateditt;
|
||
var lngeditt;
|
||
var accident_251;
|
||
var accident_251_code;
|
||
var speed_limit;
|
||
var speed_average;
|
||
var accident_possibility;
|
||
var road_guard;
|
||
var geometric_desc;
|
||
var accident_cause;
|
||
var accident_cause_suggest;
|
||
var accident_severity;
|
||
var accident_severity_suggest;
|
||
var correction_plan_done;
|
||
var correction_plan_doing;
|
||
var correction_plan_doing_desc;
|
||
var correction_plan_doing_suggest;
|
||
var tablesecond;
|
||
var slideIndexlayer = 1;
|
||
let showbuttondate = 0;
|
||
var boundingbox;
|
||
var selectlat;
|
||
var selectlng;
|
||
var latstart;
|
||
var lngstart;
|
||
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 perDatePicker;
|
||
var perTimePicker;
|
||
let serialNumber;
|
||
let datePick;
|
||
let weekendDay;
|
||
let occurTime;
|
||
let vehicleDir;
|
||
let collisionType;
|
||
let bikeMotor;
|
||
let passer;
|
||
let animal;
|
||
let object;
|
||
let lightVehicle;
|
||
let heavyVehicle;
|
||
let accidentFactors = {};
|
||
let injury;
|
||
let death;
|
||
let accidentType = [];
|
||
let deathNumber;
|
||
let injuredNumber;
|
||
let accidentResult = {};
|
||
var statusrow;
|
||
var scrolled = 0;
|
||
var rowStatus = -1;
|
||
|
||
function showLoaderScreen() {
|
||
$(".starter-loader-container").css("display", "flex").hide().fadeIn();
|
||
}
|
||
|
||
function hideLoaderScreen() {
|
||
$(".starter-loader-container").fadeOut();
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
getProvinces();
|
||
table = $("#example").DataTable({
|
||
dom: "lBfrtip",
|
||
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, "asc"][(1, "asc")],
|
||
[2, "desc"],
|
||
[3, "desc"],
|
||
[4, "desc"]
|
||
],
|
||
order: [
|
||
[0, "desc"]
|
||
],
|
||
processing: true,
|
||
select: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/webapi/danger-point/getlist",
|
||
type: "GET",
|
||
dataSrc: function(json) {
|
||
if (json.can_submit == 0) {
|
||
$('#point-add').prop('disabled', true)
|
||
}
|
||
|
||
canSubmit = json.can_submit
|
||
console.log("testtt", json.data)
|
||
return json.data;
|
||
},
|
||
},
|
||
columns: [{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function(data, type, row, meta) {
|
||
// console.log(meta.row);
|
||
return meta.row + 1;
|
||
},
|
||
},
|
||
{ data: "province.name" },
|
||
{ data: "axis_name" },
|
||
{
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
if (data.axis_type != undefined) {
|
||
if (data.axis_type == 1) {
|
||
return "ازادراه";
|
||
} else if (data.axis_type == 2) {
|
||
return "بزرگراه";
|
||
} else if (data.axis_type == 3) {
|
||
return " راه اصلی";
|
||
} else if (data.axis_type == 4) {
|
||
return "راه فرعی با عملکرد اصلی ";
|
||
} else if (data.axis_type == 5) {
|
||
return "راه فرعی (درجه 1 یا 2)";
|
||
} else if (data.axis_type == 6) {
|
||
return "راه روستایی (درجه 3)";
|
||
}
|
||
} else {
|
||
return `<select class="form-control" name="mehvar-type" id="mehvar-type"><option value="0" > انتخاب </option><option value="1">آزادراه</option><option value="2">بزرگراه</option><option value="3">راه اصلی </option><option value="4">راه فرعی با عملکرد اصلی </option><option value="5">راه فرعی (درجه 1 یا 2) </option><option value="6">راه روستایی (فرعی درجه 3)</option></select>`;
|
||
}
|
||
},
|
||
},
|
||
{ data: "axis_start" },
|
||
{ data: "axis_end" },
|
||
{ data: "distance_axis_start" },
|
||
{ data: "local_name" },
|
||
{
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
if (data.status == 1 || data.status == 2 || data.status == 4) {
|
||
return data.submited_at;
|
||
} else {
|
||
return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
if (data.code != null) {
|
||
return data.code;
|
||
} else {
|
||
return "-";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
orderable: false,
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
console.log(canSubmit)
|
||
if (canSubmit == 1) {
|
||
if (data.status == 0) {
|
||
var firstbtn = "";
|
||
var secondbtn = "";
|
||
var thirdbtn = "";
|
||
var fourthbtn = "";
|
||
var previewbtn = "";
|
||
var sixthbtn = "";
|
||
if (data.btn_deactive[0] == 1) {
|
||
firstbtn =
|
||
'<button class="btn btn-secondary btn-sm historic" title="تاریخچه تصادفات" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ;opacity: 0.65;" ><i class="fas fa-history"></i></button>';
|
||
} else {
|
||
firstbtn =
|
||
'<button class="btn btn-info btn-sm historic" title="تاریخچه تصادفات" ><i class="fas fa-history"></i></button>';
|
||
}
|
||
if (data.btn_deactive[1] == 1) {
|
||
secondbtn =
|
||
'<button class="btn btn-secondary btn-sm watchdata" title="ارزیابی تیم استانی" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fas fa-eye"></i></button>';
|
||
} else {
|
||
secondbtn =
|
||
'<button class="btn btn-primary btn-sm watchdata" title="ارزیابی تیم استانی"><i class="fas fa-eye"></i></button>';
|
||
}
|
||
if (data.btn_deactive[2] == 1) {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-secondary preview" title=" پیش نمایش" disabled><i class="fa fa-print"></i></button>';
|
||
} else {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-success preview" title=" پیش نمایش" style="width:28px"><i class="fa fa-print"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[3] == 1) {
|
||
thirdbtn =
|
||
'<button class="btn btn-secondary btn-sm row-upload-images" title="آپلود عکس" style="background-color: #6c757d !important;border: 1px solid #6c757d !important; opacity: 0.65;"><i class="fas fa-images"></i></button>';
|
||
} else {
|
||
thirdbtn =
|
||
'<button class="btn btn-warning btn-sm row-upload-images" title="آپلود عکس"><i class="fas fa-images"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[4] == 1) {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fa fa-upload"></i></button>';
|
||
} else {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color:#ff5630!important;border-color:#ff5630!important;width:28.5px"><i class="fa fa-upload"></i></button>';
|
||
}
|
||
if (data.btn_deactive[5] == 1) {
|
||
sixthbtn =
|
||
'<button class="btn btn-sm btn-secondary finalsubmit" title=" ثبت نهایی " style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fa fa-check"></i></button>';
|
||
} else {
|
||
sixthbtn =
|
||
'<button class="btn btn-sm btn-success finalsubmit" title=" ثبت نهایی " ><i class="fa fa-check"></i></button>';
|
||
}
|
||
|
||
return (
|
||
'<button class="btn btn-danger btn-sm editor details-control " title="ویرایش"><i class="fa fa-edit"></i><div></div></button>' +
|
||
" " +
|
||
firstbtn +
|
||
" " +
|
||
secondbtn +
|
||
" " +
|
||
previewbtn +
|
||
" " +
|
||
thirdbtn +
|
||
" " +
|
||
fourthbtn +
|
||
" " +
|
||
sixthbtn +
|
||
" " +
|
||
'<button class="btn btn-sm btn-danger deletsubmit" title=" حذف " style="width:28px"><i class="fa fa-trash"></i></button>'
|
||
);
|
||
}
|
||
if (
|
||
data.status == 2 ||
|
||
data.status == 1 ||
|
||
data.status == 4
|
||
) {
|
||
var firstbtn = "";
|
||
var secondbtn = "";
|
||
var thirdbtn = "";
|
||
var fourthbtn = "";
|
||
var previewbtn = "";
|
||
if (data.btn_deactive[0] == 1) {
|
||
firstbtn =
|
||
'<button class="btn btn-secondary btn-sm historic" title="تاریخچه تصادفات" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ;opacity: 0.65;" ><i class="fas fa-history"></i></button>';
|
||
} else {
|
||
firstbtn =
|
||
'<button class="btn btn-info btn-sm historic" title="تاریخچه تصادفات" ><i class="fas fa-history"></i></button>';
|
||
}
|
||
if (data.btn_deactive[1] == 1) {
|
||
secondbtn =
|
||
'<button class="btn btn-secondary btn-sm watchdata" title="ارزیابی تیم استانی" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fas fa-eye"></i></button>';
|
||
} else {
|
||
secondbtn =
|
||
'<button class="btn btn-primary btn-sm watchdata" title="ارزیابی تیم استانی"><i class="fas fa-eye"></i></button>';
|
||
}
|
||
if (data.btn_deactive[2] == 1) {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-secondary preview" title=" پیش نمایش" style="width:28px;background-color: #6c757d !important;border: 1px solid #6c757d !important ;opacity: 0.65;"><i class="fa fa-print"></i></button>';
|
||
} else {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-success preview" title=" پیش نمایش" style="width:28px"><i class="fa fa-print"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[3] == 1) {
|
||
thirdbtn =
|
||
'<button class="btn btn-secondary btn-sm row-upload-images" title="آپلود عکس" style="background-color: #6c757d !important;border: 1px solid #6c757d !important;opacity: 0.65;"><i class="fas fa-images"></i></button>';
|
||
} else {
|
||
thirdbtn =
|
||
'<button class="btn btn-warning btn-sm row-upload-images" title="آپلود عکس"><i class="fas fa-images"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[4] == 1) {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fa fa-upload"></i></button>';
|
||
} else {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color:#ff5630!important;border-color:#ff5630!important;width:28.5px;"><i class="fa fa-upload"></i></button>';
|
||
}
|
||
|
||
return (
|
||
'<button class="btn btn-danger btn-sm editor details-control " title="ویرایش"><i class="fa fa-edit"></i><div></div></button>' +
|
||
" " +
|
||
firstbtn +
|
||
" " +
|
||
secondbtn +
|
||
" " +
|
||
previewbtn +
|
||
" " +
|
||
thirdbtn +
|
||
" " +
|
||
fourthbtn +
|
||
" " +
|
||
'<button class="btn btn-sm btn-success finalsubmit" title=" ثبت نهایی " disabled><i class="fa fa-check"></i></button>' +
|
||
" " +
|
||
'<button class="btn btn-sm btn-secondary deletsubmit" title=" حذف " style="width:28px" disabled><i class="fa fa-trash"></i></button>'
|
||
);
|
||
}
|
||
if (data.status == 3) {
|
||
var firstbtn = "";
|
||
var secondbtn = "";
|
||
var thirdbtn = "";
|
||
var fourthbtn = "";
|
||
var previewbtn = "";
|
||
var sixthbtn = "";
|
||
if (data.btn_deactive[0] == 1) {
|
||
firstbtn =
|
||
'<button class="btn btn-secondary btn-sm historic" title="تاریخچه تصادفات" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ;opacity: 0.65;" ><i class="fas fa-history"></i></button>';
|
||
} else {
|
||
firstbtn =
|
||
'<button class="btn btn-info btn-sm historic" title="تاریخچه تصادفات" ><i class="fas fa-history"></i></button>';
|
||
}
|
||
if (data.btn_deactive[1] == 1) {
|
||
secondbtn =
|
||
'<button class="btn btn-secondary btn-sm watchdata" title="ارزیابی تیم استانی" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fas fa-eye"></i></button>';
|
||
} else {
|
||
secondbtn =
|
||
'<button class="btn btn-primary btn-sm watchdata" title="ارزیابی تیم استانی"><i class="fas fa-eye"></i></button>';
|
||
}
|
||
if (data.btn_deactive[2] == 1) {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-secondary preview" title=" پیش نمایش" disabled><i class="fa fa-print"></i></button>';
|
||
} else {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-success preview" title=" پیش نمایش" style="width:28px"><i class="fa fa-print"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[3] == 1) {
|
||
thirdbtn =
|
||
'<button class="btn btn-secondary btn-sm row-upload-images" title="آپلود عکس" style="background-color: #6c757d !important;border: 1px solid #6c757d !important; opacity: 0.65;"><i class="fas fa-images"></i></button>';
|
||
} else {
|
||
thirdbtn =
|
||
'<button class="btn btn-warning btn-sm row-upload-images" title="آپلود عکس"><i class="fas fa-images"></i></button>';
|
||
}
|
||
|
||
if (data.btn_deactive[4] == 1) {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fa fa-upload"></i></button>';
|
||
} else {
|
||
fourthbtn =
|
||
'<button class="btn btn-sm btn-secondary confirmdata" title=" آپلود مستندات " style="background-color:#ff5630!important;border-color:#ff5630!important;width:28.5px"><i class="fa fa-upload"></i></button>';
|
||
}
|
||
if (data.btn_deactive[5] == 1) {
|
||
sixthbtn =
|
||
'<button class="btn btn-sm btn-secondary finalsubmit" title=" ثبت نهایی " style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;"><i class="fa fa-check"></i></button>';
|
||
} else {
|
||
sixthbtn =
|
||
'<button class="btn btn-sm btn-success finalsubmit" title=" ثبت نهایی " ><i class="fa fa-check"></i></button>';
|
||
}
|
||
|
||
return (
|
||
'<button class="btn btn-danger btn-sm editor details-control " title="ویرایش"><i class="fa fa-edit"></i><div></div></button>' +
|
||
" " +
|
||
firstbtn +
|
||
" " +
|
||
secondbtn +
|
||
" " +
|
||
previewbtn +
|
||
" " +
|
||
thirdbtn +
|
||
" " +
|
||
fourthbtn +
|
||
" " +
|
||
sixthbtn +
|
||
" " +
|
||
'<button class="btn btn-sm btn-danger deletsubmit" title=" حذف " style="width:28px"><i class="fa fa-trash"></i></button>'
|
||
);
|
||
}
|
||
} else {
|
||
let previewbtn;
|
||
|
||
if (data.btn_deactive[2] == 1) {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-secondary preview" title=" پیش نمایش" disabled><i class="fa fa-print"></i></button>';
|
||
} else {
|
||
previewbtn =
|
||
'<button class="btn btn-sm btn-success preview" title=" پیش نمایش" style="width:28px"><i class="fa fa-print"></i></button>';
|
||
}
|
||
|
||
return (
|
||
previewbtn
|
||
);
|
||
}
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
if (data.status == 0) {
|
||
return '<button class="btn btn-sm btn-secondary" style="background-color: #6c757d !important;border: 1px solid #6c757d !important; opacity: 0.65;" title="در انتظار ثبت نهایی" > در انتظار ثبت نهایی</button>';
|
||
}
|
||
if (data.status == 1) {
|
||
return '<button class="btn btn-sm btn-secondary" style="background-color: #6c757d !important;border: 1px solid #6c757d !important ; opacity: 0.65;" title="در انتظار بررسی" > در انتظار بررسی </button>';
|
||
} else if (data.status == 2) {
|
||
return '<button class="btn btn-sm btn-success approve" title="تایید " >تایید</button>';
|
||
} else if (data.status == 3) {
|
||
return '<button class="btn btn-sm btn-warning lackofdoc" title=" نقص مدارک " >نقص مدارک</button>';
|
||
} else if (data.status == 4) {
|
||
return '<button class="btn btn-sm btn-danger notapprove" title="عدم تایید" >عدم تایید</button>';
|
||
}
|
||
},
|
||
},
|
||
],
|
||
|
||
buttons: [{
|
||
extend: "excelHtml5",
|
||
title: "Excel",
|
||
text: "خروجی به اکسل",
|
||
messageTop: " شناسنامه نقطه دارای تصادف ",
|
||
exportOptions: {
|
||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||
},
|
||
},
|
||
{
|
||
// extend: "download",
|
||
// title: "Video",
|
||
text: "دانلود فیلم راهنما",
|
||
action: function(e, dt, node, config) {
|
||
window.open("/storage/video_2020-07-04_11-30-38.mp4", "_blank");
|
||
},
|
||
},
|
||
{
|
||
text: "راهنمای تبدیل مختصات UTM",
|
||
action: function(e, dt, node, config) {
|
||
window.open("/storage/UTM_to_degrees_decimal.pdf", "_blank");
|
||
},
|
||
},
|
||
],
|
||
});
|
||
|
||
$(function() {
|
||
$("#danger-point1").click(function() {
|
||
if ($(this).is(":checked")) {
|
||
$("#pointcode").attr("disabled", false);
|
||
}
|
||
});
|
||
});
|
||
$(function() {
|
||
$("#danger-point2").click(function() {
|
||
if ($(this).is(":checked")) {
|
||
$("#pointcode").attr("disabled", true);
|
||
$("#pointcode").val("");
|
||
}
|
||
});
|
||
});
|
||
$('input:checkbox[name="rishe"]').change(function() {
|
||
if (this.checked) {
|
||
$("#risheerae").attr("disabled", false);
|
||
}
|
||
});
|
||
$('input:checkbox[name="acc"]').change(function() {
|
||
if (this.checked) {
|
||
$("#accarea").attr("disabled", false);
|
||
}
|
||
});
|
||
});
|
||
$("#example").on("click", "tbody tr", function() {
|
||
if ($(this).hasClass("selected")) {
|
||
// console.log("selected")
|
||
$(this).removeClass("selected");
|
||
} else {
|
||
// console.log("deselect")
|
||
table.$("tr.selected").removeClass("selected");
|
||
$(this).addClass("selected");
|
||
}
|
||
});
|
||
$("#example").on("click", "button.latlngshow", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
$("#showposition").modal("show");
|
||
$("#latshow").val(row.data().lat_lng[0]);
|
||
$("#lngshow").val(row.data().lat_lng[1]);
|
||
// console.log(row.data().lat_lng)
|
||
setTimeout(() => {
|
||
if (mapshow == null) {
|
||
creatmapshow(row.data().lat_lng[0], row.data().lat_lng[1]);
|
||
} else {
|
||
setmapshow(row.data().lat_lng[0], row.data().lat_lng[1]);
|
||
setTimeout(() => {
|
||
checkStartMarkerValidation(false, true);
|
||
}, 25);
|
||
}
|
||
}, 200);
|
||
});
|
||
$("#example").on("click", "button.lackofdoc", function() {
|
||
$("#showtozihat").empty()
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
var status_desc = row.data().status_desc;
|
||
$("#showtozihat").append(
|
||
'<textarea class="form-control" name="gettozihat" id="gettozihat" disabled>' +
|
||
status_desc +
|
||
"</textarea>"
|
||
);
|
||
$("#stepmodallackdata").modal("show");
|
||
});
|
||
// $('#example').on('click', 'button.finalsubmit', function () {
|
||
// var tr = $(this).closest("tr");
|
||
// var row = table.row(tr);
|
||
// idkol = row.data().id;
|
||
|
||
// formData = new FormData();
|
||
|
||
// formData.append("danger-id", idkol);
|
||
|
||
// Swal.fire({
|
||
// icon: "warning",
|
||
// title: "آیا مطمئن هستید؟",
|
||
// showCancelButton: true,
|
||
// confirmButtonColor: "#3085d6",
|
||
// cancelButtonColor: "#d33",
|
||
// confirmButtonText: "بله، تایید میشود",
|
||
// cancelButtonText: "منصرف شدم!",
|
||
// showLoaderOnConfirm: true,
|
||
// preConfirm: () => {
|
||
// $.ajax({
|
||
// url: "/webapi/danger-point/status/province-submit",
|
||
// type: "POST",
|
||
// headers: {
|
||
// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
// },
|
||
// data: formData,
|
||
// cache: false,
|
||
// contentType: false,
|
||
// processData: false,
|
||
// success: function (result) {
|
||
// showbuttondate = 1
|
||
// showLoaderScreen()
|
||
// ajaxcalltable()
|
||
// // Swal.fire({
|
||
// // icon: "success",
|
||
// // title: "با موفقیت بروزرسانی شد",
|
||
// // confirmButtonText: "بستن",
|
||
// // // preConfirm: () => {
|
||
// // // console.log("hi")
|
||
// // // // location.reload()
|
||
// // // ajaxcalltable()
|
||
// // // // console.log("bye")
|
||
// // // }
|
||
|
||
// // });
|
||
// },
|
||
// error: function (error) {
|
||
// console.log(error);
|
||
// 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 btn_deactive = row.data().btn_deactive;
|
||
var speed_limit = row.data().speed_limit;
|
||
var uploaded_files = row.data().uploaded_files;
|
||
var point_images = row.data().point_images;
|
||
formData = new FormData();
|
||
|
||
formData.append("danger-id", idkol);
|
||
if (
|
||
speed_limit != null &&
|
||
uploaded_files[0].signature_file != null &&
|
||
uploaded_files[1].police_file != null &&
|
||
point_images.length == 9 &&
|
||
btn_deactive[0] != 1
|
||
) {
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/status/province-submit",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
showbuttondate = 1;
|
||
showLoaderScreen();
|
||
ajaxcalltable();
|
||
// Swal.fire({
|
||
// icon: "success",
|
||
// title: "با موفقیت بروزرسانی شد",
|
||
// confirmButtonText: "بستن",
|
||
// // preConfirm: () => {
|
||
// // console.log("hi")
|
||
// // // location.reload()
|
||
// // ajaxcalltable()
|
||
// // // console.log("bye")
|
||
// // }
|
||
|
||
// });
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "پر کردن تمامی عناوین خواسته شده الزامی است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "لطفا تمام فیلد ها را کامل پر کنید ",
|
||
confirmButtonText: "بستن",
|
||
// preConfirm: () => {
|
||
// console.log("hi")
|
||
// // location.reload()
|
||
// ajaxcalltable()
|
||
// // console.log("bye")
|
||
// }
|
||
});
|
||
}
|
||
});
|
||
$("#example").on("click", "button.deletsubmit", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/" + idkol + "/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
$("#example").on("click", "button.confirmdata", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
uploaded_files = row.data().uploaded_files;
|
||
signaturefile = row.data().uploaded_files[0].signature_file;
|
||
policefile = row.data().uploaded_files[1].police_file;
|
||
|
||
if (row.data().status == 0 || row.data().status == 3) {
|
||
$("#submitupload").prop("disabled", false);
|
||
} else {
|
||
$("#submitupload").prop("disabled", true);
|
||
}
|
||
|
||
// console.log(signaturefile)
|
||
// console.log(policefile)
|
||
$("#see-danger").css("display", "none");
|
||
$("#see-danger2").css("display", "none");
|
||
$("#see-danger3").css("display", "none");
|
||
|
||
$("#stepmodalupload").modal("show");
|
||
|
||
$("#policeshow").css("display", "block");
|
||
$("#fileshow").css("display", "block");
|
||
|
||
if (signaturefile != null) {
|
||
// showLoaderScreen()
|
||
$("#fileshow").css("display", "none");
|
||
if (row.data().status == 0 || row.data().status == 3) {
|
||
$("#uploadfile").append(
|
||
'<div class="remove-image-s" id="remove-image-containerupload' +
|
||
idkol +
|
||
'" style="color: red; position:absolute; top: 4px; left: 16px;cursor: pointer;">✕</div>'
|
||
);
|
||
} else {
|
||
$(".remove-image-s").remove();
|
||
}
|
||
$("#image_upload_previewmostanad").css("display", "block");
|
||
$("#image_upload_previewmostanad").attr("src", signaturefile);
|
||
// $("#remove-image-containerupload" + idkol).on('click', function () {
|
||
// console.log("containerupload")
|
||
// })
|
||
} else {
|
||
$("#image_upload_previewmostanad").css("display", "none");
|
||
}
|
||
if (policefile != null) {
|
||
$("#policeshow").css("display", "none");
|
||
if (row.data().status == 0 || row.data().status == 3) {
|
||
$("#policekoroki").append(
|
||
'<div class="remove-image-p" id="remove-image-containerpolice' +
|
||
idkol +
|
||
'" style="color: red; position:absolute; top: 4px; left: 16px; cursor: pointer;">✕</div>'
|
||
);
|
||
} else {
|
||
$(".remove-image-p").remove();
|
||
}
|
||
$("#image_upload_preview").css("display", "block");
|
||
$("#image_upload_preview").attr("src", policefile);
|
||
// hideLoaderScreen()
|
||
// $("#remove-image-containerpolice" + idkol).on('click', function () {
|
||
// console.log("containerpolice")
|
||
// })
|
||
} else {
|
||
$("#image_upload_preview").css("display", "none");
|
||
}
|
||
|
||
function readURL(input) {
|
||
if (input.files && input.files[0]) {
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function(e) {
|
||
$("#image_upload_preview").css("display", "block");
|
||
$("#removepic1").css("display", "block");
|
||
$("#image_upload_preview").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_previewmostanad").css("display", "block");
|
||
$("#removepic2").css("display", "block");
|
||
$("#image_upload_previewmostanad").attr("src", e.target.result);
|
||
};
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
$("#inputFile").change(function() {
|
||
$("#policeshow").css("display", "none");
|
||
readURL(this);
|
||
});
|
||
$("#inputFile1").change(function() {
|
||
$("#fileshow").css("display", "none");
|
||
readURL2(this);
|
||
});
|
||
$("#removepic1").on("click", function() {
|
||
$("#removepic1").css("display", "none");
|
||
$("#image_upload_preview").css("display", "none");
|
||
});
|
||
$("#removepic2").on("click", function() {
|
||
$("#removepic2").css("display", "none");
|
||
$("#image_upload_previewmostanad").css("display", "none");
|
||
});
|
||
//delet
|
||
$("#remove-image-containerpolice" + idkol).on("click", function() {
|
||
console.log("#remove-image-containerpolice" + idkol);
|
||
formData = new FormData();
|
||
|
||
formData.append("danger-id", idkol);
|
||
|
||
formData.append("name", "police-file");
|
||
//remove
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/images/files/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "پر کردن تمامی فیلد ها الزامی است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
});
|
||
$("#remove-image-containerupload" + idkol).on("click", function() {
|
||
console.log("#remove-image-containerupload" + idkol);
|
||
formData = new FormData();
|
||
|
||
formData.append("danger-id", idkol);
|
||
|
||
formData.append("name", "signature-file");
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/images/files/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "پر کردن تمامی فیلد ها الزامی است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
});
|
||
$("#example").on("click", "button.preview", function() {
|
||
//modalalireza
|
||
$("#dangerPointPreviewModal").modal("show");
|
||
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
|
||
$(".section-preview-2-data").remove();
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/" + idkol + "/preview/get",
|
||
type: "GET",
|
||
success: function(result) {
|
||
console.log(result);
|
||
|
||
$("#preview-template-created-at").text(result.data.created_at);
|
||
$("#preview-template-province-name").text(result.data.province_name);
|
||
$("#preview-template-axis-name").text(result.data.axis_name);
|
||
$("#preview-template-axis-type").text(result.data.axis_type);
|
||
$("#preview-template-axis-start").text(result.data.axis_start);
|
||
$("#preview-template-axis-end").text(result.data.axis_end);
|
||
$("#preview-template-distance-axis-start").text(
|
||
result.data.distance_axis_start
|
||
);
|
||
$("#preview-template-local-name").text(result.data.local_name);
|
||
$("#preview-template-lat-lng").text(
|
||
"x: " + result.data.lat_lng[0] + ", y: " + result.data.lat_lng[1]
|
||
);
|
||
|
||
let arrayIndex = result.data.danger_point_accidents.length;
|
||
|
||
result.data.danger_point_accidents.forEach(function(value, index) {
|
||
console.log(value);
|
||
|
||
let elementRow = `
|
||
<tr class="section-preview-2-data" style="font-size: 10px; font-weight: 400;">
|
||
<td> ${arrayIndex} </td>
|
||
<td> ${value.serial_number} </td>
|
||
<td> ${value.accident_day} </td>
|
||
<td> ${value.accident_month} </td>
|
||
<td> ${value.accident_year} </td>
|
||
<td> ${value.day} </td>
|
||
<td> ${value.time} </td>
|
||
<td> ${
|
||
value.accident_direction == 1
|
||
? '<i class="fa fa-check" style="font-size: 7px;line-height: 15px;" aria-hidden="true"></i>'
|
||
: ""
|
||
} </td>
|
||
<td> ${
|
||
value.accident_direction == 2
|
||
? '<i class="fa fa-check" style="font-size: 7px;line-height: 15px;" aria-hidden="true"></i>'
|
||
: ""
|
||
} </td>
|
||
<td> ${value.collision_type} </td>
|
||
<td> ${value.accident_factors.bi} </td>
|
||
<td> ${value.accident_factors.pa} </td>
|
||
<td> ${value.accident_factors.an} </td>
|
||
<td> ${value.accident_factors.ob} </td>
|
||
<td> ${value.accident_factors.li} </td>
|
||
<td> ${value.accident_factors.he} </td>
|
||
<td> ${
|
||
value.accident_type == 1
|
||
? '<i class="fa fa-check" style="font-size: 7px;line-height: 15px;" aria-hidden="true"></i>'
|
||
: ""
|
||
} </td>
|
||
<td> ${
|
||
value.accident_type == 2
|
||
? '<i class="fa fa-check" style="font-size: 7px;line-height: 15px;" aria-hidden="true"></i>'
|
||
: ""
|
||
} </td>
|
||
<td> ${value.accident_result.de} </td>
|
||
<td> ${value.accident_result.in} </td>
|
||
</tr>
|
||
`;
|
||
|
||
$(elementRow).insertAfter("#section-preview-2-row");
|
||
|
||
arrayIndex--;
|
||
});
|
||
|
||
$("#preview-template-accident-251").text(result.data.accident_251);
|
||
if (
|
||
result.data.accident_251_code != null &&
|
||
result.data.accident_251 != "خیر"
|
||
) {
|
||
$("#preview-template-accident-251-code").text(
|
||
result.data.accident_251_code
|
||
);
|
||
} else {
|
||
$("#preview-template-accident-251-code").text("-");
|
||
}
|
||
|
||
$("#preview-template-danger-accidents-su-0").text(
|
||
result.data.danger_accidents_sum[0]
|
||
);
|
||
$("#preview-template-danger-accidents-su-1").text(
|
||
result.data.danger_accidents_sum[1]
|
||
);
|
||
//$('#preview-template-danger-accidents-su-2').text(result.data.danger_accidents_sum[2])
|
||
$("#preview-template-danger-accidents-su-3").text(
|
||
result.data.danger_accidents_sum[3]
|
||
);
|
||
$("#preview-template-danger-accidents-su-4").text(
|
||
result.data.danger_accidents_sum[4]
|
||
);
|
||
|
||
$("#preview-template-danger-speed-limit").text(result.data.speed_limit);
|
||
$("#preview-template-danger-accident-possibility").text(
|
||
result.data.accident_possibility
|
||
);
|
||
$("#preview-template-danger-geometric-desc").text(
|
||
result.data.geometric_desc
|
||
);
|
||
$("#preview-template-danger-speed-average").text(
|
||
result.data.speed_average
|
||
);
|
||
$("#preview-template-danger-road-guard").text(result.data.road_guard);
|
||
|
||
$("#preview-template-danger-accident-cause-suggest").text(
|
||
result.data.accident_cause_suggest
|
||
);
|
||
$("#preview-template-danger-accident-severity-suggest").text(
|
||
result.data.accident_severity_suggest
|
||
);
|
||
|
||
$("#preview-template-danger-correction-plan-done").text(
|
||
result.data.correction_plan_done
|
||
);
|
||
$("#preview-template-danger-correction-plan-doing").text(
|
||
result.data.correction_plan_doing
|
||
);
|
||
$("#preview-template-danger-correction-plan-doing-desc").text(
|
||
result.data.correction_plan_doing_desc
|
||
);
|
||
$("#preview-template-danger-correction-plan-doing-suggest").text(
|
||
result.data.correction_plan_doing_suggest
|
||
);
|
||
|
||
$("#preview-template-danger-accident-cause").text(
|
||
result.data.accident_cause
|
||
);
|
||
$("#preview-template-danger-accident-severity").text(
|
||
result.data.accident_severity
|
||
);
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
},
|
||
});
|
||
});
|
||
|
||
function showPrintPDF() {
|
||
window.open("https://rms.rmto.ir/webapi/danger-point/" + idkol + "/preview/print", "_blank");
|
||
}
|
||
|
||
function setmapshow(startlat, startlng) {
|
||
mapshow.setView([startlat, startlng], 9);
|
||
console.log(startlat, startlng);
|
||
startAbrarMarkershow.setLatLng([startlat, startlng]);
|
||
}
|
||
|
||
function creatmapshow(startlat, startlng) {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
mapshow = L.map("abrar-map-show", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([startlat, startlng], 9);
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
mapshow
|
||
);
|
||
startAbrarMarkershow = new L.marker(L.latLng(startlat, startlng), {
|
||
icon: startAbrarDivIcon,
|
||
}).addTo(mapshow);
|
||
|
||
// startAbrarMarkershow.setLatLng(L.latLng(startlat, startlng))
|
||
|
||
// mapshow.on('move', function () {
|
||
// if (!isSetStartAbrarMarkershow) {
|
||
// startAbrarMarkershow.setLatLng(L.latLng(mapshow.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-set').addClass('pin-move');
|
||
// }
|
||
// });
|
||
|
||
// mapshow.on('moveend', function () {
|
||
// if (!isSetStartAbrarMarkershow) {
|
||
|
||
// startAbrarMarkershow.setLatLng(L.latLng(mapshow.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-move pin-set');
|
||
// }
|
||
// });
|
||
}
|
||
|
||
$("#example").on("click", "button.details-control", function() {
|
||
// console.log("hi")
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
statusrow = row.data().status;
|
||
$("#province-idedit").removeClass("is-invalid");
|
||
$("#mehvar-type").removeClass("is-invalid");
|
||
$("#mehvarnamesub").removeClass("is-invalid");
|
||
$("#firstroad").removeClass("is-invalid");
|
||
$("#lastroad").removeClass("is-invalid");
|
||
$("#distancesub").removeClass("is-invalid");
|
||
$("#localnamesub").removeClass("is-invalid");
|
||
// $('input[name=abrar-project-latlng-startt]').removeClass("is-invalid-input")
|
||
$("input[name=abrar-project-latlng-startt]").removeClass("is-invalid");
|
||
|
||
$("input[name=abrar-project-latlng-startt]").val("");
|
||
$("#stepModaledit").modal("show");
|
||
$("[data-mask]").inputmask();
|
||
lateditt = row.data().lat_lng[0];
|
||
lngeditt = row.data().lat_lng[1];
|
||
$("#mehvarnamesub1").val(row.data().axis_name);
|
||
$("#firstroad1").val(row.data().axis_start);
|
||
$("#lastroad1").val(row.data().axis_end);
|
||
$("#mehvar-type1").val(row.data().axis_type);
|
||
$("#distancesub1").val(row.data().distance_axis_start);
|
||
$("#localnamesub1").val(row.data().local_name);
|
||
showprovincebutton(row.data().province.id);
|
||
setTimeout(() => {
|
||
if (mapedit == null) {
|
||
creatmapedit(row.data().lat_lng);
|
||
} else {
|
||
setmapviewedit(row.data().lat_lng[0], row.data().lat_lng[1]);
|
||
setTimeout(() => {
|
||
checkStartMarkerValidationedit(false, true);
|
||
}, 25);
|
||
}
|
||
}, 200);
|
||
$("#abrar-edit-card-edit input[name=abrar-project-latlng-startt]").on(
|
||
"keyup",
|
||
function() {
|
||
checkStartMarkerValidationedit();
|
||
}
|
||
);
|
||
restrictInputOtherThanArabic($("#mehvarnamesub1"));
|
||
restrictInputOtherThanArabic($("#firstroad1"));
|
||
restrictInputOtherThanArabic($("#lastroad1"));
|
||
restrictInputOtherThanArabic($("#mehvar-type1"));
|
||
restrictInputOtherThanArabic($("#distancesub1"));
|
||
restrictInputOtherThanArabic($("#localnamesub1"));
|
||
});
|
||
$("#example").on("click", "button.historic", function() {
|
||
$("#dangersecond-mainshow").css("display", "block");
|
||
$("#see-danger").css("display", "none");
|
||
$("#see-danger2").css("display", "none");
|
||
$("#see-danger3").css("display", "none");
|
||
scrolldownarzyabi();
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
statusrow = row.data().status;
|
||
tablesecond = $("#examplee").DataTable({
|
||
dom: "lBfrtip",
|
||
destroy: true,
|
||
// "pagingType": "full_numbers",
|
||
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, "asc"][(1, "asc")],
|
||
[2, "desc"],
|
||
[3, "desc"],
|
||
[4, "desc"]
|
||
],
|
||
order: [
|
||
[0, "desc"]
|
||
],
|
||
processing: true,
|
||
ajax: {
|
||
url: "https://rms.rmto.ir/webapi/danger-point/" + idkol + "/getacclist",
|
||
type: "GET",
|
||
dataSrc: function(json) {
|
||
|
||
|
||
// console.log("json start");
|
||
// console.log(idkol)
|
||
// console.log(json.data);
|
||
// console.log("json end");
|
||
|
||
// if (json.data.length > 19) {
|
||
// $("#point-addsecond")
|
||
// .attr("disabled", true)
|
||
// .removeClass("btn-success");
|
||
// } else {
|
||
// $("#point-addsecond").attr("disabled", false).addClass("btn-success");
|
||
// }
|
||
|
||
console.log("idkol", idkol)
|
||
console.log("test", json.data)
|
||
return json.data;
|
||
},
|
||
},
|
||
columns: [{
|
||
className: "text-center",
|
||
data: null,
|
||
render: function(data, type, row, meta) {
|
||
// console.log(meta.row);
|
||
return meta.row + 1;
|
||
},
|
||
},
|
||
{
|
||
data: "serial_number",
|
||
className: "text-center",
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
// console.log(data.accident_date);
|
||
return data.accident_date.substring(8);
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
// console.log(data.accident_date);
|
||
return data.accident_date.substring(5, 7);
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
// console.log(data.accident_date);
|
||
return data.accident_date.substring(2, 4);
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.day == "1") {
|
||
return "شنبه";
|
||
} else if (data.day == "2") {
|
||
return "یکشنبه";
|
||
} else if (data.day == "3") {
|
||
return "دوشنبه";
|
||
} else if (data.day == "4") {
|
||
return "سهشنبه";
|
||
} else if (data.day == "5") {
|
||
return "چهارشنبه";
|
||
} else if (data.day == "6") {
|
||
return "پنجشنبه";
|
||
} else {
|
||
return "جمعه";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: "time",
|
||
className: "text-center",
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.accident_direction == "1") {
|
||
return `<i class="fa fa-check" aria-hidden="true"></i>`;
|
||
} else {
|
||
return "";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.accident_direction == "2") {
|
||
return `<i class="fa fa-check" aria-hidden="true"></i>`;
|
||
} else {
|
||
return "";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.collision_type == 1) {
|
||
return "رخ به رخ";
|
||
} else if ((data.collision_type == 2)) {
|
||
return "واژگونی";
|
||
} else if ((data.collision_type == 3)) {
|
||
return "جلو به عقب";
|
||
} else if ((data.collision_type == 4)) {
|
||
return "جلو به پهلو";
|
||
} else if ((data.collision_type == 5)) {
|
||
return "برخورد با شی ثابت";
|
||
} else {
|
||
return "برخورد با عابر";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.bi;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.pa;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.an;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.ob;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.li;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_factors.he;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.accident_type == "1") {
|
||
return `<i class="fa fa-check" aria-hidden="true"></i>`;
|
||
} else {
|
||
return "";
|
||
}
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
if (data.accident_type == "2") {
|
||
return `<i class="fa fa-check" aria-hidden="true"></i>`;
|
||
} else {
|
||
return "";
|
||
}
|
||
},
|
||
},
|
||
//farsam change start
|
||
// {
|
||
// data: null,
|
||
// className: "text-center",
|
||
// render: function (data, type, row) {
|
||
// if (data.accident_type == "3") {
|
||
// return `<i class="fa fa-check" aria-hidden="true"></i>`;
|
||
// } else {
|
||
// return "";
|
||
// }
|
||
// },
|
||
// width: 10,
|
||
// },
|
||
//farsam change end
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_result.in;
|
||
},
|
||
},
|
||
{
|
||
data: null,
|
||
className: "text-center",
|
||
render: function(data, type, row) {
|
||
return data.accident_result.de;
|
||
},
|
||
},
|
||
{
|
||
className: "text-center",
|
||
orderable: false,
|
||
data: null,
|
||
render: function(data, type, row) {
|
||
// console.log(meta.row);
|
||
if (statusrow == 0) {
|
||
return '<button class="btn btn-danger btn-sm editor details-controlEdit " title="ویرایش"><i class="fa fa-edit"></i></button>' +
|
||
" " +
|
||
'<button class="btn btn-sm btn-danger tarikhchedel" title=" حذف " style="width:28px ;background-color: #0062cc;border-color: #005cbf;color: #ffffff;"><i class="fa fa-trash"></i></button> ';
|
||
|
||
} else {
|
||
return '<button class="btn btn-danger btn-sm editor details-controlEdit " title="ویرایش"><i class="fa fa-edit"></i></button>'
|
||
|
||
}
|
||
|
||
},
|
||
},
|
||
],
|
||
|
||
buttons: [{
|
||
extend: "excelHtml5",
|
||
title: "Excel",
|
||
text: "خروجی به اکسل",
|
||
messageTop: " تاریخچه تصادفات نقطه دارای تصادف ",
|
||
exportOptions: {
|
||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||
},
|
||
}, ],
|
||
|
||
initComplete: function(settings, json) {},
|
||
});
|
||
});
|
||
$("#example").on("click", "button.watchdata", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
statusrow = row.data().status;
|
||
$("[data-mask]").inputmask();
|
||
|
||
$("#danger-point1").prop("checked", false);
|
||
$("#danger-point2").prop("checked", false);
|
||
$("#rokhberokh2").prop("checked", false);
|
||
$("#rokhberokh1").prop("checked", false);
|
||
$("#hefaz1").prop("checked", false);
|
||
$("#hefaz2").prop("checked", false);
|
||
// is-invalid
|
||
$("#sppedmid").removeClass("is-invalid");
|
||
$("#speedtest").removeClass("is-invalid");
|
||
$("#hendesi").removeClass("is-invalid");
|
||
$("#pointcode").removeClass("is-invalid");
|
||
$(".rokhberokhlabel1").css("color", "rgba(0, 0, 0, 0.5)");
|
||
$(".rokhberokhlabel2").css("color", "rgba(0, 0, 0, 0.5)");
|
||
$("#risheerae").removeClass("is-invalid");
|
||
$(".risherealabel").css("color", "rgba(0, 0, 0, 0.5)");
|
||
$(".acclabel1").css("color", "rgba(0, 0, 0, 0.5)");
|
||
$("#accarea").removeClass("is-invalid");
|
||
$("#tarheeslahi").removeClass("is-invalid");
|
||
$("#dardasteejra").removeClass("is-invalid");
|
||
$("#sumery").removeClass("is-invalid");
|
||
$("#sugesttarh").removeClass("is-invalid");
|
||
|
||
for (var i = 0; i < 25; i++) {
|
||
$("#rishe" + i).prop("checked", false);
|
||
}
|
||
for (var i = 0; i < 8; i++) {
|
||
$("#acc" + i).prop("checked", false);
|
||
}
|
||
$("#dangersecond-mainshow").css("display", "none");
|
||
|
||
$("#see-danger").css("display", "block");
|
||
$("#see-danger2").css("display", "none");
|
||
$("#see-danger3").css("display", "none");
|
||
|
||
scrolldown();
|
||
|
||
accident_251 = row.data().accident_251;
|
||
// console.log("|accident_251", accident_251);
|
||
accident_251_code = row.data().accident_251_code;
|
||
speed_limit = row.data().speed_limit;
|
||
speed_average = row.data().speed_average;
|
||
accident_possibility = row.data().accident_possibility;
|
||
road_guard = row.data().road_guard;
|
||
geometric_desc = row.data().geometric_desc;
|
||
accident_cause = row.data().accident_cause;
|
||
accident_cause_suggest = row.data().accident_cause_suggest;
|
||
accident_severity = row.data().accident_severity;
|
||
accident_severity_suggest = row.data().accident_severity_suggest;
|
||
correction_plan_done = row.data().correction_plan_done;
|
||
correction_plan_doing = row.data().correction_plan_doing;
|
||
correction_plan_doing_desc = row.data().correction_plan_doing_desc;
|
||
correction_plan_doing_suggest = row.data().correction_plan_doing_suggest;
|
||
if (accident_251 == 0) {
|
||
$("#danger-point2").prop("checked", true);
|
||
} else if (accident_251 == 1) {
|
||
$("#danger-point1").prop("checked", true);
|
||
$("#pointcode").attr("disabled", false);
|
||
}
|
||
|
||
if (accident_possibility == 0) {
|
||
$("#rokhberokh2").prop("checked", true);
|
||
} else if (accident_possibility == 1) {
|
||
$("#rokhberokh1").prop("checked", true);
|
||
}
|
||
|
||
if (road_guard == 0) {
|
||
$("#hefaz2").prop("checked", true);
|
||
} else if (road_guard == 1) {
|
||
$("#hefaz1").prop("checked", true);
|
||
}
|
||
|
||
if (accident_cause != null) {
|
||
for (var i = 0; i < accident_cause.length; i++) {
|
||
$("#rishe" + accident_cause[i]).prop("checked", true);
|
||
}
|
||
}
|
||
|
||
if (accident_severity != null) {
|
||
for (var i = 0; i < accident_severity.length; i++) {
|
||
$("#acc" + accident_severity[i]).prop("checked", true);
|
||
}
|
||
}
|
||
|
||
$("#pointcode").val(accident_251_code);
|
||
$("#speedtest").val(speed_limit);
|
||
$("#sppedmid").val(speed_average);
|
||
$("#sppedmid").val(speed_average);
|
||
$("#hendesi").val(geometric_desc);
|
||
if (accident_cause != null) {
|
||
$("#risheerae").val(accident_cause_suggest);
|
||
$("#risheerae").attr("disabled", false);
|
||
}
|
||
if (accident_severity != null) {
|
||
$("#accarea").val(accident_severity_suggest);
|
||
$("#accarea").attr("disabled", false);
|
||
}
|
||
$("#tarheeslahi").val(correction_plan_done);
|
||
$("#dardasteejra").val(correction_plan_doing);
|
||
$("#sumery").val(correction_plan_doing_desc);
|
||
$("#sugesttarh").val(correction_plan_doing_suggest);
|
||
restrictInputOtherThanArabic($("#tarheeslahi"));
|
||
restrictInputOtherThanArabic($("#dardasteejra"));
|
||
restrictInputOtherThanArabic($("#sumery"));
|
||
restrictInputOtherThanArabic($("#tarheeslahi"));
|
||
restrictInputOtherThanArabic($("#sugesttarh"));
|
||
restrictInputOtherThanArabic($("#risheerae"));
|
||
restrictInputOtherThanArabic($("#accarea"));
|
||
});
|
||
|
||
$("#example").on("click", "button.watchdata", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = table.row(tr);
|
||
idkol = row.data().id;
|
||
$("#danger-point1").prop("checked", false);
|
||
$("#danger-point2").prop("checked", false);
|
||
$("#rokhberokh2").prop("checked", false);
|
||
$("#rokhberokh1").prop("checked", false);
|
||
$("#hefaz1").prop("checked", false);
|
||
$("#hefaz2").prop("checked", false);
|
||
for (var i = 0; i < 25; i++) {
|
||
$("#rishe" + i).prop("checked", false);
|
||
}
|
||
for (var i = 0; i < 8; i++) {
|
||
$("#acc" + i).prop("checked", false);
|
||
}
|
||
$("#dangersecond-mainshow").css("display", "none");
|
||
|
||
$("#see-danger").css("display", "block");
|
||
scrolldown();
|
||
|
||
accident_251 = row.data().accident_251;
|
||
console.log("|accident_251", accident_251);
|
||
accident_251_code = row.data().accident_251_code;
|
||
speed_limit = row.data().speed_limit;
|
||
speed_average = row.data().speed_average;
|
||
accident_possibility = row.data().accident_possibility;
|
||
road_guard = row.data().road_guard;
|
||
geometric_desc = row.data().geometric_desc;
|
||
accident_cause = row.data().accident_cause;
|
||
accident_cause_suggest = row.data().accident_cause_suggest;
|
||
accident_severity = row.data().accident_severity;
|
||
accident_severity_suggest = row.data().accident_severity_suggest;
|
||
correction_plan_done = row.data().correction_plan_done;
|
||
correction_plan_doing = row.data().correction_plan_doing;
|
||
correction_plan_doing_desc = row.data().correction_plan_doing_desc;
|
||
correction_plan_doing_suggest = row.data().correction_plan_doing_suggest;
|
||
if (accident_251 == 0) {
|
||
$("#danger-point2").prop("checked", true);
|
||
} else if (accident_251 == 1) {
|
||
$("#danger-point1").prop("checked", true);
|
||
$("#pointcode").attr("disabled", false);
|
||
}
|
||
|
||
if (accident_possibility == 0) {
|
||
$("#rokhberokh2").prop("checked", true);
|
||
} else if (accident_possibility == 1) {
|
||
$("#rokhberokh1").prop("checked", true);
|
||
}
|
||
|
||
if (road_guard == 0) {
|
||
$("#hefaz2").prop("checked", true);
|
||
} else if (road_guard == 1) {
|
||
$("#hefaz1").prop("checked", true);
|
||
}
|
||
|
||
if (accident_cause != null) {
|
||
for (var i = 0; i < accident_cause.length; i++) {
|
||
$("#rishe" + accident_cause[i]).prop("checked", true);
|
||
}
|
||
}
|
||
|
||
if (accident_severity != null) {
|
||
for (var i = 0; i < accident_severity.length; i++) {
|
||
$("#acc" + accident_severity[i]).prop("checked", true);
|
||
}
|
||
}
|
||
|
||
$("#pointcode").val(accident_251_code);
|
||
$("#speedtest").val(speed_limit);
|
||
$("#sppedmid").val(speed_average);
|
||
$("#sppedmid").val(speed_average);
|
||
$("#hendesi").val(geometric_desc);
|
||
if (accident_cause != null) {
|
||
$("#risheerae").val(accident_cause_suggest);
|
||
$("#risheerae").attr("disabled", false);
|
||
}
|
||
if (accident_severity != null) {
|
||
$("#accarea").val(accident_severity_suggest);
|
||
$("#accarea").attr("disabled", false);
|
||
}
|
||
$("#tarheeslahi").val(correction_plan_done);
|
||
$("#dardasteejra").val(correction_plan_doing);
|
||
$("#sumery").val(correction_plan_doing_desc);
|
||
$("#sugesttarh").val(correction_plan_doing_suggest);
|
||
restrictInputOtherThanArabic($("#tarheeslahi"));
|
||
restrictInputOtherThanArabic($("#dardasteejra"));
|
||
restrictInputOtherThanArabic($("#sumery"));
|
||
restrictInputOtherThanArabic($("#tarheeslahi"));
|
||
restrictInputOtherThanArabic($("#sugesttarh"));
|
||
restrictInputOtherThanArabic($("#risheerae"));
|
||
restrictInputOtherThanArabic($("#accarea"));
|
||
});
|
||
$("#examplee").on("click", "button.details-controlEdit", function() {
|
||
// console.log("hi")
|
||
perDatePicker = $("#datePickEdit").persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
autoClose: true,
|
||
initialValue: true,
|
||
initialValueType: "persian",
|
||
|
||
onSelect: function(unix) {
|
||
weekendDay = perDatePicker.getState().selected.dateObject.State.persian
|
||
.weekday;
|
||
|
||
let weekDayP = null;
|
||
|
||
switch (weekendDay) {
|
||
case 1:
|
||
{
|
||
weekDayP = "شنبه";
|
||
break;
|
||
}
|
||
case 2:
|
||
{
|
||
weekDayP = "یکشنبه";
|
||
break;
|
||
}
|
||
case 3:
|
||
{
|
||
weekDayP = "دوشنبه";
|
||
break;
|
||
}
|
||
case 4:
|
||
{
|
||
weekDayP = "سه شنبه";
|
||
break;
|
||
}
|
||
case 5:
|
||
{
|
||
weekDayP = "چهارشنبه";
|
||
break;
|
||
}
|
||
case 6:
|
||
{
|
||
weekDayP = "پنج شنبه";
|
||
break;
|
||
}
|
||
case 7:
|
||
{
|
||
weekDayP = "جمعه";
|
||
}
|
||
}
|
||
|
||
$("#weekendDayEdit").val(weekDayP);
|
||
},
|
||
});
|
||
|
||
perTimePicker = $("#occurTimeEdit").persianDatepicker({
|
||
format: "HH:mm",
|
||
initialValue: true,
|
||
onlyTimePicker: true,
|
||
onSelect: function(unix) {
|
||
$("#occurTimeEdit").removeClass("is-invalid");
|
||
},
|
||
timePicker: {
|
||
second: {
|
||
enabled: false,
|
||
},
|
||
},
|
||
});
|
||
|
||
|
||
$("#bikeMotorEdit").keypress(function(evt) {
|
||
|
||
if (($("#bikeMotorEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#passerEdit").keypress(function(evt) {
|
||
|
||
if (($("#passerEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#animalEdit").keypress(function(evt) {
|
||
|
||
if (($("#animalEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#objectEdit").keypress(function(evt) {
|
||
|
||
if (($("#objectEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#lightVehicleEdit").keypress(function(evt) {
|
||
|
||
if (($("#lightVehicleEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#heavyVehicleEdit").keypress(function(evt) {
|
||
|
||
if (($("#heavyVehicleEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#injuredNumberEdit").keypress(function(evt) {
|
||
|
||
if (($("#injuredNumberEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#deathNumberEdit").keypress(function(evt) {
|
||
|
||
if (($("#deathNumberEdit").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
|
||
|
||
$(".accidentTypooEdit").change(function() {
|
||
if ($("#deathEdit").is(":checked")) {
|
||
$("#deathNumberEdit").prop("disabled", false);
|
||
$("#deathNumberEdit").val("1");
|
||
} else {
|
||
$("#deathNumberEdit").prop("disabled", true);
|
||
$("#deathNumberEdit").val(undefined);
|
||
deathNumber = 0;
|
||
}
|
||
});
|
||
|
||
showmodalsecondEditsecond();
|
||
$("#serialNumEdit").removeClass("is-invalid");
|
||
$("#collisionTypeEdit").removeClass("is-invalid");
|
||
|
||
$("#vehicleDirEdit").removeClass("is-invalid");
|
||
|
||
$("#injuredNumberEdit").removeClass("is-invalid");
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
|
||
var tr = $(this).closest("tr");
|
||
var row = tablesecond.row(tr);
|
||
serialNumberKeep = row.data().serial_number;
|
||
$("#serialNumEdit").val(row.data().serial_number);
|
||
$("#datePickEdit").val(row.data().accident_date);
|
||
|
||
let weekDayP = null;
|
||
switch (row.data().day) {
|
||
case 1:
|
||
{
|
||
weekDayP = "شنبه";
|
||
break;
|
||
}
|
||
case 2:
|
||
{
|
||
weekDayP = "یکشنبه";
|
||
break;
|
||
}
|
||
case 3:
|
||
{
|
||
weekDayP = "دوشنبه";
|
||
break;
|
||
}
|
||
case 4:
|
||
{
|
||
weekDayP = "سه شنبه";
|
||
break;
|
||
}
|
||
case 5:
|
||
{
|
||
weekDayP = "چهارشنبه";
|
||
break;
|
||
}
|
||
case 6:
|
||
{
|
||
weekDayP = "پنج شنبه";
|
||
break;
|
||
}
|
||
case 7:
|
||
{
|
||
weekDayP = "جمعه";
|
||
}
|
||
}
|
||
$("#weekendDayEdit").val(weekDayP);
|
||
weekendDay = row.data().day;
|
||
|
||
restrictInputOtherThanArabic($("#collisionTypeEdit"));
|
||
|
||
$("#serialNumEdit").keypress(function() {
|
||
$("#serialNumEdit").removeClass("is-invalid");
|
||
});
|
||
$("#collisionTypeEdit").change(function() {
|
||
$("#collisionTypeEdit").removeClass("is-invalid");
|
||
});
|
||
$("#vehicleDirEdit").change(function() {
|
||
$("#vehicleDirEdit").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#injuredNumberEdit").change(function() {
|
||
$("#injuredNumberEdit").removeClass("is-invalid");
|
||
});
|
||
$("#injuryEdit").change(function() {
|
||
// $(".accidentTypoo").removeClass("not-valid");
|
||
$("#injuredNumberEdit").removeClass("is-invalid");
|
||
});
|
||
$("#deathEdit").change(function() {
|
||
// $(".accidentTypoo").removeClass("not-valid");
|
||
$("#injuredNumberEdit").removeClass("is-invalid");
|
||
});
|
||
$("#bikeMotorEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
$("#passerEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
$("#animalEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
$("#objectEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
$("#lightVehicleEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
$("#heavyVehicleEdit").change(function() {
|
||
$("#bikeMotorEdit").removeClass("is-invalid");
|
||
$("#passerEdit").removeClass("is-invalid");
|
||
$("#animalEdit").removeClass("is-invalid");
|
||
$("#objectEdit").removeClass("is-invalid");
|
||
$("#lightVehicleEdit").removeClass("is-invalid");
|
||
$("#heavyVehicleEdit").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#occurTimeEdit").val(row.data().time);
|
||
$("#vehicleDirEdit").val(row.data().accident_direction);
|
||
$("#collisionTypeEdit").val(row.data().collision_type);
|
||
$("#bikeMotorEdit").val(row.data().accident_factors.bi);
|
||
$("#passerEdit").val(row.data().accident_factors.pa);
|
||
$("#animalEdit").val(row.data().accident_factors.an);
|
||
$("#objectEdit").val(row.data().accident_factors.ob);
|
||
$("#lightVehicleEdit").val(row.data().accident_factors.li);
|
||
$("#heavyVehicleEdit").val(row.data().accident_factors.he);
|
||
|
||
if (row.data().accident_type == "1") {
|
||
$("#injuryEdit").prop("checked", true);
|
||
} else {
|
||
$("#deathEdit").prop("checked", true);
|
||
|
||
$("#deathNumberEdit").prop("disabled", false);
|
||
}
|
||
$("#deathNumberEdit").val(row.data().accident_result.de);
|
||
$("#injuredNumberEdit").val(row.data().accident_result.in);
|
||
|
||
$(".cancel").on("click", function() {
|
||
$("#stepModalaccidentEdit").modal("hide");
|
||
});
|
||
|
||
$("#submitNewRowEdit").on("click", function() {
|
||
injury = $("#injuryEdit").is(":checked");
|
||
death = $("#deathEdit").is(":checked");
|
||
|
||
getDataEdit();
|
||
if (
|
||
$("#serialNumEdit").val() == undefined ||
|
||
$("#serialNumEdit").val() == "" ||
|
||
$("#occurTimeEdit").val() == undefined ||
|
||
$("#occurTimeEdit").val() == "" ||
|
||
$("#collisionTypeEdit").val() == undefined ||
|
||
$("#collisionTypeEdit").val() == 0 ||
|
||
$("#vehicleDirEdit").val() == undefined ||
|
||
$("#vehicleDirEdit").val() == 0 ||
|
||
(injury && $("#injuredNumberEdit").val() < 1) ||
|
||
($("#bikeMotorEdit").val() < 1 &&
|
||
$("#passerEdit").val() < 1 &&
|
||
$("#animalEdit").val() < 1 &&
|
||
$("#objectEdit").val() < 1 &&
|
||
$("#lightVehicleEdit").val() < 1 &&
|
||
$("#heavyVehicleEdit").val() < 1)
|
||
) {
|
||
if (
|
||
$("#serialNumEdit").val() == undefined ||
|
||
$("#serialNumEdit").val() == ""
|
||
) {
|
||
$("#serialNumEdit").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#occurTimeEdit").val() == undefined ||
|
||
$("#occurTimeEdit").val() == ""
|
||
) {
|
||
$("#occurTimeEdit").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#collisionTypeEdit").val() == undefined ||
|
||
$("#collisionTypeEdit").val() == 0
|
||
) {
|
||
$("#collisionTypeEdit").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#vehicleDirEdit").val() == undefined ||
|
||
$("#vehicleDirEdit").val() == 0
|
||
) {
|
||
$("#vehicleDirEdit").addClass("is-invalid");
|
||
}
|
||
if (injury && $("#injuredNumberEdit").val() < 1) {
|
||
$("#injuredNumberEdit").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#bikeMotorEdit").val() < 1 &&
|
||
$("#passerEdit").val() < 1 &&
|
||
$("#animalEdit").val() < 1 &&
|
||
$("#objectEdit").val() < 1 &&
|
||
$("#lightVehicleEdit").val() < 1 &&
|
||
$("#heavyVehicleEdit").val() < 1
|
||
) {
|
||
$("#bikeMotorEdit").addClass("is-invalid");
|
||
$("#passerEdit").addClass("is-invalid");
|
||
$("#animalEdit").addClass("is-invalid");
|
||
$("#objectEdit").addClass("is-invalid");
|
||
$("#lightVehicleEdit").addClass("is-invalid");
|
||
$("#heavyVehicleEdit").addClass("is-invalid");
|
||
}
|
||
} else {
|
||
submitajax(true, row.data().id);
|
||
}
|
||
});
|
||
|
||
$("#datePickEdit").change(function() {
|
||
alert("The text has been changed.");
|
||
});
|
||
});
|
||
$("#examplee").on("click", "button.tarikhchedel", function() {
|
||
var tr = $(this).closest("tr");
|
||
var row = tablesecond.row(tr);
|
||
var acc_id = row.data().id;
|
||
|
||
formData = new FormData();
|
||
formData.append("danger-id", idkol);
|
||
formData.append("acc-id", acc_id);
|
||
|
||
for (var value of formData.values()) {
|
||
console.log("value", value);
|
||
}
|
||
console.log("danger-id", idkol, acc_id)
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/delete/acc",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت حذف شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload()
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
// todo edit
|
||
})
|
||
|
||
function getrowdata() {
|
||
$(".cancel").on("click", function() {
|
||
$("#stepModalaccident").modal("hide");
|
||
});
|
||
|
||
$("#serialNum").removeClass("is-invalid");
|
||
$("#datePick").removeClass("is-invalid");
|
||
$("#collisionType").removeClass("is-invalid");
|
||
$("#occurTime").removeClass("is-invalid");
|
||
$("#vehicleDir").removeClass("is-invalid");
|
||
$("#injuredNumber").removeClass("is-invalid");
|
||
$("#accidentTypeTitle").removeClass("not-valid");
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
|
||
$("#submitNewRow").on("click", function() {
|
||
// damage = $("#damage").is(":checked");
|
||
|
||
injury = $("#injury").is(":checked");
|
||
death = $("#death").is(":checked");
|
||
|
||
getData();
|
||
|
||
if (
|
||
$("#serialNum").val() == undefined ||
|
||
$("#serialNum").val() == "" ||
|
||
$("#occurTime").val() == undefined ||
|
||
$("#occurTime").val() == "" ||
|
||
$("#collisionType").val() == undefined ||
|
||
$("#collisionType").val() == 0 ||
|
||
$("#vehicleDir").val() == undefined ||
|
||
$("#vehicleDir").val() == 0 ||
|
||
(!injury && !death) ||
|
||
$("#datePick").val() == undefined ||
|
||
$("#datePick").val() == "" ||
|
||
$("#weekendDay").val() == undefined ||
|
||
$("#weekendDay").val() == "" ||
|
||
(injury && $("#injuredNumber").val() < 1) ||
|
||
($("#bikeMotor").val() < 1 &&
|
||
$("#passer").val() < 1 &&
|
||
$("#animal").val() < 1 &&
|
||
$("#object").val() < 1 &&
|
||
$("#lightVehicle").val() < 1 &&
|
||
$("#heavyVehicle").val() < 1)
|
||
) {
|
||
if ($("#serialNum").val() == undefined || $("#serialNum").val() == "") {
|
||
$("#serialNum").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#collisionType").val() == undefined ||
|
||
$("#collisionType").val() == 0
|
||
) {
|
||
$("#collisionType").addClass("is-invalid");
|
||
}
|
||
if ($("#vehicleDir").val() == undefined || $("#vehicleDir").val() == 0) {
|
||
$("#vehicleDir").addClass("is-invalid");
|
||
}
|
||
if (!injury && !death) {
|
||
$("#accidentTypeTitle").addClass("not-valid");
|
||
}
|
||
if ($("#datePick").val() == undefined || $("#datePick").val() == "") {
|
||
$("#datePick").addClass("is-invalid");
|
||
}
|
||
if ($("#occurTime").val() == undefined || $("#occurTime").val() == "") {
|
||
$("#occurTime").addClass("is-invalid");
|
||
}
|
||
if (injury && $("#injuredNumber").val() < 1) {
|
||
$("#injuredNumber").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#bikeMotor").val() < 1 &&
|
||
$("#passer").val() < 1 &&
|
||
$("#animal").val() < 1 &&
|
||
$("#object").val() < 1 &&
|
||
$("#lightVehicle").val() < 1 &&
|
||
$("#heavyVehicle").val() < 1
|
||
) {
|
||
$("#bikeMotor").addClass("is-invalid");
|
||
$("#passer").addClass("is-invalid");
|
||
$("#animal").addClass("is-invalid");
|
||
$("#object").addClass("is-invalid");
|
||
$("#lightVehicle").addClass("is-invalid");
|
||
$("#heavyVehicle").addClass("is-invalid");
|
||
}
|
||
} else {
|
||
submitajax(false, null);
|
||
}
|
||
});
|
||
}
|
||
|
||
function getData() {
|
||
// perDatePicker = $('#datePick').persianDatepicker({
|
||
// format: 'YYYY/MM/DD',
|
||
// autoClose: true,
|
||
// initialValue: true,
|
||
// initialValueType: 'persian'
|
||
// });
|
||
|
||
serialNumber = $("#serialNum").val();
|
||
|
||
datePick =
|
||
perDatePicker.getState().selected.year + "-";
|
||
datePick +=
|
||
perDatePicker.getState().selected.month < 10 ?
|
||
"0" + perDatePicker.getState().selected.month :
|
||
perDatePicker.getState().selected.month;
|
||
datePick += "-";
|
||
datePick +=
|
||
perDatePicker.getState().selected.date < 10 ?
|
||
"0" + perDatePicker.getState().selected.date :
|
||
perDatePicker.getState().selected.date;
|
||
|
||
//weekendDay = $("#weekendDay").val();
|
||
occurTime = $("#occurTime").val();
|
||
vehicleDir = $("#vehicleDir").val();
|
||
collisionType = $("#collisionType").val();
|
||
|
||
console.log("manamaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||
console.log($("#bikeMotor").val().charAt(0));
|
||
|
||
bikeMotor = $("#bikeMotor").val().charAt(0) == 0 ? 0 : $("#bikeMotor").val();
|
||
passer = $("#passer").val().charAt(0) == 0 ? 0 : $("#passer").val();
|
||
animal = $("#animal").val().charAt(0) == 0 ? 0 : $("#animal").val();
|
||
object = $("#object").val().charAt(0) == 0 ? 0 : $("#object").val();
|
||
lightVehicle = $("#lightVehicle").val().charAt(0) == 0 ? 0 : $("#lightVehicle").val();
|
||
heavyVehicle = $("#heavyVehicle").val().charAt(0) == 0 ? 0 : $("#heavyVehicle").val();
|
||
|
||
accidentFactors.bi = bikeMotor;
|
||
accidentFactors.pa = passer;
|
||
accidentFactors.an = animal;
|
||
accidentFactors.ob = object;
|
||
accidentFactors.li = lightVehicle;
|
||
accidentFactors.he = heavyVehicle;
|
||
|
||
injury = $("#injury").is(":checked");
|
||
death = $("#death").is(":checked");
|
||
|
||
if (injury) {
|
||
accidentType = "1";
|
||
} else {
|
||
accidentType = "2";
|
||
}
|
||
|
||
if ($("#deathNumber").val() == undefined || $("#deathNumber").val() == "" || $("#deathNumber").val().charAt(0) == 0) {
|
||
deathNumber = "0";
|
||
} else {
|
||
deathNumber = $("#deathNumber").val().charAt(0) == "0" ? "0" : $("#deathNumber").val();;
|
||
}
|
||
|
||
|
||
|
||
injuredNumber = $("#injuredNumber").val();
|
||
|
||
accidentResult.de = deathNumber;
|
||
accidentResult.in = injuredNumber;
|
||
|
||
console.log("heeeelllooooooooooo");
|
||
console.log(accidentResult.de);
|
||
|
||
console.log(serialNumber);
|
||
console.log(datePick);
|
||
console.log(weekendDay);
|
||
console.log(occurTime);
|
||
console.log(vehicleDir);
|
||
console.log(collisionType);
|
||
console.log(accidentFactors);
|
||
console.log(accidentType);
|
||
console.log(accidentResult);
|
||
}
|
||
|
||
function getDataEdit() {
|
||
serialNumber = $("#serialNumEdit").val();
|
||
console.log("testttttttttttttt");
|
||
console.log(weekendDay);
|
||
|
||
datePick =
|
||
perDatePicker.getState().selected.year + "-";
|
||
datePick +=
|
||
perDatePicker.getState().selected.month < 10 ?
|
||
"0" + perDatePicker.getState().selected.month :
|
||
perDatePicker.getState().selected.month;
|
||
datePick += "-";
|
||
datePick +=
|
||
perDatePicker.getState().selected.date < 10 ?
|
||
"0" + perDatePicker.getState().selected.date :
|
||
perDatePicker.getState().selected.date;
|
||
|
||
occurTime = $("#occurTimeEdit").val();
|
||
vehicleDir = $("#vehicleDirEdit").val();
|
||
collisionType = $("#collisionTypeEdit").val();
|
||
|
||
bikeMotor = $("#bikeMotorEdit").val().charAt(0) == 0 ? 0 : $("#bikeMotorEdit").val();
|
||
passer = $("#passerEdit").val().charAt(0) == 0 ? 0 : $("#passerEdit").val();
|
||
animal = $("#animalEdit").val().charAt(0) == 0 ? 0 : $("#animalEdit").val();
|
||
object = $("#objectEdit").val().charAt(0) == 0 ? 0 : $("#objectEdit").val();
|
||
lightVehicle = $("#lightVehicleEdit").val().charAt(0) == 0 ? 0 : $("#lightVehicleEdit").val();
|
||
heavyVehicle = $("#heavyVehicleEdit").val().charAt(0) == 0 ? 0 : $("#heavyVehicleEdit").val();
|
||
|
||
accidentFactors.bi = bikeMotor;
|
||
accidentFactors.pa = passer;
|
||
accidentFactors.an = animal;
|
||
accidentFactors.ob = object;
|
||
accidentFactors.li = lightVehicle;
|
||
accidentFactors.he = heavyVehicle;
|
||
|
||
injury = $("#injuryEdit").is(":checked");
|
||
death = $("#deathEdit").is(":checked");
|
||
|
||
if (injury) {
|
||
accidentType = "1";
|
||
} else {
|
||
accidentType = "2";
|
||
}
|
||
|
||
if (
|
||
$("#deathNumberEdit").val() == undefined ||
|
||
$("#deathNumberEdit").val() == "" || $("#deathNumberEdit").val().charAt(0) == 0
|
||
) {
|
||
deathNumber = "0";
|
||
} else {
|
||
deathNumber = $("#deathNumberEdit").val();
|
||
}
|
||
|
||
injuredNumber = $("#injuredNumberEdit").val().charAt(0) == "0" ? "0" : $("#injuredNumberEdit").val();
|
||
|
||
accidentResult.de = deathNumber;
|
||
accidentResult.in = injuredNumber;
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
function submitajax(edit, rowID) {
|
||
|
||
|
||
// console.log("sssssssssssss");
|
||
// console.log(serialNumber);
|
||
// console.log(datePick);
|
||
// console.log(weekendDay);
|
||
// console.log(occurTime);
|
||
// console.log(vehicleDir);
|
||
// console.log(collisionType);
|
||
// console.log("fuuuuu",accidentFactors);
|
||
// console.log(accidentType);
|
||
console.log(accidentResult);
|
||
// console.log("eeeeeeeeeeeeeeeeee");
|
||
// console.log("mehva", mehvarname)
|
||
// console.log("hiiiiik")
|
||
let reqUrl = "https://rms.rmto.ir/webapi/danger-point/accident";
|
||
|
||
if (edit) {
|
||
reqUrl =
|
||
"https://rms.rmto.ir/webapi/danger-point/accident/" + rowID + "/edit";
|
||
}
|
||
formData = new FormData();
|
||
|
||
formData.append("danger-id", idkol);
|
||
|
||
if (serialNumber != null && serialNumber != undefined && serialNumberKeep != serialNumber) {
|
||
formData.append("serial-number", serialNumber);
|
||
}
|
||
if (datePick != null && datePick != undefined) {
|
||
formData.append("accident-date", datePick);
|
||
}
|
||
if (weekendDay != null && weekendDay != undefined) {
|
||
formData.append("day", weekendDay);
|
||
}
|
||
if (occurTime != null && occurTime != undefined) {
|
||
formData.append("time", occurTime);
|
||
}
|
||
if (vehicleDir != null && vehicleDir != undefined && vehicleDir != 0) {
|
||
formData.append("accident-direction", vehicleDir);
|
||
}
|
||
if (
|
||
collisionType != null &&
|
||
collisionType != undefined &&
|
||
collisionType != 0
|
||
) {
|
||
formData.append("collision-type", collisionType);
|
||
}
|
||
let accidentFactorsJson = JSON.stringify(accidentFactors);
|
||
formData.append("accident-factors", accidentFactorsJson);
|
||
|
||
if (accidentType != 0) {
|
||
formData.append("accident-type", accidentType);
|
||
}
|
||
let accidentResultJson = JSON.stringify(accidentResult);
|
||
formData.append("accident-result", accidentResultJson);
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
$.ajax({
|
||
url: reqUrl,
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
// hideLoaderScreen();
|
||
ajaxcalltable();
|
||
ajaxcalltableaccident(idkol);
|
||
// Swal.fire({
|
||
// icon: "success",
|
||
// title: "با موفقیت بروزرسانی شد",
|
||
// confirmButtonText: "بستن",
|
||
// preConfirm: () => {
|
||
// location.reload();
|
||
// },
|
||
// });
|
||
// console.log("sucsseeeeeees");
|
||
// console.log(result);
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
if (error.responseJSON != undefined && error.responseJSON.errors != undefined && error.responseJSON.errors["serial-number"] != undefined) {
|
||
if (edit) {
|
||
$('#serialNumEdit').addClass('is-invalid');
|
||
$('#serialNumEdit').after(`
|
||
<div id="serialNumEditError" class="invalid-feedback">
|
||
این شماره سریال قبلا در سامانه ثبت شده است.
|
||
</div>
|
||
`)
|
||
} else {
|
||
$('#serialNum').addClass('is-invalid');
|
||
$('#serialNum').after(`
|
||
<div id="serialNumError" class="invalid-feedback">
|
||
این شماره سریال قبلا در سامانه ثبت شده است.
|
||
</div>
|
||
`)
|
||
}
|
||
}
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "پر کردن تمامی فیلد ها الزامی است",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
|
||
}
|
||
|
||
function emptyFields() {
|
||
$("#serialNum").val(undefined);
|
||
$("#datePick").val(undefined);
|
||
$("#weekendDay").val(undefined);
|
||
$("#occurTime").val(undefined);
|
||
$("#vehicleDir").val("0");
|
||
$("#collisionType").val("0");
|
||
$("#bikeMotor").val("0");
|
||
$("#passer").val("0");
|
||
$("#animal").val("0");
|
||
$("#object").val("0");
|
||
$("#lightVehicle").val("0");
|
||
$("#heavyVehicle").val("0");
|
||
$("#injury").prop("checked", false);
|
||
$("#death").prop("checked", false);
|
||
|
||
$("#injuredNumber").val("0");
|
||
$("#deathNumber").val(undefined);
|
||
|
||
serialNumber = undefined;
|
||
datePick = undefined;
|
||
weekendDay = undefined;
|
||
occurTime = undefined;
|
||
vehicleDir = "1";
|
||
collisionType = "0";
|
||
bikeMotor = "0";
|
||
passer = "0";
|
||
animal = "0";
|
||
object = "0";
|
||
lightVehicle = "0";
|
||
heavyVehicle = "0";
|
||
accidentFactors.bi = "0";
|
||
accidentFactors.pa = "0";
|
||
accidentFactors.an = "0";
|
||
accidentFactors.ob = "0";
|
||
accidentFactors.li = "0";
|
||
accidentFactors.he = "0";
|
||
accidentType = "0";
|
||
deathNumber = "0";
|
||
injuredNumber = "0";
|
||
accidentResult.de = "0";
|
||
accidentResult.in = "0";
|
||
|
||
// console.log(serialNumber);
|
||
// console.log(datePick);
|
||
// console.log(weekendDay);
|
||
// console.log(occurTime);
|
||
// console.log(vehicleDir);
|
||
// console.log(collisionType);
|
||
// console.log(accidentFactors);
|
||
// console.log(accidentType);
|
||
// console.log(accidentResult);
|
||
|
||
// }
|
||
|
||
// function getDataEdit() {
|
||
// serialNumber = $("#serialNumEdit").val()
|
||
// console.log("testttttttttttttt")
|
||
// console.log(weekendDay)
|
||
|
||
// datePick = perDatePicker.getState().selected.dateObject.State.gregorian.year + '-'
|
||
// datePick += (perDatePicker.getState().selected.dateObject.State.gregorian.month < 10) ? ('0' + perDatePicker.getState().selected.dateObject.State.gregorian.month) : perDatePicker.getState().selected.dateObject.State.gregorian.month
|
||
// datePick += '-'
|
||
// datePick += (perDatePicker.getState().selected.dateObject.State.gregorian.day < 10) ? ('0' + perDatePicker.getState().selected.dateObject.State.gregorian.day) : perDatePicker.getState().selected.dateObject.State.gregorian.day
|
||
|
||
// occurTime = $("#occurTimeEdit").val();
|
||
// vehicleDir = $("#vehicleDirEdit").val();
|
||
// collisionType = $("#collisionTypeEdit").val();
|
||
|
||
// bikeMotor = $("#bikeMotorEdit").val();
|
||
// passer = $("#passerEdit").val();
|
||
// animal = $("#animalEdit").val();
|
||
// object = $("#objectEdit").val();
|
||
// lightVehicle = $("#lightVehicleEdit").val();
|
||
// heavyVehicle = $("#heavyVehicleEdit").val();
|
||
|
||
// accidentFactors.bi = bikeMotor;
|
||
// accidentFactors.pa = passer;
|
||
// accidentFactors.an = animal;
|
||
// accidentFactors.ob = object;
|
||
// accidentFactors.li = lightVehicle;
|
||
// accidentFactors.he = heavyVehicle;
|
||
|
||
// damage = $("#damageEdit").is(":checked");
|
||
// injury = $("#injuryEdit").is(":checked");
|
||
// death = $("#deathEdit").is(":checked");
|
||
|
||
// if (damage) {
|
||
// accidentType = "1"
|
||
// }
|
||
// else if (injury) {
|
||
// accidentType = "2"
|
||
// }
|
||
// else {
|
||
// accidentType = "3"
|
||
// }
|
||
|
||
// deathNumber = $("#deathNumberEdit").val();
|
||
// injuredNumber = $("#injuredNumberEdit").val();
|
||
|
||
// accidentResult.de = deathNumber;
|
||
// accidentResult.in = injuredNumber;
|
||
}
|
||
|
||
$("#point-addsecond").on("click", function() {
|
||
|
||
emptyFields();
|
||
|
||
showmodalsecond();
|
||
perDatePicker = $("#datePick").persianDatepicker({
|
||
format: "YYYY/MM/DD",
|
||
autoClose: true,
|
||
initialValue: false,
|
||
initialValueType: "persian",
|
||
onSelect: function(unix) {
|
||
$("#datePick").removeClass("is-invalid");
|
||
weekendDay = perDatePicker.getState().selected.dateObject.State.persian
|
||
.weekday;
|
||
|
||
let weekDayP = null;
|
||
|
||
switch (weekendDay) {
|
||
case 1:
|
||
{
|
||
weekDayP = "شنبه";
|
||
break;
|
||
}
|
||
case 2:
|
||
{
|
||
weekDayP = "یکشنبه";
|
||
break;
|
||
}
|
||
case 3:
|
||
{
|
||
weekDayP = "دوشنبه";
|
||
break;
|
||
}
|
||
case 4:
|
||
{
|
||
weekDayP = "سه شنبه";
|
||
break;
|
||
}
|
||
case 5:
|
||
{
|
||
weekDayP = "چهارشنبه";
|
||
break;
|
||
}
|
||
case 6:
|
||
{
|
||
weekDayP = "پنج شنبه";
|
||
break;
|
||
}
|
||
case 7:
|
||
{
|
||
weekDayP = "جمعه";
|
||
}
|
||
}
|
||
|
||
$("#weekendDay").val(weekDayP);
|
||
},
|
||
});
|
||
|
||
perTimePicker = $("#occurTime").persianDatepicker({
|
||
format: "HH:mm",
|
||
initialValue: true,
|
||
onlyTimePicker: true,
|
||
onSelect: function(unix) {
|
||
$("#occurTime").removeClass("is-invalid");
|
||
},
|
||
timePicker: {
|
||
second: {
|
||
enabled: false,
|
||
},
|
||
},
|
||
});
|
||
|
||
// weekendDay = perDatePicker.getState().selected.dateObject.State.persian.weekday
|
||
|
||
// let weekDayP = null
|
||
|
||
// switch (weekendDay) {
|
||
// case 1: { weekDayP = "شنبه"; break }
|
||
// case 2: { weekDayP = "یکشنبه"; break }
|
||
// case 3: { weekDayP = "دوشنبه"; break }
|
||
// case 4: { weekDayP = "سه شنبه"; break }
|
||
// case 5: { weekDayP = "چهارشنبه"; break }
|
||
// case 6: { weekDayP = "پنج شنبه"; break }
|
||
// case 7: { weekDayP = "جمعه" }
|
||
// }
|
||
// console.log(weekendDay)
|
||
|
||
// $("#weekendDay").val(weekDayP)
|
||
|
||
|
||
|
||
|
||
$("#bikeMotor").keydown(function(evt) {
|
||
|
||
console.log("start")
|
||
console.log(evt.key);
|
||
console.log($("#bikeMotor").val());
|
||
console.log($("#bikeMotor").val().length);
|
||
console.log("end")
|
||
|
||
if (($("#bikeMotor").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
|
||
// evt.preventDefault();
|
||
})
|
||
$("#passer").keydown(function(evt) {
|
||
if (($("#passer").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#animal").keydown(function(evt) {
|
||
if (($("#animal").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#object").keydown(function(evt) {
|
||
if (($("#object").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#lightVehicle").keydown(function(evt) {
|
||
if (($("#lightVehicle").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#heavyVehicle").keydown(function(evt) {
|
||
if (($("#heavyVehicle").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#injuredNumber").keydown(function(evt) {
|
||
if (($("#injuredNumber").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
$("#deathNumber").keydown(function(evt) {
|
||
if (($("#deathNumber").val().length == 2) && evt.key != "Delete" && evt.key != "Backspace") {
|
||
|
||
evt.preventDefault();
|
||
|
||
}
|
||
})
|
||
|
||
|
||
|
||
restrictInputOtherThanArabic($("#collisionType"));
|
||
|
||
$("#serialNum").keypress(function() {
|
||
$("#serialNum").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#collisionType").change(function() {
|
||
$("#collisionType").removeClass("is-invalid");
|
||
});
|
||
$("#occurTime").change(function() {
|
||
$("#occurTime").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#bikeMotor").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
$("#passer").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
$("#animal").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
$("#object").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
$("#lightVehicle").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
$("#heavyVehicle").change(function() {
|
||
$("#bikeMotor").removeClass("is-invalid");
|
||
$("#passer").removeClass("is-invalid");
|
||
$("#animal").removeClass("is-invalid");
|
||
$("#object").removeClass("is-invalid");
|
||
$("#lightVehicle").removeClass("is-invalid");
|
||
$("#heavyVehicle").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#injury").change(function() {
|
||
$("#accidentTypeTitle").removeClass("not-valid");
|
||
$("#injuredNumber").removeClass("is-invalid");
|
||
});
|
||
$("#death").change(function() {
|
||
$("#accidentTypeTitle").removeClass("not-valid");
|
||
$("#injuredNumber").removeClass("is-invalid");
|
||
});
|
||
$("#injuredNumber").change(function() {
|
||
$("#injuredNumber").removeClass("is-invalid");
|
||
});
|
||
|
||
$("#vehicleDir").change(function() {
|
||
$("#vehicleDir").removeClass("is-invalid");
|
||
});
|
||
$(".accidentTypoo").change(function() {
|
||
if ($("#death").is(":checked")) {
|
||
$("#deathNumber").prop("disabled", false);
|
||
$("#deathNumber").val("1");
|
||
} else {
|
||
$("#deathNumber").prop("disabled", true);
|
||
$("#deathNumber").val(undefined);
|
||
deathNumber = 0;
|
||
}
|
||
});
|
||
|
||
//farsam body
|
||
// table.row.add($(`<tr>
|
||
// <td>_</td>
|
||
// <td><input class="form-control" id="serialNum" ></td>
|
||
// <td><input class="form-control" id="datePick" ></td>
|
||
// <td><input class="form-control" id="weekendDay" ></td>
|
||
// <td><input type="number" class="form-control" id="occurTime" name="occurTime" min="0" max="23"></td>
|
||
// <td><select class="form-control" name="vehicleDir" id="vehicleDir" ><option value="0" > انتخاب </option ><option value="1">رفت</option><option value="2">برگشت</option></select ></td>
|
||
// <td><input class="form-control" id="collisionType"></td>
|
||
// <td>
|
||
// <input type="number" id="bikeMotor" name="bikeMotor" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="bikeMotor" class"inputNumberLabelClass">دوچرخه و موتور</label></br>
|
||
// <input type="number" id="passer" name="passer" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="passer" class"inputNumberLabelClass">عابر</label></br>
|
||
// <input type="number" id="animal" name="animal" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="animal" class"inputNumberLabelClass">حیوان</label></br>
|
||
// <input type="number" id="object" name="object" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="object" class"inputNumberLabelClass">شی ثابت</label></br>
|
||
// <input type="number" id="lightVehicle" name="lightVehicle" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="lightVehicle" class"inputNumberLabelClass">وسیله نقلیه سبک</label></br>
|
||
// <input type="number" id="heavyVehicle" name="heavyVehicle" min="0" class="form-control inputNumberClass" value="0">
|
||
// <label for="heavyVehicle" class"inputNumberLabelClass">وسیله نقلیه سنگین</label>
|
||
// </td>
|
||
// <td>
|
||
// <input type="checkbox" id="damage" name="accidentType" value="0" >
|
||
// <label for="damage" >خسارتی</label></br>
|
||
// <input type="checkbox" id="injury" name="accidentType" value="1">
|
||
// <label for="injury">جرحی</label></br>
|
||
// <input type="checkbox" id="death" name="accidentType" value="2">
|
||
// <label for="death">فوتی</label>
|
||
// </td>
|
||
// <td>
|
||
// <input type="number" id="deathNumber" name="deathNumber" class="form-control inputNumberClass" value="0">
|
||
// <label for="deathNumber" class"inputNumberLabelClass">متوفی</label>
|
||
// <input type="number" id="injuredNumber" name="injuredNumber" class="form-control inputNumberClass" value="0">
|
||
// <label for="injuredNumber" class"inputNumberLabelClass">مجروح شدید</label>
|
||
// </td>
|
||
// <td>_</td></tr>
|
||
// `)[0]).draw()
|
||
// showprovinceedit()
|
||
getrowdata();
|
||
|
||
|
||
});
|
||
|
||
function showmodalsecond() {
|
||
$("#stepModalaccident").modal("show");
|
||
|
||
// $('[data-mask]').inputmask();
|
||
// setTimeout(() => {
|
||
// if (map == null) {
|
||
// creatmap();
|
||
// setTimeout(() => {
|
||
// setmapview(latadd, lngadd)
|
||
// }, 100)
|
||
// }
|
||
// else {
|
||
// setmapview(latadd, lngadd)
|
||
// }
|
||
// }, 200);
|
||
}
|
||
|
||
function showmodalsecondEditsecond() {
|
||
// console.log("test")
|
||
$("#stepModalaccidentEdit").modal("show");
|
||
}
|
||
|
||
function ajaxcalltableaccident(idkol) {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/" + idkol + "/getacclist",
|
||
type: "GET",
|
||
success: function(result) {
|
||
// console.log(result.data[0]);
|
||
$("#examplee").dataTable().fnClearTable();
|
||
$("#examplee").dataTable().fnAddData(result.data);
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
|
||
$("#stepModalaccident").modal("hide");
|
||
$("#stepModalaccidentEdit").modal("hide");
|
||
},
|
||
});
|
||
}
|
||
|
||
function scrolldownarzyabi() {
|
||
$("html, body").animate({
|
||
scrollTop: $(".uparzyabi").offset().top,
|
||
},
|
||
50
|
||
);
|
||
}
|
||
|
||
function scrolldown() {
|
||
$("html, body").animate({
|
||
scrollTop: $(".up").offset().top + 100,
|
||
},
|
||
50
|
||
);
|
||
}
|
||
|
||
function scrolldownnextsec() {
|
||
console.log($(".upnextsec").offset().top);
|
||
$("html, body").animate({
|
||
scrollTop: $(".upnextsec").offset().top + 800,
|
||
},
|
||
200
|
||
);
|
||
}
|
||
|
||
function undefineddetail(tr, row) {
|
||
if (row.child.isShown()) {
|
||
row.child.hide();
|
||
tr.removeClass("shown");
|
||
} else {
|
||
row.child(formatget(row.data())).show();
|
||
tr.addClass("shown");
|
||
datamainrow = row.data();
|
||
console.log(datamainrow);
|
||
idkol = row.data().province.id;
|
||
showprovincebutton(row.data().province.id);
|
||
$("#mehvar-type-edit" + idkol).val(row.data().axis_type);
|
||
}
|
||
}
|
||
$("#point-add").on("click", function() {
|
||
$("#province-idedit").removeClass("is-invalid");
|
||
$("#mehvar-type").removeClass("is-invalid");
|
||
$("#mehvarnamesub").removeClass("is-invalid");
|
||
$("#firstroad").removeClass("is-invalid");
|
||
$("#lastroad").removeClass("is-invalid");
|
||
$("#distancesub").removeClass("is-invalid");
|
||
$("#localnamesub").removeClass("is-invalid");
|
||
$("input[name=abrar-project-latlng-start]").removeClass("is-invalid");
|
||
|
||
$("input[name=abrar-project-latlng-start]").val("");
|
||
$("#province-idedit").val(0);
|
||
$("#mehvarnamesub").val("");
|
||
$("#firstroad").val("");
|
||
$("#lastroad").val("");
|
||
$("#mehvar-type").val(0);
|
||
$("#distancesub").val("");
|
||
$("#localnamesub").val("");
|
||
|
||
$("#stepModal").modal("show");
|
||
$("[data-mask]").inputmask();
|
||
|
||
// table.row.add($('<tr><td>_</td><td><select class="form-control" name="provincesub" id="province-idedit"></select></td><td><input class="form-control" id="mehvarnamesub"></td><td> <select class="form-control" name="mehvar-type" id="mehvar-type"><option value="0" > انتخاب </option><option value="1">آزادراه</option><option value="2">بزرگراه</option><option value="3">راه اصلی </option><option value="4">راه فرعی با عملکرد اصلی </option><option value="5">راه فرعی (درجه 1 یا 2) </option><option value="6">راه روستایی (فرعی درجه 3)</option></select></td><td><input class="form-control" name="firstroad" id="firstroad"></td><td><input class="form-control" name="lastroad" id="lastroad"></td><td><input type="number" class="form-control" name="distancesub" id="distancesub"></td><td><input class="form-control" name="localnamesub" id="localnamesub"></td><td id="datalat"><button class="btn btn-outline-info" id="datashow" onclick="showmodal()" style="width:100%"> انتخاب نقطه روی نقشه</button></td><td>1</td></tr>')[0]).draw()
|
||
showprovinceedit();
|
||
setTimeout(() => {
|
||
if (map == null) {
|
||
creatmap();
|
||
} else {
|
||
setmapview(latadd, lngadd);
|
||
}
|
||
}, 200);
|
||
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").on(
|
||
"keyup",
|
||
function() {
|
||
checkStartMarkerValidation();
|
||
}
|
||
);
|
||
|
||
restrictInputOtherThanArabic($("#mehvarnamesub"));
|
||
restrictInputOtherThanArabic($("#firstroad"));
|
||
restrictInputOtherThanArabic($("#lastroad"));
|
||
restrictInputOtherThanArabic($("#localnamesub"));
|
||
});
|
||
//dasti
|
||
function checkStartMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let startLatLngVal = $(
|
||
"#abrar-edit-card input[name=abrar-project-latlng-start]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function(e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
// console.log(startLatLng)
|
||
|
||
if (isNaN(startLatLng[0])) {
|
||
if (!forSaveData) {
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
} else {
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
}
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").val("");
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").attr(
|
||
"placeholder",
|
||
"(طول جغرافیایی) - (عرض جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (!startLatLng == 2 ||
|
||
!reg.test(startLatLng[0]) ||
|
||
!reg.test(startLatLng[1])
|
||
) {
|
||
$("#abrar-edit-card input[name=abrar-project-latlng-start]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$("#abrar-edit-card 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");
|
||
}
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
|
||
isSetStartAbrarMarker = true;
|
||
} else {
|
||
projectEditData["project-start-latlng"] = [
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6),
|
||
];
|
||
}
|
||
|
||
return true;
|
||
}
|
||
}
|
||
//dasti
|
||
function checkStartMarkerValidationedit(
|
||
forSaveData = false,
|
||
pageOnLoad = false
|
||
) {
|
||
let reg = /^([0-9]){2}\.([0-9])+$/;
|
||
let startLatLngVal = $(
|
||
"#abrar-edit-card-edit input[name=abrar-project-latlng-startt]"
|
||
)
|
||
.val()
|
||
.split(" - ");
|
||
let startLatLng = startLatLngVal.map(function(e) {
|
||
e = e.replace(/_/g, "");
|
||
return parseFloat(e.slice(1, -1));
|
||
});
|
||
// console.log(startLatLng)
|
||
|
||
if (isNaN(startLatLng[0])) {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#abrar-edit-card-edit input[name=abrar-project-latlng-startt]"
|
||
).removeClass("is-invalid-input");
|
||
} else {
|
||
$(
|
||
"#abrar-edit-card-edit input[name=abrar-project-latlng-startt]"
|
||
).addClass("is-invalid-input");
|
||
}
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
$("#abrar-edit-card-edit input[name=abrar-project-latlng-startt]").val("");
|
||
$("#abrar-edit-card-edit input[name=abrar-project-latlng-startt]").attr(
|
||
"placeholder",
|
||
"(طول جغرافیایی) - (عرض جغرافیایی)"
|
||
);
|
||
return false;
|
||
} else if (!startLatLng == 2 ||
|
||
!reg.test(startLatLng[0]) ||
|
||
!reg.test(startLatLng[1])
|
||
) {
|
||
$("#abrar-edit-card-edit input[name=abrar-project-latlng-startt]").addClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
return false;
|
||
} else {
|
||
if (!forSaveData) {
|
||
$(
|
||
"#abrar-edit-card-edit input[name=abrar-project-latlng-startt]"
|
||
).removeClass("is-invalid-input");
|
||
|
||
startAbrarMarkeredit.setLatLng(startLatLng);
|
||
|
||
if (pageOnLoad) {
|
||
setTimeout(() => {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
startAbrarMarkeredit.setLatLng(startLatLng);
|
||
}, 10);
|
||
} else {
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
}
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarkeredit.getLatLng().lat,
|
||
startAbrarMarkeredit.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
mapedit.setView(markerLatLng);
|
||
|
||
isSetStartAbrarMarkeredit = true;
|
||
} else {
|
||
projectEditData["project-start-latlng"] = [
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6),
|
||
];
|
||
}
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function showmodal() {
|
||
$("#stepModal").modal("show");
|
||
$("[data-mask]").inputmask();
|
||
setTimeout(() => {
|
||
if (map == null) {
|
||
creatmapfirst(latstart, lngstart);
|
||
setTimeout(() => {
|
||
setmapview(latadd, lngadd);
|
||
}, 100);
|
||
} else {
|
||
setmapview(latadd, lngadd);
|
||
}
|
||
}, 200);
|
||
}
|
||
|
||
function setmapview(first, last) {
|
||
|
||
map.removeLayer(startAbrarMarker);
|
||
|
||
// console.log([first , last])
|
||
if (first != null && last != null) {
|
||
map.setView([first, last], 9);
|
||
|
||
startAbrarMarker = new L.marker(L.latLng(map.getCenter()), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(map);
|
||
map.on("move", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
map.on("moveend", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
startAbrarMarker.on("click", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
var latlng = $("input[name=abrar-project-latlng-start]").val();
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
startAbrarMarker.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarker.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartAbrarMarker) {
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
map.setView(startAbrarMarker.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
} else {
|
||
map.setView([35.7065, 51.3477], 9);
|
||
|
||
startAbrarMarker = new L.marker(L.latLng(map.getCenter()), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(map);
|
||
map.on("move", function() {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
});
|
||
|
||
map.on("moveend", function() {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
});
|
||
startAbrarMarker.on("click", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
}
|
||
});
|
||
startAbrarMarker.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarker.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartAbrarMarker) {
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
map.setView(startAbrarMarker.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function creatmap() {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
map = L.map("abrar-map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([35.7065, 51.3477], 9);
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(map);
|
||
startAbrarMarker = new L.marker(L.latLng(map.getCenter()), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(map);
|
||
|
||
map.on("move", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
map.on("moveend", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
startAbrarMarker.on("click", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
var latlng = $("input[name=abrar-project-latlng-start]").val();
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
startAbrarMarker.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarker.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartAbrarMarker) {
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
map.setView(startAbrarMarker.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
}
|
||
|
||
function creatmapfirst(first, last) {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
map = L.map("abrar-map", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([first, last], 9);
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(map);
|
||
startAbrarMarker = new L.marker(L.latLng(map.getCenter()), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(map);
|
||
|
||
map.on("move", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
||
}
|
||
});
|
||
|
||
map.on("moveend", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
$("#pin-marker-start").removeClass("pin-move pin-set");
|
||
}
|
||
});
|
||
startAbrarMarker.on("click", function() {
|
||
if (!isSetStartAbrarMarker) {
|
||
startAbrarMarker.setLatLng(L.latLng(map.getCenter()));
|
||
isSetStartAbrarMarker = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarker.getLatLng().lat,
|
||
startAbrarMarker.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
map.setView(markerLatLng);
|
||
var latlng = $("input[name=abrar-project-latlng-start]").val();
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
startAbrarMarker.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarker.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartAbrarMarker) {
|
||
$(" input[name=abrar-project-latlng-start]").val(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-start]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
map.setView(startAbrarMarker.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarker.getLatLng().lat.toFixed(6),
|
||
startAbrarMarker.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
}
|
||
$("#submitlatlng").on("click", function() {
|
||
if (
|
||
$("#province-idedit").val() == 0 ||
|
||
$("#mehvar-type").val() == "" ||
|
||
$("#mehvarnamesub").val() == "" ||
|
||
$("#firstroad").val() == "" ||
|
||
$("#lastroad").val() == "" ||
|
||
$("#distancesub").val() == "" ||
|
||
$("#localnamesub").val() == "" ||
|
||
$("input[name=abrar-project-latlng-start]").val() == ""
|
||
) {
|
||
if ($("#province-idedit").val() == 0) {
|
||
$("#province-idedit").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#mehvar-type").val() == 0) {
|
||
$("#mehvar-type").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#mehvarnamesub").val() == "") {
|
||
$("#mehvarnamesub").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#firstroad").val() == "") {
|
||
$("#firstroad").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#lastroad").val() == "") {
|
||
$("#lastroad").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#distancesub").val() == "") {
|
||
$("#distancesub").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#localnamesub").val() == "") {
|
||
$("#localnamesub").addClass("is-invalid");
|
||
}
|
||
if ($("input[name=abrar-project-latlng-start]").val() == "") {
|
||
$("input[name=abrar-project-latlng-start]").addClass("is-invalid");
|
||
}
|
||
} else {
|
||
submitlatlngajax();
|
||
}
|
||
});
|
||
|
||
function submitlatlngajax() {
|
||
var provinceinput = $('select[name="provincesub"]')
|
||
.children("option:selected")
|
||
.val();
|
||
// console.log(provinceinput)
|
||
var mehvarnameinput = $("#mehvarnamesub").val();
|
||
// console.log(mehvarnameinput)
|
||
var typeroadsub = $('select[name="mehvar-type"]')
|
||
.children("option:selected")
|
||
.val();
|
||
// console.log(typeroadsub)
|
||
var startmehvar = $("#firstroad").val();
|
||
var endmehvar = $("#lastroad").val();
|
||
// console.log(startmehvar, endmehvar)
|
||
var distancefrom = $("#distancesub").val();
|
||
var localnamesub = $("#localnamesub").val();
|
||
// console.log(distancefrom, localnamesub)
|
||
var latsub = startAbrarMarker.getLatLng().lat.toFixed(6);
|
||
// console.log(latsub)
|
||
var lngsub = startAbrarMarker.getLatLng().lng.toFixed(6);
|
||
console.log("lat", latsub, boundingbox[0], boundingbox[1]);
|
||
console.log("lng", lngsub, boundingbox[2], boundingbox[3]);
|
||
// console.log(boundingbox)
|
||
if (
|
||
latsub >= boundingbox[0] &&
|
||
latsub <= boundingbox[1] &&
|
||
lngsub >= boundingbox[2] &&
|
||
lngsub <= boundingbox[3]
|
||
) {
|
||
let formData = new FormData();
|
||
|
||
if (
|
||
provinceinput != null &&
|
||
provinceinput != undefined &&
|
||
provinceinput != 0
|
||
)
|
||
formData.append("province-id", provinceinput);
|
||
|
||
if (mehvarnameinput != null) formData.append("axis-name", mehvarnameinput);
|
||
|
||
if (typeroadsub != null && typeroadsub != undefined && typeroadsub != 0)
|
||
formData.append("axis-type", typeroadsub);
|
||
|
||
if (startmehvar != null) formData.append("axis-start", startmehvar);
|
||
|
||
if (endmehvar != null) formData.append("axis-end", endmehvar);
|
||
|
||
if (distancefrom != null)
|
||
formData.append("distance-axis-start", distancefrom);
|
||
|
||
if (localnamesub != null) formData.append("local-name", localnamesub);
|
||
|
||
if ($("input[name=abrar-project-latlng-start]").val() != "") {
|
||
if (latsub != null) formData.append("lat", latsub);
|
||
|
||
if (lngsub != null) formData.append("lng", lngsub);
|
||
}
|
||
console.log("lat", latsub);
|
||
console.log("lng", lngsub);
|
||
|
||
for (var value of formData.values()) {
|
||
console.log(value);
|
||
}
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/create",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
showLoaderScreen();
|
||
ajaxcalltable();
|
||
// Swal.fire({
|
||
// icon: "success",
|
||
// title: "با موفقیت بروزرسانی شد",
|
||
// confirmButtonText: "بستن",
|
||
// preConfirm: () => {
|
||
// location.reload();
|
||
// },
|
||
// });
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: ".لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
} else {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: ". لطفا در محدوده استان موقعیت را ثبت کنید ",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
}
|
||
}
|
||
$("#submitlatlngedit").on("click", function() {
|
||
if (
|
||
$("#province-id").val() == 0 ||
|
||
$("#mehvar-type1").val() == 0 ||
|
||
$("#mehvarnamesub1").val() == "" ||
|
||
$("#firstroad1").val() == "" ||
|
||
$("#lastroad1").val() == "" ||
|
||
$("#distancesub1").val() == "" ||
|
||
$("#localnamesub1").val() == "" ||
|
||
$("input[name=abrar-project-latlng-startt]").val() == ""
|
||
) {
|
||
if ($("#province-id").val() == 0) {
|
||
$("#province-id").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#mehvar-type1").val() == 0) {
|
||
$("#mehvar-type1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#mehvarnamesub1").val() == "") {
|
||
$("#mehvarnamesub1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#firstroad1").val() == "") {
|
||
$("#firstroad1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#lastroad1").val() == "") {
|
||
$("#lastroad1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#distancesub1").val() == "") {
|
||
$("#distancesub1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("#localnamesub1").val() == "") {
|
||
$("#localnamesub1").addClass("is-invalid");
|
||
}
|
||
|
||
if ($("input[name=abrar-project-latlng-startt]").val() == "") {
|
||
$("input[name=abrar-project-latlng-startt]").addClass("is-invalid");
|
||
}
|
||
} else {
|
||
submitlatlngajaxedit();
|
||
}
|
||
});
|
||
|
||
function submitlatlngajaxedit() {
|
||
var provinceinput = $('select[name="provincesub1"]')
|
||
.children("option:selected")
|
||
.val();
|
||
// console.log(provinceinput)
|
||
var mehvarnameinput = $("#mehvarnamesub1").val();
|
||
// console.log(mehvarnameinput)
|
||
var typeroadsub = $('select[name="mehvar-type1"]')
|
||
.children("option:selected")
|
||
.val();
|
||
// console.log(typeroadsub)
|
||
var startmehvar = $("#firstroad1").val();
|
||
var endmehvar = $("#lastroad1").val();
|
||
// console.log(startmehvar, endmehvar)
|
||
var distancefrom = $("#distancesub1").val();
|
||
var localnamesub = $("#localnamesub1").val();
|
||
var latsub;
|
||
var lngsub;
|
||
console.log(distancefrom, localnamesub);
|
||
|
||
if ($("#editlatlng").val() != "") {
|
||
latsub = startAbrarMarkeredit.getLatLng().lat.toFixed(6);
|
||
console.log(latsub);
|
||
lngsub = startAbrarMarkeredit.getLatLng().lng.toFixed(6);
|
||
console.log(lngsub);
|
||
} else {
|
||
latsub = lateditt;
|
||
lngsub = lngeditt;
|
||
}
|
||
|
||
let formData = new FormData();
|
||
|
||
if (
|
||
provinceinput != null &&
|
||
provinceinput != undefined &&
|
||
provinceinput != 0
|
||
)
|
||
formData.append("province-id", provinceinput);
|
||
|
||
if (mehvarnameinput != null) formData.append("axis-name", mehvarnameinput);
|
||
|
||
if (typeroadsub != null && typeroadsub != undefined && typeroadsub != 0)
|
||
formData.append("axis-type", typeroadsub);
|
||
|
||
if (startmehvar != null) formData.append("axis-start", startmehvar);
|
||
|
||
if (endmehvar != null) formData.append("axis-end", endmehvar);
|
||
|
||
if (distancefrom != null)
|
||
formData.append("distance-axis-start", distancefrom);
|
||
|
||
if (localnamesub != null) formData.append("local-name", localnamesub);
|
||
|
||
if ($("input[name=abrar-project-latlng-startt]").val() != "") {
|
||
if (latsub != null) formData.append("lat", latsub);
|
||
|
||
if (lngsub != null) formData.append("lng", lngsub);
|
||
}
|
||
|
||
for (var value of formData.values()) {
|
||
console.log(value);
|
||
}
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/" + idkol + "/edit",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
$("#stepModaledit").modal("hide");
|
||
// showLoaderScreen();
|
||
// ajaxcalltable();
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: ".لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
|
||
}
|
||
|
||
function getnominatim(lat, lng) {
|
||
$.ajax({
|
||
url: "https://rmsmap.rmto.ir/nominatim/reverse.php?format=json" +
|
||
"&lat=" +
|
||
lat +
|
||
"&lon=" +
|
||
lng +
|
||
"&accept-language=fa",
|
||
type: "GET",
|
||
success: function(result) {
|
||
// boundingbox = result.boundingbox
|
||
addressnomin = result.address.road;
|
||
// console.log(addressnomin)
|
||
if (addressnomin != undefined) {
|
||
var spilitroad = addressnomin.split("-");
|
||
}
|
||
if (spilitroad != undefined) {
|
||
if (spilitroad.length >= 2) {
|
||
$("#firstroad").val(spilitroad[0]);
|
||
$("#lastroad").val(spilitroad[1]);
|
||
} else {
|
||
$("#firstroad").val("");
|
||
$("#lastroad").val("");
|
||
}
|
||
} else {
|
||
$("#firstroad").val("");
|
||
$("#lastroad").val("");
|
||
}
|
||
if (addressnomin != undefined) {
|
||
$("#mehvarnamesub").val(addressnomin);
|
||
}
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
},
|
||
});
|
||
}
|
||
|
||
function getnominatimlatlng(lat, lng) {
|
||
console.log(lat, lng);
|
||
$.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("test", boundingbox);
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
},
|
||
});
|
||
}
|
||
|
||
function getProvinces() {
|
||
let reqUrl = "https://rms.rmto.ir/webapi/danger-point/get-user-provinces";
|
||
// showLoaderScreen();
|
||
$.ajax({
|
||
url: reqUrl,
|
||
type: "GET",
|
||
success: function(result) {
|
||
hideLoaderScreen();
|
||
//console.log(result);
|
||
provinces = result.data;
|
||
latstart = result.data.center_lat
|
||
lngstart = result.data.center_long
|
||
// console.log(provinces)
|
||
},
|
||
error: function(error) {
|
||
// hideLoaderScreen();
|
||
//console.log(error);
|
||
},
|
||
});
|
||
}
|
||
|
||
function showprovinceedit() {
|
||
$("#province-idedit").empty();
|
||
$("#province-idedit").append('<option value="0">انتخاب اداره کل</option>');
|
||
if (provinces.length > 0) {
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#province-idedit").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
$("#province-idedit").change(function() {
|
||
if ((value = $(this).val()) && $(this).val() != 0) {
|
||
latadd = provinces[value - 1].center_lat;
|
||
lngadd = provinces[value - 1].center_long;
|
||
$("input[name=abrar-project-latlng-start]").val("");
|
||
setmapview(latadd, lngadd);
|
||
getnominatimlatlng(latadd, lngadd);
|
||
} else {
|
||
latadd = 35.7065;
|
||
lngadd = 51.3477;
|
||
}
|
||
});
|
||
} else {
|
||
$("#province-idedit").append(
|
||
"\
|
||
<option value=" +
|
||
provinces.id +
|
||
">" +
|
||
provinces.name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
$("#province-idedit").val(provinces.id);
|
||
$("#province-idedit").attr("disabled", true);
|
||
latadd = provinces.center_lat;
|
||
lngadd = provinces.center_long;
|
||
// creatmapfirst(latadd, lngadd)
|
||
setTimeout(() => {
|
||
if (map == null) {
|
||
creatmapfirst(latadd, lngadd);
|
||
setTimeout(() => {
|
||
setmapview(latadd, lngadd);
|
||
}, 100);
|
||
} else {
|
||
setmapview(latadd, lngadd);
|
||
}
|
||
}, 200);
|
||
// setmapview(latadd, lngadd);
|
||
getnominatimlatlng(latadd, lngadd);
|
||
// setmapview(latadd, lngadd)
|
||
}
|
||
}
|
||
|
||
function showprovincebutton(idostan) {
|
||
$("#province-id").empty();
|
||
$("#province-id").append('<option value="0">انتخاب اداره کل</option>');
|
||
if (provinces.length > 0) {
|
||
for (let index = 0; index < provinces.length; index++) {
|
||
$("#province-id").append(
|
||
"\
|
||
<option value=" +
|
||
provinces[index].id +
|
||
">" +
|
||
provinces[index].name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
}
|
||
$("#province-id").change(function() {
|
||
if ((value = $(this).val()) && $(this).val() != 0) {
|
||
latadd = provinces[value - 1].center_lat;
|
||
lngadd = provinces[value - 1].center_long;
|
||
$("input[name=abrar-project-latlng-startt]").val("");
|
||
setmapviewedit(latadd, lngadd);
|
||
} else {
|
||
latadd = 35.7065;
|
||
lngadd = 51.3477;
|
||
}
|
||
});
|
||
$("#province-id").val(idostan);
|
||
// creatmapedit(latadd, lngadd)
|
||
} else {
|
||
$("#province-id").append(
|
||
"\
|
||
<option value=" +
|
||
provinces.id +
|
||
">" +
|
||
provinces.name_fa +
|
||
"</option>\
|
||
"
|
||
);
|
||
$("#province-id").val(idostan);
|
||
$("#province-id").attr("disabled", true);
|
||
latadd = provinces.center_lat;
|
||
lngadd = provinces.center_long;
|
||
// setmapview(latadd, lngadd)
|
||
}
|
||
}
|
||
|
||
$("#reverse").on("click", function() {
|
||
$("#stepModal").modal("hide");
|
||
});
|
||
$("#reverseedit").on("click", function() {
|
||
$("#stepModaledit").modal("hide");
|
||
});
|
||
|
||
// function restrictInputOtherThanArabic($field) {
|
||
// // Arabic characters fall in the Unicode range 0600 - 06FF
|
||
// var arabicCharUnicodeRange = /[\u0600-\u06FF]/;
|
||
|
||
// $field.bind("keypress", function (event) {
|
||
// var key = event.which;
|
||
// // 0 = numpad
|
||
// // 8 = backspace
|
||
// // 32 = space
|
||
// if (key == 8 || key == 0 || key === 32) {
|
||
// return true;
|
||
// }
|
||
|
||
// var str = String.fromCharCode(key);
|
||
// if (arabicCharUnicodeRange.test(str)) {
|
||
// return true;
|
||
// }
|
||
|
||
// return false;
|
||
// });
|
||
// }
|
||
function restrictInputOtherThanArabic($field) {
|
||
// Arabic characters fall in the Unicode range 0600 - 06FF
|
||
var arabicCharUnicodeRange = /[\u0600-\u06FF-0-9]/;
|
||
|
||
$field.bind("keypress", function(event) {
|
||
var key = event.which;
|
||
// 0 = numpad
|
||
// 8 = backspace
|
||
// 32 = space
|
||
if (key == 8 || key == 0 || key === 32) {
|
||
return true;
|
||
}
|
||
|
||
var str = String.fromCharCode(key);
|
||
if (arabicCharUnicodeRange.test(str)) {
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
});
|
||
}
|
||
$("#submitform").on("click", function() {
|
||
//ll
|
||
|
||
if (
|
||
$("#tarheeslahi").val() == "" ||
|
||
$("#dardasteejra").val() == "" ||
|
||
$("#sumery").val() == "" ||
|
||
$("#sugesttarh").val() == ""
|
||
) {
|
||
// to do
|
||
if (
|
||
$("#tarheeslahi").val() == undefined ||
|
||
$("#tarheeslahi").val() == ""
|
||
) {
|
||
$("#tarheeslahi").addClass("is-invalid");
|
||
}
|
||
if (
|
||
$("#dardasteejra").val() == undefined ||
|
||
$("#dardasteejra").val() == ""
|
||
) {
|
||
$("#dardasteejra").addClass("is-invalid");
|
||
}
|
||
if ($("#sumery").val() == undefined || $("#sumery").val() == "") {
|
||
$("#sumery").addClass("is-invalid");
|
||
}
|
||
if ($("#sugesttarh").val() == undefined || $("#sugesttarh").val() == "") {
|
||
$("#sugesttarh").addClass("is-invalid");
|
||
}
|
||
// Swal.fire({
|
||
// icon: "error",
|
||
// title: "خطا",
|
||
// text: " . لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
// confirmButtonText: "بستن",
|
||
// });
|
||
} else {
|
||
if (speed_average == null) {
|
||
var point251 = null;
|
||
var accidentpos = null;
|
||
var hefaz = null;
|
||
var rishearray = [];
|
||
var accarray = [];
|
||
var pointcode = $("#pointcode").val();
|
||
// console.log(pointcode)
|
||
if ($("#danger-point1").is(":checked")) {
|
||
point251 = 1;
|
||
} else if ($("#danger-point2").is(":checked")) {
|
||
point251 = 0;
|
||
}
|
||
// console.log(point251)
|
||
var speedlimit = $("#speedtest").val();
|
||
var speed_av = $("#sppedmid").val();
|
||
var hendesi = $('select[name="hendesi"]')
|
||
.children("option:selected")
|
||
.val();
|
||
|
||
if ($("#rokhberokh1").is(":checked")) {
|
||
accidentpos = 1;
|
||
} else if ($("#rokhberokh2").is(":checked")) {
|
||
accidentpos = 0;
|
||
}
|
||
|
||
if ($("#hefaz1").is(":checked")) {
|
||
hefaz = 1;
|
||
} else if ($("#hefaz2").is(":checked")) {
|
||
hefaz = 0;
|
||
}
|
||
if ($("#rishe1").is(":checked")) {
|
||
rishearray.push(1);
|
||
}
|
||
|
||
if ($("#rishe2").is(":checked")) {
|
||
rishearray.push(2);
|
||
}
|
||
|
||
if ($("#rishe3").is(":checked")) {
|
||
rishearray.push(3);
|
||
}
|
||
if ($("#rishe4").is(":checked")) {
|
||
rishearray.push(4);
|
||
}
|
||
if ($("#rishe5").is(":checked")) {
|
||
rishearray.push(5);
|
||
}
|
||
if ($("#rishe6").is(":checked")) {
|
||
rishearray.push(6);
|
||
}
|
||
if ($("#rishe7").is(":checked")) {
|
||
rishearray.push(7);
|
||
}
|
||
if ($("#rishe8").is(":checked")) {
|
||
rishearray.push(8);
|
||
}
|
||
if ($("#rishe9").is(":checked")) {
|
||
rishearray.push(9);
|
||
}
|
||
if ($("#rishe10").is(":checked")) {
|
||
rishearray.push(10);
|
||
}
|
||
if ($("#rishe11").is(":checked")) {
|
||
rishearray.push(11);
|
||
}
|
||
if ($("#rishe12").is(":checked")) {
|
||
rishearray.push(12);
|
||
}
|
||
if ($("#rishe13").is(":checked")) {
|
||
rishearray.push(13);
|
||
}
|
||
if ($("#rishe14").is(":checked")) {
|
||
rishearray.push(14);
|
||
}
|
||
if ($("#rishe15").is(":checked")) {
|
||
rishearray.push(15);
|
||
}
|
||
if ($("#rishe16").is(":checked")) {
|
||
rishearray.push(16);
|
||
}
|
||
if ($("#rishe17").is(":checked")) {
|
||
rishearray.push(17);
|
||
}
|
||
if ($("#rishe18").is(":checked")) {
|
||
rishearray.push(18);
|
||
}
|
||
if ($("#rishe19").is(":checked")) {
|
||
rishearray.push(19);
|
||
}
|
||
if ($("#rishe20").is(":checked")) {
|
||
rishearray.push(20);
|
||
}
|
||
if ($("#rishe21").is(":checked")) {
|
||
rishearray.push(21);
|
||
}
|
||
if ($("#rishe22").is(":checked")) {
|
||
rishearray.push(22);
|
||
}
|
||
if ($("#rishe23").is(":checked")) {
|
||
rishearray.push(23);
|
||
}
|
||
if ($("#rishe24").is(":checked")) {
|
||
rishearray.push(24);
|
||
}
|
||
if ($("#rishe25").is(":checked")) {
|
||
rishearray.push(25);
|
||
}
|
||
if ($("#rishe26").is(":checked")) {
|
||
rishearray.push(26);
|
||
}
|
||
if ($("#rishe27").is(":checked")) {
|
||
rishearray.push(27);
|
||
}
|
||
if ($("#rishe28").is(":checked")) {
|
||
rishearray.push(28);
|
||
}
|
||
if ($("#rishe29").is(":checked")) {
|
||
rishearray.push(29);
|
||
}
|
||
if ($("#rishe30").is(":checked")) {
|
||
rishearray.push(30);
|
||
}
|
||
// console.log(rishearray)
|
||
var rishetext = $("#risheerae").val();
|
||
// console.log(rishetext)
|
||
if ($("#acc1").is(":checked")) {
|
||
accarray.push(1);
|
||
}
|
||
if ($("#acc2").is(":checked")) {
|
||
accarray.push(2);
|
||
}
|
||
if ($("#acc3").is(":checked")) {
|
||
accarray.push(3);
|
||
}
|
||
if ($("#acc4").is(":checked")) {
|
||
accarray.push(4);
|
||
}
|
||
if ($("#acc5").is(":checked")) {
|
||
accarray.push(5);
|
||
}
|
||
if ($("#acc6").is(":checked")) {
|
||
accarray.push(6);
|
||
}
|
||
if ($("#acc7").is(":checked")) {
|
||
accarray.push(7);
|
||
}
|
||
if ($("#acc8").is(":checked")) {
|
||
accarray.push(8);
|
||
}
|
||
// console.log(accarray)
|
||
var acctext = $("#accarea").val();
|
||
var tarheeslahi = $("#tarheeslahi").val();
|
||
var dardasteejra = $("#dardasteejra").val();
|
||
var sumery = $("#sumery").val();
|
||
var sugesttarh = $("#sugesttarh").val();
|
||
console.log("hhhhh", accarray)
|
||
console.log("hhhhh111111", sugesttarh)
|
||
|
||
let formData = new FormData();
|
||
|
||
if (idkol != null) formData.append("danger-id", idkol);
|
||
|
||
if (point251 != null && point251 != undefined)
|
||
formData.append("accident-251", point251);
|
||
|
||
if (pointcode != null && pointcode != undefined && pointcode != "")
|
||
formData.append("accident-251-code", pointcode);
|
||
|
||
if (speedlimit != null && speedlimit != "")
|
||
formData.append("speed-limit", speedlimit);
|
||
|
||
if (speed_av != null && speed_av != "")
|
||
formData.append("speed-average", speed_av);
|
||
|
||
if (hendesi != null && hendesi != 0)
|
||
formData.append("geometric-desc", hendesi);
|
||
|
||
if (accidentpos != null)
|
||
formData.append("accident-possibility", accidentpos);
|
||
|
||
if (hefaz != null) formData.append("road-guard", hefaz);
|
||
|
||
if (rishearray != null)
|
||
if (rishearray.length != 0) {
|
||
formData.append("accident-cause", rishearray);
|
||
}
|
||
|
||
if (rishetext != null)
|
||
if (rishearray.length != 0) {
|
||
formData.append("accident-cause-suggest", rishetext);
|
||
}
|
||
|
||
if (accarray != null)
|
||
formData.append("accident-severity", accarray);
|
||
|
||
|
||
|
||
|
||
formData.append("accident-severity-suggest", acctext);
|
||
|
||
|
||
if (tarheeslahi != null && tarheeslahi != "")
|
||
formData.append("correction-plan-done", tarheeslahi);
|
||
|
||
if (dardasteejra != null && dardasteejra != "")
|
||
formData.append("correction-plan-doing", dardasteejra);
|
||
|
||
if (sumery != null && sumery != "")
|
||
formData.append("correction-plan-doing-desc", sumery);
|
||
|
||
if (sugesttarh != null && sugesttarh != "")
|
||
formData.append("correction-plan-doing-suggest", sugesttarh);
|
||
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ' - ' + pair[1]);
|
||
}
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/details",
|
||
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);
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
// console.log("hiii")
|
||
return false;
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: " . لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
//ll
|
||
if (speed_average != null) {
|
||
var point251 = null;
|
||
var accidentpos = null;
|
||
var hefaz = null;
|
||
var rishearray = [];
|
||
var accarray = [];
|
||
var pointcode = $("#pointcode").val();
|
||
// console.log(pointcode)
|
||
if ($("#danger-point1").is(":checked")) {
|
||
point251 = 1;
|
||
} else if ($("#danger-point2").is(":checked")) {
|
||
point251 = 0;
|
||
}
|
||
// console.log(point251)
|
||
var speedlimit = $("#speedtest").val();
|
||
var speed_av = $("#sppedmid").val();
|
||
var hendesi = $('select[name="hendesi"]')
|
||
.children("option:selected")
|
||
.val();
|
||
|
||
if ($("#rokhberokh1").is(":checked")) {
|
||
accidentpos = 1;
|
||
} else if ($("#rokhberokh2").is(":checked")) {
|
||
accidentpos = 0;
|
||
}
|
||
|
||
if ($("#hefaz1").is(":checked")) {
|
||
hefaz = 1;
|
||
} else if ($("#hefaz2").is(":checked")) {
|
||
hefaz = 0;
|
||
}
|
||
if ($("#rishe1").is(":checked")) {
|
||
rishearray.push(1);
|
||
}
|
||
|
||
if ($("#rishe2").is(":checked")) {
|
||
rishearray.push(2);
|
||
}
|
||
|
||
if ($("#rishe3").is(":checked")) {
|
||
rishearray.push(3);
|
||
}
|
||
if ($("#rishe4").is(":checked")) {
|
||
rishearray.push(4);
|
||
}
|
||
if ($("#rishe5").is(":checked")) {
|
||
rishearray.push(5);
|
||
}
|
||
if ($("#rishe6").is(":checked")) {
|
||
rishearray.push(6);
|
||
}
|
||
if ($("#rishe7").is(":checked")) {
|
||
rishearray.push(7);
|
||
}
|
||
if ($("#rishe8").is(":checked")) {
|
||
rishearray.push(8);
|
||
}
|
||
if ($("#rishe9").is(":checked")) {
|
||
rishearray.push(9);
|
||
}
|
||
if ($("#rishe10").is(":checked")) {
|
||
rishearray.push(10);
|
||
}
|
||
if ($("#rishe11").is(":checked")) {
|
||
rishearray.push(11);
|
||
}
|
||
if ($("#rishe12").is(":checked")) {
|
||
rishearray.push(12);
|
||
}
|
||
if ($("#rishe13").is(":checked")) {
|
||
rishearray.push(13);
|
||
}
|
||
if ($("#rishe14").is(":checked")) {
|
||
rishearray.push(14);
|
||
}
|
||
if ($("#rishe15").is(":checked")) {
|
||
rishearray.push(15);
|
||
}
|
||
if ($("#rishe16").is(":checked")) {
|
||
rishearray.push(16);
|
||
}
|
||
if ($("#rishe17").is(":checked")) {
|
||
rishearray.push(17);
|
||
}
|
||
if ($("#rishe18").is(":checked")) {
|
||
rishearray.push(18);
|
||
}
|
||
if ($("#rishe19").is(":checked")) {
|
||
rishearray.push(19);
|
||
}
|
||
if ($("#rishe20").is(":checked")) {
|
||
rishearray.push(20);
|
||
}
|
||
if ($("#rishe21").is(":checked")) {
|
||
rishearray.push(21);
|
||
}
|
||
if ($("#rishe22").is(":checked")) {
|
||
rishearray.push(22);
|
||
}
|
||
if ($("#rishe23").is(":checked")) {
|
||
rishearray.push(23);
|
||
}
|
||
if ($("#rishe24").is(":checked")) {
|
||
rishearray.push(24);
|
||
}
|
||
if ($("#rishe25").is(":checked")) {
|
||
rishearray.push(25);
|
||
}
|
||
if ($("#rishe26").is(":checked")) {
|
||
rishearray.push(26);
|
||
}
|
||
if ($("#rishe27").is(":checked")) {
|
||
rishearray.push(27);
|
||
}
|
||
if ($("#rishe28").is(":checked")) {
|
||
rishearray.push(28);
|
||
}
|
||
if ($("#rishe29").is(":checked")) {
|
||
rishearray.push(29);
|
||
}
|
||
if ($("#rishe30").is(":checked")) {
|
||
rishearray.push(30);
|
||
}
|
||
// console.log(rishearray)
|
||
var rishetext = $("#risheerae").val();
|
||
// console.log(rishetext)
|
||
if ($("#acc1").is(":checked")) {
|
||
accarray.push(1);
|
||
}
|
||
if ($("#acc2").is(":checked")) {
|
||
accarray.push(2);
|
||
}
|
||
if ($("#acc3").is(":checked")) {
|
||
accarray.push(3);
|
||
}
|
||
if ($("#acc4").is(":checked")) {
|
||
accarray.push(4);
|
||
}
|
||
if ($("#acc5").is(":checked")) {
|
||
accarray.push(5);
|
||
}
|
||
if ($("#acc6").is(":checked")) {
|
||
accarray.push(6);
|
||
}
|
||
if ($("#acc7").is(":checked")) {
|
||
accarray.push(7);
|
||
}
|
||
if ($("#acc8").is(":checked")) {
|
||
accarray.push(8);
|
||
}
|
||
// console.log(accarray)
|
||
var acctext = $("#accarea").val();
|
||
var tarheeslahi = $("#tarheeslahi").val();
|
||
var dardasteejra = $("#dardasteejra").val();
|
||
var sumery = $("#sumery").val();
|
||
var sugesttarh = $("#sugesttarh").val();
|
||
console.log("hhh", accarray)
|
||
let formData = new FormData();
|
||
|
||
if (point251 != null && point251 != undefined)
|
||
formData.append("accident-251", point251);
|
||
|
||
if (pointcode != null && pointcode != undefined && pointcode != "")
|
||
formData.append("accident-251-code", pointcode);
|
||
|
||
if (speedlimit != null && speedlimit != "")
|
||
formData.append("speed-limit", speedlimit);
|
||
|
||
if (speed_av != null && speed_av != "")
|
||
formData.append("speed-average", speed_av);
|
||
|
||
if (hendesi != null && hendesi != 0)
|
||
formData.append("geometric-desc", hendesi);
|
||
|
||
if (accidentpos != null)
|
||
formData.append("accident-possibility", accidentpos);
|
||
|
||
if (hefaz != null) formData.append("road-guard", hefaz);
|
||
|
||
if (rishearray != null)
|
||
if (rishearray.length != 0) {
|
||
formData.append("accident-cause", rishearray);
|
||
}
|
||
|
||
if (rishetext != null)
|
||
if (rishearray.length != 0) {
|
||
formData.append("accident-cause-suggest", rishetext);
|
||
}
|
||
|
||
if (accarray != null)
|
||
|
||
formData.append("accident-severity", accarray);
|
||
|
||
|
||
|
||
|
||
formData.append("accident-severity-suggest", acctext);
|
||
|
||
|
||
if (tarheeslahi != null && tarheeslahi != "")
|
||
formData.append("correction-plan-done", tarheeslahi);
|
||
|
||
if (dardasteejra != null && dardasteejra != "")
|
||
formData.append("correction-plan-doing", dardasteejra);
|
||
|
||
if (sumery != null && sumery != "")
|
||
formData.append("correction-plan-doing-desc", sumery);
|
||
|
||
if (sugesttarh != null && sugesttarh != "")
|
||
formData.append("correction-plan-doing-suggest", sugesttarh);
|
||
|
||
for (var value of formData.values()) {
|
||
console.log(value);
|
||
}
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/details/" +
|
||
idkol +
|
||
"/edit",
|
||
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)
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
// console.log("result" , result)
|
||
return false;
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: " . لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
function ajaxcalltable() {
|
||
console.log("showbuttondate", showbuttondate);
|
||
showbuttondate = 0;
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/getlist",
|
||
type: "GET",
|
||
success: function(result) {
|
||
// console.log(result.data[0]);
|
||
$("#example").dataTable().fnClearTable();
|
||
$("#example").dataTable().fnAddData(result.data);
|
||
// $('#example button.details-control').removeClass('btn-outline-danger')
|
||
// $('#example button.details-control').addClass('btn-danger')
|
||
hideLoaderScreen();
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "با موفقیت بروزرسانی شد",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
|
||
$("#stepModal").modal("hide");
|
||
$("stepmodaledit").modal("hide");
|
||
},
|
||
});
|
||
}
|
||
|
||
// Start alirezaZ image code
|
||
|
||
// Start alirezaZ image code
|
||
|
||
var mapImage = null;
|
||
var setAbrarMarkerImage = null;
|
||
var setAbrarDivIconImage = L.divIcon({
|
||
html: `
|
||
<div id="pin-marker-start" class="pin-marker pin-set">
|
||
<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 pointImageLat = 35.686509;
|
||
var pointImageLng = 52.618139;
|
||
var pointImagePopup = [];
|
||
var pointImageLinks = [];
|
||
var pointImageId = null;
|
||
|
||
function createMapImage() {
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
mapImage = L.map("abrar-map-image", {
|
||
maxBounds: bounds,
|
||
minZoom: 15,
|
||
maxZoom: 15,
|
||
zoomControl: false,
|
||
});
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
mapImage
|
||
);
|
||
setAbrarMarkerImage = new L.marker(L.latLng([pointImageLat, pointImageLng]), {
|
||
icon: setAbrarDivIconImage,
|
||
}).addTo(mapImage);
|
||
|
||
$(".leaflet-bottom.leaflet-right").remove();
|
||
}
|
||
|
||
function uploadInputImage(boxid) {
|
||
switch (boxid) {
|
||
case 501:
|
||
{
|
||
if ((rowStatus != 0 && rowStatus != 3) || ($(".remove-image-container501").css("display") != "none")) {
|
||
// show image slider
|
||
show_photo_slider(pointImageLinks, 1);
|
||
break;
|
||
}
|
||
$('input[name="image-right-50-1"]').click();
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container502").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 2);
|
||
break;
|
||
}
|
||
$('input[name="image-right-50-2"]').click();
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container503").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 3);
|
||
break;
|
||
}
|
||
$('input[name="image-left-50-1"]').click();
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container504").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 4);
|
||
break;
|
||
}
|
||
$('input[name="image-left-50-2"]').click();
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container1001").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 5);
|
||
break;
|
||
}
|
||
$('input[name="image-right-100-1"]').click();
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container1002").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 6);
|
||
break;
|
||
}
|
||
$('input[name="image-right-100-2"]').click();
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container1003").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 7);
|
||
break;
|
||
}
|
||
$('input[name="image-left-100-1"]').click();
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container1004").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 8);
|
||
break;
|
||
}
|
||
$('input[name="image-left-100-2"]').click();
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
if (rowStatus != 0 && rowStatus != 3 || ($(".remove-image-container1005").css("display") != "none")) {
|
||
show_photo_slider(pointImageLinks, 9);
|
||
break;
|
||
}
|
||
$('input[name="image-satellite"]').click();
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
function show_photo_slider(array, selectedIndex) {
|
||
console.log(array);
|
||
let dataLength = array.length;
|
||
//first
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
|
||
if (array[0].path.includes("public")) {
|
||
for (let index = 0; index < array.length; index++) {
|
||
if (array[index].path.includes("image-right-50-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> ۵۰ متری از آکس محور (رفت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 1 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-50-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> ۵۰ متری از آکس محور (رفت) - 2 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 2 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-50-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 50 متری از آکس محور (برگشت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 3 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-50-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 50 متری از آکس محور (برگشت) - 2 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 4 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-100-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (رفت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 5 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-100-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (رفت) - 2' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 6 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-100-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (برگشت) - 1' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 7 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-100-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (برگشت) - 2' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 8 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-satellite")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
'</div><img src="/' +
|
||
array[index].path.replace("public", "storage") +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> تصویر ماهواره ای' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 9 + ')"></span>'
|
||
);
|
||
}
|
||
}
|
||
} else {
|
||
for (let index = 0; index < array.length; index++) {
|
||
if (array[index].path.includes("image-right-50-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> ۵۰ متری از آکس محور (رفت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 1 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-50-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> ۵۰ متری از آکس محور (رفت) - 2 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 2 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-50-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 50 متری از آکس محور (برگشت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 3 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-50-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 50 متری از آکس محور (برگشت) - 2 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 4 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-100-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (رفت) - 1 ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 5 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-right-100-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (رفت) - 2' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 6 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-100-1")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (برگشت) - 1' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 7 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-left-100-2")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> 100 متری از آکس محور (برگشت) - 2' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 8 + ')"></span>'
|
||
);
|
||
} else if (array[index].path.includes("image-satellite")) {
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
(index + 1) +
|
||
" / " +
|
||
array.length +
|
||
`</div><img src="${array[index].path}"` +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> تصویر ماهواره ای' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 9 + ')"></span>'
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (dataLength > 0) {
|
||
slideindex = selectedIndex;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
|
||
function setMapImageView() {
|
||
setAbrarMarkerImage.setLatLng(L.latLng([pointImageLat, pointImageLng]));
|
||
|
||
mapImage.setView([pointImageLat - 0.0035, pointImageLng], 15);
|
||
|
||
setAbrarMarkerImage.setLatLng(L.latLng([pointImageLat, pointImageLng]));
|
||
|
||
$(".abrar-map-layout-image").append(`
|
||
<div class="right50-container" style="font-family: IRANSansWeb;">
|
||
<div class="right50-header" style="display:block; text-align:center; padding-bottom: 5px; border-bottom: 1px solid #AAA; margin-bottom: 5px;">
|
||
<span class="right50-header-text" style="font-size:10px; font-weight: 600; color: #0051cd;"> ۵۰ متری از آکس محور (رفت) </span>
|
||
</div>
|
||
<div class="popupHeaderContent">
|
||
<div class="popupContent" style="display: flex; flex-direction: column; align-items: center;">
|
||
<div class="popUpBox right50-image-1-container" style="width: 90%; height: 75px; cursor: pointer; color: #efefef;" onclick="uploadInputImage(501)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container501" onclick="removeImage(501)" style="display: none;">✕</div>
|
||
<div class="popUpBox right50-image-2-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(502)">
|
||
<span style="font-size: 11px !important;font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container502" onclick="removeImage(502)" style="display: none;">✕</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`);
|
||
|
||
$(".abrar-map-layout-image").append(`
|
||
<div class="right100-container" style="font-family: IRANSansWeb;">
|
||
<div class="right50-header" style="display:block; text-align:center; padding-bottom: 5px; border-bottom: 1px solid #AAA; margin-bottom: 5px;">
|
||
<span class="right50-header-text" style="font-size:10px; font-weight: 600; color: #0051cd;"> 100 متری از آکس محور (رفت) </span>
|
||
</div>
|
||
<div class="popupHeaderContent">
|
||
<div class="popupContent" style="display: flex; flex-direction: column; align-items: center;">
|
||
<div class="popUpBox right100-image-1-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(1001)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container1001" onclick="removeImage(1001)" style="display: none;">✕</div>
|
||
<div class="popUpBox right100-image-2-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(1002)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container1002" onclick="removeImage(1002)" style="display: none;">✕</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`);
|
||
|
||
$(".abrar-map-layout-image").append(`
|
||
<div class="left50-container" style="font-family: IRANSansWeb;">
|
||
<div class="right50-header" style="display:block; text-align:center; padding-bottom: 5px; border-bottom: 1px solid #AAA; margin-bottom: 5px;">
|
||
<span class="right50-header-text" style="font-size:10px; font-weight: 600; color: #0051cd;"> 50 متری از آکس محور (برگشت) </span>
|
||
</div>
|
||
<div class="popupHeaderContent">
|
||
<div class="popupContent" style="display: flex; flex-direction: column; align-items: center;">
|
||
<div class="popUpBox left50-image-1-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(503)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container503" onclick="removeImage(503)" style="display: none;">✕</div>
|
||
<div class="popUpBox left50-image-2-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(504)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container504" onclick="removeImage(504)" style="display: none;">✕</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`);
|
||
|
||
$(".abrar-map-layout-image").append(`
|
||
<div class="left100-container" style="font-family: IRANSansWeb;">
|
||
<div class="right50-header" style="display:block; text-align:center; padding-bottom: 5px; border-bottom: 1px solid #AAA; margin-bottom: 5px;">
|
||
<span class="right50-header-text" style="font-size:10px; font-weight: 600; color: #0051cd;"> 100 متری از آکس محور (برگشت) </span>
|
||
</div>
|
||
<div class="popupHeaderContent">
|
||
<div class="popupContent" style="display: flex; flex-direction: column; align-items: center;">
|
||
<div class="popUpBox left100-image-1-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(1003)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container1003" onclick="removeImage(1003)" style="display: none;">✕</div>
|
||
<div class="popUpBox left100-image-2-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(1004)">
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
</div>
|
||
<div class="remove-image-container1004" onclick="removeImage(1004)" style="display: none;">✕</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`);
|
||
|
||
$(".abrar-map-layout-image").append(`
|
||
<div class="middle-image-container" style="font-family: IRANSansWeb;">
|
||
<div class="right50-header" style="display:block; text-align:center; padding-bottom: 5px; border-bottom: 1px solid #AAA; margin-bottom: 5px;">
|
||
<span class="right50-header-text" style="font-size:10px; font-weight: 600; color: #0051cd;"> تصویر ماهواره ای </span>
|
||
</div>
|
||
<div class="popupHeaderContent">
|
||
<div class="popupContent" style="display: flex; flex-direction: column; align-items: center; margin-top: 40px;">
|
||
<div class="popUpBox middle-image-inner-container" style="width: 90%; height: 75px; cursor: pointer;" onclick="uploadInputImage(1005)">
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 23px;" />
|
||
</div>
|
||
<div class="remove-image-container1005" onclick="removeImage(1005)" style="display: none;">✕</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`);
|
||
|
||
setUploadEventHandlers();
|
||
}
|
||
|
||
function setUploadEventHandlers() {
|
||
var fr = new FileReader();
|
||
|
||
$("input[name=image-right-50-1]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".right50-image-1-container").empty();
|
||
$(".right50-image-1-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container501").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-right-50-2]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".right50-image-2-container").empty();
|
||
$(".right50-image-2-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container502").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-left-50-1]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".left50-image-1-container").empty();
|
||
$(".left50-image-1-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container503").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-left-50-2]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".left50-image-2-container").empty();
|
||
$(".left50-image-2-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container504").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-right-100-1]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".right100-image-1-container").empty();
|
||
$(".right100-image-1-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1001").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-right-100-2]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".right100-image-2-container").empty();
|
||
$(".right100-image-2-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1002").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-left-100-1]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".left100-image-1-container").empty();
|
||
$(".left100-image-1-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1003").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-left-100-2]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".left100-image-2-container").empty();
|
||
$(".left100-image-2-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1004").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
|
||
$("input[name=image-satellite]").on("change", function() {
|
||
fr.onload = function(e) {
|
||
// target.src = this.result;
|
||
$(".middle-image-inner-container").empty();
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="${this.result}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1005").show();
|
||
};
|
||
fr.readAsDataURL(this.files[0]);
|
||
});
|
||
}
|
||
|
||
function showImageThumbnailll(code) {
|
||
let formData = new FormData();
|
||
|
||
formData.append("danger-id", pointImageId);
|
||
|
||
switch (code) {
|
||
case 501:
|
||
{
|
||
formData.append("image", $("input[name=image-right-50-1]")[0].files[0]);
|
||
formData.append("name", "image-right-50-1");
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
formData.append("image", $("input[name=image-right-50-2]")[0].files[0]);
|
||
formData.append("name", "image-right-50-2");
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
formData.append("image", $("input[name=image-left-50-1]")[0].files[0]);
|
||
formData.append("name", "image-left-50-1");
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
formData.append("image", $("input[name=image-left-50-2]")[0].files[0]);
|
||
formData.append("name", "image-left-50-2");
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
formData.append("image", $("input[name=image-right-100-1]")[0].files[0]);
|
||
formData.append("name", "image-right-100-1");
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
formData.append("image", $("input[name=image-right-100-2]")[0].files[0]);
|
||
formData.append("name", "image-right-100-2");
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
formData.append("image", $("input[name=image-left-100-1]")[0].files[0]);
|
||
formData.append("name", "image-left-100-1");
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
formData.append("image", $("input[name=image-left-100-2]")[0].files[0]);
|
||
formData.append("name", "image-left-100-2");
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
formData.append("image", $("input[name=image-satellite]")[0].files[0]);
|
||
formData.append("name", "image-satellite");
|
||
break;
|
||
}
|
||
}
|
||
|
||
// Upload
|
||
showLoaderScreen();
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/images/upload",
|
||
type: "POST",
|
||
data: formData,
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
hideLoaderScreen();
|
||
console.log("res ", result);
|
||
|
||
switch (code) {
|
||
case 501:
|
||
{
|
||
$(".right50-image-1-container").empty();
|
||
$(".right50-image-1-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container501").show();
|
||
pointImageLinks.push({ path: result.data });
|
||
console.log(pointImageLinks);
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
$(".right50-image-2-container").empty();
|
||
$(".right50-image-2-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container502").show();
|
||
pointImageLinks.push({ path: result.data });
|
||
console.log(pointImageLinks);
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
$(".left50-image-1-container").empty();
|
||
$(".left50-image-1-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container503").show();
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
$(".left50-image-2-container").empty();
|
||
$(".left50-image-2-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container504").show();
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
$(".right100-image-1-container").empty();
|
||
$(".right100-image-1-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1001").show();
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
$(".right100-image-2-container").empty();
|
||
$(".right100-image-2-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1002").show();
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
$(".left100-image-1-container").empty();
|
||
$(".left100-image-1-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1003").show();
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
$(".left100-image-2-container").empty();
|
||
$(".left100-image-2-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
$(".remove-image-container1004").show();
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
$(".middle-image-inner-container").empty();
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="/${result.data.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images-middle" />
|
||
`);
|
||
$(".remove-image-container1005").show();
|
||
break;
|
||
}
|
||
}
|
||
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "بارگذاری تصویر",
|
||
text: "بارگذاری تصویر با موفقیت انجام شد!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
error: function(error) {
|
||
hideLoaderScreen();
|
||
console.log(error);
|
||
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "در بارگذاری تصویر مشکلی پیش آمده است!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
|
||
function removeImage(code) {
|
||
switch (code) {
|
||
case 501:
|
||
{
|
||
if ($("input[name='image-right-50-1']")[0].files.length > 0) {
|
||
$("input[name=image-right-50-1]").val("");
|
||
$(".right50-image-1-container").empty();
|
||
|
||
$(".right50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container501").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
if ($("input[name='image-right-50-2']")[0].files.length > 0) {
|
||
$("input[name=image-right-50-2]").val("");
|
||
$(".right50-image-2-container").empty();
|
||
|
||
$(".right50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;"" />
|
||
`);
|
||
$(".remove-image-container502").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
if ($("input[name='image-left-50-1']")[0].files.length > 0) {
|
||
$("input[name=image-left-50-1]").val("");
|
||
$(".left50-image-1-container").empty();
|
||
|
||
$(".left50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container503").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
if ($("input[name='image-left-50-2']")[0].files.length > 0) {
|
||
$("input[name=image-left-50-2]").val("");
|
||
$(".left50-image-2-container").empty();
|
||
|
||
$(".left50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container504").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
if ($("input[name='image-right-100-1']")[0].files.length > 0) {
|
||
$("input[name=image-right-100-1]").val("");
|
||
$(".right100-image-1-container").empty();
|
||
|
||
$(".right100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1001").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
if ($("input[name='image-right-100-2']")[0].files.length > 0) {
|
||
$("input[name=image-right-100-2]").val("");
|
||
$(".right100-image-2-container").empty();
|
||
|
||
$(".right100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1002").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
if ($("input[name='image-left-100-1']")[0].files.length > 0) {
|
||
$("input[name=image-left-100-1]").val("");
|
||
$(".left100-image-1-container").empty();
|
||
|
||
$(".left100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1003").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
if ($("input[name='image-left-100-2']")[0].files.length > 0) {
|
||
$("input[name=image-left-100-2]").val("");
|
||
$(".left100-image-2-container").empty();
|
||
|
||
$(".left100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1004").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
if ($("input[name='image-satellite']")[0].files.length > 0) {
|
||
$("input[name=image-satellite]").val("");
|
||
$(".middle-image-inner-container").empty();
|
||
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 23px;" />
|
||
`);
|
||
$(".remove-image-container1005").hide();
|
||
} else {
|
||
requestRemoveImage(code);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
function requestRemoveImage(code) {
|
||
let formData = new FormData();
|
||
|
||
formData.append("danger-id", pointImageId);
|
||
|
||
switch (code) {
|
||
case 501:
|
||
{
|
||
formData.append("name", "image-right-50-1");
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
formData.append("name", "image-right-50-2");
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
formData.append("name", "image-left-50-1");
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
formData.append("name", "image-left-50-2");
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
formData.append("name", "image-right-100-1");
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
formData.append("name", "image-right-100-2");
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
formData.append("name", "image-left-100-1");
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
formData.append("name", "image-left-100-2");
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
formData.append("name", "image-satellite");
|
||
break;
|
||
}
|
||
}
|
||
|
||
// Remove
|
||
showLoaderScreen();
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/images/delete",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
hideLoaderScreen();
|
||
// console.log(result);
|
||
switch (code) {
|
||
case 501:
|
||
{
|
||
// console.log(pointImageLinks);
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-right-50-1");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-right-50-1]").val("");
|
||
$(".right50-image-1-container").empty();
|
||
|
||
$(".right50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container501").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 502:
|
||
{
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-right-50-2");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-right-50-2]").val("");
|
||
$(".right50-image-2-container").empty();
|
||
|
||
$(".right50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container502").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 503:
|
||
{
|
||
// console.log(pointImageLinks);
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-left-50-1");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-left-50-1]").val("");
|
||
$(".left50-image-1-container").empty();
|
||
|
||
$(".left50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container503").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 504:
|
||
{
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-left-50-2");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-left-50-2]").val("");
|
||
$(".left50-image-2-container").empty();
|
||
|
||
$(".left50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container504").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 1001:
|
||
{
|
||
// console.log(pointImageLinks);
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-right-100-1");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-right-100-1]").val("");
|
||
$(".right100-image-1-container").empty();
|
||
|
||
$(".right100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container1001").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 1002:
|
||
{
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-right-100-2");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-right-100-2]").val("");
|
||
$(".right100-image-2-container").empty();
|
||
|
||
$(".right100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container1002").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 1003:
|
||
{
|
||
// console.log(pointImageLinks);
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-left-100-1");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-left-100-1]").val("");
|
||
$(".left100-image-1-container").empty();
|
||
|
||
$(".left100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container1003").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 1004:
|
||
{
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-left-100-2");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-left-100-2]").val("");
|
||
$(".left100-image-2-container").empty();
|
||
|
||
$(".left100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px; />
|
||
`);
|
||
$(".remove-image-container1004").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
case 1005:
|
||
{
|
||
let linkIndex = pointImageLinks.findIndex(function(link) {
|
||
return link.path.includes("image-satellite");
|
||
});
|
||
// console.log(linkIndex);
|
||
if (linkIndex > -1) {
|
||
pointImageLinks.splice(linkIndex, 1);
|
||
}
|
||
|
||
$("input[name=image-satellite]").val("");
|
||
$(".middle-image-inner-container").empty();
|
||
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 23px; />
|
||
`);
|
||
$(".remove-image-container1005").hide();
|
||
setUploadEventHandlers();
|
||
break;
|
||
}
|
||
}
|
||
console.log(pointImageLinks);
|
||
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "حذف فایل",
|
||
text: "حذف تصویر با موفقیت انجام شد!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
error: function(error) {
|
||
hideLoaderScreen();
|
||
console.log(error);
|
||
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "در حذف تصویر مشکلی پیش آمده است!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
|
||
$("#example").on("click", "button.row-upload-images", function() {
|
||
$("#stepModalImage").modal("show");
|
||
$("#see-danger").css("display", "none");
|
||
$("#see-danger2").css("display", "none");
|
||
$("#see-danger3").css("display", "none");
|
||
$("#dangersecond-mainshow").css("display", "none");
|
||
let row = table.row($(this).closest("tr"));
|
||
|
||
// console.log("row.data().status: ", row.data().status);
|
||
rowStatus = row.data().status;
|
||
|
||
if (row.data().lat_lng != undefined) {
|
||
pointImageLat = parseFloat(row.data().lat_lng[0]);
|
||
pointImageLng = parseFloat(row.data().lat_lng[1]);
|
||
}
|
||
|
||
if (row.data().point_images != undefined) {
|
||
pointImageLinks = row.data().point_images;
|
||
} else {
|
||
pointImageLinks = [];
|
||
}
|
||
|
||
if (row.data().id != undefined) {
|
||
pointImageId = row.data().id;
|
||
}
|
||
|
||
setTimeout(() => {
|
||
if (mapImage == null) {
|
||
createMapImage();
|
||
setTimeout(() => {
|
||
setMapImageView();
|
||
}, 100);
|
||
} else {
|
||
setMapImageView();
|
||
}
|
||
}, 200);
|
||
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$("#submitUploadImage").show();
|
||
} else {
|
||
$("#submitUploadImage").hide();
|
||
}
|
||
|
||
if (pointImageLinks != undefined && pointImageLinks.length) {
|
||
setTimeout(() => {
|
||
pointImageLinks.forEach((link) => {
|
||
// console.log(link.path);
|
||
if (link.path.includes("image-right-50-1")) {
|
||
$(".right50-image-1-container").empty();
|
||
$(".right50-image-1-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container501").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-right-50-2")) {
|
||
$(".right50-image-2-container").empty();
|
||
$(".right50-image-2-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container502").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-left-50-1")) {
|
||
$(".left50-image-1-container").empty();
|
||
$(".left50-image-1-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container503").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-left-50-2")) {
|
||
$(".left50-image-2-container").empty();
|
||
$(".left50-image-2-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container504").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-right-100-1")) {
|
||
$(".right100-image-1-container").empty();
|
||
$(".right100-image-1-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container1001").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-right-100-2")) {
|
||
$(".right100-image-2-container").empty();
|
||
$(".right100-image-2-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container1002").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-left-100-1")) {
|
||
$(".left100-image-1-container").empty();
|
||
$(".left100-image-1-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container1003").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-left-100-2")) {
|
||
$(".left100-image-2-container").empty();
|
||
$(".left100-image-2-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container1004").show();
|
||
}
|
||
}
|
||
if (link.path.includes("image-satellite")) {
|
||
$(".middle-image-inner-container").empty();
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="/${link.path.replace(
|
||
"public",
|
||
"storage"
|
||
)}" class="box-images" />
|
||
`);
|
||
if (rowStatus == 0 || rowStatus == 3) {
|
||
$(".remove-image-container1005").show();
|
||
}
|
||
}
|
||
});
|
||
}, 500);
|
||
} else {
|
||
setTimeout(() => {
|
||
$(".right50-image-1-container").empty();
|
||
$(".right50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container501").hide();
|
||
|
||
$(".right50-image-2-container").empty();
|
||
$(".right50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container502").hide();
|
||
|
||
$(".left50-image-1-container").empty();
|
||
$(".left50-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container503").hide();
|
||
|
||
$(".left50-image-2-container").empty();
|
||
$(".left50-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container504").hide();
|
||
|
||
$(".right100-image-1-container").empty();
|
||
$(".right100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1001").hide();
|
||
|
||
$(".right100-image-2-container").empty();
|
||
$(".right100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1002").hide();
|
||
|
||
$(".left100-image-1-container").empty();
|
||
$(".left100-image-1-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس اول </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1003").hide();
|
||
|
||
$(".left100-image-2-container").empty();
|
||
$(".left100-image-2-container").append(`
|
||
<span style="font-size: 11px !important; font-family: IRANSans;"> عکس دوم </span>
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 15px;" />
|
||
`);
|
||
$(".remove-image-container1004").hide();
|
||
|
||
$(".middle-image-inner-container").empty();
|
||
$(".middle-image-inner-container").append(`
|
||
<img src="../dist/images/icons/add-image.svg" style="height: 20px; margin-top: 23px;" />
|
||
`);
|
||
$(".remove-image-container1005").hide();
|
||
}, 500);
|
||
}
|
||
});
|
||
|
||
$("#backUploadImage").on("click", function() {
|
||
$("#stepModalImage").modal("hide");
|
||
});
|
||
|
||
var errorUploadAllImages = false;
|
||
|
||
$("#submitUploadImage").on("click", function() {
|
||
errorUploadAllImages = false;
|
||
|
||
let imageRight501Input = $("input[name=image-right-50-1]")[0].files[0];
|
||
let imageRight502Input = $("input[name=image-right-50-2]")[0].files[0];
|
||
let imageRight1001Input = $("input[name=image-right-100-1]")[0].files[0];
|
||
let imageRight1002Input = $("input[name=image-right-100-2]")[0].files[0];
|
||
let imageLeft501Input = $("input[name=image-left-50-1]")[0].files[0];
|
||
let imageLeft502Input = $("input[name=image-left-50-2]")[0].files[0];
|
||
let imageLeft1001Input = $("input[name=image-left-100-1]")[0].files[0];
|
||
let imageLeft1002Input = $("input[name=image-left-100-2]")[0].files[0];
|
||
let imageSatelliteInput = $("input[name=image-satellite]")[0].files[0];
|
||
|
||
let imageRight501Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-right-50-1")
|
||
);
|
||
let imageRight502Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-right-50-2")
|
||
);
|
||
let imageRight1001Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-right-100-1")
|
||
);
|
||
let imageRight1002Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-right-100-2")
|
||
);
|
||
let imageLeft501Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-left-50-1")
|
||
);
|
||
let imageLeft502Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-left-50-2")
|
||
);
|
||
let imageLeft1001Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-left-100-1")
|
||
);
|
||
let imageLeft1002Link = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-left-100-2")
|
||
);
|
||
let imageSatelliteLink = pointImageLinks.filter((item) =>
|
||
item.path.includes("image-satellite")
|
||
);
|
||
|
||
if (imageRight501Input == undefined && !imageRight501Link.length) {
|
||
// Image 501 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageRight502Input == undefined && !imageRight502Link.length) {
|
||
// Image 502 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageRight1001Input == undefined && !imageRight1001Link.length) {
|
||
// Image 1001 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageRight1002Input == undefined && !imageRight1002Link.length) {
|
||
// Image 1002 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageLeft501Input == undefined && !imageLeft501Link.length) {
|
||
// Image 503 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageLeft502Input == undefined && !imageLeft502Link.length) {
|
||
// Image 504 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageLeft1001Input == undefined && !imageLeft1001Link.length) {
|
||
// Image 1003 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageLeft1002Input == undefined && !imageLeft1002Link.length) {
|
||
// Image 1004 is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
if (imageSatelliteInput == undefined && !imageSatelliteLink.length) {
|
||
// Image satellite is empty!
|
||
errorUploadAllImages = true;
|
||
}
|
||
|
||
if (pointImageId != null && !errorUploadAllImages) {
|
||
formData = new FormData();
|
||
|
||
formData.append("danger-id", pointImageId);
|
||
if (imageRight1001Input != undefined)
|
||
formData.append(
|
||
"image-right-100-1",
|
||
$("input[name=image-right-100-1]")[0].files[0]
|
||
);
|
||
if (imageRight1002Input != undefined)
|
||
formData.append(
|
||
"image-right-100-2",
|
||
$("input[name=image-right-100-2]")[0].files[0]
|
||
);
|
||
if (imageLeft1001Input != undefined)
|
||
formData.append(
|
||
"image-left-100-1",
|
||
$("input[name=image-left-100-1]")[0].files[0]
|
||
);
|
||
if (imageLeft1002Input != undefined)
|
||
formData.append(
|
||
"image-left-100-2",
|
||
$("input[name=image-left-100-2]")[0].files[0]
|
||
);
|
||
if (imageRight501Input != undefined)
|
||
formData.append(
|
||
"image-right-50-1",
|
||
$("input[name=image-right-50-1]")[0].files[0]
|
||
);
|
||
if (imageRight502Input != undefined)
|
||
formData.append(
|
||
"image-right-50-2",
|
||
$("input[name=image-right-50-2]")[0].files[0]
|
||
);
|
||
if (imageLeft501Input != undefined)
|
||
formData.append(
|
||
"image-left-50-1",
|
||
$("input[name=image-left-50-1]")[0].files[0]
|
||
);
|
||
if (imageLeft502Input != undefined)
|
||
formData.append(
|
||
"image-left-50-2",
|
||
$("input[name=image-left-50-2]")[0].files[0]
|
||
);
|
||
if (imageSatelliteInput != undefined)
|
||
formData.append(
|
||
"image-satellite",
|
||
$("input[name=image-satellite]")[0].files[0]
|
||
);
|
||
|
||
Swal.fire({
|
||
icon: "warning",
|
||
title: "آیا مطمئن هستید؟",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#d33",
|
||
confirmButtonText: "بله، تایید میشود",
|
||
cancelButtonText: "منصرف شدم!",
|
||
showLoaderOnConfirm: true,
|
||
preConfirm: () => {
|
||
showLoaderScreen();
|
||
|
||
$.ajax({
|
||
url: "https://rms.rmto.ir/webapi/danger-point/images",
|
||
type: "POST",
|
||
data: formData,
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
hideLoaderScreen();
|
||
$("#stepModalImage").modal("hide");
|
||
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "بارگذاری فایل",
|
||
text: "بارگذاری تصاویر باموفقیت انجام شد!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
|
||
setTimeout(function() {
|
||
location.reload();
|
||
}, 2000);
|
||
},
|
||
error: function(error) {
|
||
hideLoaderScreen();
|
||
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "در بارگذاری فایلها مشکلی پیش آمده است!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
} else {
|
||
alert("تعداد تصاویر بارگذاری شده از ۹ تصویر کمتر است!");
|
||
}
|
||
});
|
||
|
||
$("#accordion .card-body").on("click", function() {
|
||
$("#accordion .card-link.blink_me_imageupload").click();
|
||
});
|
||
|
||
// End alirezaZ image code
|
||
|
||
// End alirezaZ image code
|
||
|
||
$("#shownext").on("click", function() {
|
||
scrolldown();
|
||
if (
|
||
$("#speedtest").val() == "" ||
|
||
$("#sppedmid").val() == "" ||
|
||
$("#hendesi").val() == 0 ||
|
||
(!$("#rokhberokh1").is(":checked") && !$("#rokhberokh2").is(":checked")) ||
|
||
(!$("#hefaz1").is(":checked") && !$("#hefaz2").is(":checked")) ||
|
||
($("#danger-point1").is(":checked") && $("#pointcode").val() == "")
|
||
) {
|
||
$("#see-danger2").css("display", "none");
|
||
if ($("#speedtest").val() == undefined || $("#speedtest").val() == "") {
|
||
$("#speedtest").addClass("is-invalid");
|
||
}
|
||
if ($("#sppedmid").val() == undefined || $("#sppedmid").val() == "") {
|
||
$("#sppedmid").addClass("is-invalid");
|
||
}
|
||
if ($("#hendesi").val() == undefined || $("#hendesi").val() == "") {
|
||
$("#hendesi").addClass("is-invalid");
|
||
}
|
||
if ($("#danger-point1").is(":checked") && $("#pointcode").val() == "") {
|
||
$("#pointcode").addClass("is-invalid");
|
||
}
|
||
if (!$("#rokhberokh1").is(":checked") &&
|
||
!$("#rokhberokh2").is(":checked")
|
||
) {
|
||
$(".rokhberokhlabel1").css("color", "red");
|
||
}
|
||
if (!$("#hefaz1").is(":checked") && !$("#hefaz2").is(":checked")) {
|
||
$(".rokhberokhlabel2").css("color", "red");
|
||
}
|
||
// Swal.fire({
|
||
// icon: "error",
|
||
// title: "خطا",
|
||
// text: " . لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
// confirmButtonText: "بستن",
|
||
// });
|
||
} else {
|
||
$("#see-danger2").css("display", "block");
|
||
}
|
||
});
|
||
$("#shownext2").on("click", function() {
|
||
// scrolldown();
|
||
if (
|
||
(!$("#rishe1").is(":checked") &&
|
||
!$("#rishe2").is(":checked") &&
|
||
!$("#rishe3").is(":checked") &&
|
||
!$("#rishe4").is(":checked") &&
|
||
!$("#rishe5").is(":checked") &&
|
||
!$("#rishe6").is(":checked") &&
|
||
!$("#rishe7").is(":checked") &&
|
||
!$("#rishe8").is(":checked") &&
|
||
!$("#rishe9").is(":checked") &&
|
||
!$("#rishe10").is(":checked") &&
|
||
!$("#rishe11").is(":checked") &&
|
||
!$("#rishe12").is(":checked") &&
|
||
!$("#rishe13").is(":checked") &&
|
||
!$("#rishe14").is(":checked") &&
|
||
!$("#rishe15").is(":checked") &&
|
||
!$("#rishe16").is(":checked") &&
|
||
!$("#rishe17").is(":checked") &&
|
||
!$("#rishe18").is(":checked") &&
|
||
!$("#rishe19").is(":checked") &&
|
||
!$("#rishe20").is(":checked") &&
|
||
!$("#rishe21").is(":checked") &&
|
||
!$("#rishe22").is(":checked") &&
|
||
!$("#rishe23").is(":checked") &&
|
||
!$("#rishe24").is(":checked") &&
|
||
!$("#rishe25").is(":checked") &&
|
||
!$("#rishe26").is(":checked") &&
|
||
!$("#rishe27").is(":checked") &&
|
||
!$("#rishe28").is(":checked") &&
|
||
!$("#rishe29").is(":checked") &&
|
||
!$("#rishe30").is(":checked")) ||
|
||
$("#risheerae").val() == ""
|
||
) {
|
||
$("#see-danger3").css("display", "none");
|
||
if ($("#risheerae").val() == undefined || $("#risheerae").val() == "") {
|
||
$("#risheerae").addClass("is-invalid");
|
||
}
|
||
if (!$("#rishe1").is(":checked") &&
|
||
!$("#rishe2").is(":checked") &&
|
||
!$("#rishe3").is(":checked") &&
|
||
!$("#rishe4").is(":checked") &&
|
||
!$("#rishe5").is(":checked") &&
|
||
!$("#rishe6").is(":checked") &&
|
||
!$("#rishe7").is(":checked") &&
|
||
!$("#rishe8").is(":checked") &&
|
||
!$("#rishe9").is(":checked") &&
|
||
!$("#rishe10").is(":checked") &&
|
||
!$("#rishe11").is(":checked") &&
|
||
!$("#rishe12").is(":checked") &&
|
||
!$("#rishe13").is(":checked") &&
|
||
!$("#rishe14").is(":checked") &&
|
||
!$("#rishe15").is(":checked") &&
|
||
!$("#rishe16").is(":checked") &&
|
||
!$("#rishe17").is(":checked") &&
|
||
!$("#rishe18").is(":checked") &&
|
||
!$("#rishe19").is(":checked") &&
|
||
!$("#rishe20").is(":checked") &&
|
||
!$("#rishe21").is(":checked") &&
|
||
!$("#rishe22").is(":checked") &&
|
||
!$("#rishe23").is(":checked") &&
|
||
!$("#rishe24").is(":checked") &&
|
||
!$("#rishe25").is(":checked") &&
|
||
!$("#rishe26").is(":checked") &&
|
||
!$("#rishe27").is(":checked") &&
|
||
!$("#rishe28").is(":checked") &&
|
||
!$("#rishe29").is(":checked") &&
|
||
!$("#rishe30").is(":checked")
|
||
) {
|
||
$(".risherealabel").css("color", "red");
|
||
}
|
||
// Swal.fire({
|
||
// icon: "error",
|
||
// title: "خطا",
|
||
// text: " . لطفا تمام آیتم های ستاره دار را پر کنید",
|
||
// confirmButtonText: "بستن",
|
||
// });
|
||
} else {
|
||
$("#see-danger3").css("display", "block");
|
||
scrolldownnextsec();
|
||
// scrolldown();
|
||
}
|
||
});
|
||
|
||
function setmapviewedit(first, last) {
|
||
// console.log("test")
|
||
mapedit.removeLayer(startAbrarMarkeredit);
|
||
// $('input[name=abrar-project-latlng-startt]').removeClass('is-invalid-input');
|
||
// console.log([first , last])
|
||
if (first != null && last != null) {
|
||
mapedit.setView([first, last], 10);
|
||
|
||
startAbrarMarkeredit = new L.marker(L.latLng(first, last), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(mapedit);
|
||
// startAbrarMarkeredit.setLatLng([first, last])
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
$("input[name=abrar-project-latlng-startt]").val(first + last);
|
||
$("input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
// mapedit.on('move', function () {
|
||
// if (!isSetStartAbrarMarkeredit) {
|
||
|
||
// startAbrarMarkeredit.setLatLng([first, last]);
|
||
// $('#pin-marker-start').removeClass('pin-set').addClass('pin-move');
|
||
// }
|
||
// });
|
||
|
||
// mapedit.on('moveend', function () {
|
||
// if (!isSetStartAbrarMarkeredit) {
|
||
// startAbrarMarkeredit.setLatLng([first, last]);
|
||
// $('#pin-marker-start').removeClass('pin-move pin-set');
|
||
// }
|
||
|
||
// });
|
||
startAbrarMarkeredit.on("click", function() {
|
||
if (!isSetStartAbrarMarkeredit) {
|
||
startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
isSetStartAbrarMarkeredit = true;
|
||
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarkeredit.getLatLng().lat,
|
||
startAbrarMarkeredit.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
mapedit.setView(markerLatLng);
|
||
var latlng = $("input[name=abrar-project-latlng-startt]").val();
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
startAbrarMarkeredit.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarkeredit.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if (
|
||
$("#pin-marker-start").hasClass("pin-set") ||
|
||
isSetStartAbrarMarkeredit
|
||
) {
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
mapedit.setView(startAbrarMarkeredit.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
} else {
|
||
mapedit.setView([35.7065, 51.3477], 9);
|
||
|
||
startAbrarMarkeredit = new L.marker(L.latLng(mapedit.getCenter()), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(mapedit);
|
||
// mapedit.on('move', function () {
|
||
// startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-set').addClass('pin-move');
|
||
// });
|
||
|
||
// mapedit.on('moveend', function () {
|
||
// startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-move pin-set');
|
||
// });
|
||
startAbrarMarkeredit.on("click", function() {
|
||
if (!isSetStartAbrarMarkeredit) {
|
||
startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
isSetStartAbrarMarkeredit = true;
|
||
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarkeredit.getLatLng().lat,
|
||
startAbrarMarkeredit.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
mapedit.setView(markerLatLng);
|
||
}
|
||
});
|
||
startAbrarMarkeredit.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarkeredit.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if (
|
||
$("#pin-marker-start").hasClass("pin-set") ||
|
||
isSetStartAbrarMarkeredit
|
||
) {
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
map.setView(startAbrarMarkeredit.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function creatmapedit(arraypoint) {
|
||
// $('input[name=abrar-project-latlng-startt]').removeClass('is-invalid');
|
||
var latapi = arraypoint[0];
|
||
var lngapi = arraypoint[1];
|
||
var bounds = [
|
||
[42.9130026312, 75.6166317076],
|
||
[20.5782370061, 35.5092252948],
|
||
];
|
||
|
||
mapedit = L.map("abrar-maptest", {
|
||
maxBounds: bounds,
|
||
minZoom: 6,
|
||
}).setView([latapi, lngapi], 10);
|
||
|
||
L.tileLayer("https://rmsmap.rmto.ir/141map/{z}/{x}/{y}.png", {}).addTo(
|
||
mapedit
|
||
);
|
||
startAbrarMarkeredit = new L.marker(L.latLng(latapi, lngapi), {
|
||
icon: startAbrarDivIcon,
|
||
draggable: true,
|
||
}).addTo(mapedit);
|
||
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
||
$("input[name=abrar-project-latlng-startt]").val(latapi + lngapi);
|
||
|
||
// mapedit.on('move', function () {
|
||
// if (!isSetStartAbrarMarkeredit) {
|
||
// startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-set').addClass('pin-move');
|
||
// }
|
||
// });
|
||
|
||
// mapedit.on('moveend', function () {
|
||
// if (!isSetStartAbrarMarkeredit) {
|
||
|
||
// startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
// $('#pin-marker-start').removeClass('pin-move pin-set');
|
||
// }
|
||
// });
|
||
startAbrarMarkeredit.on("click", function() {
|
||
if (!isSetStartAbrarMarkeredit) {
|
||
startAbrarMarkeredit.setLatLng(L.latLng(mapedit.getCenter()));
|
||
isSetStartAbrarMarkeredit = true;
|
||
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
|
||
let markerLatLng = [
|
||
startAbrarMarkeredit.getLatLng().lat,
|
||
startAbrarMarkeredit.getLatLng().lng + 0.0008,
|
||
];
|
||
|
||
mapedit.setView(markerLatLng);
|
||
var latlng = $("input[name=abrar-project-latlng-startt]").val();
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
startAbrarMarkeredit.on("drag", function() {
|
||
$("#pin-marker-start").addClass("pin-move");
|
||
});
|
||
startAbrarMarkeredit.on("dragend", function() {
|
||
$("#pin-marker-start").removeClass("pin-move");
|
||
|
||
if (
|
||
$("#pin-marker-start").hasClass("pin-set") ||
|
||
isSetStartAbrarMarkeredit
|
||
) {
|
||
$(" input[name=abrar-project-latlng-startt]").val(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6) +
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
$(" input[name=abrar-project-latlng-startt]").removeClass(
|
||
"is-invalid-input"
|
||
);
|
||
$("#pin-marker-start").addClass("pin-set");
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
} else {
|
||
mapedit.setView(startAbrarMarkeredit.getLatLng());
|
||
getnominatim(
|
||
startAbrarMarkeredit.getLatLng().lat.toFixed(6),
|
||
startAbrarMarkeredit.getLatLng().lng.toFixed(6)
|
||
);
|
||
}
|
||
});
|
||
}
|
||
|
||
// $("#shownext").on('click' , function (){
|
||
// scrolldownnext()
|
||
// })
|
||
|
||
// $("#shownext2").on('click', function () {
|
||
// scrolldownnextsec()
|
||
// })
|
||
$("#submitupload").on("click", function() {
|
||
formData = new FormData();
|
||
formData.append("danger-id", idkol);
|
||
|
||
if ($("input[name=image_upload_preview]")[0].files.length != 0)
|
||
formData.append(
|
||
"police-file",
|
||
$("input[name=image_upload_preview]")[0].files[0]
|
||
);
|
||
|
||
if ($("input[name=image_upload_previewmostanad]")[0].files.length != 0)
|
||
formData.append(
|
||
"signature-file",
|
||
$("input[name=image_upload_previewmostanad]")[0].files[0]
|
||
);
|
||
|
||
for (var value of formData.values()) {
|
||
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/webapi/danger-point/images/files",
|
||
type: "POST",
|
||
headers: {
|
||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||
},
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function(result) {
|
||
hideLoaderScreen();
|
||
$("#stepmodalupload").modal("hide");
|
||
|
||
Swal.fire({
|
||
icon: "success",
|
||
title: "بارگذاری فایل",
|
||
text: "بارگذاری تصاویر باموفقیت انجام شد!",
|
||
confirmButtonText: "بستن",
|
||
preConfirm: () => {
|
||
location.reload();
|
||
},
|
||
});
|
||
},
|
||
error: function(error) {
|
||
hideLoaderScreen();
|
||
|
||
console.log(error);
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "خطا",
|
||
text: "در بارگذاری فایلها مشکلی پیش آمده است!",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
});
|
||
});
|
||
|
||
$("#comebackfirst").on("click", function() {
|
||
$("#see-danger").css("display", "none");
|
||
});
|
||
$("#comebacksecond").on("click", function() {
|
||
// $("#see-danger").css('display', 'none')
|
||
$("#see-danger2").css("display", "none");
|
||
});
|
||
$("#comebackthird").on("click", function() {
|
||
// $("#see-danger").css('display', 'none')
|
||
// $("#see-danger").css('display', 'none')
|
||
$("#see-danger3").css("display", "none");
|
||
});
|
||
$("#reverseuplad").on("click", function() {
|
||
$("#stepmodalupload").modal("hide");
|
||
});
|
||
$("#showslider").on("click", function() {
|
||
// console.log("uploaded_files", uploaded_files)
|
||
// $("#stepmodalupload").modal('hide')
|
||
if (
|
||
uploaded_files[0].signature_file != null ||
|
||
uploaded_files[1].police_file != null
|
||
) {
|
||
show_point_photo(uploaded_files);
|
||
} else {
|
||
Swal.fire({
|
||
icon: "error",
|
||
title: "",
|
||
text: "تصویری برای نمایش وجود ندارد ",
|
||
confirmButtonText: "بستن",
|
||
});
|
||
}
|
||
});
|
||
$("#slideroverlay > .upload-confirm").on("click", function() {
|
||
$(this).parent().css("display", "none");
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
});
|
||
$("#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 show_point_photo(array) {
|
||
let dataLength = array.length;
|
||
//first
|
||
$("#slideshow-slide").find(".mySlides").remove();
|
||
$("#slideshow-dot").find(".dot").remove();
|
||
|
||
if (array[0].signature_file != null && array[1].police_file != null) {
|
||
console.log("null");
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
"1" +
|
||
" / " +
|
||
"2" +
|
||
'</div><img src="' +
|
||
array[0].signature_file +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> آپلود تصویر تاییدیه مدیر کل ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 1 + ')"></span>'
|
||
);
|
||
}
|
||
if (array[0].signature_file != null && array[1].police_file == null) {
|
||
console.log("null");
|
||
let divSlide =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
"1" +
|
||
" / " +
|
||
"1" +
|
||
'</div><img src="' +
|
||
array[0].signature_file +
|
||
'"><div class="text" style="bottom: -3px;font-family: "IRANSans""> آپلود تصویر تاییدیه مدیر کل ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 1 + ')"></span>'
|
||
);
|
||
}
|
||
|
||
//second
|
||
if (array[1].police_file != null && array[0].signature_file != null) {
|
||
console.log("nulo");
|
||
let divSlide1 =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
"2" +
|
||
" / " +
|
||
"2" +
|
||
'</div><img src="' +
|
||
array[1].police_file +
|
||
'"><div class="text" style=" bottom: -3px;font-family: IRANSans"> آپلود تصویر صورتجلسه اداره کل با پلیس راه ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide1);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 2 + ')"></span>'
|
||
);
|
||
if (dataLength > 0) {
|
||
slideindex = 1;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
if (array[1].police_file != null && array[0].signature_file == null) {
|
||
console.log("nulo");
|
||
let divSlide1 =
|
||
'<div class="mySlides"><div class="numbertext">' +
|
||
"1" +
|
||
" / " +
|
||
"1" +
|
||
'</div><img src="' +
|
||
array[1].police_file +
|
||
'"><div class="text" style=" bottom: -3px;font-family: "IRANSans""> آپلود تصویر صورتجلسه اداره کل با پلیس راه ' +
|
||
"</div></div>";
|
||
$("#slideshow-slide").append(divSlide1);
|
||
$("#slideshow-dot").append(
|
||
'<span class="dot" onclick="currentphotoshow(' + 2 + ')"></span>'
|
||
);
|
||
if (dataLength > 0) {
|
||
slideindex = 1;
|
||
layerslidershow(slideindex);
|
||
$("#slideroverlay").css("display", "block");
|
||
}
|
||
}
|
||
|
||
// console.log(array.length)
|
||
}
|
||
|
||
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");
|
||
} |