var citydata = [] var querylength = 0 var queryparams = "" var urlParams var filterstring = "" var globalDataCount = {} var globalData = [] var windoWidth function showLoaderScreen() { $(".divloader").css("display", "flex").hide().fadeIn(); } function hideLoaderScreen() { $(".divloader").fadeOut(); } windoWidth = $(window).width() $(document).ready(function () { showLoaderScreen() document.location.search.length != 0 ? querylength = 1 : querylength = 0 urlParams = new URLSearchParams(window.location.search); queryparams = window.location.search; $.ajax({ url: "https://rms.rmto.ir/bama-index" + window.location.search, type: "GET", success: function (result) { globalDataCount = result.counts globalData = result.data hideLoaderScreen() checkWindowSize() showFilterBama(queryparams) showcountall(globalDataCount.projects) if (globalData.length != 0) { showcountproject(globalDataCount.projectTypes) status_num(globalDataCount.last_statuses) showprovincefilter(globalDataCount.provinces) axisfilter(globalDataCount.axis_types) showyearfilter(globalDataCount.years) prioritiesfilter(globalDataCount.priorities) followupprioritiesfilter(globalDataCount.followup_priority) } // else { // showFilterNone() // hideLoaderScreen() // } }, error: function (error) { Swal.fire({ icon: "error", title: "خطا سرور", text: "مشکل در دریافت اطلاعات ", confirmButtonText: "بارگذاری مجدد", }).then((result) => { if (result.isConfirmed) { location.reload(true); return true; } }); }, }); }) // data-filter show/hide $(".filter-type").on("click", function () { var dataid = $(this).data('filter'); if ($('.filter-type-' + dataid).css("display") == "none") { $('.filter-type-' + dataid).show(1000) } else { $('.filter-type-' + dataid).hide(1000) } }) //data-filter show/hide function paginatepage() { var width = $(window).width(); if (width < 766) { // $('div.content').removeClass('col-sm-6').addClass('col-sm-12'); } // Number of items and limits the number of items per page var numberOfItems = $("#projectcontent .content").length; var limitPerPage = 6; // Total pages rounded upwards var totalPages = Math.ceil(numberOfItems / limitPerPage); var paginationSize = 7; var currentPage; function showPage(whichPage) { if (whichPage < 1 || whichPage > totalPages) return false; currentPage = whichPage; $("#exampleshowpage .content").hide() .slice((currentPage - 1) * limitPerPage, currentPage * limitPerPage).show(); // Replace the navigation items (not prev/next): $(".pagination li").slice(1, -1).remove(); getPageList(totalPages, currentPage, paginationSize).forEach(item => { $("
  • ").addClass("page-item") .addClass(item ? "current-page" : "disabled") .toggleClass("active", item === currentPage).append( $("").addClass("page-link").attr({ href: "javascript:void(0)" }).text(item || "...") ).insertBefore("#next-page"); }); // Disable prev/next when at first/last page: $("#previous-page").toggleClass("disabled", currentPage === 1); $("#next-page").toggleClass("disabled", currentPage === totalPages); return true; } // Include the prev/next buttons: $(".pagination").append( $("
  • ").addClass("page-item").attr({ id: "previous-page" }).append( $("").addClass("page-link").attr({ href: "javascript:void(0)" }).text("<<") ), $("
  • ").addClass("page-item").attr({ id: "next-page" }).append( $("").addClass("page-link").attr({ href: "javascript:void(0)" }).text(">>") ) ); // Show the page links $("#exampleshowpage").show(); showPage(1); // Use event delegation, as these items are recreated later $(document).on("click", ".pagination li.current-page:not(.active)", function () { return showPage(+$(this).text()); }); $("#next-page").on("click", function () { return showPage(currentPage + 1); }); $("#previous-page").on("click", function () { return showPage(currentPage - 1); }); } function getPageList(totalPages, page, maxLength) { if (maxLength < 5) throw "maxLength must be at least 5"; function range(start, end) { return Array.from(Array(end - start + 1), (_, i) => i + start); } var sideWidth = maxLength < 9 ? 1 : 2; var leftWidth = (maxLength - sideWidth * 2 - 3) >> 1; var rightWidth = (maxLength - sideWidth * 2 - 2) >> 1; if (totalPages <= maxLength) { // no breaks in list return range(1, totalPages); } if (page <= maxLength - sideWidth - 1 - rightWidth) { // no break on left of page return range(1, maxLength - sideWidth - 1) .concat(0, range(totalPages - sideWidth + 1, totalPages)); } if (page >= totalPages - sideWidth - 1 - rightWidth) { // no break on right of page return range(1, sideWidth) .concat(0, range(totalPages - sideWidth - 1 - rightWidth - leftWidth, totalPages)); } // Breaks on both sides return range(1, sideWidth) .concat(0, range(page - leftWidth, page + rightWidth), 0, range(totalPages - sideWidth + 1, totalPages)); } function showeachcard(data) { var listdata = "" for (var index = 0; index < data.length; index++) { listdata += `
    اداره کل :${data[index].province_fa}
    تاریخ انعقاد قرارداد : ${moment(data[index].contract_date_from_parent_contract).format("jYYYY/jMM/jDD")}
    شهرستان : ${data[index].city_fa}
    نام محور : ${data[index].axis_name_fa}
    نوع پروژه : ${data[index].project_type_fa}
    عنوان پروژه:${data[index].project_title}
    آخرین وضعیت پروژه :${data[index].last_status_fa}
    ` } $("#projectcontent").append(listdata) paginatepage() } function showResponsiveCard(data) { var listdata = "" for (var index = 0; index < data.length; index++) { listdata += `
    اداره کل :${data[index].province_fa}
    تاریخ انعقاد قرارداد : ${moment(data[index].contract_date_from_parent_contract).format("jYYYY/jMM/jDD")}
    شهرستان : ${data[index].city_fa}
    نام محور : ${data[index].axis_name_fa}
    نوع پروژه : ${data[index].project_type_fa}
    عنوان پروژه:${data[index].project_title}
    آخرین وضعیت پروژه :${data[index].last_status_fa}
    ` } $("#projectcontent").append(listdata) paginatepage() } function returnimage(url) { return url != null ? "https://rms.rmto.ir/" + url : "../dist/images/notavailable.jpg" } function projectfilter(num) { if (querylength == 1) { if (queryparams.indexOf("project_type") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?project_type=" + num } else { window.location.href = window.location.href + "&project_type=" + num } } else { window.location.href = window.location.href + "?project_type=" + num } } function showimagefilter(data) { if (data != null) { return "https://rms.rmto.ir/storage" + data.slice(6) } else { return "../dist/images/notavailable.jpg" } } function showcountall(num) { $(".widthcounter").append( '' + num + '' ) counternum() } function counternum() { $('.count-this').each(function () { // Start the counting from a specified number - in this case, 0! $(this).prop('Counter', 0).animate({ Counter: $(this).text() }, { // Speed of counter in ms, default animation style duration: 2000, easing: 'swing', step: function (now) { // Round up the number $(this).text(Math.ceil(now)); } }); }); } function showyearfilter(obj) { var filterYear = ""; $.each(obj, function (key, value) { filterYear += `
    ${key} (${value})
    ` }) $(".startyear").append(filterYear); } function showcountproject(array) { var projectType = "" for (var i = 0; i < array.length; i++) { projectType += `
    ${array[i].project_type_fa}

    (${array[i].count})

    ` } $(".project-type").append(projectType) } function setprojectimage(num) { switch (num) { case 1: return "../dist/images/bamaicons/rookesh-bama.svg" break; case 2: return "../dist/images/bamaicons/dangerpoint-bama.svg" break; case 3: return "../dist/images/bamaicons/oprative-bama.svg" break; case 4: return "../dist/images/bamaicons/abniefani-bama.svg" break; case 5: return "../dist/images/bamaicons/green-home-bama.svg" break; case 6: return "../dist/images/bamaicons/green-home-bama.svg" break; } } function axisfilter(array) { var axisFilter = "" for (var i = 0; i < array.length; i++) { axisFilter += `
    ${array[i].axis_type_fa}

    (${array[i].count})

    ` } $(".axisfilter").append(axisFilter) } function status_num(array) { var statusfilter = "" for (var i = 0; i < array.length; i++) { statusfilter += `
    ${array[i].last_status_fa}

    (${array[i].count})

    ` } $(".status-append").append(statusfilter) } function showprovincefilter(array) { $(".appendcity").empty() var ostandata = []; $.each(array, function (key, value) { ostandata = ostandata + '
    ' + value.province_fa + '(' + value.count + ')
    ' }) $(".appendostan").append(ostandata); if (array.length == 1) { showCityFilter(array[0].province_id) } } function showCityFilter(num) { $.ajax({ url: "https://rms.rmto.ir/public/contents/provinces/" + num, type: "GET", success: function (result) { showCityList(result.data) }, error: function (error) { Swal.fire({ icon: "error", title: "خطا سرور", text: " مشکل در دریافت اطلاعات شهرستان ", confirmButtonText: "بارگذاری مجدد", }).then((result) => { if (result.isConfirmed) { location.reload(true); return true; } }); }, }); } function showCityList(citylist) { for (var i = 0; i < citylist.length; i++) { citydata = citydata + '
    ' + citylist[i].name_fa + '
    ' } $(".appendcity").append(citydata) } function newsee(id) { if (querylength == 1) { if (queryparams.indexOf("province") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?province=" + id } else { window.location.href = window.location.href + "&province=" + id } } else { window.location.href = window.location.href + "?province=" + id } } function axistypenum(num) { if (querylength == 1) { if (queryparams.indexOf("axis") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?axis=" + num } else { window.location.href = window.location.href + "&axis=" + num } } else { window.location.href = window.location.href + "?axis=" + num } } function projectstatus(id) { if (querylength == 1) { if (queryparams.indexOf("last_status") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?last_status=" + id } else { window.location.href = window.location.href + "&last_status=" + id } } else { window.location.href = window.location.href + "?last_status=" + id } } function showpriorities(num) { if (querylength == 1) { if (queryparams.indexOf("priority") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?priority=" + num } else { window.location.href = window.location.href + "&priority=" + num } } else { window.location.href = window.location.href + "?priority=" + num } } function showfollowuppriorities(num) { if (querylength == 1) { if (queryparams.indexOf("followup") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?followup=" + num } else { window.location.href = window.location.href + "&followup=" + num } } else { window.location.href = window.location.href + "?followup=" + num } } function showyearclick(num) { var currentDate = {} currentFilterYear = num currentDate.from = moment(currentFilterYear, "jYYYY"); var currentFilterQueryfrom = currentDate.from .locale("en") .format("YYYY-MM-DD"); currentDate.to = moment(currentFilterYear, "jYYYY"); currentDate.to.add(1, "year"); var currentFilterQueryto = currentDate.to .locale("en") .format("YYYY-MM-DD"); if (querylength == 1) { if (queryparams.indexOf("from_date") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?from_date=" + currentFilterQueryfrom + "&to_date=" + currentFilterQueryto } else { window.location.href = window.location.href + "&from_date=" + currentFilterQueryfrom + "&to_date=" + currentFilterQueryto } } else { window.location.href = window.location.href + "?from_date=" + currentFilterQueryfrom + "&to_date=" + currentFilterQueryto } } function showFilterBama(query) { var filterlist = "" if (urlParams.get('project_type') != null) { filterlist += `
    ${showProjectType(urlParams.get('project_type'))}
    ×
    ` } if (urlParams.get('province') != null) { filterlist += `
    ${showProvinceNum()}
    ×
    ` } if (urlParams.get('axis') != null) { filterlist += `
    ${showAxisNum()}
    ×
    ` } if (urlParams.get('last_status') != null) { filterlist += `
    ${showlast_status()}
    ×
    ` } if (urlParams.get('from_date') != null) { filterlist += `
    ${showFilterChoose(urlParams.get('from_date'))}
    ×
    ` } if (urlParams.get('priority') != null) { filterlist += `
    ${showpriority()}
    ×
    ` } if (urlParams.get('followup') != null) { filterlist += `
    ${showfollowup()}
    ×
    ` } if (urlParams.get('city') != null) { filterlist += `
    ${showCityChoosen()}
    ×
    ` } $(".projectFilterChoosen").append(filterlist) } function showProjectType(num) { switch (num) { case "1": return "روکش آسفالت(نگهداری رویه راه)" break; case "2": return "رفع نقاط حادثه خیز" break; case "3": return "ایمنی راه" break; case "4": return "ابنیه فنی(تعمیر و بازسازی)" break; case "5": return "راهدارخانه" break; case "6": return "راه روستایی" break; } } function showProvinceNum() { var specificProName = "" if (globalDataCount.provinces.length == 0) { $.ajax({ url: `https://rms.rmto.ir/webapi/getuser/province-perm?type=all`, type: "GET", async: false, success: function (result) { for (var i = 0; i < result.data.length; i++) { if (urlParams.get('province') == result.data[i].id) { specificProName = result.data[i].name_fa } } }, error: function (error) { }, }); return specificProName } else { return globalDataCount.provinces[0].province_fa } } function showAxisNum() { var axis if (globalDataCount.axis_types.length == 0) { axis = urlParams.get('axis') switch (axis) { case "1": return "آزادراه" break; case "2": return "بزرگراه" break; case "3": return "اصلی" break; case "4": return "فرعی" break; case "5": return "روستایی" break; } } else { return globalDataCount.axis_types[0].axis_type_fa } } function showlast_status() { var last_status if (globalDataCount.last_statuses.length == 0) { last_status = urlParams.get('last_status') switch (last_status) { case "1": return "در حال تجهیز کارگاه" break; case "2": return "در حال اجرا" break; case "3": return "خاتمه یافته و بهره برداری شده" break; case "4": return "در دست مناقصه" break; } } return globalDataCount.last_statuses[0].last_status_fa } function showFilterChoose(date) { var selectedYear = moment(date).locale("fa").format("YYYY"); return selectedYear } function showpriority() { if (globalDataCount.priorities.length == 0) { priority = urlParams.get('priority') switch (priority) { case "1": return "کم" break; case "2": return "متوسط" break; case "3": return "زیاد" break; } } else { return globalDataCount.priorities[0].priority_project_fa } } function showfollowup() { var followup if (globalDataCount.priorities.length == 0) { followup = urlParams.get('followup') switch (followup) { case "1": return "کم(ماهیت محلی و منطقه ای…ری های ویژه در سطح ملی)" break; case "2": return "متوسط (ماهیت ملی یا استانی)" break; case "3": return "زیاد (مورد تاکید و پیگیر…ژه مسیولین محلی یا ملی)" break; } } else { return globalDataCount.followup_priority[0].followup_priority_project } } function showCityChoosen() { if (globalDataCount.cities.length == 0) { var province = urlParams.get('province') var city = urlParams.get('city') var cityName if (province != null) { $.ajax({ url: "https://rms.rmto.ir/public/contents/provinces/" + province, type: "GET", async: false, success: function (result) { console.log(result) for (var i = 0; i < result.data.length; i++) { if (city == result.data[i].id) { cityName = result.data[i].name_fa } } }, error: function (error) { }, }); } else { cityName = " شهرستان" } return cityName } else { return globalDataCount.cities[0].city_fa } } function cityclick(num) { if (querylength == 1) { if (queryparams.indexOf("city") != -1) { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } location.reload() window.location.href = window.location.href + "?city=" + num } else { window.location.href = window.location.href + "&city=" + num } } else { window.location.href = window.location.href + "?city=" + num } } function removeURLParameter(url, parameter) { var to_date // prefer to use l.search if you have a location/link object var urlparts = url.split('?'); if (urlparts.length >= 2) { var prefix = encodeURIComponent(parameter) + '='; if (parameter == 'from_date') { to_date = encodeURIComponent('to_date') + '='; } var pars = urlparts[1].split(/[&;]/g); for (var i = pars.length; i-- > 0;) { if (parameter == 'from_date') { if (pars[i].lastIndexOf(to_date, 0) !== -1) { pars.splice(i, 1); } else if (pars[i].lastIndexOf(prefix, 0) !== -1) { pars.splice(i, 1); } } else { if (pars[i].lastIndexOf(prefix, 0) !== -1) { pars.splice(i, 1); } } } if (pars.length > 0) { url = urlparts[0] + '?' + pars.join('&'); } else { url = urlparts[0] } window.location.href = url } else { return url; } } function deletproject() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'project_type') } } function deletprovince() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'province') } } function deletCity() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'city') } } function deletaxis() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'axis') } } function deletstatus() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'last_status') } } function deletdate() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'from_date') } } function deleteprio() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'priority') } } function deletefollowup() { var uri = window.location.toString(); if (uri.indexOf("?") > 0) { removeURLParameter(uri, 'followup') } } function prioritiesfilter(array) { var priorities = "" for (var i = 0; i < array.length; i++) { priorities += `
    ${array[i].priority_project_fa} (${array[i].count})
    ` } $(".importancediv").append(priorities) } function followupprioritiesfilter(array) { var followuppriorities = "" for (var i = 0; i < array.length; i++) { followuppriorities += `
    ${array[i].followup_priority_project} (${array[i].count})
    ` } $(".followup-priority").append(followuppriorities) } function checkWindowSize() { if (windoWidth <= 768) { $(".BamaFilter").addClass("d-none") $(".showbama").addClass("col-sm-12").removeClass("col-sm-9") showResponsiveCard(globalData) } else { $(".BamaFilter").removeClass("d-none") showeachcard(globalData) } } function showFilterNone() { if (urlParams.has('project_type')) { }; if (urlParams.has('province')) { }; if (urlParams.has('city')) { }; if (urlParams.has('axis')) { }; if (urlParams.has('last_status')) { }; if (urlParams.has('priority')) { }; if (urlParams.has('followup')) { }; if (urlParams.has('from_date')) { }; } function findProvinces(num) { console.log("num", num) $.ajax({ url: `https://rms.rmto.ir/webapi/getuser/province-perm?type=all`, type: "GET", success: function (result) { console.log(result) for (var i = 0; i < result.data.length; i++) { if (num == result.data[i].id) { return result.data[i].name_fa } } }, error: function (error) { }, }); }