var table var projectid var tablee var arraykey = [] var idkol = null var mountKey = {} var maxi = null function showLoaderScreen() { $('.starter-loader-container').css('display', 'flex').hide().fadeIn(); } function hideLoaderScreen() { $('.starter-loader-container').fadeOut(); } function format(d) { // console.log("data-row", d) idkol = d.id // console.log('#submit' + idkol) var showdetail = '
' + '
' + '
' + '' + '' + '
' + '
' + '' + '
' + '
' + '
' + '' + '' + '
' + '
' + '' + '' + '
' + '
' + '
' + '
' + '' + '
' // `d` is the original data object for the row return showdetail } $(document).ready(function () { table = $("#example").DataTable({ dom: 'lBfrtip', // "pagingType": "full_numbers", pagingType: "simple_numbers", language: { sEmptyTable: "هیچ داده‌ای در جدول وجود ندارد", sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف", sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف", sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)", sInfoPostFix: "", sInfoThousands: ",", sLengthMenu: "نمایش _MENU_ ردیف", sLoadingRecords: "در حال بارگزاری...", sProcessing: "در حال پردازش...", sSearch: "جستجو: ", sZeroRecords: "رکوردی با این مشخصات پیدا نشد", oPaginate: { sFirst: "برگه‌ی نخست", sLast: "برگه‌ی آخر", sNext: "بعدی", sPrevious: "قبلی", }, oAria: { sSortAscending: ": فعال سازی نمایش به صورت صعودی", sSortDescending: ": فعال سازی نمایش به صورت نزولی", }, }, order: [ [0, "asc"] [1, "asc"], [2, "desc"], [3, "desc"], [4, "desc"], ], order: [[0, "asc"]], processing: true, ajax: { url: "/road-maintenance-project/getstatuslist", type: "GET", dataSrc: function (json) { return json.data; }, }, columns: [ { data: null, render: function (data, type, row, meta) { // console.log(meta.row); return meta.row + 1; }, }, { data: "axis_name" }, { data: "axis_type", render: function (data, type, row) { if (data == 1) { return "شریانی" } else if (data == 2) { return "اصلی" } else if (data == 3) { return "فرعی" } else if (data == 4) { return " روستایی" } else return "_" } }, { data: "project_name" }, { data: "province.name" }, { data: "city.name" }, { data: "contractor_name" }, { data: "consultant_name" }, { data: "contract_credit" }, { "className": 'details-control text-center', "orderable": false, "data": null, "defaultContent": '' }, ], buttons: [ ], }); $('#example tbody').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isShown()) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child(format(row.data())).show(); tr.addClass('shown'); showslider(row.data().physical_progress, row.data().id) mountKey = row.data().project_distance_update maxi = row.data().project_distance console.log("maxi", maxi) showprogressmountKey(mountKey, row.data().id) idkol = row.data().id } }); }) function showslider(percent, id) { // console.log("idkol" , idkol) // $('#ex2').emty() $('#ex' + id).slider({ value: percent, formatter: function (value) { return value + "٪"; }, tooltip: 'always', }); } function showprogressmountKey(mount, id) { arraykey = [] // console.log(mount) for (var key in mount) { console.log(key) if (mount.hasOwnProperty(key)) { var maxmount = maxi[key] arraykey.push(key) var val = mount[key]; console.log(val[0]) showlabel(key, val, id, maxmount) } } } function showlabel(number, value, id, maxvalue) { if (number == 1) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 2) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 3) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 4) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 5) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 6) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 7) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 8) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 9) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 10) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 11) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 12) { var datashown = '
' + '' + '
' + '
' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } else if (number == 13) { var datashown = '
' + '' + '
' + '
' + '
' + '
' $('#appenddata' + id).append(datashown) } } function showUploadedFiles(input) { if (input.files) { // var reader = new FileReader(); // reader.onload = function (e) { // $('#uploadedItems') // .append(input.value); // }; for (let index = 0; index < input.files.length; index++) { $('#uploadedItems').append( '\
\
نام: ' + input.files[index].name + '
\
حجم: ' + input.files[index].size / 1000 + 'KB
\

\
\ ' ); } } } function deletfile(id) { // console.log("GGG",id) $('#item-' + id).remove() } function ajaxcall() { var kilo1 var kilo2 var kilo3 var kilo4 var kilo5 var kilo6 var kilo7 var kilo8 var kilo9 var kilo10 var kilo11 var kilo12 var kilo13 var tonazh1 var tonazh2 var tonazh3 var tonazh4 var tonazh5 var tonazh6 var tonazh7 var tonazh8 var tonazh9 var tonazh10 var tonazh11 var tonazh12 var editdata1 var editdata2 var editdata3 var editdata4 var editdata5 var editdata6 var editdata7 var editdata8 var editdata9 var editdata10 var editdata11 var editdata12 var editdata13 var metrmoraba var contractor_credit = $("#promoney" + idkol).val() var description = $("#texti" + idkol).val() var progress = $('#ex' + idkol).data('slider').getValue() for (var i = 0; i < arraykey.length; i++) { if (arraykey[i] == 1) { kilo1 = $('#kilo1').val() if (kilo1 == "") { kilo1 = "-" } tonazh1 = $('#tonazh1').val() if (tonazh1 == "") { tonazh1 = "-" } editdata1 = [kilo1, tonazh1] } if (arraykey[i] == 2) { kilo2 = $('#kilo2').val() if (kilo2 == "") { kilo2 = "-" } tonazh2 = $('#tonazh2').val() if (tonazh2 == "") { tonazh2 = "-" } editdata2 = [kilo2, tonazh2] } if (arraykey[i] == 3) { kilo3 = $('#kilo3').val() if (kilo3 == "") { kilo3 = "-" } tonazh3 = $('#tonazh3').val() if (tonazh3 == "") { tonazh3 = "-" } editdata3 = [kilo3, tonazh3] } if (arraykey[i] == 4) { kilo4 = $('#kilo4').val() if (kilo4 == "") { kilo4 = "-" } tonazh4 = $('#tonazh4').val() if (tonazh4 == "") { tonazh4 = "-" } editdata4 = [kilo4, tonazh4] } if (arraykey[i] == 5) { kilo5 = $('#kilo5').val() if (kilo5 == "") { kilo5 = "-" } tonazh5 = $('#tonazh5').val() if (tonazh5 == "") { tonazh5 = "-" } editdata5 = [kilo5, tonazh5] } if (arraykey[i] == 6) { kilo6 = $('#kilo6').val() if (kilo6 == "") { kilo6 = "-" } tonazh6 = $('#tonazh6').val() if (tonazh6 == "") { tonazh6 = "-" } editdata6 = [kilo6, tonazh6] } if (arraykey[i] == 7) { kilo7 = $('#kilo7').val() if (kilo7 == "") { kilo7 = "-" } tonazh7 = $('#tonazh7').val() if (tonazh7 == "") { tonazh7 = "-" } editdata7 = [kilo7, tonazh7] } if (arraykey[i] == 8) { kilo8 = $('#kilo8').val() if (kilo8 == "") { kilo8 = "-" } tonazh8 = $('#tonazh8').val() if (tonazh8 == "") { tonazh8 = "-" } editdata8 = [kilo8, tonazh8] } if (arraykey[i] == 9) { kilo9 = $('#kilo9').val() if (kilo9 == "") { kilo9 = "-" } tonazh9 = $('#tonazh9').val() if (tonazh9 == "") { tonazh9 = "-" } editdata9 = [kilo9, tonazh9] } if (arraykey[i] == 10) { kilo10 = $('#kilo10').val() if (kilo10 == "") { kilo10 = "-" } tonazh10 = $('#tonazh10').val() if (tonazh10 == "") { tonazh10 = "-" } editdata10 = [kilo10, tonazh10] } if (arraykey[i] == 11) { kilo11 = $('#kilo11').val() if (kilo11 == "") { kilo11 = "-" } tonazh11 = $('#tonazh11').val() if (tonazh11 == "") { tonazh11 = "-" } editdata11 = [kilo11, tonazh11] } if (arraykey[i] == 12) { kilo12 = $('#kilo12').val() if (kilo12 == "") { kilo12 = "-" } tonazh12 = $('#tonazh12').val() if (tonazh12 == "") { tonazh12 = "-" } metrmoraba = $("#metrmorab").val() if (metrmoraba == "") { metrmoraba = "-" } editdata12 = [kilo12, tonazh12, metrmoraba] } if (arraykey[i] == 13) { kilo13 = $('#kilo13').val() if (kilo13 == "") { kilo13 = "-" } editdata13 = [kilo13] } } for (const [key, value] of Object.entries(mountKey)) { if (key == 1) { mountKey[key] = editdata1 } if (key == 2) { mountKey[key] = editdata2 } if (key == 3) { mountKey[key] = editdata3 } if (key == 4) { mountKey[key] = editdata4 } if (key == 5) { mountKey[key] = editdata5 } if (key == 6) { mountKey[key] = editdata6 } if (key == 7) { mountKey[key] = editdata7 } if (key == 8) { mountKey[key] = editdata8 } if (key == 9) { mountKey[key] = editdata9 } if (key == 10) { mountKey[key] = editdata10 } if (key == 11) { mountKey[key] = editdata11 } if (key == 12) { mountKey[key] = editdata12 } if (key == 13) { mountKey[key] = editdata13 } } let formData = new FormData(); if (contractor_credit != "" || contractor_credit != "-") formData.append('contractor-credit', contractor_credit); if (description != "" || description != "-") formData.append('description', description); if (progress != "" || progress != "-") formData.append('physical-progress', progress); let project_distance = JSON.stringify(mountKey); formData.append("project-distance", project_distance); for (let i = 0; i < $('input[name=modalUpFile]')[0].files.length; i++) { formData.append('files_' + i, $('input[name=modalUpFile]')[0].files[i]); } // for (var value of formData.values()) { // console.log(value); // } Swal.fire({ icon: 'warning', title: 'آیا مطمئن هستید؟', text: "این عملیات قابل بازگشت نیست!", showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'بله، تایید می‌شود', cancelButtonText: 'منصرف شدم!', showLoaderOnConfirm: true, preConfirm: () => { $.ajax({ url: "/road-maintenance-project/" + idkol + "/edit-status", type: "POST", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: formData, cache: false, contentType: false, processData: false, success: function (result) { showLoaderScreen() ajaxcalltable() console.log(result) }, error: function (error) { console.log(error) Swal.fire({ icon: 'error', title: 'خطا', text: 'مشکلی پیش آمده', confirmButtonText: 'بستن' }) } }); }, }) } function ajaxcalltable() { $.ajax({ url: "/road-maintenance-project/getstatuslist", type: "GET", success: function (result) { // console.log(result.data[0]); $("#example").dataTable().fnClearTable(); $("#example").dataTable().fnAddData(result.data); hideLoaderScreen() Swal.fire({ icon: 'success', title: 'با موفقیت بروزرسانی شد', confirmButtonText: 'بستن' }) }, }); }