Commit 75b657e5 authored by Manggar Mahardhika's avatar Manggar Mahardhika

27/07/2021 gabungan

parent 7a1c1270
......@@ -44,6 +44,10 @@ urlpatterns = [
path('terminal', views.editterminal, name='terminal'),
path('gardu', views.editgardu, name='gardu'),
path('hapus', views.hapus, name='hapus'),
path('dkantor', views.deletekantoradmin, name='dkantor'),
path('c_bangunan', views.createbang, name='c_bangunan'),
path('edit-tuplah', login_required(views.edittuplah), name='edit-tuplah'),
......
......@@ -31,7 +31,7 @@ def group_required(group, login_url=None, raise_exception=False):
else:
groups = group
if user.groups.filter(name__in=groups).exists():
if user.groups.filter(name__in=groups).exists() or user.is_superuser:
return True
if raise_exception:
......@@ -234,7 +234,7 @@ def editpointka(request):
JOIN geo_prov_kab b ON st_intersects ( A.geom, b.geom )
JOIN geo_data_kecamatan c ON st_intersects(A.geom, c.geom)
join geo_data_kelurahan d on st_intersects(A.geom, d.geom)
WHERE a.id = %s"""% int(id_point))
WHERE a.is_deleted = 0 and a.id = %s"""% int(id_point))
build = buldings.fetchall()
return Response(build[0][0])
......@@ -647,9 +647,9 @@ def editpointcb(request):
return Response(build[0][0])
import json
@api_view(('POST',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def validatedit(request):
if request.method == 'POST':
name_b = request.POST.get("name_b")
......@@ -658,6 +658,7 @@ def validatedit(request):
kec_b = request.POST.get("kec_b")
kab_b = request.POST.get("kab_b")
pro_b = request.POST.get("pro_b")
gmb_b = request.POST.get("gambar")
id_poly = request.POST.get("id_poly")
polygon = request.POST.get("polygon")
......@@ -678,7 +679,7 @@ def validatedit(request):
filename = fss.save(namafile, file)
url = fss.url(filename)
except:
namafile = "NONE"
namafile = gmb_b
print(co_edit,name_b, info_b, desa_b, kec_b, kab_b, pro_b, namafile, int(id_poly))
with conn.cursor() as buldings:
......@@ -707,15 +708,30 @@ def validatedit(request):
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hapus(request):
if request.method == 'POST':
try:
id_poly = request.POST.get("id_poly")
with conn.cursor() as buldings:
buldings.execute("""DELETE from geo_bangunan where id = %s"""% int(id_poly))
conn.commit()
data = {'status':'Success'}
return Response(data)
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
except:
data = 'SORRY'
info = 'hubungi orang terdekat'
status = 1
respon = {
'data':data,
'info':info,
'code':status,
}
print(respon)
return Response(respon)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hasilsearch(request):
......@@ -908,9 +924,9 @@ def editkantoradmin(request):
alamat = request.POST.get('alamat')
perangkat = request.POST.get('perangkat')
if perangkat is None:
perangkat = 'bpk'
perangkat = 'Bpk'
elif perangkat == '':
perangkat = 'bpk'
perangkat = 'Bpk'
else:
perangkat = request.POST.get('perangkat')
......@@ -935,12 +951,33 @@ def editkantoradmin(request):
editka.execute("""update geo_kantor_administrasi set geom = st_geomfromgeojson('{"type":"Point", "coordinates":%s, "crs":{"type":"name","properties":{"name":"EPSG:4326"}}}'), namobj = '%s', remark = '%s', luas_bangunan = %s, luas_tanah = %s, tinggi_bangunan = %s, perangkat = '%s', alamat = '%s', gambar = '%s' where id = %s"""%(co_edit, namobj, remark, luas_bangunan, luat_tanah, tinggi_bangunan, perangkat, alamat, namafile, idkantor))
conn.commit()
with conn.cursor() as hasiledit:
hasiledit.execute("""select namobj, remark, luas_bangunan, luas_tanah, tinggi_bangunan, perangkat, gambar, alamat from geo_kantor_administrasi where id = %s"""% idkantor)
hasileditkantor = hasiledit.fetchall()
data = {'status':'Success'}
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
respon={'data':data, 'info': info, 'status':status}
return Response(respon)
data = hasileditkantor[0]
return Response(data)
@api_view(('POST',))
def deletekantoradmin(request):
idkantor = request.POST.get('id')
try:
with conn.cursor() as editka:
editka.execute("""update geo_kantor_administrasi set is_deleted = 1 where id = %s"""%(idkantor))
conn.commit()
data = {'status':'Success'}
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
except:
data = 'Sorry'
info = 'Dalam Perbaikan'
status = 1
respon={'data':data, 'info': info, 'status':status}
return Response(respon)
@api_view(('POST',))
def editlayanankesehatan(request):
......
This diff is collapsed.
......@@ -216,4 +216,8 @@
#btn_edit_cb {
display: none;
}
.leaflet-popup{
display: none;
}
</style>
\ No newline at end of file
This diff is collapsed.
......@@ -20,7 +20,11 @@
display: block;
}
#btn_bangunan_edit {
#btn_edit_bangunan {
display: block;
}
#btn_delete_bangunan {
display: block;
}
......@@ -31,6 +35,17 @@
#btn_edit_gl {
display: block;
}
#btn_edit_adm {
display: block;
}
#btn_delete_adm {
display: block;
}
.leaflet-popup{
display: block;
}
</style>
{% elif group.name == 'Dinas Kependudukan dan Pencatatan Sipil' %}
<style>
......@@ -68,6 +83,10 @@
display: block;
}
#btn_delete_bangunan {
display: block;
}
#btn_jalan {
display: block;
}
......@@ -75,6 +94,10 @@
#btn_edit_cb {
display: block;
}
.leaflet-popup{
display: block;
}
</style>
{% elif group.name == 'Dinas Pariwisata dan Kebudayaan' %}
<style>
......@@ -143,6 +166,15 @@
#btn_edit_bangunan {
display: block;
}
#btn_delete_bangunan {
display: block;
}
.leaflet-popup{
display: block;
}
</style>
{% elif group.name == 'Dinas Sosial' %}
<style>
......@@ -1478,6 +1510,8 @@
</p>
<p class="text-center" style="margin-top: 25px;">
<a href="#" class="btn btn-default" data-toggle="modal" data-target="#modal_bangunan_edit" id="btn_edit_bangunan" data-backdrop="static" data-keyboard="false"><i>Edit Informasi Bangunan</i></a>
<a href="#" id='btn_delete_bangunan' class='btn
btn-default btn_edit_bangunan' data-toggle="modal" data-target="#modal_bangunan_delete" data-backdrop="static" data-keyboard="false"><i>Delete Bangunan</i></a>
</p>
</th>
</tr>
......@@ -1499,10 +1533,16 @@
$('#luastanah').val(feature.administrasi.f7);
$('#tinggibangunan').val(feature.administrasi.f8);
$('#pemilik').val(feature.administrasi.f10);
$('#gambar').val(feature.administrasi.f9);
$("#coordinatebangunan").val(feature.geometry);
$("#panel-samping").css("display", "block");
$("#button_hide_panel").css("display", "block");
$('#idbangunanhps').val(feature.properties.f1);
$('#namebangunanhps').val(feature.properties.f2);
$('#infobangunanhps').val(feature.properties.f3);
panel_samp()
}
});
......@@ -1639,9 +1679,7 @@
})
});
$(document).on("click", "#btnsavebangunan", function() {
var data = new FormData();
data.append("file", $("input[id^='imgbangunan']")[0].files[0]);
data.append("csrfmiddlewaretoken", "{{ csrf_token }}");
......@@ -1653,6 +1691,7 @@
data.append('kab_b', $('#nmkabkota').val())
data.append('pro_b', $('#nmprovinsi').val())
data.append('id_poly', $('#idbangunan').val())
data.append('gambar', $('#gambar').val())
data.append('luasbangunan', $('#luasbangunan').val())
data.append('luastanah', $('#luastanah').val())
......@@ -1693,6 +1732,91 @@
});
$(document).on("click", "#btn_delete_bangunan", function() {
var map_delete = new L.map('map-delete', {
editable: true,
zoomControl: false,
drawControl: true
}).setView([-2, 118], 5);
mapss = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
maxZoom: 22,
minZoom: 4,
}).addTo(map_delete);
var id_polyhps = $('#idbangunanhps').val();
// console.log(id_polyhps)
loaderPage(true);
$.ajax({
url: "{% url 'api:edit' %}",
data: {
'id_poly': id_polyhps
},
dataType: 'json',
success: function(data) {
setTimeout(function() {
map_delete.invalidateSize();
}, 1000);
loaderPage(false);
map_delete.setView([data['geometry']['coordinates'][0][0][0][1], data['geometry']['coordinates'][0][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);
};
var polyly = L.polygon(list_poly_edit).addTo(map_delete)
$('#btnsavedeletebangunan').click(function() {
var hasil = (JSON.stringify(polyly.toGeoJSON()))
$("#coordinatebangunan").val(hasil);
})
}
})
});
$(document).on("click", "#btnsavedeletebangunan", function() {
var data = new FormData();
data.append('id_poly', $('#idbangunan').val())
$.ajax({
url: "{% url 'api:hapus' %}",
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() {
$("#modal_bangunan_delete").css('display', 'none');
})
} else {
swal({
title: 'Error',
text: 'Hubungi Mereka',
type: "warning",
icon: "error",
confirmButtonColor: "#00BCD4"
})
}
}
})
});
var geo_jalan = L.geoJson(null, {
style: function(feature) {
var zoom = map.getZoom()
......
......@@ -237,6 +237,7 @@
</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=""required>
</td>
</tr>
<tr>
......@@ -260,25 +261,25 @@
<tr>
<th>Kelurahan</th>
<td>
<input type=" text " name="nmkelurahan " id="nmkelurahan " class="form-control " value="">
<input type=" text " name="nmkelurahan " id="nmkelurahan" class="form-control " value="">
</td>
</tr>
<tr>
<th>Kecamatan</th>
<td>
<input type="text " name="nmkecamatan " id="nmkecamatan " class="form-control " value="">
<input type="text " name="nmkecamatan " id="nmkecamatan" class="form-control " value="">
</td>
</tr>
<tr>
<th>Kab/Kota</th>
<td>
<input type="text " name="nmkabkota " id="nmkabkota " class="form-control " value="">
<input type="text " name="nmkabkota " id="nmkabkota" class="form-control " value="">
</td>
</tr>
<tr>
<th>Provinsi</th>
<td>
<input type="text " name="nmprovinsi " id="nmprovinsi " class="form-control " value="">
<input type="text " name="nmprovinsi " id="nmprovinsi" class="form-control " value="">
</td>
</tr>
......@@ -291,25 +292,25 @@
<tr>
<th>Luas Bangunan</th>
<td>
<input type="text " name="luasbangunan " id="luasbangunan " class="form-control " value=" ">
<input type="text " name="luasbangunan " id="luasbangunan" class="form-control " value=" ">
</td>
</tr>
<tr>
<th>Luas Tanah</th>
<td>
<input type="text " name="luastanah " id="luastanah " class="form-control " value=" ">
<input type="text " name="luastanah " id="luastanah" class="form-control " value=" ">
</td>
</tr>
<tr>
<th>Tinggi Bangunan</th>
<td>
<input type="text " name="tinggibangunan " id="tinggibangunan " class="form-control " value=" ">
<input type="text " name="tinggibangunan " id="tinggibangunan" class="form-control " value=" ">
</td>
</tr>
<tr>
<th>Pemilik</th>
<td>
<input type="text " name="pemilik " id="pemilik " class="form-control " value=" ">
<input type="text " name="pemilik " id="pemilik" class="form-control " value=" ">
</td>
</tr>
</table>
......@@ -319,12 +320,43 @@
<div class="modal-footer ">
<button type="button " class="btn btn-link " data-dismiss="modal ">Close</button>
<button type="button " id="btnsavebangunan " class="btn btn-info ">Save changes</button>
<button type="button " id="btnsavebangunan" class="btn btn-info ">Save changes</button>
</div>
</div>
</div>
</div>
<div id="modal_bangunan_delete" class="modal fade">
<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;">
<table>
<tr>
<th><h6 class="modal-title">Delete Bangunan dan Informasinya</h6></th>
<td><button type="button" class="close" data-dismiss="modal">&times;</button></td>
</tr>
</table>
</div>
<div class="form-group" style="margin-bottom:10px;">
<div id="map-delete" style="width: 300px;height: 250px;position: relative;margin-left: 10px;margin-right: 10px;margin-top: 10px;"></div>
<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="" disable>
<input type="text" name="namebangunan" id="namebangunanhps" class="form-control" value="">
<input type="text" name="infobangunan" id="infobangunanhps" class="form-control" value="">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="btnsavedeletebangunan" class="btn btn-info">Hapus</button>
</div>
</div>
</div>
</div>
<!-- modal tuplah -->
<div id="modal-edit-tuplah" class="modal fade">
<div class="modal-dialog" style="width: max-content;height: max-content;">
<div class="modal-content">
......@@ -362,3 +394,12 @@
</div>
</div>
</div>
<!-- modal point -->
<div class="modal fade" id="modald_adm">
</div>
<div class="modal fade" id="modal_adm">
</div>
\ No newline at end of file
......@@ -476,7 +476,7 @@
}
.leaflet-container ul li a {
color: white;
color: #333333;
}
</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