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

fix perbaikan bangunan dan jalan

parent 4a9869d6
...@@ -823,7 +823,8 @@ import re ...@@ -823,7 +823,8 @@ import re
import json import json
@api_view(('POST',)) @api_view(('POST',))
def saveperbaikan(request): 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") id_object = request.POST.get("object_id")
name = request.POST.get("name") name = request.POST.get("name")
type = request.POST.get("type") type = request.POST.get("type")
...@@ -852,42 +853,60 @@ def saveperbaikan(request): ...@@ -852,42 +853,60 @@ def saveperbaikan(request):
fss_p = FileSystemStorage(location='/var/www/django/oku.khansia.co.id/media/proposal/') 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/') 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)) pjg_perbaikan = re.sub('[^0-9.]+', '', str(pjg_perbaikan))
lbr_perbaikan = re.sub('[^0-9.]+', '', str(lbr_perbaikan)) lbr_perbaikan = re.sub('[^0-9.]+', '', str(lbr_perbaikan))
luas = re.sub('[^0-9.]+', '', str(luas)) luas = re.sub('[^0-9.]+', '', str(luas))
if coord['features'][0]['geometry']['type'] == 'LineString': # if coord['features'][0]['geometry']['type'] == 'LineString':
print("oke") # print("oke")
for co in coord['features']: # for co in coord['features']:
ll = str(co["geometry"]['coordinates']) # ll = str(co["geometry"]['coordinates'])
ll += ll # ll += ll
ll = ll.replace(", "," ") # ll = ll.replace(", "," ")
ll = ll.replace("]][[","),(") # ll = ll.replace("]][[","),(")
ll = ll.replace("] [",", ") # ll = ll.replace("] [",", ")
ll = ll.replace("]]",")") # ll = ll.replace("]]",")")
ll = ll.replace("[[","(") # ll = ll.replace("[[","(")
coordinat = f'MULTILINESTRING({ll})' # coordinat = f'MULTILINESTRING({ll})'
print(ll) # print(ll)
if coord['features'][0]['geometry']['type'] == 'Polygon': # if coord['features'][0]['geometry']['type'] == 'Polygon':
print('tidakoke') # print('tidakoke')
try: yak = str(coor)
format = (proposal.name).split(".") suk = yak.replace("""{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":""","")
num = random.randrange(1, 10000000000000) sik = suk.replace("""}}""","")
nproposal = f"{name}_{num}.{format[-1:][0]}" cor = sik.replace("""[[[""","(")
nproposal = nproposal.replace(" ","-") coran = cor.replace("""]]]""",")")
filename_p = fss_p.save(nproposal, proposal) ll = coran.replace(","," ")
url_p = fss_p.url(filename_p) ii = ll.replace("] [",",")
mm = ii.replace('{"type":"FeatureCollection" "features":', '')
nn = mm.replace('}', '')
corcoran = f'MULTILINESTRING({nn})'
format = (proposal.name).split(".")
num = random.randrange(1, 10000000000000)
nproposal = f"{name}_{num}.{format[-1:][0]}"
nproposal = nproposal.replace(" ","-")
filename_p = fss_p.save(nproposal, proposal)
url_p = fss_p.url(filename_p)
format_ = (bukti_selesai.name).split(".") format_ = (bukti_selesai.name).split(".")
nbukti = f"{name}_{num}.{format_[-1:][0]}" nbukti = f"{name}_{num}.{format_[-1:][0]}"
nbukti = nbukti.replace(" ","-") nbukti = nbukti.replace(" ","-")
filename_b = fss_b.save(nbukti, bukti_selesai) filename_b = fss_b.save(nbukti, bukti_selesai)
url_b = fss_b.url(filename_b) 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: with conn.cursor() as data_per:
data_per.execute(""" data_per.execute("""
INSERT INTO tbl_perbaikan ( INSERT INTO tbl_perbaikan (
...@@ -927,7 +946,7 @@ def saveperbaikan(request): ...@@ -927,7 +946,7 @@ def saveperbaikan(request):
%s, %s,
%s, %s,
'%s', '%s',
ST_GeomFromText('%s') ST_GeomFromText('%s')
) )
"""% ( """% (
int(type_id), int(type_id),
...@@ -946,7 +965,7 @@ def saveperbaikan(request): ...@@ -946,7 +965,7 @@ def saveperbaikan(request):
float(pjg_perbaikan), float(pjg_perbaikan),
float(lbr_perbaikan), float(lbr_perbaikan),
jenis_perbaikan, jenis_perbaikan,
coordinat)) corcoran))
conn.commit() conn.commit()
data = "Sukses" data = "Sukses"
info = "Data Telah Berhasil di Perbaharui" info = "Data Telah Berhasil di Perbaharui"
......
...@@ -4883,7 +4883,6 @@ ...@@ -4883,7 +4883,6 @@
} else { } else {
var alamak = feature.administrasi.f3; var alamak = feature.administrasi.f3;
} }
if (feature.administrasi.f10 == 'bpk') { if (feature.administrasi.f10 == 'bpk') {
var raja = ""; var raja = "";
...@@ -8001,11 +8000,18 @@ ...@@ -8001,11 +8000,18 @@
$("#modal_detail_non_kelurahan").modal('show'); $("#modal_detail_non_kelurahan").modal('show');
var geogeo = geocodeService.reverse().latlng(e.latlng).run(function(error, result) { var geogeo = geocodeService.reverse().latlng(e.latlng).run(function(error, result) {
if (result.address.Address != '') { // tay = result.address.Address;
var alamat = result.address.Address + `, ` // if (feature.administrasi.f3 == 'None') {
} else { // if (tay != '') {
var alamat = '' // var alamak = tay;
};
// } else {
// alamak = ""
// }
// } else {
// var alamak = feature.administrasi.f3;
// }
if (feature.administrasi.f9 == 'None') { if (feature.administrasi.f9 == 'None') {
var path_img = "static/img/image_null.jpg" var path_img = "static/img/image_null.jpg"
...@@ -8318,8 +8324,8 @@ ...@@ -8318,8 +8324,8 @@
<input type="text" class="hidden" id="id_bang_perbaikan" value="` + feature.properties.f1 + `" disable> <input type="text" class="hidden" id="id_bang_perbaikan" value="` + feature.properties.f1 + `" disable>
<input type="text" class="hidden" id="type_id_bang"> <input type="text" class="hidden" id="type_id_bang">
<div id="map-insert-renov-bang" style="height: 375px;width: 100%"> <div id="map-insert-renov-bang" style="height: 375px;width: 100%">
</div>
</div> </div>
</div>
<div class="tab-pane" id="right-tab2-feas-upl"> <div class="tab-pane" id="right-tab2-feas-upl">
<div class="row"> <div class="row">
...@@ -8387,9 +8393,7 @@ ...@@ -8387,9 +8393,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -8443,7 +8447,7 @@ ...@@ -8443,7 +8447,7 @@
</p> </p>
<p> <p>
<span> <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> </span>
</p> </p>
</th> </th>
...@@ -8496,7 +8500,7 @@ ...@@ -8496,7 +8500,7 @@
</div> </div>
<div> <div>
<span> <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> </span>
</div> </div>
...@@ -9014,10 +9018,16 @@ ...@@ -9014,10 +9018,16 @@
}; };
polylyly = L.polygon(list_poly_edit).addTo(map_bang) polylyly = L.polygon(list_poly_edit).addTo(map_bang)
polylyly.enableEdit(); // polylyly.enableEdit();
var hasil = (JSON.stringify(polylyly.toGeoJSON())) var hasil = (JSON.stringify(polylyly.toGeoJSON()))
// console.log(polylyly)
// console.log(hasil)
// $("#coorbangbaru").val(hasil);
$('#save-perbaikan_bang').click(function() { $('#save-perbaikan_bang').click(function() {
$("#coorbangbaru").val(hasil); $("#coorbangbaru").val(hasil);
console.log(hasil);
// console.log("tes");
}) })
} }
}) })
...@@ -9083,6 +9093,9 @@ ...@@ -9083,6 +9093,9 @@
data.append(keyss[0], data_umum[i][keyss[0]]) data.append(keyss[0], data_umum[i][keyss[0]])
} }
// console.log(data)
// console.log(data_umum)
$.ajax({ $.ajax({
url: "{% url 'apps:save-perbaikan-bang' %}", url: "{% url 'apps:save-perbaikan-bang' %}",
data: data, data: data,
......
...@@ -1965,7 +1965,7 @@ ...@@ -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> <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> </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 { } else {
var perbaikan_jl = `<div class='row'> var perbaikan_jl = `<div class='row'>
...@@ -1974,7 +1974,7 @@ ...@@ -1974,7 +1974,7 @@
</div> </div>
</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(` $(".nama_keterangan").html(`
...@@ -2030,6 +2030,125 @@ ...@@ -2030,6 +2030,125 @@
</div> </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 != '') { //if (result.address.Address != '') {
// var nmjalan = result.address.Address // var nmjalan = result.address.Address
//} else { //} else {
...@@ -2073,8 +2192,7 @@ ...@@ -2073,8 +2192,7 @@
//} //}
// //
$('#namajalan').val(feature.properties.f2); $('#namajalan2').val(feature.properties.f2);
$('#idjalan').val(feature.properties.f1); $('#idjalan').val(feature.properties.f1);
$('#panjangjalan').val(feature.properties.f3); $('#panjangjalan').val(feature.properties.f3);
...@@ -2082,6 +2200,9 @@ ...@@ -2082,6 +2200,9 @@
$('#tipejalan').val(feature.properties.f5); $('#tipejalan').val(feature.properties.f5);
$("#coordinatejalan").val(feature.geometry); $("#coordinatejalan").val(feature.geometry);
$("#input_perbaikan").html(content_his_jal);
} }
}); });
...@@ -2314,7 +2435,7 @@ ...@@ -2314,7 +2435,7 @@
data.append("csrfmiddlewaretoken", "{{ csrf_token }}"); data.append("csrfmiddlewaretoken", "{{ csrf_token }}");
data.append('idjalan', $("#idjalan").val()) data.append('idjalan', $("#idjalan").val())
data.append('namajalan', $("#namajalan").val()) data.append('namajalan2', $("#namajalan2").val())
data.append('panjangjalan', $("#panjangjalan").val()) data.append('panjangjalan', $("#panjangjalan").val())
data.append('lebarjalan', $("#lebarjalan").val()) data.append('lebarjalan', $("#lebarjalan").val())
data.append('tipejalan', $("#tipejalan").val()) data.append('tipejalan', $("#tipejalan").val())
...@@ -2665,126 +2786,129 @@ ...@@ -2665,126 +2786,129 @@
</script> </script>
<script type="text/javascript" src="{% static 'js/plugins/tables/datatables/datatables.min.js' %}"></script> <script type="text/javascript" src="{% static 'js/plugins/tables/datatables/datatables.min.js' %}"></script>
<script> <script>
function destroyfade() { // function destroyfade() {
$(".modal-backdrop").css("display", "none") // $(".modal-backdrop").css("display", "none")
$(".modal-backdrop").removeClass('show'); // $(".modal-backdrop").removeClass('show');
$("body").css('padding-right', '0px !important') // $("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(6) > div > label").html(`Pimpinan`)
document.querySelector("#right-tab2-feas-upli > div > div:nth-child(3)").css("display", "block") // 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");
}
var map_input = L.map('map-insert', {
editable: true,
zoomControl: false,
drawControl: true
}).setView([-4.125826277307029, 104.1881561279297], 10);
maps = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&s=Gal&apistyle=s.t:0|s.e:l|p.v:off', { // function destroyWraper() {
maxZoom: 22, // $("#input_perbaikan").css("display", "none");
minZoom: 4, // $("#edit_kelurahan").css("display", "none");
}).addTo(map_input); // }
var editableLayers = new L.FeatureGroup();
map_input.addLayer(editableLayers);
var options = { $(document).on("click", "#btn_perbaikan_jalan", function() {
position: 'topleft', // $("#input_perbaikan").css("display", "block");
draw: { // $("#koordinat_cek").addClass("active")
polyline: { // $("#info_umum").removeClass("active")
shapeOptions: { // $("#left-tab1-feas-upl-j").addClass("active")
color: 'red', // $("#right-tab2-feas-upl-j").removeClass("active")
weight: 10
} var map_input = L.map('map-insert', {
editable: true,
zoomControl: false,
drawControl: true
}).setView([-4.125826277307029, 104.1881561279297], 10);
maps = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&s=Gal&apistyle=s.t:0|s.e:l|p.v:off', {
maxZoom: 22,
minZoom: 4,
}).addTo(map_input);
var editableLayers = new L.FeatureGroup();
map_input.addLayer(editableLayers);
var options = {
position: 'topleft',
draw: {
polyline: {
shapeOptions: {
color: 'red',
weight: 10
}
},
polyline: true,
}, },
polyline: true, edit: {
}, featureGroup: editableLayers, //REQUIRED!!
edit: { remove: true
featureGroup: editableLayers, //REQUIRED!!
remove: true
},
color: 'red'
};
var drawControl = new L.Control.Draw(options);
map_input.addControl(drawControl);
map_input.on('draw:created', function(e) {
var type = e.layerType,
layer = e.layer;
layer.options.color = 'yellow';
layer.options.weight = 10;
layer.options.opacity = 1;
var koordina = ""
if (type === 'polyline') {
var tempLatLng = null;
var totalDistance = 0.00000;
$.each(e.layer._latlngs, function(i, latlng) {
if (tempLatLng == null) {
tempLatLng = latlng;
return;
}
totalDistance += tempLatLng.distanceTo(latlng);
tempLatLng = latlng;
});
e.layer.bindPopup((totalDistance).toFixed(2) + ' meter');
e.layer.openPopup();
$("#panjangjalanperbaikan").val((totalDistance).toFixed(2) + ' meter');
}
editableLayers.addLayer(layer);
});
function getjalanper(id) {
$.ajax({
url: "{% url 'apps:get-jalan-perbaikan' %}",
data: {
'id': id
}, },
dataType: 'json', color: 'red'
success: function(data) { };
map.setView([data[0]['geometry']['coordinates'][0][0][1], data[0]['geometry']['coordinates'][0][0][0]], 18)
var drawControl = new L.Control.Draw(options);
var geo_jalan_perbaikan = L.geoJson(data[0], { map_input.addControl(drawControl);
style: function(feature) {
return { map_input.on('draw:created', function(e) {
color: "#FAFA00", var type = e.layerType,
weight: 10, layer = e.layer;
opacity: 2, layer.options.color = 'yellow';
zIndex: 1999 layer.options.weight = 10;
}; layer.options.opacity = 1;
var koordina = ""
if (type === 'polyline') {
var tempLatLng = null;
var totalDistance = 0.00000;
$.each(e.layer._latlngs, function(i, latlng) {
if (tempLatLng == null) {
tempLatLng = latlng;
return;
} }
}).addTo(map);
totalDistance += tempLatLng.distanceTo(latlng);
tempLatLng = latlng;
});
e.layer.bindPopup((totalDistance).toFixed(2));
e.layer.openPopup();
$("#panjangjalanperbaikan").val((totalDistance).toFixed(2));
} }
editableLayers.addLayer(layer);
}); });
};
var geo_jalan_input = L.geoJson(null, { function getjalanper(id) {
style: function(feature) { $.ajax({
return { url: "{% url 'apps:get-jalan-perbaikan' %}",
color: "#06FF08", data: {
weight: 8, 'id': id
opacity: 2, },
zIndex: 1000 dataType: 'json',
}; success: function(data) {
} map.setView([data[0]['geometry']['coordinates'][0][0][1], data[0]['geometry']['coordinates'][0][0][0]], 18)
}).addTo(map_input);
var geo_jalan_perbaikan = L.geoJson(data[0], {
style: function(feature) {
return {
color: "#FAFA00",
weight: 10,
opacity: 2,
zIndex: 1999
};
}
}).addTo(map);
}
});
};
$(document).on("click", "#btn_perbaikan_jalan", function() { var geo_jalan_input = L.geoJson(null, {
$("#koordinat_cek").addClass("active") style: function(feature) {
$("#info_umum").removeClass("active") return {
$("#left-tab1-feas-upl-j").addClass("active") color: "#06FF08",
$("#right-tab2-feas-upl-j").removeClass("active") weight: 8,
opacity: 2,
zIndex: 1000
};
}
}).addTo(map_input);
geo_jalan_input.clearLayers(geo_jalan_input) geo_jalan_input.clearLayers(geo_jalan_input)
$("#input_perbaikan").css("display", "block"); // $("#input_perbaikan").css("display", "block");
var id_jalan = $("#idjalan").val(); var id_jalan = $("#idjalan").val();
editableLayers.clearLayers(); editableLayers.clearLayers();
...@@ -2800,29 +2924,44 @@ ...@@ -2800,29 +2924,44 @@
}, },
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
$("#namajalan").val(data[0]); if ((data[0]==null) || (data[0]=="")){
$("#namajalan2").val();
} else {
$("#namajalan2").val(data[0]);
}
$("#typejalan").val(data[1]); $("#typejalan").val(data[1]);
$("#panjangjalanall").val(data[2]); $("#panjangjalanall").val(data[2]);
$("#id_jalan_perbaikan").val(data[4]); $("#id_jalan_perbaikan").val(data[4]);
$("#type_id").val(data[5]) $("#type_id").val(data[5])
var latlngs = data[3]; var latlngs = data[3];
map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17) map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17)
geo_jalan_input.addData(data[3]); 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") $("#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 id_jalan = $("#id_jalan_perbaikan").val();
var type_id = $("#type_id").val(); var type_id = $("#type_id").val();
var name = $("#namajalan").val(); var name = $("#namajalan2").val();
var type = $("#typejalan").val(); var type = $("#typejalan").val();
var tgl_perbaikan = $("#tglmulaiperbaikan").val(); var tgl_perbaikan = $("#tglmulaiperbaikan").val();
var tgl_selesai = $("#tglselesaiperbaikan").val(); var tgl_selesai = $("#tglselesaiperbaikan").val();
...@@ -2841,7 +2980,7 @@ ...@@ -2841,7 +2980,7 @@
var kecamatan = $("#kecamatan").val(); var kecamatan = $("#kecamatan").val();
var data_umum = [{ var data_umum = [{
'coord': hasil 'coord': polijalbar
}, { }, {
'object_id': id_jalan 'object_id': id_jalan
}, { }, {
...@@ -3510,10 +3649,10 @@ ...@@ -3510,10 +3649,10 @@
tempLatLng = latlng; tempLatLng = latlng;
}); });
e.layer.bindPopup((totalDistance).toFixed(2) + ' meter'); e.layer.bindPopup((totalDistance).toFixed(2));
e.layer.openPopup(); 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())); $("#poly_create_jalan").val(JSON.stringify(layer.toGeoJSON()));
layer.addTo(map_create_all); layer.addTo(map_create_all);
......
...@@ -1648,130 +1648,9 @@ ...@@ -1648,130 +1648,9 @@
</div> </div>
</div> </div>
<div class="content-wrapper modal" id="input_perbaikan" style="display: none;padding: 60px;margin-left: 10%;border-radius:10px;top: -40px;"> <div id="input_perbaikan" class="modal fade">
<div class="content modal-md" style="padding: 15px;max-height: 550px;"> <!-- <div class="content-wrapper modal" id="input_perbaikan" style="display: none;padding: 60px;margin-left: 10%;border-radius:10px;top: -40px;"> -->
<!-- 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> </div>
<table id="table_downloader" style="display: none;"> <table id="table_downloader" style="display: none;">
......
...@@ -396,8 +396,8 @@ ...@@ -396,8 +396,8 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label>Nama Jalan :</label> <!-- <label>Nama Jalan :</label>
<input type="text" id="namajalan" class="form-control" value=""> <input type="text" id="namajalan" class="form-control" value=""> -->
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Type Jalan :</label> <label>Type Jalan :</label>
...@@ -479,7 +479,7 @@ ...@@ -479,7 +479,7 @@
</div> </div>
<div class="panel-footer"> <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> <button type="button" class="btn btn-link" onclick="destroyWraper()">Close</button>
</div> </div>
...@@ -666,153 +666,153 @@ ...@@ -666,153 +666,153 @@
$("#info-pendidikan").css("display", "none"); $("#info-pendidikan").css("display", "none");
} }
$("#inputdata").on("click", function() { // $("#inputdata").on("click", function() {
$("#input_perbaikan").css("display", "block"); // $("#input_perbaikan").css("display", "block");
$("#info-jalan").css("display", "none"); // $("#info-jalan").css("display", "none");
$("#info-pendidikan").css("display", "none"); // $("#info-pendidikan").css("display", "none");
editableLayers.clearLayers(); // editableLayers.clearLayers();
setTimeout(function() { // setTimeout(function() {
map_input.invalidateSize(); // map_input.invalidateSize();
}, 1000); // }, 1000);
$.ajax({ // $.ajax({
url: "{% url 'apps:input-perbaikan' %}", // url: "{% url 'apps:input-perbaikan' %}",
data: { // data: {
'id_jalan': 1 // 'id_jalan': 1
}, // },
dataType: 'json', // dataType: 'json',
success: function(data) { // success: function(data) {
$("#namajalan").val(data[0]); // $("#namajalan").val(data[0]);
$("#typejalan").val(data[1]); // $("#typejalan").val(data[1]);
$("#panjangjalanall").val(data[2]); // $("#panjangjalanall").val(data[2]);
$("#id_jalan_perbaikan").val(data[4]); // $("#id_jalan_perbaikan").val(data[4]);
$("#type_id").val(data[5]) // $("#type_id").val(data[5])
var latlngs = data[3]; // var latlngs = data[3];
map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17) // map_input.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 17)
var geo_jalan = L.geoJson(data[3], { // var geo_jalan = L.geoJson(data[3], {
style: function(feature) { // style: function(feature) {
return { // return {
color: "#808080", // color: "#808080",
weight: 8, // weight: 8,
opacity: 2, // opacity: 2,
zIndex: 1000 // zIndex: 1000
}; // };
} // }
}).addTo(map_input); // }).addTo(map_input);
} // }
}) // })
}); // });
$("#save-perbaikan").click(function() { // $("#save-perbaikan").click(function() {
var hasil = JSON.stringify(editableLayers.toGeoJSON()); // var hasil = JSON.stringify(editableLayers.toGeoJSON());
var id_jalan = $("#id_jalan_perbaikan").val(); // var id_jalan = $("#id_jalan_perbaikan").val();
var type_id = $("#type_id").val(); // var type_id = $("#type_id").val();
var name = $("#namajalan").val(); // var name = $("#namajalan").val();
var type = $("#typejalan").val(); // var type = $("#typejalan").val();
var tgl_perbaikan = $("#tglmulaiperbaikan").val(); // var tgl_perbaikan = $("#tglmulaiperbaikan").val();
var tgl_selesai = $("#tglselesaiperbaikan").val(); // var tgl_selesai = $("#tglselesaiperbaikan").val();
var tgl_disetujui = $("#tgldisetujui").val(); // var tgl_disetujui = $("#tgldisetujui").val();
var anggaran = $("#anggaran").val(); // var anggaran = $("#anggaran").val();
var proposal = $("#proposal").val(); // var proposal = $("#proposal").val();
var bukti_selesai = $("#buktiselesai").val(); // var bukti_selesai = $("#buktiselesai").val();
var pj = $("#pihakpengesahan").val(); // var pj = $("#pihakpengesahan").val();
var pj_lapangan = $("#pjlapangan").val(); // var pj_lapangan = $("#pjlapangan").val();
var kontraktor = $("#kontraktor").val(); // var kontraktor = $("#kontraktor").val();
var pjg_perbaikan = $("#panjangjalanperbaikan").val(); // var pjg_perbaikan = $("#panjangjalanperbaikan").val();
var lbr_perbaikan = $("#lebarjalanperbaikan").val(); // var lbr_perbaikan = $("#lebarjalanperbaikan").val();
var jenis_perbaikan = $("#jenisperbaikan").val(); // var jenis_perbaikan = $("#jenisperbaikan").val();
var luas = $("#luas").val(); // var luas = $("#luas").val();
var kelurahan = $("#kelurahan").val(); // var kelurahan = $("#kelurahan").val();
var kecamatan = $("#kecamatan").val(); // var kecamatan = $("#kecamatan").val();
var data_umum = [{ // var data_umum = [{
'coord': hasil // 'coord': hasil
}, { // }, {
'object_id': id_jalan // 'object_id': id_jalan
}, { // }, {
'type_id': type_id // 'type_id': type_id
}, { // }, {
'name': name // 'name': name
}, { // }, {
'type': type // 'type': type
}, { // }, {
'tgl_selesai': tgl_selesai // 'tgl_selesai': tgl_selesai
}, { // }, {
'tgl_perbaikan': tgl_perbaikan // 'tgl_perbaikan': tgl_perbaikan
}, { // }, {
'tgl_disetujui': tgl_disetujui // 'tgl_disetujui': tgl_disetujui
}, { // }, {
'anggaran': anggaran // 'anggaran': anggaran
}, { // }, {
'pj': pj // 'pj': pj
}, { // }, {
'pj_lapangan': pj_lapangan // 'pj_lapangan': pj_lapangan
}, { // }, {
'kontraktor': kontraktor // 'kontraktor': kontraktor
}, { // }, {
'pjg_perbaikan': pjg_perbaikan // 'pjg_perbaikan': pjg_perbaikan
}, { // }, {
'lbr_perbaikan': lbr_perbaikan // 'lbr_perbaikan': lbr_perbaikan
}, { // }, {
'jenis_perbaikan': jenis_perbaikan // 'jenis_perbaikan': jenis_perbaikan
}, { // }, {
'luas': luas // 'luas': luas
}, { // }, {
'kelurahan': kelurahan // 'kelurahan': kelurahan
}, { // }, {
'kecamatan': kecamatan // 'kecamatan': kecamatan
}] // }]
data = new FormData() // data = new FormData()
data.append("proposal", $("input[id^='proposal']")[0].files[0]); // data.append("proposal", $("input[id^='proposal']")[0].files[0]);
data.append("bukti_selesai", $("input[id^='buktiselesai']")[0].files[0]); // data.append("bukti_selesai", $("input[id^='buktiselesai']")[0].files[0]);
console.log(data) // console.log(data)
for (var i = 0; i < data_umum.length; i++) { // for (var i = 0; i < data_umum.length; i++) {
var keyss = Object.keys(data_umum[i]); // var keyss = Object.keys(data_umum[i]);
data.append(keyss[0], data_umum[i][keyss[0]]) // data.append(keyss[0], data_umum[i][keyss[0]])
} // }
$.ajax({ // $.ajax({
url: "{% url 'apps:save-perbaikan' %}", // url: "{% url 'apps:save-perbaikan' %}",
data: data, // data: data,
dataType: 'json', // dataType: 'json',
type: 'POST', // type: 'POST',
processData: false, // processData: false,
contentType: false, // contentType: false,
success: function(data) { // success: function(data) {
let response = data; // let response = data;
if (response.code == 0) { // if (response.code == 0) {
swal({ // swal({
title: response.info, // title: response.info,
text: response.data, // text: response.data,
type: "success", // type: "success",
icon: "success", // icon: "success",
confirmButtonColor: "#00BCD4" // confirmButtonColor: "#00BCD4"
}, function() { // }, function() {
$("#input_perbaikan").css("display", "none"); // $("#input_perbaikan").css("display", "none");
$("#info-jalan").css("display", "block"); // $("#info-jalan").css("display", "block");
$("#info-pendidikan").css("display", "none"); // $("#info-pendidikan").css("display", "none");
}) // })
} else { // } else {
swal({ // swal({
title: response.info, // title: response.info,
text: response.data, // text: response.data,
type: "warning", // type: "warning",
icon: "error", // icon: "error",
confirmButtonColor: "#00BCD4" // 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