Skip to content

Commit

Permalink
Susulan perbaikan (#421)
Browse files Browse the repository at this point in the history
* Perbaiki dan hapus yang tidak digunakan

* Update program_bantuan_22_12_2020_opendk.zip

* Hapus yang tidak digunakan

* Update 2022_04_20_115358_alter_programbantuan.php

* Fix styling

* Update 2022_04_20_115358_alter_programbantuan.php

* Revert "Update 2022_04_20_115358_alter_programbantuan.php"

This reverts commit efbfb3a.

* Revert "Update 2022_04_20_115358_alter_programbantuan.php"

This reverts commit d84c3ee.

* Update ProgramBantuanController.php

* Ganti kode_desa jadi desa_id

* Update SinkronPesertaBantuan.php

* Update SinkronPembangunan.php

* Update PembangunanController.php

Co-authored-by: andifahruddinakas <[email protected]>
  • Loading branch information
andifahruddinakas and andifahruddinakas authored May 31, 2022
1 parent 7047c29 commit 2feb46d
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 786 deletions.
10 changes: 5 additions & 5 deletions app/Http/Controllers/Api/PembangunanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function store(PembangunanRequest $request)
return response()->json([
"message" => "Proses Sinkronisasi Data gagal. Error : " . $e->getMessage(),
"status" => "danger"
]);
]);
}

// Hapus folder temp ketika sudah selesai
Expand All @@ -82,8 +82,8 @@ public function store(PembangunanRequest $request)
Storage::disk('public')->delete('pembangunan/' . $filecsv);

return response()->json([
"message" => "Proses Sinkronisasi Data Pembangunan OpenSID sedang berjalan",
"status" => "success"
"message" => "Proses Sinkronisasi Data Pembangunan OpenSID sedang berjalan",
"status" => "success"
]);
}

Expand Down Expand Up @@ -118,8 +118,8 @@ public function storeDokumentasi(PembangunanDokumentasiRequest $request)
Storage::disk('public')->delete('pembangunan/' . $filecsv);

return response()->json([
"message" => "Proses Sinkronisasi Data Pembangunan OpenSID sedang berjalan",
"status" => "success"
"message" => "Proses Sinkronisasi Data Pembangunan OpenSID sedang berjalan",
"status" => "success"
]);
}
}
12 changes: 6 additions & 6 deletions app/Http/Controllers/Data/DataPembangunanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,31 @@ public function getPembangunan(Request $request)

$pembangunan = Pembangunan::when($desa, function ($q) use ($desa) {
return $desa === 'Semua'
? $q : $q->where('kode_desa', $desa);
? $q : $q->where('desa_id', $desa);
})
->with('dokumentasi');

return DataTables::of($pembangunan)
->addColumn('aksi', function ($row) {
$data['detail_url'] = route('data.pembangunan.rincian', ['id' => $row->id,'kode_desa' => $row->kode_desa]);
$data['detail_url'] = route('data.pembangunan.rincian', ['id' => $row->id,'desa_id' => $row->desa_id]);
return view('forms.aksi', $data);
})->make();
}
}

public function rincian($id, $kode_desa)
public function rincian($id, $desa_id)
{
$page_title = 'Pembangunan';
$page_description = 'Rincian Pembangunan';
$pembangunan = Pembangunan::where('id', $id)->where('kode_desa', $kode_desa)->first();
$pembangunan = Pembangunan::where('id', $id)->where('desa_id', $desa_id)->first();

return view('data.pembangunan.rincian', compact('page_title', 'page_description', 'pembangunan'));
}

public function getrinciandata($id, $kode_desa)
public function getrinciandata($id, $desa_id)
{
if (request()->ajax()) {
$pembangunanDokumentasi = PembangunanDokumentasi::where('kode_desa', $kode_desa)->where('id_pembangunan', $id)->get();
$pembangunanDokumentasi = PembangunanDokumentasi::where('desa_id', $desa_id)->where('id_pembangunan', $id)->get();
return DataTables::of($pembangunanDokumentasi)
->addIndexColumn()
->make();
Expand Down
105 changes: 3 additions & 102 deletions app/Http/Controllers/Data/ProgramBantuanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,6 @@ public function getaProgramBantuan(Request $request)
->rawColumns(['aksi'])->make();
}

public function create()
{
$page_title = 'Tambah';
$page_description = 'Tambah Program Bantuan Baru';

return view('data.program_bantuan.create', compact('page_title', 'page_description'));
}

public function store(Request $request)
{
request()->validate([
'sasaran' => 'required',
'nama' => 'required',
'start_date' => 'required|date',
'end_date' => 'required|date',
]);

try {
Program::create($request->all());
} catch (\Exception $e) {
report($e);
return back()->withInput()->with('error', 'Data gagal disimpan!');
}

return redirect()->route('data.program-bantuan.index')->with('success', 'Data berhasil disimpan!');
}

public function show($id, $desa_id)
{
$program = Program::with('desa')->findOrFail($id);
Expand All @@ -108,78 +81,6 @@ public function show($id, $desa_id)
return view('data.program_bantuan.show', compact('page_title', 'page_description', 'program', 'sasaran', 'peserta'));
}

public function update(Request $request, $id)
{
request()->validate([
'sasaran' => 'required',
'nama' => 'required',
'start_date' => 'required|date',
'end_date' => 'required|date',
]);

try {
$program = Program::findOrFail($id);
$program->fill($request->all());
$program->update();
} catch (\Exception $e) {
report($e);
return back()->withInput()->with('error', 'Data gagal disimpan!');
}

return redirect()->route('data.program-bantuan.index')->with('success', 'Data berhasil disimpan!');
}

public function edit($id)
{
$program = Program::findOrFail($id);
$page_title = 'Edit Program';
$page_description = 'Program Bantuan ' . $program->nama;
$sasaran = [1 => 'Penduduk/Perorangan', 2 => 'Keluarga-KK'];
$peserta = PesertaProgram::where('program_id', $id)->get();

return view('data.program_bantuan.edit', compact('page_title', 'page_description', 'program', 'sasaran', 'peserta'));
}

public function destroy($id)
{
try {
Program::findOrFail($id)->delete();
PesertaProgram::where('program_id', $id)->delete();
} catch (\Exception $e) {
report($e);
return back()->withInput()->with('error', 'Data gagal dihapus!');
}

return redirect()->route('data.program-bantuan.index')->with('success', 'Data berhasil dihapus!');
}

public function createPeserta($id)
{
$program = Program::findOrFail($id);
$page_title = 'Tambah Peserta';
$page_description = 'Program Bantuan ' . $program->nama;
$sasaran = [1 => 'Penduduk/Perorangan', 2 => 'Keluarga-KK'];

return view('data.program_bantuan.add_peserta', compact('page_title', 'page_description', 'program', 'sasaran'));
}

public function add_peserta(Request $request)
{
request()->validate([
'peserta' => 'required',
'tanggal_lahir' => 'date',
]);

try {
PesertaProgram::create($request->all());
} catch (\Exception $e) {
report($e);
return back()->withInput()->with('error', 'Data gagal disimpan!');
}

return redirect()->route('data.program-bantuan.show', $request->input('program_id'))->with('success', 'Data berhasil disimpan!');
}

public function import()
{
$page_title = 'Impor';
Expand Down Expand Up @@ -209,12 +110,12 @@ public function do_import(Request $request)
$zip->extractTo($extract);
$zip->close();

$fileExtracted = glob($extract.'*.xlsx');
glob($extract.'*.xlsx');

(new SinkronBantuan())
->queue($extract . $csvName = Str::replaceLast('zip', 'csv', $name));
->queue($extract . Str::replaceLast('zip', 'csv', $name));
(new SinkronPesertaBantuan())
->queue($extract . $csvName = Str::replaceLast('zip', 'csv', 'peserta+'.$name));
->queue($extract . Str::replaceLast('zip', 'csv', 'peserta_'.$name));
} catch (\Exception $e) {
report($e);
return back()->with('error', 'Import data gagal. '. $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion app/Imports/SinkronBantuan.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function collection(Collection $collection)
{
foreach ($collection as $value) {
$insert = [
'desa_id' => $value['desa_id'],
'id' => $value['id'],
'nama' => $value['nama'],
'sasaran' => $value['sasaran'],
'status' => $value['status'],
'start_date' => $value['sdate'],
'end_date' => $value['edate'],
'description' => $value['ndesc'],
'desa_id' => $value['kode_desa']
];

Program::updateOrCreate([
Expand Down
42 changes: 21 additions & 21 deletions app/Imports/SinkronPembangunan.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ public function collection(Collection $collection)
{
foreach ($collection as $value) {
$insert = [
"id" => $value['id'],
"sumber_dana" => $value['sumber_dana'],
"lokasi" => $value['lokasi'],
"keterangan" => $value['keterangan'],
"judul" => $value['judul'],
"volume" => $value['volume'],
"tahun_anggaran" => $value['tahun_anggaran'],
"pelaksana_kegiatan" => $value['pelaksana_kegiatan'],
"status" => $value['status'],
"anggaran" => $value['anggaran'],
"perubahan_anggaran" => $value['perubahan_anggaran'],
"desa_id" => $value['desa_id'],
"id" => $value['id'],
"sumber_dana" => $value['sumber_dana'],
"lokasi" => $value['lokasi'],
"keterangan" => $value['keterangan'],
"judul" => $value['judul'],
"volume" => $value['volume'],
"tahun_anggaran" => $value['tahun_anggaran'],
"pelaksana_kegiatan" => $value['pelaksana_kegiatan'],
"status" => $value['status'],
"anggaran" => $value['anggaran'],
"perubahan_anggaran" => $value['perubahan_anggaran'],
"sumber_biaya_pemerintah" => $value['sumber_biaya_pemerintah'],
"sumber_biaya_provinsi" => $value['sumber_biaya_provinsi'],
"sumber_biaya_kab_kota" => $value['sumber_biaya_kab_kota'],
"sumber_biaya_swadaya" => $value['sumber_biaya_swadaya'],
"sumber_biaya_jumlah" => $value['sumber_biaya_jumlah'],
"manfaat" => $value['manfaat'],
"waktu" => $value['waktu'],
"foto" => $value['foto'],
"kode_desa" => (string) $value['desa_id'],
"sumber_biaya_provinsi" => $value['sumber_biaya_provinsi'],
"sumber_biaya_kab_kota" => $value['sumber_biaya_kab_kota'],
"sumber_biaya_swadaya" => $value['sumber_biaya_swadaya'],
"sumber_biaya_jumlah" => $value['sumber_biaya_jumlah'],
"manfaat" => $value['manfaat'],
"waktu" => $value['waktu'],
"foto" => $value['foto'],
];

Pembangunan::updateOrCreate([
'kode_desa' => $insert['kode_desa'],
'id' => $insert['id']
'desa_id' => $insert['desa_id'],
'id' => $insert['id']
], $insert);
}
}
Expand Down
20 changes: 10 additions & 10 deletions app/Imports/SinkronPembangunanDokumentasi.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ public function collection(Collection $collection)
{
foreach ($collection as $value) {
$insert = [
"id" => $value['id'],
"desa_id" => $value['desa_id'],
"id" => $value['id'],
"id_pembangunan" => $value['id_pembangunan'],
"gambar" => $value['gambar'],
"persentase" => $value['persentase'],
"keterangan" => $value['keterangan'],
"created_at" => $value['created_at'],
"updated_at" => $value['updated_at'],
"kode_desa" => (string) $value['desa_id'],
"gambar" => $value['gambar'],
"persentase" => $value['persentase'],
"keterangan" => $value['keterangan'],
"created_at" => $value['created_at'],
"updated_at" => $value['updated_at'],
];

PembangunanDokumentasi::updateOrCreate([
'kode_desa' => $insert['kode_desa'],
'id' => $insert['id'],
'id_pembangunan' => $insert['id_pembangunan']
'desa_id' => $insert['desa_id'],
'id' => $insert['id'],
'id_pembangunan' => $insert['id_pembangunan']
], $insert);
}
}
Expand Down
10 changes: 3 additions & 7 deletions app/Imports/SinkronPesertaBantuan.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@

namespace App\Imports;

use App\Models\Keluarga;
use App\Models\Penduduk;
use App\Models\PesertaProgram;
use Exception;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
Expand All @@ -63,8 +61,6 @@ public function chunkSize(): int
*/
public function collection(Collection $collection)
{
$col_kk = Arr::flatten(Keluarga::pluck('no_kk'));
$col_nik = Arr::flatten(Keluarga::pluck('no_kk'));
DB::beginTransaction(); //multai transaction

foreach ($collection as $value) {
Expand All @@ -87,6 +83,7 @@ public function collection(Collection $collection)
}

$insert = [
'desa_id' => $value['desa_id'],
'id' => $value['id'],
'peserta' => $value['peserta'],
'program_id' => $value['program_id'],
Expand All @@ -98,13 +95,12 @@ public function collection(Collection $collection)
'kartu_tanggal_lahir' => $value['kartu_tanggal_lahir'],
'kartu_alamat' => $value['kartu_alamat'],
'kartu_peserta' => $value['kartu_peserta'],
'desa_id' => $value['kode_desa'],
];

PesertaProgram::updateOrCreate([
'kartu_nik' => $insert['kartu_nik'],
'desa_id' => $insert['desa_id'],
'program_id' => $insert['program_id'],
'desa_id' => $insert['desa_id']
'kartu_nik' => $insert['kartu_nik'],
], $insert);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function up()
{
Schema::create('das_pembangunan', function (Blueprint $table) {
$table->integer('id', false);
$table->char('kode_desa', 13);
$table->char('desa_id', 13);
$table->string('lokasi', 255)->nullable();
$table->string('sumber_dana', 255)->nullable();
$table->string('judul', 255)->nullable();
Expand All @@ -65,7 +65,7 @@ public function up()
$table->string('manfaat', 100)->nullable();
$table->integer('waktu')->nullable();
$table->timestamps();
$table->unique(['id', 'kode_desa']);
$table->unique(['id', 'desa_id']);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public function up()
Schema::create('das_pembangunan_dokumentasi', function (Blueprint $table) {
$table->integer('id');
$table->integer('id_pembangunan');
$table->char('kode_desa', 13);
$table->char('desa_id', 13);
$table->string('gambar', 255)->nullable();
$table->string('persentase', 255)->nullable();
$table->string('keterangan', 255)->nullable();
$table->timestamps();
$table->unique(['id', 'kode_desa', 'id_pembangunan']);
$table->unique(['id', 'desa_id', 'id_pembangunan']);
});
}

Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/pembangunan/rincian.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
processing: true,
serverSide: true,
ajax: {
url: "{!! route( 'data.pembangunan.getrinciandata', ['id' => $pembangunan->id, 'kode_desa' => $pembangunan->kode_desa ] ) !!}"
url: "{!! route( 'data.pembangunan.getrinciandata', ['id' => $pembangunan->id, 'desa_id' => $pembangunan->desa_id ] ) !!}"
},
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex', class: 'text-center', searchable: false, orderable: true},
Expand Down
Loading

0 comments on commit 2feb46d

Please sign in to comment.