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

27/07/2021 gabungan

parent 7a1c1270
...@@ -44,6 +44,10 @@ urlpatterns = [ ...@@ -44,6 +44,10 @@ urlpatterns = [
path('terminal', views.editterminal, name='terminal'), path('terminal', views.editterminal, name='terminal'),
path('gardu', views.editgardu, name='gardu'), 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('c_bangunan', views.createbang, name='c_bangunan'),
path('edit-tuplah', login_required(views.edittuplah), name='edit-tuplah'), path('edit-tuplah', login_required(views.edittuplah), name='edit-tuplah'),
......
...@@ -31,7 +31,7 @@ def group_required(group, login_url=None, raise_exception=False): ...@@ -31,7 +31,7 @@ def group_required(group, login_url=None, raise_exception=False):
else: else:
groups = group groups = group
if user.groups.filter(name__in=groups).exists(): if user.groups.filter(name__in=groups).exists() or user.is_superuser:
return True return True
if raise_exception: if raise_exception:
...@@ -234,7 +234,7 @@ def editpointka(request): ...@@ -234,7 +234,7 @@ def editpointka(request):
JOIN geo_prov_kab b ON st_intersects ( A.geom, b.geom ) 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_kecamatan c ON st_intersects(A.geom, c.geom)
join geo_data_kelurahan d on st_intersects(A.geom, d.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() build = buldings.fetchall()
return Response(build[0][0]) return Response(build[0][0])
...@@ -646,10 +646,10 @@ def editpointcb(request): ...@@ -646,10 +646,10 @@ def editpointcb(request):
return Response(build[0][0]) return Response(build[0][0])
import json import json
@api_view(('POST',)) @api_view(('POST',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer)) @renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def validatedit(request): def validatedit(request):
if request.method == 'POST': if request.method == 'POST':
name_b = request.POST.get("name_b") name_b = request.POST.get("name_b")
...@@ -658,6 +658,7 @@ def validatedit(request): ...@@ -658,6 +658,7 @@ def validatedit(request):
kec_b = request.POST.get("kec_b") kec_b = request.POST.get("kec_b")
kab_b = request.POST.get("kab_b") kab_b = request.POST.get("kab_b")
pro_b = request.POST.get("pro_b") pro_b = request.POST.get("pro_b")
gmb_b = request.POST.get("gambar")
id_poly = request.POST.get("id_poly") id_poly = request.POST.get("id_poly")
polygon = request.POST.get("polygon") polygon = request.POST.get("polygon")
...@@ -678,7 +679,7 @@ def validatedit(request): ...@@ -678,7 +679,7 @@ def validatedit(request):
filename = fss.save(namafile, file) filename = fss.save(namafile, file)
url = fss.url(filename) url = fss.url(filename)
except: 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)) print(co_edit,name_b, info_b, desa_b, kec_b, kab_b, pro_b, namafile, int(id_poly))
with conn.cursor() as buldings: with conn.cursor() as buldings:
...@@ -707,15 +708,30 @@ def validatedit(request): ...@@ -707,15 +708,30 @@ def validatedit(request):
@renderer_classes((TemplateHTMLRenderer, JSONRenderer)) @renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hapus(request): def hapus(request):
if request.method == 'POST': if request.method == 'POST':
id_poly = request.POST.get("id_poly") try:
id_poly = request.POST.get("id_poly")
with conn.cursor() as buldings: with conn.cursor() as buldings:
buldings.execute("""DELETE from geo_bangunan where id = %s"""% int(id_poly)) buldings.execute("""DELETE from geo_bangunan where id = %s"""% int(id_poly))
conn.commit() conn.commit()
data = {'status':'Success'} data = 'SUCCESS'
return Response(data) 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',)) @api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer)) @renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hasilsearch(request): def hasilsearch(request):
...@@ -908,9 +924,9 @@ def editkantoradmin(request): ...@@ -908,9 +924,9 @@ def editkantoradmin(request):
alamat = request.POST.get('alamat') alamat = request.POST.get('alamat')
perangkat = request.POST.get('perangkat') perangkat = request.POST.get('perangkat')
if perangkat is None: if perangkat is None:
perangkat = 'bpk' perangkat = 'Bpk'
elif perangkat == '': elif perangkat == '':
perangkat = 'bpk' perangkat = 'Bpk'
else: else:
perangkat = request.POST.get('perangkat') perangkat = request.POST.get('perangkat')
...@@ -933,14 +949,35 @@ def editkantoradmin(request): ...@@ -933,14 +949,35 @@ def editkantoradmin(request):
with conn.cursor() as editka: with conn.cursor() as editka:
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)) 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() conn.commit()
with conn.cursor() as hasiledit: data = {'status':'Success'}
hasiledit.execute("""select namobj, remark, luas_bangunan, luas_tanah, tinggi_bangunan, perangkat, gambar, alamat from geo_kantor_administrasi where id = %s"""% idkantor) data = 'SUCCESS'
hasileditkantor = hasiledit.fetchall() info = 'data telah diperbaharui'
status = 0
respon={'data':data, 'info': info, 'status':status}
return Response(respon)
@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
data = hasileditkantor[0] respon={'data':data, 'info': info, 'status':status}
return Response(data) return Response(respon)
@api_view(('POST',)) @api_view(('POST',))
def editlayanankesehatan(request): def editlayanankesehatan(request):
......
This diff is collapsed.
...@@ -216,4 +216,8 @@ ...@@ -216,4 +216,8 @@
#btn_edit_cb { #btn_edit_cb {
display: none; display: none;
} }
.leaflet-popup{
display: none;
}
</style> </style>
\ No newline at end of file
This diff is collapsed.
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
display: block; display: block;
} }
#btn_bangunan_edit { #btn_edit_bangunan {
display: block;
}
#btn_delete_bangunan {
display: block; display: block;
} }
...@@ -31,6 +35,17 @@ ...@@ -31,6 +35,17 @@
#btn_edit_gl { #btn_edit_gl {
display: block; display: block;
} }
#btn_edit_adm {
display: block;
}
#btn_delete_adm {
display: block;
}
.leaflet-popup{
display: block;
}
</style> </style>
{% elif group.name == 'Dinas Kependudukan dan Pencatatan Sipil' %} {% elif group.name == 'Dinas Kependudukan dan Pencatatan Sipil' %}
<style> <style>
...@@ -67,6 +82,10 @@ ...@@ -67,6 +82,10 @@
#btn_edit_bangunan { #btn_edit_bangunan {
display: block; display: block;
} }
#btn_delete_bangunan {
display: block;
}
#btn_jalan { #btn_jalan {
display: block; display: block;
...@@ -75,6 +94,10 @@ ...@@ -75,6 +94,10 @@
#btn_edit_cb { #btn_edit_cb {
display: block; display: block;
} }
.leaflet-popup{
display: block;
}
</style> </style>
{% elif group.name == 'Dinas Pariwisata dan Kebudayaan' %} {% elif group.name == 'Dinas Pariwisata dan Kebudayaan' %}
<style> <style>
...@@ -143,6 +166,15 @@ ...@@ -143,6 +166,15 @@
#btn_edit_bangunan { #btn_edit_bangunan {
display: block; display: block;
} }
#btn_delete_bangunan {
display: block;
}
.leaflet-popup{
display: block;
}
</style> </style>
{% elif group.name == 'Dinas Sosial' %} {% elif group.name == 'Dinas Sosial' %}
<style> <style>
...@@ -1478,6 +1510,8 @@ ...@@ -1478,6 +1510,8 @@
</p> </p>
<p class="text-center" style="margin-top: 25px;"> <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="#" 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> </p>
</th> </th>
</tr> </tr>
...@@ -1499,10 +1533,16 @@ ...@@ -1499,10 +1533,16 @@
$('#luastanah').val(feature.administrasi.f7); $('#luastanah').val(feature.administrasi.f7);
$('#tinggibangunan').val(feature.administrasi.f8); $('#tinggibangunan').val(feature.administrasi.f8);
$('#pemilik').val(feature.administrasi.f10); $('#pemilik').val(feature.administrasi.f10);
$('#gambar').val(feature.administrasi.f9);
$("#coordinatebangunan").val(feature.geometry); $("#coordinatebangunan").val(feature.geometry);
$("#panel-samping").css("display", "block"); $("#panel-samping").css("display", "block");
$("#button_hide_panel").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() panel_samp()
} }
}); });
...@@ -1639,9 +1679,7 @@ ...@@ -1639,9 +1679,7 @@
}) })
}); });
$(document).on("click", "#btnsavebangunan", function() { $(document).on("click", "#btnsavebangunan", function() {
var data = new FormData(); var data = new FormData();
data.append("file", $("input[id^='imgbangunan']")[0].files[0]); data.append("file", $("input[id^='imgbangunan']")[0].files[0]);
data.append("csrfmiddlewaretoken", "{{ csrf_token }}"); data.append("csrfmiddlewaretoken", "{{ csrf_token }}");
...@@ -1653,6 +1691,7 @@ ...@@ -1653,6 +1691,7 @@
data.append('kab_b', $('#nmkabkota').val()) data.append('kab_b', $('#nmkabkota').val())
data.append('pro_b', $('#nmprovinsi').val()) data.append('pro_b', $('#nmprovinsi').val())
data.append('id_poly', $('#idbangunan').val()) data.append('id_poly', $('#idbangunan').val())
data.append('gambar', $('#gambar').val())
data.append('luasbangunan', $('#luasbangunan').val()) data.append('luasbangunan', $('#luasbangunan').val())
data.append('luastanah', $('#luastanah').val()) data.append('luastanah', $('#luastanah').val())
...@@ -1693,6 +1732,91 @@ ...@@ -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, { var geo_jalan = L.geoJson(null, {
style: function(feature) { style: function(feature) {
var zoom = map.getZoom() var zoom = map.getZoom()
......
...@@ -237,6 +237,7 @@ ...@@ -237,6 +237,7 @@
</th> </th>
<td> <td>
<input type="file" id="imgbangunan" name="images[]" multiple accept="image/jpg,image/png,image/jpeg,image/gif"> <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> </td>
</tr> </tr>
<tr> <tr>
...@@ -260,25 +261,25 @@ ...@@ -260,25 +261,25 @@
<tr> <tr>
<th>Kelurahan</th> <th>Kelurahan</th>
<td> <td>
<input type=" text " name="nmkelurahan " id="nmkelurahan " class="form-control " value=""> <input type=" text " name="nmkelurahan " id="nmkelurahan" class="form-control " value="">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Kecamatan</th> <th>Kecamatan</th>
<td> <td>
<input type="text " name="nmkecamatan " id="nmkecamatan " class="form-control " value=""> <input type="text " name="nmkecamatan " id="nmkecamatan" class="form-control " value="">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Kab/Kota</th> <th>Kab/Kota</th>
<td> <td>
<input type="text " name="nmkabkota " id="nmkabkota " class="form-control " value=""> <input type="text " name="nmkabkota " id="nmkabkota" class="form-control " value="">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Provinsi</th> <th>Provinsi</th>
<td> <td>
<input type="text " name="nmprovinsi " id="nmprovinsi " class="form-control " value=""> <input type="text " name="nmprovinsi " id="nmprovinsi" class="form-control " value="">
</td> </td>
</tr> </tr>
...@@ -291,25 +292,25 @@ ...@@ -291,25 +292,25 @@
<tr> <tr>
<th>Luas Bangunan</th> <th>Luas Bangunan</th>
<td> <td>
<input type="text " name="luasbangunan " id="luasbangunan " class="form-control " value=" "> <input type="text " name="luasbangunan " id="luasbangunan" class="form-control " value=" ">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Luas Tanah</th> <th>Luas Tanah</th>
<td> <td>
<input type="text " name="luastanah " id="luastanah " class="form-control " value=" "> <input type="text " name="luastanah " id="luastanah" class="form-control " value=" ">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Tinggi Bangunan</th> <th>Tinggi Bangunan</th>
<td> <td>
<input type="text " name="tinggibangunan " id="tinggibangunan " class="form-control " value=" "> <input type="text " name="tinggibangunan " id="tinggibangunan" class="form-control " value=" ">
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Pemilik</th> <th>Pemilik</th>
<td> <td>
<input type="text " name="pemilik " id="pemilik " class="form-control " value=" "> <input type="text " name="pemilik " id="pemilik" class="form-control " value=" ">
</td> </td>
</tr> </tr>
</table> </table>
...@@ -319,12 +320,43 @@ ...@@ -319,12 +320,43 @@
<div class="modal-footer "> <div class="modal-footer ">
<button type="button " class="btn btn-link " data-dismiss="modal ">Close</button> <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> </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 id="modal-edit-tuplah" class="modal fade">
<div class="modal-dialog" style="width: max-content;height: max-content;"> <div class="modal-dialog" style="width: max-content;height: max-content;">
<div class="modal-content"> <div class="modal-content">
...@@ -361,4 +393,13 @@ ...@@ -361,4 +393,13 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- modal point -->
<div class="modal fade" id="modald_adm">
</div>
<div class="modal fade" id="modal_adm">
</div> </div>
\ No newline at end of file
...@@ -476,7 +476,7 @@ ...@@ -476,7 +476,7 @@
} }
.leaflet-container ul li a { .leaflet-container ul li a {
color: white; color: #333333;
} }
</style> </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