Commit 1356d6e8 authored by Manggar Mahardhika's avatar Manggar Mahardhika

fix perbaikan bangunan dan jalan

parent 4a9869d6
......@@ -823,7 +823,8 @@ import re
import json
@api_view(('POST',))
def saveperbaikan(request):
type_id = request.POST.get("type_id")
# type_id = request.POST.get("type_id")
type_id = 2
id_object = request.POST.get("object_id")
name = request.POST.get("name")
type = request.POST.get("type")
......@@ -852,29 +853,40 @@ def saveperbaikan(request):
fss_p = FileSystemStorage(location='/var/www/django/oku.khansia.co.id/media/proposal/')
fss_b = FileSystemStorage(location='/var/www/django/oku.khansia.co.id/media/bukti_penyelesaian/')
coord = json.loads(str(coor))
# coord = json.loads(str(coor))
pjg_perbaikan = re.sub('[^0-9.]+', '', str(pjg_perbaikan))
lbr_perbaikan = re.sub('[^0-9.]+', '', str(lbr_perbaikan))
luas = re.sub('[^0-9.]+', '', str(luas))
if coord['features'][0]['geometry']['type'] == 'LineString':
print("oke")
for co in coord['features']:
ll = str(co["geometry"]['coordinates'])
ll += ll
ll = ll.replace(", "," ")
ll = ll.replace("]][[","),(")
ll = ll.replace("] [",", ")
ll = ll.replace("]]",")")
ll = ll.replace("[[","(")
coordinat = f'MULTILINESTRING({ll})'
print(ll)
if coord['features'][0]['geometry']['type'] == 'Polygon':
print('tidakoke')
# if coord['features'][0]['geometry']['type'] == 'LineString':
# print("oke")
# for co in coord['features']:
# ll = str(co["geometry"]['coordinates'])
# ll += ll
# ll = ll.replace(", "," ")
# ll = ll.replace("]][[","),(")
# ll = ll.replace("] [",", ")
# ll = ll.replace("]]",")")
# ll = ll.replace("[[","(")
# coordinat = f'MULTILINESTRING({ll})'
# print(ll)
# if coord['features'][0]['geometry']['type'] == 'Polygon':
# print('tidakoke')
yak = str(coor)
suk = yak.replace("""{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":""","")
sik = suk.replace("""}}""","")
cor = sik.replace("""[[[""","(")
coran = cor.replace("""]]]""",")")
ll = coran.replace(","," ")
ii = ll.replace("] [",",")
mm = ii.replace('{"type":"FeatureCollection" "features":', '')
nn = mm.replace('}', '')
corcoran = f'MULTILINESTRING({nn})'
try:
format = (proposal.name).split(".")
num = random.randrange(1, 10000000000000)
nproposal = f"{name}_{num}.{format[-1:][0]}"
......@@ -888,6 +900,13 @@ def saveperbaikan(request):
filename_b = fss_b.save(nbukti, bukti_selesai)
url_b = fss_b.url(filename_b)
print("-------------------")
print(str(corcoran))
print("-------------------")
print(str(type_id),("-"),str(id_object),("-"),str(name),("-"),str(type),("-"),str(tgl_selesai),("-"),str(tgl_perbaikan),("-"),str(tgl_disetujui),("-"),str(anggaran),("-"),str(pj),("-"),str(pj_lapangan),("-"),str(kontraktor),("-"),str(pjg_perbaikan),("-"),str(lbr_perbaikan),("-"),str(jenis_perbaikan),("-"),str(nproposal),("-"),str(nbukti))
print("-------------------")
try:
with conn.cursor() as data_per:
data_per.execute("""
INSERT INTO tbl_perbaikan (
......@@ -946,7 +965,7 @@ def saveperbaikan(request):
float(pjg_perbaikan),
float(lbr_perbaikan),
jenis_perbaikan,
coordinat))
corcoran))
conn.commit()
data = "Sukses"
info = "Data Telah Berhasil di Perbaharui"
......
......@@ -4883,7 +4883,6 @@
} else {
var alamak = feature.administrasi.f3;
}
if (feature.administrasi.f10 == 'bpk') {
var raja = "";
......@@ -8001,11 +8000,18 @@
$("#modal_detail_non_kelurahan").modal('show');
var geogeo = geocodeService.reverse().latlng(e.latlng).run(function(error, result) {
if (result.address.Address != '') {
var alamat = result.address.Address + `, `
} else {
var alamat = ''
};
// tay = result.address.Address;
// if (feature.administrasi.f3 == 'None') {
// if (tay != '') {
// var alamak = tay;
// } else {
// alamak = ""
// }
// } else {
// var alamak = feature.administrasi.f3;
// }
if (feature.administrasi.f9 == 'None') {
var path_img = "static/img/image_null.jpg"
......@@ -8387,9 +8393,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -8443,7 +8447,7 @@
</p>
<p>
<span>
` + alamat + feature.administrasi.f1 + `, ` + feature.administrasi.f2 + `, ` + feature.administrasi.f3 + `, ` + feature.administrasi.f4 + `
` + feature.administrasi.f1 + `, ` + feature.administrasi.f2 + `, ` + feature.administrasi.f3 + `, ` + feature.administrasi.f4 + `
</span>
</p>
</th>
......@@ -8496,7 +8500,7 @@
</div>
<div>
<span>
` + alamat + feature.administrasi.f1 + `, ` + feature.administrasi.f2 + `, ` + feature.administrasi.f3 + `, ` + feature.administrasi.f4 + `
` + feature.administrasi.f1 + `, ` + feature.administrasi.f2 + `, ` + feature.administrasi.f3 + `, ` + feature.administrasi.f4 + `
</span>
</div>
......@@ -9014,10 +9018,16 @@
};
polylyly = L.polygon(list_poly_edit).addTo(map_bang)
polylyly.enableEdit();
// polylyly.enableEdit();
var hasil = (JSON.stringify(polylyly.toGeoJSON()))
// console.log(polylyly)
// console.log(hasil)
// $("#coorbangbaru").val(hasil);
$('#save-perbaikan_bang').click(function() {
$("#coorbangbaru").val(hasil);
console.log(hasil);
// console.log("tes");
})
}
})
......@@ -9083,6 +9093,9 @@
data.append(keyss[0], data_umum[i][keyss[0]])
}
// console.log(data)
// console.log(data_umum)
$.ajax({
url: "{% url 'apps:save-perbaikan-bang' %}",
data: data,
......
......@@ -1965,7 +1965,7 @@
<a class="col-md-4" onclick="getdetailper(` + list_history[0].split(",")[0] + `)" data-toggle="modal" data-target="#modal_detail_perbaikan_dash"><i>Detail</i></a>
</div>
<a class="col-md-6" class="btn" id="btn_perbaikan_jalan"><i>Input Perbaikan</i></a>`
<a class="col-md-6" class="btn" id="btn_perbaikan_jalan" data-toggle="modal" data-target="#input_perbaikan"><i>Input Perbaikan</i></a>`
} else {
var perbaikan_jl = `<div class='row'>
......@@ -1974,7 +1974,7 @@
</div>
</div>
<a class="col-md-6" class="btn" id="btn_perbaikan_jalan"><i>Input Perbaikan</i></a>
<a class="col-md-6" class="btn" id="btn_perbaikan_jalan" data-toggle="modal" data-target="#input_perbaikan"><i>Input Perbaikan</i></a>
`
}
$(".nama_keterangan").html(`
......@@ -2030,6 +2030,125 @@
</div>
`)
content_his_jal=`
<div class="modal-dialog" style="height: max-content;">
<div class="modal-content">
<div class="modal-header" style="height: 50px;background: #1E2233;border-top-left-radius: 10px;border-top-right-radius: 10px;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h5 class="modal-title title-create" style="color: white;margin-left: 25px;padding-top: 10px;">Input Perbaikan</h5>
</div>
<div class="modal-body" style="max-height: 450px;overflow-y: auto;">
<div class="tab-pane has-padding" id="panel-tab2">
<div class="tab-pane" id="bottom-justified-data">
<div class="tabbable">
<ul class="nav nav-tabs nav-tabs-bottom nav-justified">
<li onclick="changetabs(this)" class="active"><a href="#left-tab1-feas-upl" data-toggle="tab">Koordinat</a></li>
<li onclick="changetabs(this)"><a href="#right-tab2-feas-upl" data-toggle="tab">Informasi Umum</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="#left-tab1-feas-upl">
<input type="text" class="hidden" id="poly_create_input">
<input type="text" class="hidden" id="id_jalan_perbaikan">
<input type="text" class="hidden" id="type_id">
<div id="map-insert" style="height: 375px;width: 100%">
</div>
</div>
</div>
<div class="tab-pane" id="#right-tab2-feas-upl">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Nama Jalan :</label>
<input type="text" id="namajalan2" class="form-control" value="">
</div>
<div class="form-group">
<label>Type Jalan :</label>
<input type="text" id="typejalan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kelurahan :</label>
<input type="text" id="kelurahan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kecamatan :</label>
<input type="text" id="kecamatan" class="form-control" value="">
</div>
<div class="form-group">
<label>Anggaran :</label>
<input type="text" id="anggaran" class="form-control" value="">
</div>
<div class="form-group">
<label>Pihak yang Mengesahkan :</label>
<input type="text" id="pihakpengesahan" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Disetujui :</label>
<input type="date" id="tgldisetujui" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Mulai Perbaikan :</label>
<input type="date" id="tglmulaiperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Selesai Perbaikan :</label>
<input type="date" id="tglselesaiperbaikan" class="form-control" value="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Penanggung Jawab Lapangan :</label>
<input type="text" id="pjlapangan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kontraktor :</label>
<input type="text" id="kontraktor" class="form-control" value="">
</div>
<div class="form-group">
<label>Panjang Jalan Keseluruhan :</label>
<input type="text" id="panjangjalanall" class="form-control" value="">
</div>
<div class="form-group">
<label>Panjang Jalan Perbaikan :</label>
<input type="text" id="panjangjalanperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Lebar Jalan Perbaikan :</label>
<input type="text" id="lebarjalanperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Jenis Perbaikan :</label>
<input type="text" id="jenisperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Proposal (.pdf):</label>
<input type="file" id="proposal">
</div>
<div class="form-group">
<label>Bukti Selesai Perbaikan (.png/.jpg/.jpeg/):</label>
<input type="file" id="buktiselesai">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
<input type="text" id="coorjalbaru" class="hidden" value="">
<button type="button" class="btn btn-info" id="save-perbaikan" style="float: right; margin-top: 5px; margin-right: 10px;">SAVE</button>
</div>
</div>
</div>
`;
//if (result.address.Address != '') {
// var nmjalan = result.address.Address
//} else {
......@@ -2073,8 +2192,7 @@
//}
//
$('#namajalan').val(feature.properties.f2);
$('#namajalan2').val(feature.properties.f2);
$('#idjalan').val(feature.properties.f1);
$('#panjangjalan').val(feature.properties.f3);
......@@ -2082,6 +2200,9 @@
$('#tipejalan').val(feature.properties.f5);
$("#coordinatejalan").val(feature.geometry);
$("#input_perbaikan").html(content_his_jal);
}
});
......@@ -2314,7 +2435,7 @@
data.append("csrfmiddlewaretoken", "{{ csrf_token }}");
data.append('idjalan', $("#idjalan").val())
data.append('namajalan', $("#namajalan").val())
data.append('namajalan2', $("#namajalan2").val())
data.append('panjangjalan', $("#panjangjalan").val())
data.append('lebarjalan', $("#lebarjalan").val())
data.append('tipejalan', $("#tipejalan").val())
......@@ -2665,18 +2786,28 @@
</script>
<script type="text/javascript" src="{% static 'js/plugins/tables/datatables/datatables.min.js' %}"></script>
<script>
function destroyfade() {
$(".modal-backdrop").css("display", "none")
$(".modal-backdrop").removeClass('show');
$("body").css('padding-right', '0px !important')
document.querySelector("#right-tab2-feas-upli > div > div:nth-child(6) > div > label").html(`Pimpinan`)
document.querySelector("#right-tab2-feas-upli > div > div:nth-child(3)").css("display", "block")
}
// function destroyfade() {
// $(".modal-backdrop").css("display", "none")
// $(".modal-backdrop").removeClass('show');
// $("body").css('padding-right', '0px !important')
// document.querySelector("#right-tab2-feas-upli > div > div:nth-child(6) > div > label").html(`Pimpinan`)
// document.querySelector("#right-tab2-feas-upli > div > div:nth-child(3)").css("display", "block")
// }
// function destroyWraper() {
// $("#input_perbaikan").css("display", "none");
// $("#edit_kelurahan").css("display", "none");
// }
$(document).on("click", "#btn_perbaikan_jalan", function() {
// $("#input_perbaikan").css("display", "block");
// $("#koordinat_cek").addClass("active")
// $("#info_umum").removeClass("active")
// $("#left-tab1-feas-upl-j").addClass("active")
// $("#right-tab2-feas-upl-j").removeClass("active")
function destroyWraper() {
$("#input_perbaikan").css("display", "none");
$("#edit_kelurahan").css("display", "none");
}
var map_input = L.map('map-insert', {
editable: true,
zoomControl: false,
......@@ -2732,10 +2863,10 @@
totalDistance += tempLatLng.distanceTo(latlng);
tempLatLng = latlng;
});
e.layer.bindPopup((totalDistance).toFixed(2) + ' meter');
e.layer.bindPopup((totalDistance).toFixed(2));
e.layer.openPopup();
$("#panjangjalanperbaikan").val((totalDistance).toFixed(2) + ' meter');
$("#panjangjalanperbaikan").val((totalDistance).toFixed(2));
}
editableLayers.addLayer(layer);
});
......@@ -2776,15 +2907,8 @@
}
}).addTo(map_input);
$(document).on("click", "#btn_perbaikan_jalan", function() {
$("#koordinat_cek").addClass("active")
$("#info_umum").removeClass("active")
$("#left-tab1-feas-upl-j").addClass("active")
$("#right-tab2-feas-upl-j").removeClass("active")
geo_jalan_input.clearLayers(geo_jalan_input)
$("#input_perbaikan").css("display", "block");
// $("#input_perbaikan").css("display", "block");
var id_jalan = $("#idjalan").val();
editableLayers.clearLayers();
......@@ -2800,7 +2924,12 @@
},
dataType: 'json',
success: function(data) {
$("#namajalan").val(data[0]);
if ((data[0]==null) || (data[0]=="")){
$("#namajalan2").val();
} else {
$("#namajalan2").val(data[0]);
}
$("#typejalan").val(data[1]);
$("#panjangjalanall").val(data[2]);
$("#id_jalan_perbaikan").val(data[4]);
......@@ -2810,19 +2939,29 @@
var latlngs = data[3];
map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17)
geo_jalan_input.addData(data[3]);
$("#map-insert > div.leaflet-control-container > div.leaflet-top.leaflet-left > div:nth-child(1) > div > div > a.leaflet-draw-draw-marker").css("display", "none")
$('#save-perbaikan').click(function() {
var hasil = JSON.stringify(editableLayers.toGeoJSON());
$("#coorjalbaru").val(hasil);
// console.log(hasil);
// console.log($("#coorjalbaru").val());
})
}
})
});
$("#save-perbaikan").click(function() {
$(document).on("click", "#save-perbaikan", function() {
// $("#save-perbaikan").click(function() {
var hasil = JSON.stringify(editableLayers.toGeoJSON());
// var hasil = JSON.stringify(editableLayers.toGeoJSON());
// var hasil = $()
var polijalbar = $("#coorjalbaru").val();
var id_jalan = $("#id_jalan_perbaikan").val();
var type_id = $("#type_id").val();
var name = $("#namajalan").val();
var name = $("#namajalan2").val();
var type = $("#typejalan").val();
var tgl_perbaikan = $("#tglmulaiperbaikan").val();
var tgl_selesai = $("#tglselesaiperbaikan").val();
......@@ -2841,7 +2980,7 @@
var kecamatan = $("#kecamatan").val();
var data_umum = [{
'coord': hasil
'coord': polijalbar
}, {
'object_id': id_jalan
}, {
......@@ -3510,10 +3649,10 @@
tempLatLng = latlng;
});
e.layer.bindPopup((totalDistance).toFixed(2) + ' meter');
e.layer.bindPopup((totalDistance).toFixed(2));
e.layer.openPopup();
$("#panjang_jalan_create").val((totalDistance).toFixed(2) + ' meter');
$("#panjang_jalan_create").val((totalDistance).toFixed(2));
}
$("#poly_create_jalan").val(JSON.stringify(layer.toGeoJSON()));
layer.addTo(map_create_all);
......
......@@ -1648,129 +1648,8 @@
</div>
</div>
<div class="content-wrapper modal" id="input_perbaikan" style="display: none;padding: 60px;margin-left: 10%;border-radius:10px;top: -40px;">
<div class="content modal-md" style="padding: 15px;max-height: 550px;">
<!-- Main charts -->
<div class="panel panel-flat" style="display: none;width: 1000px;">
<div class="panel-header" style="height: 50px;background: #1E2233;border-top-left-radius: 10px;border-top-right-radius: 10px;">
<button type="button" class="close" onclick="destroyWraper()" style=" width: 30px;
color: white;
height: 30px;">&times;</button>
<h5 class="modal-title title-create" style="color: white;margin-left: 25px;padding-top: 10px;">Input Perbaikan</h5>
</div>
<div class="panel-body" style="padding-top: 10px;">
<div class="tabbable">
<ul class="nav nav-tabs nav-tabs-bottom nav-justified">
<li class="active"><a href="#left-tab-input-coordinat" data-toggle="tab">Koordinat</a></li>
<li><a href="#right-tab-input-informasi" data-toggle="tab">Insert Informasi</a></li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane active" id="left-tab-input-coordinat">
<div class="modal-body" style="max-height: 450px;overflow-y: auto;">
<input type="text" class="hidden" id="poly_create_input">
<input type="text" class="hidden" id="id_jalan_perbaikan">
<input type="text" class="hidden" id="type_id">
<div id="map-insert" style="height: 375px;width: 100%">
</div>
</div>
</div>
<div class="tab-pane" id="right-tab-input-informasi">
<div class="modal-body" style="max-height: 415px;overflow-y: auto;">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Nama Jalan :</label>
<input type="text" id="namajalan" class="form-control" value="">
</div>
<div class="form-group">
<label>Type Jalan :</label>
<input type="text" id="typejalan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kelurahan :</label>
<input type="text" id="kelurahan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kecamatan :</label>
<input type="text" id="kecamatan" class="form-control" value="">
</div>
<div class="form-group">
<label>Anggaran :</label>
<input type="text" id="anggaran" class="form-control" value="">
</div>
<div class="form-group">
<label>Pihak yang Mengesahkan :</label>
<input type="text" id="pihakpengesahan" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Disetujui :</label>
<input type="date" id="tgldisetujui" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Mulai Perbaikan :</label>
<input type="date" id="tglmulaiperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Tanggal Selesai Perbaikan :</label>
<input type="date" id="tglselesaiperbaikan" class="form-control" value="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Penanggung Jawab Lapangan :</label>
<input type="text" id="pjlapangan" class="form-control" value="">
</div>
<div class="form-group">
<label>Kontraktor :</label>
<input type="text" id="kontraktor" class="form-control" value="">
</div>
<div class="form-group">
<label>Panjang Jalan Keseluruhan :</label>
<input type="text" id="panjangjalanall" class="form-control" value="">
</div>
<div class="form-group">
<label>Panjang Jalan Perbaikan :</label>
<input type="text" id="panjangjalanperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Lebar Jalan Perbaikan :</label>
<input type="text" id="lebarjalanperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Jenis Perbaikan :</label>
<input type="text" id="jenisperbaikan" class="form-control" value="">
</div>
<div class="form-group">
<label>Proposal (.pdf):</label>
<input type="file" id="proposal">
</div>
<div class="form-group">
<label>Bukti Selesai Perbaikan (.png/.jpg/.jpeg/):</label>
<input type="file" id="buktiselesai">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
<button type="button" class="btn btn-info" id="save-perbaikan" style="float: right; margin-right: 40px;">SAVE</button>
<!-- <button type="button" class="btn btn-link" onclick="destroyWraper()" style="float: right;">Close</button> -->
</div>
</div>
</div>
<!-- /main charts -->
<div id="input_perbaikan" class="modal fade">
<!-- <div class="content-wrapper modal" id="input_perbaikan" style="display: none;padding: 60px;margin-left: 10%;border-radius:10px;top: -40px;"> -->
</div>
......
......@@ -396,8 +396,8 @@
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Nama Jalan :</label>
<input type="text" id="namajalan" class="form-control" value="">
<!-- <label>Nama Jalan :</label>
<input type="text" id="namajalan" class="form-control" value=""> -->
</div>
<div class="form-group">
<label>Type Jalan :</label>
......@@ -479,7 +479,7 @@
</div>
<div class="panel-footer">
<input type="submit" class="btn btn-default" id="save-perbaikan" value="SAVE">
<!-- <input type="submit" class="btn btn-default" id="save-perbaikan" value="SAVE"> -->
<button type="button" class="btn btn-link" onclick="destroyWraper()">Close</button>
</div>
......@@ -666,153 +666,153 @@
$("#info-pendidikan").css("display", "none");
}
$("#inputdata").on("click", function() {
$("#input_perbaikan").css("display", "block");
$("#info-jalan").css("display", "none");
$("#info-pendidikan").css("display", "none");
editableLayers.clearLayers();
setTimeout(function() {
map_input.invalidateSize();
}, 1000);
$.ajax({
url: "{% url 'apps:input-perbaikan' %}",
data: {
'id_jalan': 1
},
dataType: 'json',
success: function(data) {
$("#namajalan").val(data[0]);
$("#typejalan").val(data[1]);
$("#panjangjalanall").val(data[2]);
$("#id_jalan_perbaikan").val(data[4]);
$("#type_id").val(data[5])
// $("#inputdata").on("click", function() {
// $("#input_perbaikan").css("display", "block");
// $("#info-jalan").css("display", "none");
// $("#info-pendidikan").css("display", "none");
// editableLayers.clearLayers();
// setTimeout(function() {
// map_input.invalidateSize();
// }, 1000);
var latlngs = data[3];
map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17)
var geo_jalan = L.geoJson(data[3], {
style: function(feature) {
return {
color: "#808080",
weight: 8,
opacity: 2,
zIndex: 1000
};
}
}).addTo(map_input);
}
})
});
$("#save-perbaikan").click(function() {
var hasil = JSON.stringify(editableLayers.toGeoJSON());
var id_jalan = $("#id_jalan_perbaikan").val();
var type_id = $("#type_id").val();
var name = $("#namajalan").val();
var type = $("#typejalan").val();
var tgl_perbaikan = $("#tglmulaiperbaikan").val();
var tgl_selesai = $("#tglselesaiperbaikan").val();
var tgl_disetujui = $("#tgldisetujui").val();
var anggaran = $("#anggaran").val();
var proposal = $("#proposal").val();
var bukti_selesai = $("#buktiselesai").val();
var pj = $("#pihakpengesahan").val();
var pj_lapangan = $("#pjlapangan").val();
var kontraktor = $("#kontraktor").val();
var pjg_perbaikan = $("#panjangjalanperbaikan").val();
var lbr_perbaikan = $("#lebarjalanperbaikan").val();
var jenis_perbaikan = $("#jenisperbaikan").val();
var luas = $("#luas").val();
var kelurahan = $("#kelurahan").val();
var kecamatan = $("#kecamatan").val();
var data_umum = [{
'coord': hasil
}, {
'object_id': id_jalan
}, {
'type_id': type_id
}, {
'name': name
}, {
'type': type
}, {
'tgl_selesai': tgl_selesai
}, {
'tgl_perbaikan': tgl_perbaikan
}, {
'tgl_disetujui': tgl_disetujui
}, {
'anggaran': anggaran
}, {
'pj': pj
}, {
'pj_lapangan': pj_lapangan
}, {
'kontraktor': kontraktor
}, {
'pjg_perbaikan': pjg_perbaikan
}, {
'lbr_perbaikan': lbr_perbaikan
}, {
'jenis_perbaikan': jenis_perbaikan
}, {
'luas': luas
}, {
'kelurahan': kelurahan
}, {
'kecamatan': kecamatan
}]
data = new FormData()
data.append("proposal", $("input[id^='proposal']")[0].files[0]);
data.append("bukti_selesai", $("input[id^='buktiselesai']")[0].files[0]);
console.log(data)
for (var i = 0; i < data_umum.length; i++) {
var keyss = Object.keys(data_umum[i]);
data.append(keyss[0], data_umum[i][keyss[0]])
}
$.ajax({
url: "{% url 'apps:save-perbaikan' %}",
data: data,
dataType: 'json',
type: 'POST',
processData: false,
contentType: false,
success: function(data) {
let response = data;
if (response.code == 0) {
swal({
title: response.info,
text: response.data,
type: "success",
icon: "success",
confirmButtonColor: "#00BCD4"
}, function() {
$("#input_perbaikan").css("display", "none");
$("#info-jalan").css("display", "block");
$("#info-pendidikan").css("display", "none");
})
} else {
swal({
title: response.info,
text: response.data,
type: "warning",
icon: "error",
confirmButtonColor: "#00BCD4"
})
}
}
})
});
// $.ajax({
// url: "{% url 'apps:input-perbaikan' %}",
// data: {
// 'id_jalan': 1
// },
// dataType: 'json',
// success: function(data) {
// $("#namajalan").val(data[0]);
// $("#typejalan").val(data[1]);
// $("#panjangjalanall").val(data[2]);
// $("#id_jalan_perbaikan").val(data[4]);
// $("#type_id").val(data[5])
// var latlngs = data[3];
// map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17)
// var geo_jalan = L.geoJson(data[3], {
// style: function(feature) {
// return {
// color: "#808080",
// weight: 8,
// opacity: 2,
// zIndex: 1000
// };
// }
// }).addTo(map_input);
// }
// })
// });
// $("#save-perbaikan").click(function() {
// var hasil = JSON.stringify(editableLayers.toGeoJSON());
// var id_jalan = $("#id_jalan_perbaikan").val();
// var type_id = $("#type_id").val();
// var name = $("#namajalan").val();
// var type = $("#typejalan").val();
// var tgl_perbaikan = $("#tglmulaiperbaikan").val();
// var tgl_selesai = $("#tglselesaiperbaikan").val();
// var tgl_disetujui = $("#tgldisetujui").val();
// var anggaran = $("#anggaran").val();
// var proposal = $("#proposal").val();
// var bukti_selesai = $("#buktiselesai").val();
// var pj = $("#pihakpengesahan").val();
// var pj_lapangan = $("#pjlapangan").val();
// var kontraktor = $("#kontraktor").val();
// var pjg_perbaikan = $("#panjangjalanperbaikan").val();
// var lbr_perbaikan = $("#lebarjalanperbaikan").val();
// var jenis_perbaikan = $("#jenisperbaikan").val();
// var luas = $("#luas").val();
// var kelurahan = $("#kelurahan").val();
// var kecamatan = $("#kecamatan").val();
// var data_umum = [{
// 'coord': hasil
// }, {
// 'object_id': id_jalan
// }, {
// 'type_id': type_id
// }, {
// 'name': name
// }, {
// 'type': type
// }, {
// 'tgl_selesai': tgl_selesai
// }, {
// 'tgl_perbaikan': tgl_perbaikan
// }, {
// 'tgl_disetujui': tgl_disetujui
// }, {
// 'anggaran': anggaran
// }, {
// 'pj': pj
// }, {
// 'pj_lapangan': pj_lapangan
// }, {
// 'kontraktor': kontraktor
// }, {
// 'pjg_perbaikan': pjg_perbaikan
// }, {
// 'lbr_perbaikan': lbr_perbaikan
// }, {
// 'jenis_perbaikan': jenis_perbaikan
// }, {
// 'luas': luas
// }, {
// 'kelurahan': kelurahan
// }, {
// 'kecamatan': kecamatan
// }]
// data = new FormData()
// data.append("proposal", $("input[id^='proposal']")[0].files[0]);
// data.append("bukti_selesai", $("input[id^='buktiselesai']")[0].files[0]);
// console.log(data)
// for (var i = 0; i < data_umum.length; i++) {
// var keyss = Object.keys(data_umum[i]);
// data.append(keyss[0], data_umum[i][keyss[0]])
// }
// $.ajax({
// url: "{% url 'apps:save-perbaikan' %}",
// data: data,
// dataType: 'json',
// type: 'POST',
// processData: false,
// contentType: false,
// success: function(data) {
// let response = data;
// if (response.code == 0) {
// swal({
// title: response.info,
// text: response.data,
// type: "success",
// icon: "success",
// confirmButtonColor: "#00BCD4"
// }, function() {
// $("#input_perbaikan").css("display", "none");
// $("#info-jalan").css("display", "block");
// $("#info-pendidikan").css("display", "none");
// })
// } else {
// swal({
// title: response.info,
// text: response.data,
// type: "warning",
// icon: "error",
// confirmButtonColor: "#00BCD4"
// })
// }
// }
// })
// });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment