Commit 7514bdf4 authored by Manggar Mahardhika's avatar Manggar Mahardhika

bug fix + history bangunan

parent 1fcdd69e
......@@ -7,7 +7,6 @@ from django.core.files.storage import FileSystemStorage
from django.core.files.base import ContentFile, File
import base64
import json
from PIL import Image
from django.contrib.auth.decorators import login_required, user_passes_test
from django.utils.decorators import method_decorator
......@@ -82,7 +81,46 @@ def building(request):
# kulon lor, wetan lor, wetan kidul, kulon kidul, kulon lor
with conn.cursor() as buldings:
buldings.execute("SELECT json_build_object('type', 'Feature', 'properties', (id, name, information), 'administrasi',(address_1, address_2, address_3, provinsi, alamat, luas_bangunan, luas_tanah, tinggi_bangunan, gambar, pemilik, db_tipe, remark, point_id, point_name), 'geometry', ST_AsGeoJSON(geom :: geometry) :: json) FROM geo_bangunan WHERE st_intersects(geom,'SRID=0;POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))')"% (kulon, lor, wetan, lor, wetan, kidul, kulon, kidul, kulon, lor))
buldings.execute("""SELECT
json_build_object (
'type',
'Feature',
'properties',
( gb.ID, gb.NAME, gb.information,
(
SELECT ARRAY_AGG
( '' || ID || ',' || tgl_perbaikan || ',' || jenis_perbaikan || '' ORDER BY tgl_perbaikan DESC )
FROM
tbl_perbaikan
WHERE
id_object = gb.ID
AND type_id = 1
)
),
'administrasi',
(
gb.address_1,
gb.address_2,
gb.address_3,
gb.provinsi,
gb.alamat,
gb.luas_bangunan,
gb.luas_tanah,
gb.tinggi_bangunan,
gb.gambar,
gb.pemilik,
gb.db_tipe,
gb.remark,
gb.point_id,
gb.point_name
),
'geometry',
ST_AsGeoJSON ( gb.geom :: geometry ) :: json
)
FROM
geo_bangunan gb
WHERE
st_intersects ( gb.geom, 'SRID=0;POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' )"""% (kulon, lor, wetan, lor, wetan, kidul, kulon, kidul, kulon, lor))
prov_res = buldings.fetchall()
polbang = []
......
......@@ -20,5 +20,6 @@ urlpatterns = [
path('get-jalan-perbaikan', views.getjalanperbaikan, name='get-jalan-perbaikan'),
path('get-detail-perbaikan', views.getdetailperbaikan, name='get-detail-perbaikan'),
path('get-detail-perbaikan-bang', views.getdetailperbaikanbangunan, name='get-detail-perbaikan-bang'),
]
\ No newline at end of file
......@@ -1042,6 +1042,60 @@ def getdetailperbaikan(request):
respon =res_all
return Response(respon)
@api_view(('GET',))
def getdetailperbaikanbangunan(request):
id_object = request.GET.get('id')
with conn.cursor() as data_per:
data_per.execute("""
SELECT
gl.NAME,
tp.name,
gj.remark,
tp.tgl_pembuatan,
tp.tgl_perbaikan,
tp.tgl_selesai,
tp.anggaran,
tp.pj,
tp.pj_lapangan,
tp.kontraktor,
ST_AsGeoJSON ( tp.geom :: geometry ) :: json,
tp.id_object,
tp.id,
tp.proposal,
tp.bukti_selesai,
tp.jenis_perbaikan
FROM
tbl_perbaikan tp
JOIN geo_label gl ON gl.ID = tp.type_id
JOIN geo_bangunan gj ON gj.ID = tp.id_object
where tp.id_object = %s
order by tp.tgl_perbaikan desc"""% id_object)
res_perbaikan = data_per.fetchall()
res_all = []
for j in res_perbaikan:
data_all = {
'name':j[1],
'type':j[2],
'tgl_pembuatan':j[3],
'tgl_perbaikan':j[4],
'tgl_selesai':j[5],
'anggaran':j[6],
'pj':j[7],
'pj_lapangan':j[8],
'kontraktor':j[9],
'geometry':j[10],
'id_object':j[11],
'id':j[12],
'proposal':j[13],
'bukti_selesai':j[14],
'jenis_perbaikan':j[15]
}
res_all.append(data_all)
respon = res_all
return Response(respon)
@api_view(('GET',))
def editkelurahan(request):
kode_dagri = request.GET.get('kode_dagri')
......
......@@ -223,6 +223,14 @@
display: none;
}
#btn_detail_per_bang {
display: none;
}
#btn_perbaikan_bangunan {
display: none;
}
.leaflet-popup{
display: none;
}
......
......@@ -72,6 +72,14 @@
display: block;
}
#btn_detail_per_bang {
display: block;
}
#btn_perbaikan_bangunan {
display: block;
}
.leaflet-popup {
display: block;
}
......@@ -4827,8 +4835,6 @@
}
//3d end
var geocodeService = L.esri.Geocoding.geocodeService();
var geocoderNominatim = new L.Control.Geocoder.Nominatim();
......@@ -4870,7 +4876,13 @@
} else {
var path_img = `"static/image/bangunan/` + feature.administrasi.f9 + `"`
}
console.log(feature.administrasi.f11)
// var list_history = feature.properties.f4
// for (var i = 0; i < list_history.length; i++) {
// var dt_history = list_history[i].split(",");
// console.log(dt_history[0])
// console.log(dt_history[1])
// console.log(dt_history[2])
// }
// if (feature.administrasi.f11 != 'None'){
// var cbb = `<option value="null" disabled>-- Pilih Jenis Point --</option>
// <option value="bangunan" `if(feature.administrasi.f11 != 'bangunan'){`selected`};` >Bangunan Biasa</option>
......@@ -4886,31 +4898,61 @@
// <option value="cagar_budaya">Cagar Budaya dan Tempat Wisata</option>
// <option value="gardu_listrik">Gardu Listrik</option>`
// }
var history
if (feature.administrasi.f11 == 'kantor_administrasi' || feature.administrasi.f11 == 'layanan_kesehatan' || feature.administrasi.f11 == 'puskesmas'
|| feature.administrasi.f11 == 'rumah_sakit' || feature.administrasi.f11 == 'sarana_pendidikan' || feature.administrasi.f11 == 'stasiun'
|| feature.administrasi.f11 == 'terminal_bus' || feature.administrasi.f11 == 'cagar_budaya' || feature.administrasi.f11 == 'gardu_listrik'){
if (feature.properties.f4 != null) {
var list_history = feature.properties.f4
var list_history_panel = ``
for (var i = 0; i < list_history.length; i++) {
var dt_history = list_history[i].split(",");
console.log(dt_history[0])
console.log(dt_history[1])
console.log(dt_history[2])
var data_history = `<div class="form-group" style="margin-bottom:0px;">
<div class="row">
<label class="col-md-6">` + dt_history[1] + `</label>
<label class="col-md-6">` + dt_history[2] + `</label>
</div>
</div>`;
list_history_panel += data_history
};
// var list_history = feature.properties.f7
// var list_history_panel = ``
// for (var i = 0; i < list_history.length; i++) {
// var dt_history = list_history[i].split(",");
// var data_history = `<div class="form-group" style="margin-bottom:0px;">
// <div class="row">
// <label class="col-md-6">` + dt_history[1] + `</label>
// <a class="col-md-3" onclick="getjalanper(` + dt_history[0] + `)"><i>View Ruas</i></a>
// <a class="col-md-3" onclick="getdetailper(` + dt_history[0] + `)" data-toggle="modal" data-target="#modal_detail"><i>View Detail</i></a>
// </div>
// </div>`;
// list_history_panel += data_history
// };
// history = `<p class="text-center">
// History Perbaikan
// </p>
// <br>
// ` + list_history_panel + `
// <p class="text-center" style="margin-top: 10px;">
// <a href="#" id='btn_perbaikan_jalan' class="btn btn-default"><i>Tambah History Perbaikan</i></a>
// </p>`;
history = `
<tr style="height: 40px;">
<th id="history_panel">
<p class="text-center">
History Perbaikan
</p>
<br>
<label class="col-md-6"><b>Tanggal</b></label>
<label class="col-md-6"><b>Jenis Perbaikan</b></label>
` + list_history_panel + `
<p class="text-center" style="margin-top: 15px;">
<a id='btn_detail_per_bang' onclick="getdetailperbang(` + feature.properties.f1 + `)" data-toggle="modal" data-target="#modal_detail" class="btn btn-default"><i>View Detail</i></a>
<a href="#" id='btn_perbaikan_bangunan' data-toggle="modal" data-target="#input_perbaikan_bang" data-backdrop="static" data-keyboard="false" class="btn btn-default"><i>Tambah History Perbaikan</i></a>
</p>
</th>
</tr>`;
} else {
history = `
<tr style="height: 40px;">
<th id="history_panel">
<p class="text-center">
History Perbaikan
</p>
<br>
<p class="text-center" style="margin-top: 10px;">Belum Ada History</p>
<p class="text-center" style="margin-top: 10px;">
<a href="#" id='btn_perbaikan_bangunan' data-toggle="modal" data-target="#input_perbaikan_bang" data-backdrop="static" data-keyboard="false" class="btn btn-default"><i>Tambah History Perbaikan</i></a>
</p>
</th>
</tr>`;
}
} else {
history = ``
}
content_edit = `
<div class="modal-dialog" style="width: max-content;height: max-content;">
......@@ -4926,7 +4968,7 @@
</div>
</div>
<div class="col-md-4">
<input type="text" class="hidden" name="coordinatebangunan" id="coordinatebangunan" value="` + feature.geometry + `">
<input type="text" class="hidden" name="coordinatebangunan" id="coordinatebangunan" value="`+feature.geometry+`">
<table>
<tr style="margin-top: 10px">
<th>
......@@ -4934,28 +4976,28 @@
</th>
<td>
<input type="file" id="imgbangunan" name="images[]" multiple accept="image/jpg,image/png,image/jpeg,image/gif">
<input style="display:none;" id="gambar" type="text" class="form-control" value="` + feature.administrasi.f9 + `"required>
<input style="display:none;" id="gambar" type="text" class="form-control" value="`+feature.administrasi.f9+`"required>
</td>
</tr>
<tr>
<td>
<input type="text" name="idbangunan" id="idbangunan" class="form-control hidden" value="` + feature.properties.f1 + `" disable>
<input type="text" name="idbangunan" id="idbangunan" class="form-control hidden" value="`+feature.properties.f1+`" disable>
<input style="display:none;" id="coordinateZoneeditbang" type="text" class="form-control" value=""required>
</td>
</tr>
<tr>
<th>Nama Bangunan</th>
<td>
<input type="text" name="namebangunan" id="namebangunan" class="form-control" value="` + feature.properties.f2 + `">
<input type="text" name="namebangunan" id="namebangunan" class="form-control" value="`+feature.properties.f2+`">
</td>
</tr>
<tr>
<th>Jenis Bangunan</th>
<td>
<input type="text" class="hidden" name="tipe1" id="tipe111" value="` + feature.administrasi.f11 + `">
<input type="text" class="hidden" name="tipe1" id="tipe222" value="` + feature.administrasi.f12 + `">
<input type="text" class="hidden" name="tipe1" id="tipe333" value="` + feature.administrasi.f13 + `">
<input type="text" class="hidden" name="tipe1" id="tipe444" value="` + feature.administrasi.f14 + `">
<input type="text" class="hidden" name="tipe1" id="tipe111" value="`+feature.administrasi.f11+`">
<input type="text" class="hidden" name="tipe1" id="tipe222" value="`+feature.administrasi.f12+`">
<input type="text" class="hidden" name="tipe1" id="tipe333" value="`+feature.administrasi.f13+`">
<input type="text" class="hidden" name="tipe1" id="tipe444" value="`+feature.administrasi.f14+`">
<select style="border-bottom: 1px solid rgb(83, 83, 83) !important;width: 220px;" id="tipe_point_b_e" data-placeholder="select point.." class="select-size-md">
<option value="null" selected disabled>-- Pilih Jenis Point --</option>
<option value="bangunan">Bangunan Biasa</option>
......@@ -4989,31 +5031,31 @@
<tr>
<th>Informasi Bangunan</th>
<td>
<input type="text" name="infobangunan" id="infobangunan" class="form-control" value="` + feature.properties.f3 + `">
<input type="text" name="infobangunan" id="infobangunan" class="form-control" value="`+feature.properties.f3+`">
</td>
</tr>
<tr>
<th>Kelurahan</th>
<td>
<input type=" text " name="nmkelurahan " id="nmkelurahan" class="form-control " value="` + feature.administrasi.f1 + `">
<input type=" text " name="nmkelurahan " id="nmkelurahan" class="form-control " value="`+feature.administrasi.f1+`">
</td>
</tr>
<tr>
<th>Kecamatan</th>
<td>
<input type="text " name="nmkecamatan " id="nmkecamatan" class="form-control " value="` + feature.administrasi.f2 + `">
<input type="text " name="nmkecamatan " id="nmkecamatan" class="form-control " value="`+feature.administrasi.f2+`">
</td>
</tr>
<tr>
<th>Kab/Kota</th>
<td>
<input type="text " name="nmkabkota " id="nmkabkota" class="form-control " value="` + feature.administrasi.f3 + `">
<input type="text " name="nmkabkota " id="nmkabkota" class="form-control " value="`+feature.administrasi.f3+`">
</td>
</tr>
<tr>
<th>Provinsi</th>
<td>
<input type="text " name="nmprovinsi " id="nmprovinsi" class="form-control " value="` + feature.administrasi.f4 + `">
<input type="text " name="nmprovinsi " id="nmprovinsi" class="form-control " value="`+feature.administrasi.f4+`">
</td>
</tr>
......@@ -5026,25 +5068,25 @@
<tr>
<th>Luas Bangunan</th>
<td>
<input type="text " name="luasbangunan " id="luasbangunan" class="form-control " value="` + feature.administrasi.f6 + `">
<input type="text " name="luasbangunan " id="luasbangunan" class="form-control " value="`+feature.administrasi.f6+`">
</td>
</tr>
<tr>
<th>Luas Tanah</th>
<td>
<input type="text " name="luastanah " id="luastanah" class="form-control " value="` + feature.administrasi.f7 + `">
<input type="text " name="luastanah " id="luastanah" class="form-control " value="`+feature.administrasi.f7+`">
</td>
</tr>
<tr>
<th>Tinggi Bangunan</th>
<td>
<input type="text " name="tinggibangunan " id="tinggibangunan" class="form-control " value="` + feature.administrasi.f8 + `">
<input type="text " name="tinggibangunan " id="tinggibangunan" class="form-control " value="`+feature.administrasi.f8+`">
</td>
</tr>
<tr>
<th>Pemilik</th>
<td>
<input type="text " name="pemilik " id="pemilik" class="form-control " value="` + feature.administrasi.f10 + `">
<input type="text " name="pemilik " id="pemilik" class="form-control " value="`+feature.administrasi.f10+`">
</td>
</tr>
</table>
......@@ -5058,7 +5100,7 @@
</div>
</div>
</div>`;
content_delete = `
content_delete=`
<div class="modal-dialog" style="width: max-content;height: max-content;">
<div class="modal-content">
<div class="modal-header bg-info" style="background-color:#40777c;">
......@@ -5074,9 +5116,9 @@
<div class="form-group">
<div class="col-lg-12" style="margin-top:10px;margin-bottom:10px;">
<input type="text" class="hidden" name="coordinatebangunan" id="coordinatebangunanhps" value="">
<input type="text" name="idbangunan" id="idbangunanhps" class="form-control hidden" value="` + feature.properties.f1 + `" disable>
<input type="text" name="namebangunan" id="namebangunanhps" class="form-control" value="` + feature.properties.f2 + `">
<input type="text" name="infobangunan" id="infobangunanhps" class="form-control" value="` + feature.properties.f3 + `">
<input type="text" name="idbangunan" id="idbangunanhps" class="form-control hidden" value="`+feature.properties.f1+`" disable>
<input type="text" name="namebangunan" id="namebangunanhps" class="form-control" value="`+feature.properties.f2+`">
<input type="text" name="infobangunan" id="infobangunanhps" class="form-control" value="`+feature.properties.f3+`">
</div>
</div>
</div>
......@@ -5259,17 +5301,7 @@
</tr>
</div>
<div class="container">
<tr style="height: 40px;">
<th id="history_panel">
<p class="text-center">
History Perbaikan
</p>
<br>
<p class="text-center" style="margin-top: 10px;">
<a href="#" id='btn_perbaikan_bangunan' data-toggle="modal" data-target="#input_perbaikan_bang" data-backdrop="static" data-keyboard="false" class="btn btn-default"><i>Tambah History Perbaikan</i></a>
</p>
</th>
</tr>
`+history+`
</div>
</tbody>
</table>`;
......@@ -5340,10 +5372,6 @@
geo_bangunan.addData(data)
}
var checkBox_building = document.getElementById("geo_building");
var checkBox_2d = document.getElementById("2d-maps");
map.on("movestart", function() {
geo_bangunan.clearLayers();
});
......@@ -5356,7 +5384,10 @@
var center = map.getBounds().getCenter();
var zoom = map.getZoom();
if (checkBox_building.checked == true || checkBox_2d.checked == true) {
var checkBox_building = document.getElementById("geo_building");
// var checkBox_2d = document.getElementById("2d-maps");
if (checkBox_building.checked == true) {
if (zoom > 17) {
if (map.hasLayer(geo_bangunan)) {
......@@ -5425,12 +5456,7 @@
loaderPage(true);
var tipe1 = $('#tipe111').val();
<<<<<<< HEAD
$('#tipe_point_b_e option[value='+tipe1+']').attr('selected','selected');
=======
$('#tipe_point_b_e option[value=' + tipe1 + ']').attr('selected', 'selected');
// $("#tipe_point_b_e option").val(tipe1).change();
>>>>>>> 18486b82a9845aa577f0dadfb192db38146dcdcf
$("#tipe_point_b_e").change(function() {
$('#tipe_point_2_b_e').empty();
......@@ -5465,8 +5491,8 @@
var tipe2 = $('#tipe222').val();
if (tipe2 == 'null') {
$('#tipe_point_2_b_e').html(`<option value="null" selected disabled>-- Pilih Tipe Point --</option>`);
} else {
$('#tipe_point_2_b_e').html(`<option value="` + tipe2 + `" selected disabled>` + tipe2 + `</option>`);
} else{
$('#tipe_point_2_b_e').html(`<option value="`+tipe2+`" selected disabled>`+tipe2+`</option>`);
}
$("#tipe_point_2_b_e").change(function() {
......@@ -5489,7 +5515,7 @@
var data_po = data['result'][i][1];
console.log(data_id)
console.log(data_po)
var data_kab = `<option value="` + data_id + `">` + data_po + `</option>`;
var data_kab = `<option value="` +data_id + `">` + data_po + `</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_3_b_e').html(`<option value="null" selected disabled>-- Pilih Point --</option>` + data_all_kab);
......@@ -5499,16 +5525,11 @@
var tipe3 = $('#tipe333').val();
var tipe4 = $('#tipe444').val();
<<<<<<< HEAD
=======
// $('#tipe_point_3_b_e option[value='+tipe3+']').attr('selected','selected');
>>>>>>> 18486b82a9845aa577f0dadfb192db38146dcdcf
if (tipe3 == 'null') {
$('#tipe_point_3_b_e').html(`<option value="null" selected disabled>-- Pilih Point --</option>`);
} else {
$('#tipe_point_3_b_e').html(`<option value="` + tipe3 + `" selected disabled>` + tipe4 + `</option>`);
} else{
$('#tipe_point_3_b_e').html(`<option value="`+tipe3+`" selected disabled>`+tipe4+`</option>`);
}
$.ajax({
......@@ -5547,11 +5568,6 @@
});
<<<<<<< HEAD
=======
>>>>>>> 18486b82a9845aa577f0dadfb192db38146dcdcf
$(document).on("click", "#btnsavebangunan", function() {
var data = new FormData();
data.append("file", $("input[id^='imgbangunan']")[0].files[0]);
......@@ -5721,7 +5737,6 @@
// }).addTo(map_bang);
$(document).on("click", "#btn_perbaikan_bangunan", function() {
<<<<<<< HEAD
var map_bang = new L.map('map-insert-renov-bang', {
editable: true,
zoomControl: false,
......@@ -5733,19 +5748,12 @@
minZoom: 4,
}).addTo(map_bang);
=======
// if (map_bang.hasLayer(polyxxx)) {
// polyxxx.remove()
// }
// var id_polyx = $('#idbangunan').val();
>>>>>>> 18486b82a9845aa577f0dadfb192db38146dcdcf
$("#input_perbaikan_bang").css("display", "block");
if (map_bang.hasLayer(polyxxx)) {
polyxxx.remove()
}
var id_polyx = $('#idbangunan').val();
<<<<<<< HEAD
$.ajax({
url: "{% url 'apps:input-perbaikan-bang' %}",
data: {
......@@ -5880,37 +5888,57 @@
})
});
=======
// $.ajax({
// url: "{% url 'apps:input-perbaikan-bang' %}",
// data: {
// 'id_bangunan': id_polyx
// },
// dataType: 'json',
// success: function(data) {
// $("#nama_bang").val(data[0]);
// $("#type_bang").val(data[1]);
// $("#id_bang_perbaikan").val(data[3]);
// $("#type_id_bang").val("1")
// var latlngs = data[2];
// map_bang.setView([latlngs['geometry']['coordinates'][0][0][1], latlngs['geometry']['coordinates'][0][0][0]], 19)
// let lop_poly_edit = data['geometry']['coordinates'][0][0];
// let list_poly_edit = [];
// for (var i = 0; i < lop_poly_edit.length; i++) {
// geoj = lop_poly_edit[i][0];
// polygigi = [lop_poly_edit[i][1], lop_poly_edit[i][0]]
// list_poly_edit.push(polygigi);
// };
function getdetailperbang(id) {
$.ajax({
url: "{% url 'apps:get-detail-perbaikan-bang' %}",
data: {
'id': id
},
dataType: 'json',
success: function(data) {
// polylyly = L.polygon(list_poly_edit).addTo(map_bang)
// polylyly.enableEdit();
// var hasil = (JSON.stringify(polylyly.toGeoJSON()))
isi_modal_detail = []
for (var i = 0; i < data.length; i++) {
isi_modal_detail.push(`
<tr>
<td>` + i + `</td>
<td>` + data[i].name + `</td>
<td>` + data[i].type + `</td>
<td>` + data[i].tgl_perbaikan + `</td>
<td>` + data[i].anggaran + `</td>
<td>` + data[i].pj + `</td>
<td>` + data[i].pj_lapangan + `</td>
<td>` + data[i].kontraktor + `</td>
<td>` + data[i].jenis_perbaikan + `</td>
<td><a href="media/proposal/` + data[i].proposal + `" id="downloadproposal">View</a></td>
<td><a href="media/bukti_penyelesaian/` + data[i].bukti_selesai + `" onclick="viewBukti()" id="view-bukti">View</a></td>
</tr>`)
}
$("#isi_modal_detail").html(`
<table class="table table-responsive datatable-show-all table-sm" id="isi_detail" style="word-wrap:break-word;">
<thead>
<tr>
<th>No.</th>
<th>Nama</th>
<th>Type</th>
<th>Tanggal Perbaikan</th>
<th>Anggaran</th>
<th>Penanggung Jawab</th>
<th>Penanggung Jawab Lapangan</th>
<th>Kontraktor</th>
<th>Jenis Perbaikan</th>
<th>Proposal</th>
<th>Bukti Penyelesaian</th>
</tr>
</thead>
<tbody>
` + isi_modal_detail + `
</tbody>
</table>`)
// }
// })
})
>>>>>>> 18486b82a9845aa577f0dadfb192db38146dcdcf
}
});
};
</script>
{% include 'includes/insert.html' %}
\ No newline at end of file
......@@ -47,6 +47,14 @@
.leaflet-popup {
display: block;
}
#btn_detail_per_bang {
display: block;
}
#btn_perbaikan_bangunan {
display: block;
}
</style>
{% elif group.name == 'Dinas Kependudukan dan Pencatatan Sipil' %}
<style>
......
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