360 lines
12 KiB
JavaScript
360 lines
12 KiB
JavaScript
var fromDateshowrizitem, toDateshowrizitem;
|
|
var PERMISSIONS = []
|
|
var PROVINCES = [];
|
|
var gozareshtable;
|
|
var MAIN_URL = "/v2/receipt/report/province-data"
|
|
var EXCEL_API = "/v2/receipt/report/excel";
|
|
|
|
function checkfunctionS(obj) {
|
|
if (obj != undefined) {
|
|
return obj
|
|
} else {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
|
|
let reqUrl = "/public/contents/provinces";
|
|
|
|
$.ajax({
|
|
url: reqUrl,
|
|
type: "GET",
|
|
async: "false",
|
|
success: function (result) {
|
|
|
|
PROVINCES.push({
|
|
id: -1,
|
|
name_fa: "کل کشور"
|
|
})
|
|
|
|
for (var i = 0; i < result.data.length; i++) {
|
|
|
|
PROVINCES.push({
|
|
id: result.data[i].id,
|
|
name_fa: result.data[i].name_fa,
|
|
})
|
|
|
|
}
|
|
|
|
rendertable(PROVINCES)
|
|
},
|
|
});
|
|
|
|
|
|
|
|
fromDateshowrizitem = $("#fromDateshowrizitem").persianDatepicker({
|
|
format: "YYYY/MM/DD",
|
|
autoClose: true,
|
|
onSelect: function (unix) {
|
|
fromDateshowrizitem.touched = true;
|
|
|
|
$("#toDateshowrizitem").prop("disabled", "");
|
|
|
|
if (
|
|
fromDateshowrizitem.getState().selected.unixDate >=
|
|
toDateshowrizitem.getState().selected.unixDate
|
|
) {
|
|
toDateshowrizitem.setDate(fromDateshowrizitem.getState().selected.unixDate);
|
|
}
|
|
|
|
if (
|
|
toDateshowrizitem &&
|
|
toDateshowrizitem.options &&
|
|
toDateshowrizitem.options.minDate != unix
|
|
) {
|
|
let cachedValue = toDateshowrizitem.getState().selected.unixDate;
|
|
|
|
toDateshowrizitem.options = { minDate: unix };
|
|
|
|
if (toDateshowrizitem.touched) {
|
|
toDateshowrizitem.setDate(cachedValue);
|
|
}
|
|
}
|
|
},
|
|
});
|
|
|
|
toDateshowrizitem = $("#toDateshowrizitem").persianDatepicker({
|
|
format: "YYYY/MM/DD",
|
|
autoClose: true,
|
|
onSelect: function (unix) {
|
|
toDateshowrizitem.touched = true;
|
|
|
|
$("#toDateshowrizitem").prop("disabled", "");
|
|
|
|
if (
|
|
toDateshowrizitem.getState().selected.unixDate >=
|
|
toDateshowrizitem.getState().selected.unixDate
|
|
) {
|
|
toDateshowrizitem.setDate(toDateshowrizitem.getState().selected.unixDate);
|
|
}
|
|
|
|
if (
|
|
toDateshowrizitem &&
|
|
toDateshowrizitem.options &&
|
|
toDateshowrizitem.options.minDate != unix
|
|
) {
|
|
let cachedValue = toDateshowrizitem.getState().selected.unixDate;
|
|
|
|
toDateshowrizitem.options = { minDate: unix };
|
|
|
|
if (toDateshowrizitem.touched) {
|
|
toDateshowrizitem.setDate(cachedValue);
|
|
}
|
|
}
|
|
},
|
|
});
|
|
|
|
$.getScript('/version2/js/dashboard_pages/receipt/subtable.js');
|
|
|
|
$.ajax({
|
|
url: "/webapi/user/get-permission",
|
|
type: "GET",
|
|
cache: false,
|
|
async: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (result) {
|
|
PERMISSIONS = result.data
|
|
},
|
|
error: function () {
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "خطا",
|
|
text: 'مشکل در دریافت سطح دسترسی',
|
|
confirmButtonText: "بروزرسانی صفحه",
|
|
showLoaderOnConfirm: true,
|
|
preConfirm: () => {
|
|
location.reload(true);
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
$("#sorttestitems").on("click", function () {
|
|
if (
|
|
$("#fromDateshowrizitem").val() != " " &&
|
|
$("#toDateshowrizitem").val() != " "
|
|
) {
|
|
let date_from = moment(
|
|
fromDateshowrizitem.getState().selected.year +
|
|
"/" +
|
|
fromDateshowrizitem.getState().selected.month +
|
|
"/" +
|
|
fromDateshowrizitem.getState().selected.date,
|
|
"jYYYY/jM/jD"
|
|
).format("YYYY-MM-DD");
|
|
let date_to = moment(
|
|
toDateshowrizitem.getState().selected.year +
|
|
"/" +
|
|
toDateshowrizitem.getState().selected.month +
|
|
"/" +
|
|
toDateshowrizitem.getState().selected.date,
|
|
"jYYYY/jM/jD"
|
|
).format("YYYY-MM-DD");
|
|
showLoaderScreen()
|
|
$("#gozarehtowntable").dataTable().fnClearTable();
|
|
$("#gozarehtowntable")
|
|
.DataTable()
|
|
.ajax.url(
|
|
MAIN_URL +
|
|
"?from_date=" +
|
|
date_from +
|
|
"&date_to=" +
|
|
date_to
|
|
)
|
|
.load();
|
|
hideLoaderScreen()
|
|
}
|
|
});
|
|
|
|
|
|
function rendertable(PROVINCES) {
|
|
gozareshtable = $("#gozarehtowntable").DataTable({
|
|
dom: "<flB<t>p>",
|
|
scrollX: true,
|
|
destroy: true,
|
|
pagingType: "simple_numbers",
|
|
autoWidth: false,
|
|
language: {
|
|
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
|
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
|
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
|
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
|
sInfoPostFix: "",
|
|
sInfoThousands: ",",
|
|
sLengthMenu: "نمایش _MENU_ ردیف",
|
|
sLoadingRecords: "در حال بارگذاری...",
|
|
sProcessing: "در حال پردازش...",
|
|
sSearch: "جستجو: ",
|
|
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
|
oPaginate: {
|
|
sFirst: "برگهی نخست",
|
|
sLast: "برگهی آخر",
|
|
sNext: "بعدی",
|
|
sPrevious: "قبلی",
|
|
},
|
|
oAria: {
|
|
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
|
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
|
},
|
|
},
|
|
|
|
processing: true,
|
|
ajax: {
|
|
url: MAIN_URL,
|
|
type: "GET",
|
|
dataSrc: function (json) {
|
|
let temp = []
|
|
|
|
PROVINCES.map(function (province, index) {
|
|
|
|
temp[index] = {
|
|
id: province.id,
|
|
name_fa: province.name_fa,
|
|
tedade: "",
|
|
police_rah: "",
|
|
gozaresh_gasht: "",
|
|
kol_sabt_shode: "",
|
|
vasel_shode: "",
|
|
vasel_shode_bimeh: "",
|
|
vasel_shode_daghi: "",
|
|
vasel_shode_final: "",
|
|
}
|
|
|
|
json.data.map(function (element, key) {
|
|
|
|
if (element.province_id == province.id) {
|
|
temp[index] = {
|
|
id: province.id,
|
|
name_fa: province.name_fa,
|
|
tedade: parseFloat(element.tedade).toLocaleString("en"),
|
|
police_rah: parseFloat(element.police_rah).toLocaleString("en"),
|
|
gozaresh_gasht: parseFloat(element.gozaresh_gasht).toLocaleString("en"),
|
|
kol_sabt_shode: parseFloat(element.kol_sabt_shode).toLocaleString("en"),
|
|
vasel_shode: element.vasel_shode != null ? parseFloat(element.vasel_shode).toLocaleString("en") : "0",
|
|
vasel_shode_bimeh: element.vasel_shode_bimeh != null ? parseFloat(element.vasel_shode_bimeh).toLocaleString("en") : "0",
|
|
vasel_shode_daghi: element.vasel_shode_daghi != null ? parseFloat(element.vasel_shode_daghi).toLocaleString("en") : "0",
|
|
vasel_shode_final: element.vasel_shode_final != null ? parseFloat(element.vasel_shode_final).toLocaleString("en") : "0",
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
});
|
|
|
|
return temp;
|
|
},
|
|
},
|
|
columns: [
|
|
{
|
|
"className": 'details-control',
|
|
"orderable": false,
|
|
"data": null,
|
|
"defaultContent": ''
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: "name_fa",
|
|
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: "tedade"
|
|
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: "police_rah"
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: "gozaresh_gasht"
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: "kol_sabt_shode"
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
if (data.vasel_shode != null) return data.vasel_shode
|
|
else return 0
|
|
}
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
if (data.vasel_shode_bimeh != null) return data.vasel_shode_bimeh
|
|
else return 0
|
|
}
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
if (data.vasel_shode_daghi != null) return data.vasel_shode_daghi
|
|
else return 0
|
|
}
|
|
},
|
|
{
|
|
className: "text-center",
|
|
data: null,
|
|
render: function (data, type, row) {
|
|
if (data.vasel_shode_final != null) return data.vasel_shode_final
|
|
else return 0
|
|
}
|
|
},
|
|
|
|
],
|
|
buttons: [{
|
|
text: '',
|
|
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) {
|
|
|
|
let queryParems = [];
|
|
let activityDate = {}
|
|
if ($("#filter_from_activity_date_time").val() != "" && $("#filter_to_activity_date_time").val() != "") {
|
|
activityDate.from = moment(
|
|
|
|
fromDateshowrizitem.getState().selected.year +
|
|
"/" +
|
|
fromDateshowrizitem.getState().selected.month +
|
|
"/" +
|
|
fromDateshowrizitem.getState().selected.date,
|
|
"jYYYY/jM/jD"
|
|
).format("YYYY-MM-DD");
|
|
|
|
activityDate.to = moment(
|
|
toDateshowrizitem.getState().selected.year +
|
|
"/" +
|
|
toDateshowrizitem.getState().selected.month +
|
|
"/" +
|
|
toDateshowrizitem.getState().selected.date,
|
|
"jYYYY/jM/jD"
|
|
).format("YYYY-MM-DD");
|
|
|
|
queryParems.push(`from_date=${activityDate.from}`);
|
|
queryParems.push(`date_to=${activityDate.to}`);
|
|
}
|
|
const url = `${EXCEL_API}${queryParems.length != 0 ? `?${queryParems.join("&")}` : ""}`;
|
|
window.open(url);
|
|
},
|
|
|
|
},],
|
|
initComplete: function (settings, json) {
|
|
$("body").find(".dataTables_scrollBody").addClass("scrollbar");
|
|
},
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|