Commit d5ab8921 authored by Manggar Mahardhika's avatar Manggar Mahardhika

push data perbaikan full renov

parent 2c448ef9
......@@ -101,8 +101,11 @@ urlpatterns = [
path('download_perbaikan_data', views.download_perbaikan_data),
path('search_list_perbaikan', views.search_list_perbaikan),
path('dataperbaikan', views.data_perbaikan),
path('deletedataperb', views.deletedataperb),
path('pointBangunan', views.pointBangunan),
path('pointBangunan_', views.pointBangunan_),
path('editperb', views.editperb),
]
\ No newline at end of file
......@@ -4479,12 +4479,16 @@ def data_perbaikan(request):
tp.tgl_selesai,
gdl.desa,
gdc.kecamatan,
tp.id
tp.id,
tp.tgl_disetujui,
tp.proposal,
tp.bukti_selesai
FROM
( SELECT tbl_perbaikan.*, ROW_NUMBER ( ) OVER ( PARTITION BY id_object ORDER BY tgl_selesai DESC ) AS rn FROM tbl_perbaikan ) tp
JOIN geo_label gl ON gl.ID = tp.type_id
JOIN geo_data_kelurahan gdl on st_intersects(st_setsrid(gdl.geom, 4326), st_setsrid(tp.geom, 4326))
JOIN geo_data_kecamatan gdc ON st_intersects ( st_setsrid ( gdc.geom, 4326 ), st_setsrid ( tp.geom, 4326 ) )
where tp.is_deleted = 0
ORDER BY tp.id desc
""")
res_perbaikan = data_per.fetchall()
......@@ -4502,11 +4506,36 @@ def data_perbaikan(request):
'desa':j[7],
'kecamatan':j[8],
'id':j[9],
'tgl_disetujui':j[10],
'proposal':j[11],
'bukti_selesai':j[12],
}
res_all.append(data_all)
return Response(res_all)
@api_view(('POST',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def deletedataperb(request):
id_perb = request.POST.get('id_perb')
id_object = request.POST.get('id_perb_object')
try:
with conn.cursor() as desa:
desa.execute("""UPDATE tbl_perbaikan set is_deleted = 1 where id=%s and id_object=%s"""%( int(id_perb), int(id_object)))
conn.commit()
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
except:
data = 'NOT SUCCESS'
info = 'Hubungi Orang Server'
status = 1
respon={'data':data, 'info':info, 'code':status}
return Response(respon)
def pointBangunan(request):
# with conn.cursor() as points:
# points.execute("SELECT st_astext(ST_centroid(geom)) FROM geo_bangunan")
......@@ -4538,3 +4567,71 @@ def pointBangunan_(request):
result.append(i[0])
return JsonResponse({'result':result})
@api_view(('POST',))
def editperb(request):
id_perb = request.POST.get('id_perb')
id_obj = request.POST.get('id_obj')
namobj = request.POST.get('namobj')
anggaran = request.POST.get('anggaran')
sumber_dana = request.POST.get('sumber_dana')
pihak_sah = request.POST.get('pihak_sah')
pj_lap = request.POST.get('pj_lap')
kontraktor = request.POST.get('kontraktor')
tgl_disetujui = request.POST.get('tgl_disetujui')
tgl_perbaikan = request.POST.get('tgl_perbaikan')
tgl_selesai = request.POST.get('tgl_selesai')
save = saver()
proposal = request.POST.get('proposal')
file1 = request.FILES.get('file_proposal')
fss = FileSystemStorage(location=str(str(save)+'proposal/'))
try:
format = (file1.name).split(".")
num = random.randrange(1, 10000000000000)
namafile = f"{namobj}_{num}.{format[-1:][0]}"
filename = fss.save(namafile, file1)
# print(file.name)
url = fss.url(filename)
except:
namafile = proposal
bukti_selesai = request.POST.get('bukti_selesai')
file2 = request.FILES.get('file_bukti')
fss2 = FileSystemStorage(location=str(str(save)+'bukti_penyelesaian/'))
try:
format = (file2.name).split(".")
num2 = random.randrange(1, 10000000000000)
namafile2 = f"{namobj}_{num2}.{format[-1:][0]}"
filename2 = fss2.save(namafile2, file2)
# print(file.name)
url2 = fss2.url(filename2)
except:
namafile2 = bukti_selesai
with conn.cursor() as editka:
editka.execute("""update tbl_perbaikan
set
anggaran = %s,
sumber_dana = '%s',
pj = '%s',
pj_lapangan = '%s',
kontraktor = '%s',
tgl_disetujui = '%s',
tgl_perbaikan = '%s',
tgl_selesai = '%s',
proposal = '%s',
bukti_selesai = '%s'
where id = %s and id_object = %s"""
%(anggaran, sumber_dana, pihak_sah, pj_lap, kontraktor, tgl_disetujui, tgl_perbaikan, tgl_selesai, namafile, namafile2, id_perb, id_obj))
conn.commit()
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
respon={'data':data, 'info': info, 'status':status}
return Response(respon)
......@@ -734,10 +734,16 @@ def loadDetail(request):
tp.id,
tp.proposal,
tp.bukti_selesai,
tp.jenis_perbaikan
tp.jenis_perbaikan,
gdl.desa,
gdc.kecamatan,
tp.sumber_dana,
tp.tgl_disetujui
FROM
tbl_perbaikan tp
JOIN geo_label gl ON gl.ID = tp.type_id
JOIN geo_data_kelurahan gdl on st_intersects(st_setsrid(gdl.geom, 4326), st_setsrid(tp.geom, 4326))
JOIN geo_data_kecamatan gdc ON st_intersects ( st_setsrid ( gdc.geom, 4326 ), st_setsrid ( tp.geom, 4326 ) )
where tp.id_object = %s and tp.id = %s"""% (id_object,id))
res_perbaikan = data_per.fetchall()
......@@ -762,7 +768,11 @@ def loadDetail(request):
'id':j[15],
'proposal':j[16],
'bukti_selesai':j[17],
'jenis_perbaikan':j[18]
'jenis_perbaikan':j[18],
'desa':j[19],
'kecamatan':j[20],
'sumber_dana':j[21],
'tgl_disetujui':j[22]
}
res_all.append(data_all)
......@@ -826,11 +836,30 @@ def saveperbaikan(request):
id_object = request.POST.get("object_id")
name = request.POST.get("name")
type = request.POST.get("type")
tgl_pembuatan = request.POST.get("tgl_pembuatan")
tgl_perbaikan = request.POST.get("tgl_perbaikan")
tgl_disetujui = request.POST.get("tgl_disetujui")
anggaran = request.POST.get("anggaran")
tgl_perbaikan1 = request.POST.get("tgl_perbaikan")
if tgl_perbaikan1 == '':
tgl_perbaikan = '0001-01-01'
else :
tgl_perbaikan = tgl_perbaikan1
tgl_disetujui1 = request.POST.get("tgl_disetujui")
if tgl_disetujui1 == '':
tgl_disetujui = '0001-01-01'
else :
tgl_disetujui = tgl_disetujui1
tgl_selesai1 = request.POST.get("tgl_selesai")
if tgl_selesai1 == '':
tgl_selesai = '0001-01-01'
else :
tgl_selesai = tgl_selesai1
anggaran1 = request.POST.get("anggaran")
if anggaran1 == '':
anggaran = 0
else :
anggaran = anggaran1
pj = request.POST.get("pj")
pj_lapangan = request.POST.get("pj_lapangan")
......@@ -841,15 +870,7 @@ def saveperbaikan(request):
jenis_perbaikan = request.POST.get("jenis_perbaikan")
# luas = request.POST.get("luas")
coor = request.POST.get("coord")
tgl_selesai = request.POST.get("tgl_selesai")
proposal = request.FILES.get("proposal")
bukti_selesai = request.FILES.get("bukti_selesai")
print(coor, proposal)
save = saver()
fss_p = FileSystemStorage(location=str(str(save)+'proposal/'))
fss_b = FileSystemStorage(location=str(str(save)+'bukti_penyelesaian/'))
# coord = json.loads(str(coor))
......@@ -892,28 +913,43 @@ def saveperbaikan(request):
sek = siap.replace("]]]",")")
corcoran = f'MULTILINESTRING({sek})'
print(corcoran)
# print(corcoran)
format = (proposal.name).split(".")
proposal = request.FILES.get("proposal")
bukti_selesai = request.FILES.get("bukti_selesai")
print(proposal, bukti_selesai)
save = saver()
xproposal = 'None'
xbukti = 'None'
if proposal is not None:
fss_p = FileSystemStorage(location=str(str(save)+'proposal/'))
num = random.randrange(1, 10000000000000)
format = (proposal.name).split(".")
nproposal = f"{name}_{num}.{format[-1:][0]}"
nproposal = nproposal.replace(" ","-")
xproposal = nproposal
filename_p = fss_p.save(nproposal, proposal)
url_p = fss_p.url(filename_p)
if bukti_selesai is not None:
fss_b = FileSystemStorage(location=str(str(save)+'bukti_penyelesaian/'))
num = random.randrange(1, 10000000000000)
format_ = (bukti_selesai.name).split(".")
nbukti = f"{name}_{num}.{format_[-1:][0]}"
nbukti = nbukti.replace(" ","-")
xbukti = nbukti
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("-------------------")
# 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:
# try:
with conn.cursor() as data_per:
data_per.execute("""
INSERT INTO tbl_perbaikan (
......@@ -921,6 +957,9 @@ def saveperbaikan(request):
id_object,
name,
type,
pjg_perbaikan,
lbr_perbaikan,
jenis_perbaikan,
tgl_selesai,
tgl_perbaikan,
tgl_disetujui,
......@@ -930,9 +969,6 @@ def saveperbaikan(request):
pj,
pj_lapangan,
kontraktor,
pjg_perbaikan,
lbr_perbaikan,
jenis_perbaikan,
sumber_dana,
geom
)
......@@ -942,17 +978,17 @@ def saveperbaikan(request):
%s,
'%s',
'%s',
%s,
%s,
'%s',
'%s',
'%s',
%s,
'%s',
%s,
'%s',
'%s',
'%s',
'%s',
%s,
%s,
'%s',
'%s',
ST_GeomFromText('%s')
......@@ -962,29 +998,29 @@ def saveperbaikan(request):
int(id_object),
name,
type,
float(pjg_perbaikan),
float(lbr_perbaikan),
jenis_perbaikan,
tgl_selesai,
tgl_perbaikan,
tgl_disetujui,
int(anggaran),
nproposal,
nbukti,
anggaran,
xproposal,
xbukti,
pj,
pj_lapangan,
kontraktor,
float(pjg_perbaikan),
float(lbr_perbaikan),
jenis_perbaikan,
sumber_dana,
corcoran))
conn.commit()
data = "Sukses"
err = conn.commit()
data = err
info = "Data Telah Berhasil di Perbaharui"
code = 0
except:
data = "Pastikan Semua Data Terisi Termasuk Proposal dan Bukti Selesai"
info = "Oops"
code = 1
# except:
# data = "Pastikan Semua Data Terisi Termasuk Proposal dan Bukti Selesai"
# info = "Oops"
# code = 1
respon = {"data":data,"info":info,"code":code}
return Response(respon)
# return 1
......@@ -1347,3 +1383,4 @@ def sendmail(request):
context = data
return Response(context)
......@@ -42,6 +42,7 @@ $("#upload_image").change(function() {
})
});
// perbaikan jalan
function getdetailper(id) {
$(".map_detail_p_p").html(``)
// console.log(id)
......@@ -73,6 +74,7 @@ function getdetailper(id) {
if (data.length === 0) {
$(".nama_detail_dash").text("Null");
$(".type_detail_dash").html("Null");
$(".tanggal_perbaikan_detail_dash").html("Null")
......@@ -82,6 +84,7 @@ function getdetailper(id) {
$(".kontraktor_detail_dash").html("Null")
$(".panjang_jalan_detail_dash").html("Null")
$(".lebar_jalan_detail_dash").html("Null")
$(".proposal_detail_dash").html(`
<a href="media/proposal/null" id="downloadproposal ">
<img src="{% static 'img/icon-1/proposal.svg' %} " alt=" " style="height: 65px;width: 65px; ">
......@@ -105,17 +108,17 @@ function getdetailper(id) {
// $(".kontraktor_detail_dash").html(data[0]['kontraktor'])
$(".panjang_jalan_detail_dash").html(data[0]['panjang'])
$(".lebar_jalan_detail_dash").html(data[0]['lbr_jln_reno'])
// $(".proposal_detail_dash").html(`
// <a href="static/media/proposal/` + data[0]['proposal'] + `" target="_blank" "id="downloadproposal">
// <img src="static/img/icon-1/proposal.svg" alt=" " style="height: 65px;width: 65px; ">
// </a>`);
$(".proposal_detail_dash").html(`
<a href="static/media/proposal/` + data[0]['proposal'] + `" target="_blank" "id="downloadproposal">
<img src="static/img/icon-1/proposal.svg" alt=" " style="height: 65px;width: 65px; ">
</a>`);
// $(".bukti_detail_perbaikan_dash").html(`
// <a href="static/media/bukti_penyelesaian/` + data[0].bukti_selesai + `" target="_blank" id="view-bukti">
// <img src="static/img/icon-1/bukti.svg" alt=" " style="height: 70px;
// width: 50px;">
// </a>`);
$(".bukti_detail_perbaikan_dash").html(`
<a href="static/media/bukti_penyelesaian/` + data[0].bukti_selesai + `" target="_blank" id="view-bukti">
<img src="static/img/icon-1/bukti.svg" alt=" " style="height: 70px;
width: 50px;">
</a>`);
//hide ngaco
// $("#bkt_ang").html(``)
......
This diff is collapsed.
This diff is collapsed.
......@@ -1655,7 +1655,7 @@
</div>
<div style="margin-top: 20px; ">
<!-- <div class="row">
<div class="row">
<div class="col-md-6 " id="bkt_prop">
<div>
<span>Proposal</span>
......@@ -1676,7 +1676,7 @@
</div>
</div>
</div> -->
</div>
<div>
<span>Ruas yang diperbaiki</span>
<!-- <div class="row">
......
This diff is collapsed.
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