2282 lines
84 KiB
JavaScript
2282 lines
84 KiB
JavaScript
var mapUrl = 'https://rmsmap.rmto.ir/141map/';
|
|
var addMap = null;
|
|
var editMap = null;
|
|
|
|
var startMarkerAdd = null;
|
|
var endMarkerAdd = null;
|
|
|
|
var startMarkerEdit = null;
|
|
var endMarkerEdit = null;
|
|
|
|
var routeControls = [];
|
|
|
|
var isSetStartMarkerAdd = false;
|
|
var isSetEndMarkerAdd = false;
|
|
|
|
var isSetStartMarkerEdit = false;
|
|
var isSetEndMarkerEdit = false;
|
|
|
|
var arrOprationsDisable = [0, 0, 0, 0]
|
|
|
|
var projectsTable;
|
|
|
|
var access = {}
|
|
var PERMISSIONS = []
|
|
|
|
|
|
var startDivIcon = L.divIcon({
|
|
html: `
|
|
<div id="pin-marker-start" class="pin-marker">
|
|
<div class="map-pin-marker">
|
|
<div class="pin-main-circle"></div>
|
|
<div class="pin-white-circle"></div>
|
|
<div class="pin-title-circle">
|
|
<span class="title-circle-text">شروع</span>
|
|
</div>
|
|
<div class="pin-main-line"></div>
|
|
</div>
|
|
<div class="pin-main-shadow">
|
|
<div class="shadow-dot">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
iconSize: [55, 75],
|
|
iconAnchor: [33, 64],
|
|
});
|
|
|
|
var endDivIcon = L.divIcon({
|
|
html: `
|
|
<div id="pin-marker-end" class="pin-marker">
|
|
<div class="map-pin-marker">
|
|
<div class="pin-main-circle"></div>
|
|
<div class="pin-white-circle"></div>
|
|
<div class="pin-title-circle">
|
|
<span class="title-circle-text">پایان</span>
|
|
</div>
|
|
<div class="pin-main-line"></div>
|
|
</div>
|
|
<div class="pin-main-shadow">
|
|
<div class="shadow-dot">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
iconSize: [55, 75],
|
|
iconAnchor: [33, 64],
|
|
});
|
|
|
|
var startDivIconEdit = L.divIcon({
|
|
html: `
|
|
<div id="edit_pin-marker-start" class="pin-marker">
|
|
<div class="map-pin-marker">
|
|
<div class="pin-main-circle"></div>
|
|
<div class="pin-white-circle"></div>
|
|
<div class="pin-title-circle">
|
|
<span class="title-circle-text">شروع</span>
|
|
</div>
|
|
<div class="pin-main-line"></div>
|
|
</div>
|
|
<div class="pin-main-shadow">
|
|
<div class="shadow-dot">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
iconSize: [55, 75],
|
|
iconAnchor: [33, 64],
|
|
});
|
|
|
|
var endDivIconEdit = L.divIcon({
|
|
html: `
|
|
<div id="edit_pin-marker-end" class="pin-marker">
|
|
<div class="map-pin-marker">
|
|
<div class="pin-main-circle"></div>
|
|
<div class="pin-white-circle"></div>
|
|
<div class="pin-title-circle">
|
|
<span class="title-circle-text">پایان</span>
|
|
</div>
|
|
<div class="pin-main-line"></div>
|
|
</div>
|
|
<div class="pin-main-shadow">
|
|
<div class="shadow-dot">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
iconSize: [55, 75],
|
|
iconAnchor: [33, 64],
|
|
});
|
|
|
|
(function () {
|
|
$.ajax({
|
|
url: "/webapi/user/get-permission",
|
|
type: "GET",
|
|
cache: false,
|
|
async: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (result) {
|
|
PERMISSIONS = result.data
|
|
console.log(PERMISSIONS, "PERMISSIONS")
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
}
|
|
})
|
|
$.ajax({
|
|
/// [start] lawmaker_filter_province_url
|
|
url: `/webapi/getuser/province-perm${$.inArray('show-proposal-province', PERMISSIONS) != -1 ? '?type=all' : ''}`,
|
|
/// [end] lawmaker_filter_province_url
|
|
type: "GET",
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
const provinces = result.data;
|
|
|
|
$("#province_excel").empty();
|
|
$("#province_excel").append('<option value="0">انتخاب استان</option>');
|
|
|
|
for (let index = 0; index < provinces.length; index++) {
|
|
$("#province_excel").append(
|
|
"\
|
|
<option value=" +
|
|
provinces[index].id +
|
|
">" +
|
|
provinces[index].name_fa +
|
|
"</option>\
|
|
"
|
|
);
|
|
}
|
|
|
|
hideLoaderScreen();
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
|
|
|
|
/// [START] proposal_add_btn
|
|
if (!($.inArray('add-proposal', PERMISSIONS) != -1 || $.inArray('add-proposal-province', PERMISSIONS) != -1))
|
|
$('.add-contract-btn').remove()
|
|
/// [END] proposal_add_btn
|
|
|
|
$("[data-mask]").inputmask();
|
|
|
|
/// [start] proposal_add_province
|
|
if ($.inArray('add-proposal', PERMISSIONS) != -1 || $.inArray('add-proposal-province', PERMISSIONS) != -1) {
|
|
$.ajax({
|
|
/// [start] proposal_add_province_url
|
|
url: `/webapi/getuser/province-perm${$.inArray('add-proposal', PERMISSIONS) != -1 ? '?type=all' : ''}`,
|
|
/// [end] proposal_add_province_url
|
|
type: "GET",
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
const provinces = result.data;
|
|
|
|
$("#add_project_province").empty();
|
|
$("#add_project_province").append('<option value="0">انتخاب استان</option>');
|
|
|
|
for (let index = 0; index < provinces.length; index++) {
|
|
$("#add_project_province").append(
|
|
"\
|
|
<option value=" +
|
|
provinces[index].id +
|
|
">" +
|
|
provinces[index].name_fa +
|
|
"</option>\
|
|
"
|
|
);
|
|
}
|
|
|
|
hideLoaderScreen();
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
}
|
|
/// [end] proposal_add_province
|
|
|
|
/// [start] proposal_edit_province
|
|
if ($.inArray('edit-proposal', PERMISSIONS) != -1 || $.inArray('edit-proposal-province', PERMISSIONS) != -1) {
|
|
$.ajax({
|
|
/// [start] proposal_edit_province_url
|
|
url: `/webapi/getuser/province-perm${$.inArray('edit-proposal', PERMISSIONS) != -1 ? '?type=all' : ''}`,
|
|
/// [end] proposal_edit_province_url
|
|
type: "GET",
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
const provinces = result.data;
|
|
|
|
$("#edit_project_province").empty();
|
|
$("#edit_project_province").append('<option value="0">انتخاب استان</option>');
|
|
|
|
for (let index = 0; index < provinces.length; index++) {
|
|
$("#edit_project_province").append(
|
|
"\
|
|
<option value=" +
|
|
provinces[index].id +
|
|
">" +
|
|
provinces[index].name_fa +
|
|
"</option>\
|
|
"
|
|
);
|
|
}
|
|
|
|
hideLoaderScreen();
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
}
|
|
/// [end] proposal_edit_province
|
|
|
|
|
|
projectsTable = $("#table_projects").DataTable({
|
|
dom: "<flB<t>p>",
|
|
pagingType: "simple_numbers",
|
|
paging: true,
|
|
destroy: true,
|
|
responsive: true,
|
|
language: {
|
|
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
|
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
|
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
|
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
|
sInfoPostFix: "",
|
|
sInfoThousands: ",",
|
|
sLengthMenu: "نمایش _MENU_ ردیف",
|
|
sLoadingRecords: "در حال بارگذاری...",
|
|
sProcessing: "در حال پردازش...",
|
|
sSearch: "جستجو: ",
|
|
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
|
oPaginate: {
|
|
sFirst: "برگهی نخست",
|
|
sLast: "برگهی آخر",
|
|
sNext: "بعدی",
|
|
sPrevious: "قبلی",
|
|
},
|
|
oAria: {
|
|
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
|
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
|
},
|
|
},
|
|
order: [
|
|
[0, "desc"]
|
|
],
|
|
processing: true,
|
|
ajax: {
|
|
url: "/webapi/proposal/get-data",
|
|
type: "GET",
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
dataSrc: function (json) {
|
|
hideLoaderScreen();
|
|
return json.data;
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
},
|
|
columns: [{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data, type, row, meta) {
|
|
return meta.row + 1;
|
|
},
|
|
},
|
|
{
|
|
data: 'unique_code',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'project_title',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'project_type_fa',
|
|
className: 'text-center text-nowrap'
|
|
},
|
|
{
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
return '<button class="btn-dataTable btn-sm btn-opration-type">...</button>';
|
|
},
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'priority_project_fa',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'followup_priority_project',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'office_fa',
|
|
className: 'text-center text-nowrap'
|
|
},
|
|
{
|
|
data: 'province_fa',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'axis_name',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'axis_type_fa',
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data) {
|
|
const national_credit = parseInt(data.national_credit).toLocaleString('en');
|
|
return national_credit
|
|
}
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data) {
|
|
const province_credit = parseInt(data.province_credit).toLocaleString('en');
|
|
return province_credit
|
|
}
|
|
},
|
|
{
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
let content = '<div class="d-flex justify-content-center">'
|
|
/// [start] proposal_edit_can
|
|
if (data.canEdit)
|
|
content += '<button class="btn-dataTable btn-edit-project"><i class="fas fa-edit"></i></button>'
|
|
/// [end] proposal_edit_can
|
|
/// [start] proposal_delete_can
|
|
if (data.canDelete)
|
|
content += '<div class="pipeline mx-2"></div><button class="btn-dataTable btn-delete-project"><i class="fa fa-trash"></i></button>'
|
|
/// [end] proposal_delete_can
|
|
content += '</div>'
|
|
return content
|
|
},
|
|
className: 'text-center'
|
|
},
|
|
],
|
|
|
|
buttons: [
|
|
{
|
|
text: '<div class="btn-table-excel"><div class="d-flex flex-column"><i class="fa mb-2 fa-book icon-color"></i>خروجی به اکسل</div></div>',
|
|
action: function (e, dt, node, config) {
|
|
topPosition = $(e.target).parents('.btn-table-excel').offset().top + $(e.target).parents('.btn-table-excel').height() + 5
|
|
$(".parent-excel").css('top', topPosition)
|
|
$(".parent-excel").css("display", "block");
|
|
},
|
|
|
|
},
|
|
],
|
|
|
|
});
|
|
|
|
})()
|
|
|
|
function showLoaderScreen() {
|
|
$(".divloader").css("display", "flex").hide().fadeIn();
|
|
}
|
|
|
|
function hideLoaderScreen() {
|
|
$(".divloader").fadeOut();
|
|
}
|
|
|
|
function createAddMap() {
|
|
var bounds = [
|
|
[42.9130026312, 75.6166317076],
|
|
[20.5782370061, 35.5092252948],
|
|
];
|
|
|
|
addMap = L.map("add_map", {
|
|
maxBounds: bounds,
|
|
minZoom: 6,
|
|
}).setView([35.7065000000, 51.3477000000], 7);
|
|
|
|
L.tileLayer(`${mapUrl}{z}/{x}/{y}.png`, {}).addTo(addMap);
|
|
setMarkerDefaultAdd()
|
|
|
|
}
|
|
|
|
function clearAddMap() {
|
|
|
|
isSetStartMarkerAdd = false;
|
|
isSetEndMarkerAdd = false;
|
|
if (routeControls.length) {
|
|
$(routeControls).each(function (index, control) {
|
|
addMap.removeControl(control);
|
|
routeControls.splice(routeControls.indexOf(index), 1);
|
|
});
|
|
}
|
|
addMap.removeLayer(startMarkerAdd);
|
|
if (endMarkerAdd != null) {
|
|
addMap.removeLayer(endMarkerAdd);
|
|
|
|
}
|
|
addMap.setView([35.7065000000, 51.3477000000], 7);
|
|
setMarkerDefaultAdd()
|
|
|
|
|
|
}
|
|
|
|
function setMarkerDefaultAdd() {
|
|
|
|
startMarkerAdd = new L.marker(L.latLng(addMap.getCenter()), {
|
|
icon: startDivIcon,
|
|
draggable: true,
|
|
}).addTo(addMap);
|
|
|
|
endMarkerAdd = new L.marker(L.latLng(addMap.getCenter()), {
|
|
icon: endDivIcon,
|
|
draggable: true,
|
|
})
|
|
|
|
addMap.on("move", function () {
|
|
if (!isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
|
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
$("#pin-marker-start").removeClass("pin-set").addClass("pin-move");
|
|
}
|
|
|
|
if (isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
|
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
$("#pin-marker-end").removeClass("pin-set").addClass("pin-move");
|
|
}
|
|
});
|
|
|
|
addMap.on("moveend", function () {
|
|
if (!isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
|
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
$("#pin-marker-start").removeClass("pin-move pin-set");
|
|
}
|
|
|
|
if (isSetStartMarkerAdd && !isSetEndMarkerAdd) {
|
|
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
$("#pin-marker-end").removeClass("pin-move pin-set");
|
|
}
|
|
});
|
|
|
|
startMarkerAdd.on("click", function () {
|
|
if (!isSetStartMarkerAdd) {
|
|
startMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
endMarkerAdd.setLatLng(L.latLng(addMap.getCenter()));
|
|
isSetStartMarkerAdd = true;
|
|
$("#pin-marker-start")
|
|
.removeClass("pin-move pin-warn")
|
|
.addClass("pin-set");
|
|
$("#add_project_start_map").val(
|
|
startMarkerAdd.getLatLng().lat.toFixed(6) +
|
|
startMarkerAdd.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#add_project_start_map"
|
|
).removeClass("validity-checker");
|
|
}
|
|
endMarkerAdd.addTo(addMap);
|
|
|
|
$(this).hide();
|
|
$("#pin-marker-start")
|
|
.removeClass("pin-move pin-warn")
|
|
.addClass("pin-set");
|
|
})
|
|
|
|
startMarkerAdd.on("drag", function () {
|
|
$("#pin-marker-start").addClass("pin-move");
|
|
});
|
|
|
|
startMarkerAdd.on("dragend", function () {
|
|
$("#pin-marker-start").removeClass("pin-move");
|
|
if ($("#pin-marker-start").hasClass("pin-set") || isSetStartMarkerAdd) {
|
|
$("#pin-marker-start").addClass("pin-set");
|
|
$("#add_project_start_map").val(
|
|
startMarkerAdd.getLatLng().lat.toFixed(6) +
|
|
startMarkerAdd.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#add_project_start_map"
|
|
).removeClass("validity-checker");
|
|
checkMarkersAndDrawPath();
|
|
} else {
|
|
addMap.setView(startMarkerAdd.getLatLng());
|
|
}
|
|
});
|
|
|
|
endMarkerAdd.on("click", function () {
|
|
if (!isSetEndMarkerAdd) {
|
|
isSetEndMarkerAdd = true;
|
|
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
|
$("#add_project_end_map").val(
|
|
endMarkerAdd.getLatLng().lat.toFixed(6) +
|
|
endMarkerAdd.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#add_project_end_map"
|
|
).removeClass("validity-checker");
|
|
}
|
|
checkMarkersAndDrawPath();
|
|
})
|
|
|
|
endMarkerAdd.on("drag", function () {
|
|
$("#pin-marker-end").addClass("pin-move");
|
|
checkMarkersAndDrawPath();
|
|
});
|
|
|
|
endMarkerAdd.on("dragend", function () {
|
|
$("#pin-marker-end").removeClass("pin-move");
|
|
|
|
if ($("#pin-marker-end").hasClass("pin-set") || isSetEndMarkerAdd) {
|
|
$("#pin-marker-end").addClass("pin-set");
|
|
$("#add_project_end_map").val(
|
|
endMarkerAdd.getLatLng().lat.toFixed(6) +
|
|
endMarkerAdd.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#add_project_end_map"
|
|
).removeClass("validity-checker");
|
|
checkMarkersAndDrawPath();
|
|
} else {
|
|
addMap.setView(endMarkerAdd.getLatLng());
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkMarkersAndDrawPath() {
|
|
if (
|
|
$("#pin-marker-start").hasClass("pin-set") &&
|
|
!$("#pin-marker-start").hasClass("pin-move") &&
|
|
$("#pin-marker-end").hasClass("pin-set") &&
|
|
!$("#pin-marker-end").hasClass("pin-move")
|
|
) {
|
|
drawPath();
|
|
}
|
|
}
|
|
|
|
function drawPath() {
|
|
if (routeControls.length) {
|
|
$(routeControls).each(function (index, control) {
|
|
addMap.removeControl(control);
|
|
routeControls.splice(routeControls.indexOf(index), 1);
|
|
});
|
|
}
|
|
routeControls.push(
|
|
L.Routing.control({
|
|
waypoints: [
|
|
L.latLng(
|
|
parseFloat(startMarkerAdd.getLatLng().lat),
|
|
parseFloat(startMarkerAdd.getLatLng().lng)
|
|
),
|
|
L.latLng(
|
|
parseFloat(endMarkerAdd.getLatLng().lat),
|
|
parseFloat(endMarkerAdd.getLatLng().lng)
|
|
),
|
|
],
|
|
fitSelectedRoutes: false,
|
|
draggableWaypoints: true,
|
|
createMarker: function () {
|
|
return null;
|
|
},
|
|
lineOptions: {
|
|
addWaypoints: false,
|
|
styles: [{
|
|
color: "#28a745",
|
|
opacity: 0.8,
|
|
weight: 5,
|
|
},],
|
|
},
|
|
})
|
|
|
|
.addTo(addMap)
|
|
);
|
|
$(".leaflet-control-container").css("display", "none");
|
|
$(".leaflet-routing-container-hide").css("display", "none");
|
|
}
|
|
|
|
function drawPathEdit() {
|
|
if (routeControls.length) {
|
|
$(routeControls).each(function (index, control) {
|
|
editMap.removeControl(control);
|
|
routeControls.splice(routeControls.indexOf(index), 1);
|
|
});
|
|
}
|
|
routeControls.push(
|
|
L.Routing.control({
|
|
waypoints: [
|
|
L.latLng(
|
|
parseFloat(startMarkerEdit.getLatLng().lat),
|
|
parseFloat(startMarkerEdit.getLatLng().lng)
|
|
),
|
|
L.latLng(
|
|
parseFloat(endMarkerEdit.getLatLng().lat),
|
|
parseFloat(endMarkerEdit.getLatLng().lng)
|
|
),
|
|
],
|
|
fitSelectedRoutes: false,
|
|
draggableWaypoints: true,
|
|
createMarker: function () {
|
|
return null;
|
|
},
|
|
lineOptions: {
|
|
addWaypoints: false,
|
|
styles: [{
|
|
color: "#28a745",
|
|
opacity: 0.8,
|
|
weight: 5,
|
|
},],
|
|
},
|
|
})
|
|
|
|
.addTo(editMap)
|
|
);
|
|
$(".leaflet-control-container").css("display", "none");
|
|
$(".leaflet-routing-container-hide").css("display", "none");
|
|
}
|
|
|
|
function createEditMap(position) {
|
|
var bounds = [
|
|
[42.9130026312, 75.6166317076],
|
|
[20.5782370061, 35.5092252948],
|
|
];
|
|
|
|
editMap = L.map("edit_map", {
|
|
maxBounds: bounds,
|
|
minZoom: 6,
|
|
}).setView([position.start.lat, position.start.lng], 7);
|
|
|
|
L.tileLayer(`${mapUrl}{z}/{x}/{y}.png`, {}).addTo(editMap);
|
|
setMarkerDefaultEdit(position)
|
|
}
|
|
|
|
function clearEditMap(position) {
|
|
if (routeControls.length) {
|
|
$(routeControls).each(function (index, control) {
|
|
editMap.removeControl(control);
|
|
routeControls.splice(routeControls.indexOf(index), 1);
|
|
});
|
|
}
|
|
editMap.removeLayer(startMarkerEdit);
|
|
editMap.removeLayer(endMarkerEdit);
|
|
|
|
editMap.setView([position.start.lat, position.start.lng], 7);
|
|
setMarkerDefaultEdit(position)
|
|
}
|
|
|
|
function setMarkerDefaultEdit(position) {
|
|
isSetStartMarkerEdit = true;
|
|
isSetEndMarkerEdit = true;
|
|
|
|
startMarkerEdit = new L.marker([position.start.lat, position.start.lng], {
|
|
icon: startDivIconEdit,
|
|
draggable: true,
|
|
}).addTo(editMap);
|
|
|
|
endMarkerEdit = new L.marker([position.end.lat, position.end.lng], {
|
|
icon: endDivIconEdit,
|
|
draggable: true,
|
|
}).addTo(editMap);
|
|
|
|
$("#edit_pin-marker-start")
|
|
.removeClass("pin-move pin-warn")
|
|
.addClass("pin-set");
|
|
$("#edit_project_start_map").val(
|
|
position.start.lat +
|
|
position.start.lng
|
|
);
|
|
|
|
|
|
$("#edit_pin-marker-end")
|
|
.removeClass("pin-move pin-warn")
|
|
.addClass("pin-set");
|
|
$("#edit_project_end_map").val(
|
|
position.end.lat +
|
|
position.end.lng
|
|
);
|
|
drawPathEdit();
|
|
|
|
|
|
startMarkerEdit.on("click", function () {
|
|
$("#edit_project_start_map").val(
|
|
startMarkerEdit.getLatLng().lat.toFixed(6) +
|
|
startMarkerEdit.getLatLng().lng.toFixed(6)
|
|
);
|
|
})
|
|
|
|
startMarkerEdit.on("drag", function () {
|
|
$("#edit_pin-marker-start").addClass("pin-move");
|
|
});
|
|
|
|
startMarkerEdit.on("dragend", function () {
|
|
$("#edit_pin-marker-start").removeClass("pin-move");
|
|
if ($("#edit_pin-marker-start").hasClass("pin-set") || isSetStartMarkerEdit) {
|
|
$("#edit_pin-marker-start").addClass("pin-set");
|
|
$("#edit_project_start_map").val(
|
|
startMarkerEdit.getLatLng().lat.toFixed(6) +
|
|
startMarkerEdit.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#edit_project_start_map"
|
|
).removeClass("validity-checker");
|
|
drawPathEdit();
|
|
} else {
|
|
editMap.setView(startMarkerEdit.getLatLng());
|
|
}
|
|
});
|
|
|
|
endMarkerEdit.on("click", function () {
|
|
$("#edit_project_end_map").val(
|
|
endMarkerEdit.getLatLng().lat.toFixed(6) +
|
|
endMarkerEdit.getLatLng().lng.toFixed(6)
|
|
);
|
|
drawPathEdit();
|
|
})
|
|
|
|
endMarkerEdit.on("drag", function () {
|
|
$("#edit_pin-marker-end").addClass("pin-move");
|
|
});
|
|
|
|
endMarkerEdit.on("dragend", function () {
|
|
$("#edit_pin-marker-end").removeClass("pin-move");
|
|
|
|
if ($("#edit_pin-marker-end").hasClass("pin-set") || isSetEndMarkerEdit) {
|
|
$("#edit_pin-marker-end").addClass("pin-set");
|
|
$("#edit_project_end_map").val(
|
|
endMarkerEdit.getLatLng().lat.toFixed(6) +
|
|
endMarkerEdit.getLatLng().lng.toFixed(6)
|
|
);
|
|
$(
|
|
"#edit_project_end_map"
|
|
).removeClass("validity-checker");
|
|
drawPathEdit();
|
|
} else {
|
|
editMap.setView(endMarkerEdit.getLatLng());
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).bind('click', function (e) {
|
|
const clicked = $(e.target);
|
|
if (clicked.parents('.datepicker-container').length != 0) return false;
|
|
if (clicked.parents('.select2-selection__choice').length != 0) return false;
|
|
if (clicked.closest('.btn-table-filter').length == 0 && clicked.closest(".parent-filter").length == 0 && $(".parent-filter").css("display") != "none") {
|
|
$(".parent-filter").css("display", "none");
|
|
}
|
|
if (clicked.closest('.btn-table-excel').length == 0 && clicked.closest(".parent-excel").length == 0 && $(".parent-excel").css("display") != "none") {
|
|
$(".parent-excel").css("display", "none");
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '.add-contract-btn', function () {
|
|
const modal = $('#modal_add_project')
|
|
|
|
modal.find('.input-project').val('')
|
|
modal.find('.input-project').removeClass("validity-checker");
|
|
|
|
modal.find('.select-project').val(0)
|
|
modal.find('.select-project').removeClass("validity-checker");
|
|
|
|
modal.find('.select-project-opration').empty()
|
|
modal.find('.select-project-opration').prop('disabled', true)
|
|
modal.find('.select-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration').val('')
|
|
modal.find('.input-project-opration').prop('disabled', true)
|
|
modal.find('.input-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration-type-unit').text('-')
|
|
modal.find('.hidden-project-opration').val(0)
|
|
|
|
modal.find('.input-project-credit').val('')
|
|
modal.find('.input-project-credit').removeClass("validity-checker");
|
|
|
|
modal.find('.span-project-credit').text('0')
|
|
|
|
modal.find('.img-input').val('');
|
|
modal.find('.img-preview').removeAttr('src');
|
|
modal.find('.img-title').css('display', '');
|
|
modal.find('.btn-delete-img').prop('disabled', true)
|
|
modal.find('.img-box').removeClass("validity-checker");
|
|
|
|
modal.find('.file-input').val('');
|
|
modal.find('.file-title').map((index, titleElement) => {
|
|
$(titleElement).text($(titleElement).data('defaultText'))
|
|
})
|
|
modal.find('.btn-delete-file').prop('disabled', true)
|
|
modal.find('.file-box').removeClass("validity-checker");
|
|
|
|
modal.find('#btn_add_project').prop('disabled', false)
|
|
|
|
arrOprationsDisable = [0, 0, 0, 0]
|
|
|
|
if (addMap == null) {
|
|
setTimeout(() => {
|
|
createAddMap();
|
|
}, 400);
|
|
|
|
} else {
|
|
clearAddMap()
|
|
}
|
|
|
|
modal.modal('show')
|
|
})
|
|
|
|
$(document).on('click', '.btn-edit-project', function () {
|
|
const modal = $('#modal_edit_project')
|
|
const tr = $(this).closest("tr");
|
|
const row = projectsTable.row(tr);
|
|
const positions = {
|
|
start: {
|
|
lat: row.data().start_lat,
|
|
lng: row.data().start_lng
|
|
},
|
|
end: {
|
|
lat: row.data().end_lat,
|
|
lng: row.data().end_lng
|
|
}
|
|
}
|
|
|
|
modal.find('.input-project').val('')
|
|
modal.find('.input-project').removeClass("validity-checker");
|
|
|
|
modal.find('.select-project').val(0)
|
|
modal.find('.select-project').removeClass("validity-checker");
|
|
|
|
modal.find('.select-project-opration').empty()
|
|
modal.find('.select-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration').val('')
|
|
modal.find('.input-project-opration').prop('disabled', true)
|
|
modal.find('.input-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration-type-unit').text('-')
|
|
modal.find('.hidden-project-opration').val(0)
|
|
|
|
modal.find('.input-project-credit').val('')
|
|
modal.find('.input-project-credit').removeClass("validity-checker");
|
|
|
|
modal.find('.span-project-credit').text('0')
|
|
|
|
modal.find('.img-input').val('');
|
|
modal.find('.img-preview').removeAttr('src');
|
|
modal.find('.img-title').css('display', '');
|
|
modal.find('.btn-delete-img').prop('disabled', true)
|
|
modal.find('.img-box').removeClass("validity-checker");
|
|
|
|
modal.find('.file-input').val('');
|
|
modal.find('.file-title').map((index, titleElement) => {
|
|
$(titleElement).text($(titleElement).data('defaultText'))
|
|
})
|
|
modal.find('.btn-delete-file').prop('disabled', true)
|
|
modal.find('.file-box').removeClass("validity-checker");
|
|
|
|
modal.find('#btn_edit_project').prop('disabled', false)
|
|
|
|
arrOprationsDisable = [0, 0, 0, 0]
|
|
|
|
modal.find(".select-project-opration").attr("disabled", false);
|
|
modal.find(".select-project-opration").append("<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>");
|
|
|
|
$.ajax({
|
|
url: "/csi/operation/" + row.data().project_type_id,
|
|
type: "GET",
|
|
cache: false,
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (res) {
|
|
$.each(res, function (key, value) {
|
|
const unit = value.unit != "" ? value.unit : "-";
|
|
const amountable = value.amountable;
|
|
modal.find(".select-project-opration").append("<option amountable='" + amountable + "' unit='" + unit + "' value='" + key + "'>" + value.farsi + "</option>");
|
|
});
|
|
if (editMap == null) {
|
|
setTimeout(() => {
|
|
createEditMap(positions);
|
|
}, 400);
|
|
} else {
|
|
clearEditMap(positions)
|
|
}
|
|
|
|
modal.find('#edit_project_id').val(row.data().id)
|
|
modal.find('#modal_edit_uniqe_code').text(row.data().unique_code)
|
|
modal.find('#edit_project_title').val(row.data().project_title)
|
|
modal.find('#edit_project_type').val(row.data().project_type_id)
|
|
|
|
const oprations = [
|
|
modal.find('#edit_project_opration_type_id_1').val(arrOprationsDisable[0] = row.data().operation_type_id1 != null ? row.data().operation_type_id1 : 0),
|
|
modal.find('#edit_project_opration_type_id_2').val(arrOprationsDisable[1] = row.data().operation_type_id2 != null ? row.data().operation_type_id2 : 0),
|
|
modal.find('#edit_project_opration_type_id_3').val(arrOprationsDisable[2] = row.data().operation_type_id3 != null ? row.data().operation_type_id3 : 0),
|
|
modal.find('#edit_project_opration_type_id_4').val(arrOprationsDisable[3] = row.data().operation_type_id4 != null ? row.data().operation_type_id4 : 0),
|
|
]
|
|
|
|
modal.find('#edit_project_opration_type_amount_1').val(row.data().operation_type_amount1 != null ? row.data().operation_type_amount1 : '')
|
|
modal.find('#edit_project_opration_type_amount_2').val(row.data().operation_type_amount2 != null ? row.data().operation_type_amount2 : '')
|
|
modal.find('#edit_project_opration_type_amount_3').val(row.data().operation_type_amount3 != null ? row.data().operation_type_amount3 : '')
|
|
modal.find('#edit_project_opration_type_amount_4').val(row.data().operation_type_amount4 != null ? row.data().operation_type_amount4 : '')
|
|
|
|
modal.find('#edit_project_opration_type_amount_1').prop('disabled', oprations[0].find('option:selected').attr('amountable') != 1 ? true : false)
|
|
modal.find('#edit_project_opration_type_amount_2').prop('disabled', oprations[1].find('option:selected').attr('amountable') != 1 ? true : false)
|
|
modal.find('#edit_project_opration_type_amount_3').prop('disabled', oprations[2].find('option:selected').attr('amountable') != 1 ? true : false)
|
|
modal.find('#edit_project_opration_type_amount_4').prop('disabled', oprations[3].find('option:selected').attr('amountable') != 1 ? true : false)
|
|
|
|
modal.find('#edit_project_opration_type_unit_1').text(oprations[0].find('option:selected').attr('unit'))
|
|
modal.find('#edit_project_opration_type_unit_2').text(oprations[1].find('option:selected').attr('unit'))
|
|
modal.find('#edit_project_opration_type_unit_3').text(oprations[2].find('option:selected').attr('unit'))
|
|
modal.find('#edit_project_opration_type_unit_4').text(oprations[3].find('option:selected').attr('unit'))
|
|
|
|
modal.find('#edit_project_opration_type_amountable_1').val(oprations[0].find('option:selected').attr('amountable'))
|
|
modal.find('#edit_project_opration_type_amountable_2').val(oprations[1].find('option:selected').attr('amountable'))
|
|
modal.find('#edit_project_opration_type_amountable_3').val(oprations[2].find('option:selected').attr('amountable'))
|
|
modal.find('#edit_project_opration_type_amountable_4').val(oprations[3].find('option:selected').attr('amountable'))
|
|
|
|
modal.find('.select-project-opration option').prop('disabled', false)
|
|
|
|
for (let i = 0; i < arrOprationsDisable.length; i++) {
|
|
if (arrOprationsDisable[i] != 0)
|
|
modal.find(`.select-project-opration option[value=${arrOprationsDisable[i]}]`).prop('disabled', true)
|
|
}
|
|
|
|
modal.find('#edit_project_follower_person').val(row.data().follower_person ?? 0)
|
|
modal.find('#edit_project_priority').val(row.data().priority_project)
|
|
modal.find('#edit_project_followup_priority').val(row.data().followup_priority_project_id)
|
|
modal.find('#edit_project_office').val(row.data().office_id)
|
|
modal.find('#edit_project_province').val(row.data().province_id)
|
|
modal.find('#edit_project_axis_name').val(row.data().axis_name)
|
|
modal.find('#edit_project_axis_type').val(row.data().axis_type_id)
|
|
modal.find('#edit_project_user_description').val(row.data().user_description)
|
|
modal.find('#edit_project_national_credit').val(row.data().national_credit)
|
|
modal.find('#edit_project_province_credit').val(row.data().province_credit != '0' ? row.data().province_credit : '')
|
|
|
|
modal.find('#edit_project_national_credit_span').text(parseInt(row.data().national_credit).toLocaleString('en'))
|
|
modal.find('#edit_project_province_credit_span').text(parseInt(row.data().province_credit != '0' ? row.data().province_credit : 0).toLocaleString('en'))
|
|
|
|
if (row.data().document_image != null) {
|
|
modal.find('.img-title').css('display', 'none')
|
|
modal.find('.btn-delete-img').prop('disabled', false)
|
|
modal.find('#edit_project_document_image_preview').attr('src', `/storage/${row.data().document_image}`)
|
|
}
|
|
|
|
modal.modal('show')
|
|
|
|
hideLoaderScreen();
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
})
|
|
|
|
$(document).on('change', '.select-project-type', function () {
|
|
const modal = $(this).parents('.modal')
|
|
const projectType = $(this).val()
|
|
|
|
modal.find('.select-project-opration').empty()
|
|
modal.find('.select-project-opration').prop('disabled', true)
|
|
modal.find('.select-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration').val('')
|
|
modal.find('.input-project-opration').prop('disabled', true)
|
|
modal.find('.input-project-opration').removeClass("validity-checker");
|
|
|
|
modal.find('.input-project-opration-type-unit').text('-')
|
|
modal.find('.hidden-project-opration').val(0)
|
|
|
|
if (projectType != 0) {
|
|
modal.find(".select-project-opration").attr("disabled", false);
|
|
modal.find(".select-project-opration").append("<option amountable='0' unit='-' value='0'>انتخاب نوع عملیات</option>");
|
|
$.ajax({
|
|
url: "/csi/operation/" + projectType,
|
|
type: "GET",
|
|
cache: false,
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (res) {
|
|
$.each(res, function (key, value) {
|
|
const unit = value.unit != "" ? value.unit : "-";
|
|
const amountable = value.amountable;
|
|
modal.find(".select-project-opration").append("<option amountable='" + amountable + "' unit='" + unit + "' value='" + key + "'>" + value.farsi + "</option>");
|
|
});
|
|
hideLoaderScreen();
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '.btn-delete-project', function () {
|
|
const tr = $(this).closest("tr");
|
|
const row = projectsTable.row(tr);
|
|
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "آیا برای حذف مطمئن هستید؟",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "بله، حذف شود",
|
|
cancelButtonText: "منصرف شدم!",
|
|
showLoaderOnConfirm: true,
|
|
preConfirm: () => {
|
|
$.ajax({
|
|
url: "/webapi/proposal/delete/" + row.data().id,
|
|
type: "POST",
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
hideLoaderScreen();
|
|
projectsTable.ajax.reload(null, false);
|
|
},
|
|
error: function (request) {
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
},
|
|
});
|
|
})
|
|
|
|
$(document).on('change', '.select-project-opration', function () {
|
|
const modal = $(this).parents('.modal')
|
|
const oprationBox = $(this).parents('.box-project-opration')
|
|
const boxIndex = oprationBox.data('boxIndex')
|
|
const opration = {
|
|
value: $(this).val(),
|
|
unit: $(this).find('option:selected').attr('unit'),
|
|
amountable: $(this).find('option:selected').attr('amountable')
|
|
}
|
|
|
|
oprationBox.find('.input-project-opration').val('')
|
|
oprationBox.find('.input-project-opration').removeClass("validity-checker");
|
|
|
|
oprationBox.find('.input-project-opration').prop('disabled', opration.amountable != 1 ? true : false)
|
|
oprationBox.find('.input-project-opration-type-unit').text(opration.unit)
|
|
oprationBox.find('.hidden-project-opration').val(opration.amountable)
|
|
|
|
if (arrOprationsDisable[boxIndex] != opration.value)
|
|
arrOprationsDisable[boxIndex] = opration.value
|
|
|
|
modal.find('.select-project-opration option').prop('disabled', false)
|
|
|
|
for (let i = 0; i < arrOprationsDisable.length; i++) {
|
|
if (arrOprationsDisable[i] != 0)
|
|
modal.find(`.select-project-opration option[value=${arrOprationsDisable[i]}]`).prop('disabled', true)
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '#btn_add_project', function () {
|
|
const thisBtn = $(this)
|
|
thisBtn.prop('disabled', true)
|
|
|
|
const modal = $('#modal_add_project')
|
|
|
|
let isValid = true;
|
|
let hasOpration = false
|
|
|
|
let isSizeValidImage = true
|
|
let isSizeValidVideo = true
|
|
let isSizeValidTechnical = true
|
|
|
|
const project_title = modal.find('#add_project_title').val()
|
|
const project_type_id = modal.find('#add_project_type').val()
|
|
const project_type_fa = modal.find('#add_project_type option:selected').text()
|
|
const operation_type_id1 = modal.find('#add_project_opration_type_id_1 option:selected').val()
|
|
const operation_type_fa1 = modal.find('#add_project_opration_type_id_1 option:selected').text()
|
|
const operation_type_unit1 = modal.find('#add_project_opration_type_id_1 option:selected').attr('unit')
|
|
const operation_type_amount1 = modal.find('#add_project_opration_type_amount_1').val()
|
|
const operation_type_amountable1 = $('#add_project_opration_type_amountable_1').val()
|
|
const operation_type_id2 = modal.find('#add_project_opration_type_id_2 option:selected').val()
|
|
const operation_type_fa2 = modal.find('#add_project_opration_type_id_2 option:selected').text()
|
|
const operation_type_unit2 = modal.find('#add_project_opration_type_id_2 option:selected').attr('unit')
|
|
const operation_type_amount2 = modal.find('#add_project_opration_type_amount_2').val()
|
|
const operation_type_amountable2 = modal.find('#add_project_opration_type_amountable_2').val()
|
|
const operation_type_id3 = modal.find('#add_project_opration_type_id_3 option:selected').val()
|
|
const operation_type_fa3 = modal.find('#add_project_opration_type_id_3 option:selected').text()
|
|
const operation_type_unit3 = modal.find('#add_project_opration_type_id_3 option:selected').attr('unit')
|
|
const operation_type_amount3 = modal.find('#add_project_opration_type_amount_3').val()
|
|
const operation_type_amountable3 = $('#add_project_opration_type_amountable_3').val()
|
|
const operation_type_id4 = modal.find('#add_project_opration_type_id_4 option:selected').val()
|
|
const operation_type_fa4 = modal.find('#add_project_opration_type_id_4 option:selected').text()
|
|
const operation_type_unit4 = modal.find('#add_project_opration_type_id_4 option:selected').attr('unit')
|
|
const operation_type_amount4 = modal.find('#add_project_opration_type_amount_4').val()
|
|
const operation_type_amountable4 = $('#add_project_opration_type_amountable_4').val()
|
|
const follower_person = modal.find('#add_project_follower_person').val()
|
|
const follower_person_fa = modal.find('#add_project_follower_person option:selected').text()
|
|
const priority_project = modal.find('#add_project_priority').val()
|
|
const priority_project_fa = modal.find('#add_project_priority option:selected').text()
|
|
const followup_priority_project_id = modal.find('#add_project_followup_priority').val()
|
|
const followup_priority_project = modal.find('#add_project_followup_priority option:selected').text()
|
|
const office_id = modal.find('#add_project_office').val()
|
|
const office_fa = modal.find('#add_project_office option:selected').text()
|
|
const province_id = modal.find('#add_project_province').val()
|
|
const province_fa = modal.find('#add_project_province option:selected').text()
|
|
const axis_type_id = modal.find('#add_project_axis_type').val()
|
|
const axis_type_fa = modal.find('#add_project_axis_type option:selected').text()
|
|
const axis_name = modal.find('#add_project_axis_name').val()
|
|
const user_description = modal.find('#add_project_user_description').val()
|
|
const national_credit = modal.find('#add_project_national_credit').val()
|
|
const province_credit = modal.find('#add_project_province_credit').val()
|
|
|
|
const document_image = modal.find('#add_project_document_image').get(0).files[0]
|
|
const document_video = modal.find('#add_project_document_video').get(0).files[0]
|
|
const document_technical = modal.find('#add_project_document_technical').get(0).files[0]
|
|
|
|
const start_lat = startMarkerAdd.getLatLng().lat.toFixed(6)
|
|
const start_lng = startMarkerAdd.getLatLng().lng.toFixed(6)
|
|
const end_lat = endMarkerAdd.getLatLng().lat.toFixed(6)
|
|
const end_lng = endMarkerAdd.getLatLng().lng.toFixed(6)
|
|
|
|
|
|
if (project_title == '') {
|
|
isValid = false
|
|
modal.find('#add_project_title').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_title').removeClass("validity-checker");
|
|
}
|
|
|
|
if (project_type_id == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_type').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_type').removeClass("validity-checker");
|
|
}
|
|
|
|
if (modal.find('#add_project_start_map').val() == '') {
|
|
isValid = false
|
|
modal.find('#add_project_start_map').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_start_map').removeClass("validity-checker");
|
|
}
|
|
|
|
if (modal.find('#add_project_end_map').val() == '') {
|
|
isValid = false
|
|
modal.find('#add_project_end_map').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_end_map').removeClass("validity-checker");
|
|
}
|
|
|
|
if (operation_type_id1 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable1 == 1 && operation_type_amount1 == '') {
|
|
isValid = false
|
|
modal.find('#add_project_opration_type_amount_1').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_opration_type_amount_1').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id2 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable2 == 1 && operation_type_amount2 == '') {
|
|
isValid = false
|
|
modal.find('#add_project_opration_type_amount_2').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_opration_type_amount_2').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id3 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable3 == 1 && operation_type_amount3 == '') {
|
|
isValid = false
|
|
modal.find('#add_project_opration_type_amount_3').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_opration_type_amount_3').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id4 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable4 == 1 && operation_type_amount4 == '') {
|
|
isValid = false
|
|
modal.find('#add_project_opration_type_amount_4').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_opration_type_amount_4').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (follower_person == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_follower_person').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_follower_person').removeClass("validity-checker");
|
|
}
|
|
|
|
if (priority_project == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_priority').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_priority').removeClass("validity-checker");
|
|
}
|
|
|
|
if (followup_priority_project_id == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_followup_priority').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_followup_priority').removeClass("validity-checker");
|
|
}
|
|
|
|
if (office_id == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_office').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_office').removeClass("validity-checker");
|
|
}
|
|
|
|
if (province_id == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_province').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_province').removeClass("validity-checker");
|
|
}
|
|
|
|
if (axis_type_id == 0) {
|
|
isValid = false
|
|
modal.find('#add_project_axis_type').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_axis_type').removeClass("validity-checker");
|
|
}
|
|
|
|
if (axis_name == '') {
|
|
isValid = false
|
|
modal.find('#add_project_axis_name').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_axis_name').removeClass("validity-checker");
|
|
}
|
|
|
|
if (national_credit == '') {
|
|
isValid = false
|
|
modal.find('#add_project_national_credit').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_national_credit').removeClass("validity-checker");
|
|
}
|
|
|
|
if (typeof document_image === "undefined") {
|
|
isValid = false
|
|
modal.find('#add_project_document_image_label').addClass("validity-checker");
|
|
} else if (document_image.size >= 2000000) {
|
|
isSizeValidImage = false
|
|
modal.find('#add_project_document_image_label').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#add_project_document_image_label').removeClass("validity-checker");
|
|
}
|
|
|
|
if (typeof document_video !== "undefined") {
|
|
if (document_video.size >= 30000000) {
|
|
isSizeValidVideo = false
|
|
modal.find('#add_project_document_video_label').addClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (typeof document_technical !== "undefined") {
|
|
if (document_technical.size >= 5000000) {
|
|
isSizeValidTechnical = false
|
|
modal.find('#add_project_document_technical_label').addClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (!isValid) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "لطفا تمامی مقادیر اجباری را وارد کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!hasOpration) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حداقل باید یک عملیات را وارد کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidImage) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل عکس بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidVideo) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل ویدیو بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidTechnical) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل فایل بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else {
|
|
let formData = new FormData();
|
|
|
|
formData.append("project_title", project_title);
|
|
formData.append("project_type_id", project_type_id);
|
|
formData.append("project_type_fa", project_type_fa);
|
|
formData.append("office_id", office_id);
|
|
formData.append("office_fa", office_fa);
|
|
formData.append("province_id", province_id);
|
|
formData.append("province_fa", province_fa);
|
|
formData.append("axis_type_id", axis_type_id);
|
|
formData.append("axis_type_fa", axis_type_fa);
|
|
formData.append("axis_name", axis_name);
|
|
formData.append("follower_person", follower_person);
|
|
formData.append("follower_person_fa", follower_person_fa);
|
|
formData.append("followup_priority_project_id", followup_priority_project_id);
|
|
formData.append("followup_priority_project", followup_priority_project);
|
|
formData.append("priority_project", priority_project);
|
|
formData.append("priority_project_fa", priority_project_fa);
|
|
if (operation_type_id1 != 0) {
|
|
formData.append("operation_type_id1", operation_type_id1);
|
|
formData.append("operation_type_fa1", operation_type_fa1);
|
|
formData.append("operation_type_unit1", operation_type_unit1);
|
|
formData.append("operation_type_amount1", operation_type_amount1);
|
|
}
|
|
if (operation_type_id2 != 0) {
|
|
formData.append("operation_type_id2", operation_type_id2);
|
|
formData.append("operation_type_fa2", operation_type_fa2);
|
|
formData.append("operation_type_unit2", operation_type_unit2);
|
|
formData.append("operation_type_amount2", operation_type_amount2);
|
|
}
|
|
if (operation_type_id3 != 0) {
|
|
formData.append("operation_type_id3", operation_type_id3);
|
|
formData.append("operation_type_fa3", operation_type_fa3);
|
|
formData.append("operation_type_unit3", operation_type_unit3);
|
|
formData.append("operation_type_amount3", operation_type_amount3);
|
|
}
|
|
if (operation_type_id4 != 0) {
|
|
formData.append("operation_type_id4", operation_type_id4);
|
|
formData.append("operation_type_fa4", operation_type_fa4);
|
|
formData.append("operation_type_unit4", operation_type_unit4);
|
|
formData.append("operation_type_amount4", operation_type_amount4);
|
|
}
|
|
formData.append("user_description", user_description);
|
|
formData.append("national_credit", national_credit);
|
|
formData.append("province_credit", province_credit != '' ? province_credit : '0');
|
|
|
|
if (typeof document_image !== "undefined")
|
|
formData.append("document_image", document_image);
|
|
if (typeof document_video !== "undefined")
|
|
formData.append("document_video", document_video);
|
|
if (typeof document_technical !== "undefined")
|
|
formData.append("document_technical", document_technical);
|
|
|
|
formData.append("start_lat", start_lat);
|
|
formData.append("start_lng", start_lng);
|
|
formData.append("end_lat", end_lat);
|
|
formData.append("end_lng", end_lng);
|
|
|
|
$.ajax({
|
|
url: "/webapi/proposal/store",
|
|
type: "POST",
|
|
data: formData,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
thisBtn.prop('disabled', false)
|
|
modal.modal('hide')
|
|
hideLoaderScreen();
|
|
Swal.fire({
|
|
icon: "success",
|
|
title: "ثبت موفق",
|
|
text: "پروژه جدید با موفقیت ثبت شد",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
}).then(result => {
|
|
projectsTable.ajax.reload(null, false);
|
|
})
|
|
},
|
|
error: function (request) {
|
|
thisBtn.prop('disabled', false)
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '#btn_edit_project', function () {
|
|
const thisBtn = $(this)
|
|
thisBtn.prop('disabled', true)
|
|
|
|
const modal = $('#modal_edit_project')
|
|
|
|
let isValid = true;
|
|
let hasOpration = false
|
|
|
|
let isSizeValidImage = true
|
|
let isSizeValidVideo = true
|
|
let isSizeValidTechnical = true
|
|
|
|
const id = modal.find('#edit_project_id').val()
|
|
const project_title = modal.find('#edit_project_title').val()
|
|
const project_type_id = modal.find('#edit_project_type').val()
|
|
const project_type_fa = modal.find('#edit_project_type option:selected').text()
|
|
const operation_type_id1 = modal.find('#edit_project_opration_type_id_1 option:selected').val()
|
|
const operation_type_fa1 = modal.find('#edit_project_opration_type_id_1 option:selected').text()
|
|
const operation_type_unit1 = modal.find('#edit_project_opration_type_id_1 option:selected').attr('unit')
|
|
const operation_type_amount1 = modal.find('#edit_project_opration_type_amount_1').val()
|
|
const operation_type_amountable1 = $('#edit_project_opration_type_amountable_1').val()
|
|
const operation_type_id2 = modal.find('#edit_project_opration_type_id_2 option:selected').val()
|
|
const operation_type_fa2 = modal.find('#edit_project_opration_type_id_2 option:selected').text()
|
|
const operation_type_unit2 = modal.find('#edit_project_opration_type_id_2 option:selected').attr('unit')
|
|
const operation_type_amount2 = modal.find('#edit_project_opration_type_amount_2').val()
|
|
const operation_type_amountable2 = modal.find('#edit_project_opration_type_amountable_2').val()
|
|
const operation_type_id3 = modal.find('#edit_project_opration_type_id_3 option:selected').val()
|
|
const operation_type_fa3 = modal.find('#edit_project_opration_type_id_3 option:selected').text()
|
|
const operation_type_unit3 = modal.find('#edit_project_opration_type_id_3 option:selected').attr('unit')
|
|
const operation_type_amount3 = modal.find('#edit_project_opration_type_amount_3').val()
|
|
const operation_type_amountable3 = $('#edit_project_opration_type_amountable_3').val()
|
|
const operation_type_id4 = modal.find('#edit_project_opration_type_id_4 option:selected').val()
|
|
const operation_type_fa4 = modal.find('#edit_project_opration_type_id_4 option:selected').text()
|
|
const operation_type_unit4 = modal.find('#edit_project_opration_type_id_4 option:selected').attr('unit')
|
|
const operation_type_amount4 = modal.find('#edit_project_opration_type_amount_4').val()
|
|
const operation_type_amountable4 = $('#edit_project_opration_type_amountable_4').val()
|
|
const follower_person = modal.find('#edit_project_follower_person').val()
|
|
const follower_person_fa = modal.find('#edit_project_follower_person option:selected').text()
|
|
const priority_project = modal.find('#edit_project_priority').val()
|
|
const priority_project_fa = modal.find('#edit_project_priority option:selected').text()
|
|
const followup_priority_project_id = modal.find('#edit_project_followup_priority').val()
|
|
const followup_priority_project = modal.find('#edit_project_followup_priority option:selected').text()
|
|
const office_id = modal.find('#edit_project_office').val()
|
|
const office_fa = modal.find('#edit_project_office option:selected').text()
|
|
const province_id = modal.find('#edit_project_province').val()
|
|
const province_fa = modal.find('#edit_project_province option:selected').text()
|
|
const axis_type_id = modal.find('#edit_project_axis_type').val()
|
|
const axis_type_fa = modal.find('#edit_project_axis_type option:selected').text()
|
|
const axis_name = modal.find('#edit_project_axis_name').val()
|
|
const user_description = modal.find('#edit_project_user_description').val()
|
|
const national_credit = modal.find('#edit_project_national_credit').val()
|
|
const province_credit = modal.find('#edit_project_province_credit').val()
|
|
|
|
const document_image = modal.find('#edit_project_document_image').get(0).files[0]
|
|
const document_video = modal.find('#edit_project_document_video').get(0).files[0]
|
|
const document_technical = modal.find('#edit_project_document_technical').get(0).files[0]
|
|
|
|
const start_lat = startMarkerEdit.getLatLng().lat.toFixed(6)
|
|
const start_lng = startMarkerEdit.getLatLng().lng.toFixed(6)
|
|
const end_lat = endMarkerEdit.getLatLng().lat.toFixed(6)
|
|
const end_lng = endMarkerEdit.getLatLng().lng.toFixed(6)
|
|
|
|
if (project_title == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_title').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_title').removeClass("validity-checker");
|
|
}
|
|
|
|
if (project_type_id == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_type').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_type').removeClass("validity-checker");
|
|
}
|
|
|
|
if (modal.find('#edit_project_start_map').val() == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_start_map').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_start_map').removeClass("validity-checker");
|
|
}
|
|
|
|
if (modal.find('#edit_project_end_map').val() == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_end_map').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_end_map').removeClass("validity-checker");
|
|
}
|
|
|
|
if (operation_type_id1 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable1 == 1 && operation_type_amount1 == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_opration_type_amount_1').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_opration_type_amount_1').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id2 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable2 == 1 && operation_type_amount2 == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_opration_type_amount_2').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_opration_type_amount_2').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id3 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable3 == 1 && operation_type_amount3 == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_opration_type_amount_3').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_opration_type_amount_3').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (operation_type_id4 != 0) {
|
|
hasOpration = true
|
|
if (operation_type_amountable4 == 1 && operation_type_amount4 == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_opration_type_amount_4').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_opration_type_amount_4').removeClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (follower_person == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_follower_person').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_follower_person').removeClass("validity-checker");
|
|
}
|
|
|
|
if (priority_project == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_priority').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_priority').removeClass("validity-checker");
|
|
}
|
|
|
|
if (followup_priority_project_id == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_followup_priority').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_followup_priority').removeClass("validity-checker");
|
|
}
|
|
|
|
if (office_id == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_office').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_office').removeClass("validity-checker");
|
|
}
|
|
|
|
if (province_id == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_province').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_province').removeClass("validity-checker");
|
|
}
|
|
|
|
if (axis_type_id == 0) {
|
|
isValid = false
|
|
modal.find('#edit_project_axis_type').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_axis_type').removeClass("validity-checker");
|
|
}
|
|
|
|
if (axis_name == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_axis_name').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_axis_name').removeClass("validity-checker");
|
|
}
|
|
|
|
if (national_credit == '') {
|
|
isValid = false
|
|
modal.find('#edit_project_national_credit').addClass("validity-checker");
|
|
} else {
|
|
modal.find('#edit_project_national_credit').removeClass("validity-checker");
|
|
}
|
|
|
|
if (typeof document_image !== "undefined") {
|
|
if (document_image.size >= 2000000) {
|
|
isSizeValidImage = false
|
|
modal.find('#edit_project_document_image_label').addClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (typeof document_video !== "undefined") {
|
|
if (document_video.size >= 30000000) {
|
|
isSizeValidVideo = false
|
|
modal.find('#edit_project_document_video_label').addClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (typeof document_technical !== "undefined") {
|
|
if (document_technical.size >= 5000000) {
|
|
isSizeValidTechnical = false
|
|
modal.find('#edit_project_document_technical_label').addClass("validity-checker");
|
|
}
|
|
}
|
|
|
|
if (!isValid) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "لطفا تمامی مقادیر اجباری را وارد کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!hasOpration) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حداقل باید یک عملیات را وارد کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidImage) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل عکس بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidVideo) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل ویدیو بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else if (!isSizeValidTechnical) {
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "حجم فایل فایل بیشتر از حد مجاز است",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
thisBtn.prop('disabled', false)
|
|
return false
|
|
} else {
|
|
let formData = new FormData();
|
|
|
|
formData.append("project_title", project_title);
|
|
formData.append("project_type_id", project_type_id);
|
|
formData.append("project_type_fa", project_type_fa);
|
|
formData.append("office_id", office_id);
|
|
formData.append("office_fa", office_fa);
|
|
formData.append("province_id", province_id);
|
|
formData.append("province_fa", province_fa);
|
|
formData.append("axis_type_id", axis_type_id);
|
|
formData.append("axis_type_fa", axis_type_fa);
|
|
formData.append("axis_name", axis_name);
|
|
formData.append("follower_person", follower_person);
|
|
formData.append("follower_person_fa", follower_person_fa);
|
|
formData.append("followup_priority_project_id", followup_priority_project_id);
|
|
formData.append("followup_priority_project", followup_priority_project);
|
|
formData.append("priority_project", priority_project);
|
|
formData.append("priority_project_fa", priority_project_fa);
|
|
if (operation_type_id1 != 0) {
|
|
formData.append("operation_type_id1", operation_type_id1);
|
|
formData.append("operation_type_fa1", operation_type_fa1);
|
|
formData.append("operation_type_unit1", operation_type_unit1);
|
|
formData.append("operation_type_amount1", operation_type_amount1);
|
|
}
|
|
if (operation_type_id2 != 0) {
|
|
formData.append("operation_type_id2", operation_type_id2);
|
|
formData.append("operation_type_fa2", operation_type_fa2);
|
|
formData.append("operation_type_unit2", operation_type_unit2);
|
|
formData.append("operation_type_amount2", operation_type_amount2);
|
|
}
|
|
if (operation_type_id3 != 0) {
|
|
formData.append("operation_type_id3", operation_type_id3);
|
|
formData.append("operation_type_fa3", operation_type_fa3);
|
|
formData.append("operation_type_unit3", operation_type_unit3);
|
|
formData.append("operation_type_amount3", operation_type_amount3);
|
|
}
|
|
if (operation_type_id4 != 0) {
|
|
formData.append("operation_type_id4", operation_type_id4);
|
|
formData.append("operation_type_fa4", operation_type_fa4);
|
|
formData.append("operation_type_unit4", operation_type_unit4);
|
|
formData.append("operation_type_amount4", operation_type_amount4);
|
|
}
|
|
formData.append("user_description", user_description);
|
|
formData.append("national_credit", national_credit);
|
|
formData.append("province_credit", province_credit != '' ? province_credit : '0');
|
|
formData.append("start_lat", start_lat);
|
|
formData.append("start_lng", start_lng);
|
|
formData.append("end_lat", end_lat);
|
|
formData.append("end_lng", end_lng);
|
|
|
|
if (typeof document_image !== "undefined")
|
|
formData.append("document_image", document_image);
|
|
if (typeof document_video !== "undefined")
|
|
formData.append("document_video", document_video);
|
|
if (typeof document_technical !== "undefined")
|
|
formData.append("document_technical", document_technical);
|
|
|
|
$.ajax({
|
|
url: "/webapi/proposal/update/" + id,
|
|
type: "POST",
|
|
data: formData,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
beforeSend: function () {
|
|
showLoaderScreen();
|
|
},
|
|
success: function (result) {
|
|
thisBtn.prop('disabled', false)
|
|
modal.modal('hide')
|
|
hideLoaderScreen();
|
|
Swal.fire({
|
|
icon: "success",
|
|
title: "ویرایش موفق",
|
|
text: "پروژه با موفقیت ویرایش شد",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
}).then(result => {
|
|
projectsTable.ajax.reload(null, false);
|
|
})
|
|
},
|
|
error: function (request) {
|
|
thisBtn.prop('disabled', false)
|
|
ajax_error(request.responseJSON, request.status);
|
|
hideLoaderScreen();
|
|
},
|
|
});
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '.btn-opration-type', function () {
|
|
const modal = $('#modal_oprations');
|
|
const tr = $(this).closest("tr");
|
|
const row = projectsTable.row(tr);
|
|
|
|
modal.find('input').val('')
|
|
|
|
modal.find('#modal_unique_code').text(row.data().unique_code)
|
|
|
|
modal.find('#modal_oprations_type_fa1').val(row.data().operation_type_fa1)
|
|
modal.find('#modal_oprations_type_amount1').val(row.data().operation_type_amount1)
|
|
modal.find('#modal_oprations_type_unit1').val(row.data().operation_type_unit1)
|
|
|
|
modal.find('#modal_oprations_type_fa2').val(row.data().operation_type_fa2)
|
|
modal.find('#modal_oprations_type_amount2').val(row.data().operation_type_amount2)
|
|
modal.find('#modal_oprations_type_unit2').val(row.data().operation_type_unit2)
|
|
|
|
modal.find('#modal_oprations_type_fa3').val(row.data().operation_type_fa3)
|
|
modal.find('#modal_oprations_type_amount3').val(row.data().operation_type_amount3)
|
|
modal.find('#modal_oprations_type_unit3').val(row.data().operation_type_unit3)
|
|
modal.find('#modal_oprations_type_progress3').val(row.data().operation_type_progress3)
|
|
|
|
modal.find('#modal_oprations_type_fa4').val(row.data().operation_type_fa4)
|
|
modal.find('#modal_oprations_type_amount4').val(row.data().operation_type_amount4)
|
|
modal.find('#modal_oprations_type_unit4').val(row.data().operation_type_unit4)
|
|
|
|
modal.modal('show')
|
|
})
|
|
|
|
$(document).on('input', '.input-project-credit', function () {
|
|
var parent = $(this).closest('.project-credit-box')
|
|
if ($(this).val() == '') {
|
|
parent.find('.span-project-credit').text('0')
|
|
return false;
|
|
}
|
|
parent.find('.span-project-credit').text(parseInt($(this).val()).toLocaleString('en'))
|
|
});
|
|
|
|
$('input[type=text]').bind('keypress', function (event) {
|
|
const arabicCharUnicodeRange = /[\u0600-\u06FF-0-9-45]/;
|
|
const key = event.which;
|
|
|
|
if (key == 8 || key == 0 || key === 32) {
|
|
return true;
|
|
}
|
|
|
|
var str = String.fromCharCode(key);
|
|
if (arabicCharUnicodeRange.test(str)) {
|
|
return true;
|
|
}
|
|
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "لطفا فقط از حروف فارسی استفاده کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
return false;
|
|
})
|
|
|
|
$('textarea').bind('keypress', function (event) {
|
|
const arabicCharUnicodeRange = /[\u0600-\u06FF-0-9-45]/;
|
|
const key = event.which;
|
|
|
|
if (key == 8 || key == 0 || key === 32) {
|
|
return true;
|
|
}
|
|
|
|
var str = String.fromCharCode(key);
|
|
if (arabicCharUnicodeRange.test(str)) {
|
|
return true;
|
|
}
|
|
|
|
Swal.fire({
|
|
icon: "warning",
|
|
title: "هشدار",
|
|
text: "لطفا فقط از حروف فارسی استفاده کنید",
|
|
cancelButtonText: "بستن",
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
});
|
|
return false;
|
|
})
|
|
// add lat lng with input
|
|
$("#modal_add_project input[name=add_project_start_map]").on(
|
|
"keyup",
|
|
function () {
|
|
checkStartMarkerValidation();
|
|
}
|
|
);
|
|
$("#modal_add_project input[name=add_project_end_map]").on(
|
|
"keyup",
|
|
function () {
|
|
checkEndMarkerValidation();
|
|
}
|
|
);
|
|
|
|
function checkStartMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
|
let reg = /^([0-9]){2}\.([0-9])+$/;
|
|
let startLatLngVal = $(
|
|
"#modal_add_project input[name=add_project_start_map]"
|
|
)
|
|
.val()
|
|
.split(" - ");
|
|
let startLatLng = startLatLngVal.map(function (e) {
|
|
e = e.replace(/_/g, "");
|
|
return parseFloat(e.slice(1, -1));
|
|
});
|
|
if (isNaN(startLatLng[0])) {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_add_project input[name=add_project_start_map]"
|
|
).removeClass("is-invalid-input");
|
|
} else {
|
|
$(
|
|
"#modal_add_project input[name=add_project_start_map]"
|
|
).addClass("is-invalid-input");
|
|
}
|
|
$("#pin-marker-start").removeClass("pin-move pin-set");
|
|
$("#modal_add_project input[name=add_project_start_map]").val("");
|
|
$("#modal_add_project input[name=add_project_start_map]").attr(
|
|
"placeholder",
|
|
"(شروع) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
|
);
|
|
return false;
|
|
} else if (!startLatLng == 2 ||
|
|
!reg.test(startLatLng[0]) ||
|
|
!reg.test(startLatLng[1])
|
|
) {
|
|
$(
|
|
"#modal_add_project input[name=add_project_start_map]"
|
|
).addClass("is-invalid-input");
|
|
$("#pin-marker-start").removeClass("pin-move pin-set");
|
|
return false;
|
|
} else {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_add_project input[name=add_project_start_map]"
|
|
).removeClass("is-invalid-input");
|
|
|
|
startMarkerAdd.setLatLng(startLatLng);
|
|
|
|
if (pageOnLoad) {
|
|
setTimeout(() => {
|
|
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
|
startMarkerAdd.setLatLng(startLatLng);
|
|
}, 10);
|
|
} else {
|
|
$("#pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
|
}
|
|
if (!isSetEndMarkerAdd) {
|
|
let markerLatLng = [
|
|
startMarkerAdd.getLatLng().lat,
|
|
startMarkerAdd.getLatLng().lng + 0.0008,
|
|
];
|
|
|
|
addMap.setView(markerLatLng);
|
|
endMarkerAdd.setLatLng(markerLatLng);
|
|
|
|
if (!isSetStartMarkerAdd) {
|
|
endMarkerAdd.addTo(addMap);
|
|
}
|
|
}
|
|
isSetStartMarkerAdd = true;
|
|
}
|
|
checkMarkersAndDrawPath();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function checkEndMarkerValidation(forSaveData = false, pageOnLoad = false) {
|
|
let reg = /^([0-9]){2}\.([0-9])+$/;
|
|
let endLatLngVal = $(
|
|
"#modal_add_project input[name=add_project_end_map]"
|
|
)
|
|
.val()
|
|
.split(" - ");
|
|
let endLatLng = endLatLngVal.map(function (e) {
|
|
e = e.replace(/_/g, "");
|
|
return parseFloat(e.slice(1, -1));
|
|
});
|
|
|
|
if (isNaN(endLatLng[0])) {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_add_project input[name=add_project_end_map]"
|
|
).removeClass("is-invalid-input");
|
|
} else {
|
|
$(
|
|
"#modal_add_project input[name=add_project_end_map]"
|
|
).addClass("is-invalid-input");
|
|
}
|
|
$("#pin-marker-end").removeClass("pin-move pin-set");
|
|
$("#modal_add_project input[name=add_project_end_map]").val("");
|
|
$("#modal_add_project input[name=add_project_end_map]").attr(
|
|
"placeholder",
|
|
"(پایان) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
|
);
|
|
return false;
|
|
} else if (!endLatLng == 2 ||
|
|
!reg.test(endLatLng[0]) ||
|
|
!reg.test(endLatLng[1])
|
|
) {
|
|
$("#modal_add_project input[name=add_project_end_map]").addClass(
|
|
"is-invalid-input"
|
|
);
|
|
$("#pin-marker-end").removeClass("pin-move pin-set");
|
|
return false;
|
|
} else {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_add_project input[name=add_project_end_map]"
|
|
).removeClass("is-invalid-input");
|
|
|
|
endMarkerAdd.setLatLng(endLatLng);
|
|
isSetEndMarkerAdd = true;
|
|
|
|
if (pageOnLoad) {
|
|
setTimeout(() => {
|
|
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
|
endMarkerAdd.setLatLng(endLatLng);
|
|
}, 10);
|
|
} else {
|
|
$("#pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
|
}
|
|
} else {
|
|
projectEditData["project-end-latlng"] = [
|
|
endMarkerAdd.getLatLng().lat.toFixed(6),
|
|
endMarkerAdd.getLatLng().lng.toFixed(6),
|
|
];
|
|
}
|
|
|
|
checkMarkersAndDrawPath();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
//add lat lng with input
|
|
|
|
// edit lat lng with input
|
|
$("#modal_edit_project input[name=edit_project_start_map]").on(
|
|
"keyup",
|
|
function () {
|
|
checkStartMarkerValidationEdit();
|
|
}
|
|
);
|
|
$("#modal_edit_project input[name=edit_project_end_map]").on(
|
|
"keyup",
|
|
function () {
|
|
checkEndMarkerValidationEdit();
|
|
}
|
|
);
|
|
|
|
$('.img-input').on('change', function () {
|
|
var input = this;
|
|
var parent = $(this).parents('.file');
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
parent.find('.img-title').css('display', 'none')
|
|
parent.find('.btn-delete-img').prop('disabled', false)
|
|
parent.find('.img-preview')
|
|
.attr('src', e.target.result);
|
|
|
|
};
|
|
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
})
|
|
|
|
$('.btn-delete-img').on('click', function () {
|
|
var parent = $(this).parents('.file');
|
|
|
|
parent.find('.img-input').val('');
|
|
parent.find('.img-preview').removeAttr('src');
|
|
parent.find('.img-title').css('display', '');
|
|
$(this).prop('disabled', true)
|
|
})
|
|
|
|
$('.file-input').on('change', function () {
|
|
var input = this;
|
|
var parent = $(this).parents('.file');
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
parent.find('.file-title').text(input.files[0].name)
|
|
parent.find('.btn-delete-file').prop('disabled', false)
|
|
|
|
};
|
|
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
})
|
|
|
|
$('.btn-delete-file').on('click', function () {
|
|
var parent = $(this).parents('.file');
|
|
|
|
parent.find('.file-input').val('');
|
|
parent.find('.file-title').text(parent.find('.file-title').data('defaultText'))
|
|
$(this).prop('disabled', true)
|
|
})
|
|
|
|
function checkStartMarkerValidationEdit(forSaveData = false, pageOnLoad = false) {
|
|
let reg = /^([0-9]){2}\.([0-9])+$/;
|
|
let startLatLngVal = $(
|
|
"#modal_edit_project input[name=edit_project_start_map]"
|
|
)
|
|
.val()
|
|
.split(" - ");
|
|
let startLatLng = startLatLngVal.map(function (e) {
|
|
e = e.replace(/_/g, "");
|
|
return parseFloat(e.slice(1, -1));
|
|
});
|
|
if (isNaN(startLatLng[0])) {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_start_map]"
|
|
).removeClass("is-invalid-input");
|
|
} else {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_start_map]"
|
|
).addClass("is-invalid-input");
|
|
}
|
|
$("#edit-pin-marker-start").removeClass("pin-move pin-set");
|
|
$("#modal_edit_project input[name=edit_project_start_map]").val("");
|
|
$("#modal_edit_project input[name=edit_project_start_map]").attr(
|
|
"placeholder",
|
|
"(شروع) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
|
);
|
|
return false;
|
|
} else if (!startLatLng == 2 ||
|
|
!reg.test(startLatLng[0]) ||
|
|
!reg.test(startLatLng[1])
|
|
) {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_start_map]"
|
|
).addClass("is-invalid-input");
|
|
$("#edit-pin-marker-start").removeClass("pin-move pin-set");
|
|
return false;
|
|
} else {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_start_map]"
|
|
).removeClass("is-invalid-input");
|
|
|
|
startMarkerEdit.setLatLng(startLatLng);
|
|
|
|
if (pageOnLoad) {
|
|
setTimeout(() => {
|
|
$("#edit-pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
|
startMarkerEdit.setLatLng(startLatLng);
|
|
}, 10);
|
|
} else {
|
|
$("#edit-pin-marker-start").removeClass("pin-move").addClass("pin-set");
|
|
}
|
|
if (!isSetEndMarkerEdit) {
|
|
let markerLatLng = [
|
|
startMarkerEdit.getLatLng().lat,
|
|
startMarkerEdit.getLatLng().lng + 0.0008,
|
|
];
|
|
|
|
editMap.setView(markerLatLng);
|
|
endMarkerEdit.setLatLng(markerLatLng);
|
|
|
|
if (!isSetStartMarkerAdd) {
|
|
endMarkerEdit.addTo(editMap);
|
|
}
|
|
}
|
|
isSetStartMarkerEdit = true;
|
|
}
|
|
drawPathEdit();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function checkEndMarkerValidationEdit(forSaveData = false, pageOnLoad = false) {
|
|
let reg = /^([0-9]){2}\.([0-9])+$/;
|
|
let endLatLngVal = $(
|
|
"#modal_edit_project input[name=edit_project_end_map]"
|
|
)
|
|
.val()
|
|
.split(" - ");
|
|
let endLatLng = endLatLngVal.map(function (e) {
|
|
e = e.replace(/_/g, "");
|
|
return parseFloat(e.slice(1, -1));
|
|
});
|
|
|
|
if (isNaN(endLatLng[0])) {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_end_map]"
|
|
).removeClass("is-invalid-input");
|
|
} else {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_end_map]"
|
|
).addClass("is-invalid-input");
|
|
}
|
|
$("#edit-pin-marker-end").removeClass("pin-move pin-set");
|
|
$("#modal_edit_project input[name=edit_project_end_map]").val("");
|
|
$("#modal_edit_project input[name=edit_project_end_map]").attr(
|
|
"placeholder",
|
|
"(پایان) => (عرض جغرافیایی) - (طول جغرافیایی)"
|
|
);
|
|
return false;
|
|
} else if (!endLatLng == 2 ||
|
|
!reg.test(endLatLng[0]) ||
|
|
!reg.test(endLatLng[1])
|
|
) {
|
|
$("#modal_edit_project input[name=edit_project_end_map]").addClass(
|
|
"is-invalid-input"
|
|
);
|
|
$("#edit-pin-marker-end").removeClass("pin-move pin-set");
|
|
return false;
|
|
} else {
|
|
if (!forSaveData) {
|
|
$(
|
|
"#modal_edit_project input[name=edit_project_end_map]"
|
|
).removeClass("is-invalid-input");
|
|
|
|
endMarkerEdit.setLatLng(endLatLng);
|
|
isSetEndMarkerAdd = true;
|
|
|
|
if (pageOnLoad) {
|
|
setTimeout(() => {
|
|
$("#edit-pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
|
endMarkerEdit.setLatLng(endLatLng);
|
|
}, 10);
|
|
} else {
|
|
$("#edit-pin-marker-end").removeClass("pin-move").addClass("pin-set");
|
|
}
|
|
}
|
|
|
|
drawPathEdit();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
//edit lat lng with input
|
|
|
|
$("table").on("click", "tbody tr", function () {
|
|
$("tr.selected").find("i").css("color", "");
|
|
$("tr.selected").css("color", "");
|
|
$("tr.selected").removeClass("selected");
|
|
|
|
$(this).addClass("selected");
|
|
$(this).css("color", "white");
|
|
$(this).find("i").css("color", "white");
|
|
});
|
|
$(document).on('click', '#btn_excel_download', function () {
|
|
let queryParems = []
|
|
const province = $('#province_excel').val()
|
|
|
|
|
|
if (province != 0)
|
|
queryParems.push(`province=${province}`)
|
|
|
|
const url = `/reports/proposal${queryParems.length != 0 ? `?${queryParems.join('&')}` : ''}`
|
|
|
|
window.open(url, '_blank')
|
|
}) |