Skip to content

Commit

Permalink
Download surat (#619)
Browse files Browse the repository at this point in the history
* Sesuaikan migrasi dan validasi

* Buat link qrcode

* Update header.blade.php (#610)

Fix bug Foto & Nama Camat di Menu Profil

* Mutakhirkan catatan rilis

* Perbaiki panjang slug prosedur (#606)

* Perbaiki panjang slug prosedur

* Sesuaikan migrasi

* Fix styling

* Update header.blade.php (#610)

Fix bug Foto & Nama Camat di Menu Profil

* Mutakhirkan catatan rilis

* mutakhirkan catatan rilis

Co-authored-by: yogiperdana <[email protected]>
Co-authored-by: Syahran Saputra <[email protected]>
Co-authored-by: sarwono <[email protected]>

* Sesuaikan view

* Perbaiki parameter

* Perbaiki validasi prosedur (#616)

* Perbaiki validasi prosedur

* Update catatan_rilis.md

Co-authored-by: Afila <[email protected]>

* Sesuaikan tipe data nomor

* Buat migrasi

* Simpan log ketika gagal

* Sesuaikan konfigurasi guzzle

* Tes post

* Sesuaikan tipe kolom nik pengurus

* Buat fungsi tte

* Sesuaikan link qrcode

* Sesuaikan tag

* Implementasi api download

* Kirim id untuk status surat

* Sesuaikan response

* Sesuaikan parameter

* Update catatan_rilis.md

* Update catatan_rilis.md

* Update catatan_rilis.md

Co-authored-by: Syahran Saputra <[email protected]>
Co-authored-by: yogiperdana <[email protected]>
Co-authored-by: sarwono <[email protected]>
Co-authored-by: Afila <[email protected]>
  • Loading branch information
5 people authored Jan 26, 2023
1 parent 3789035 commit aa7edfc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
48 changes: 42 additions & 6 deletions app/Http/Controllers/Api/SuratController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@

namespace App\Http\Controllers\Api;

use App\Enums\StatusVerifikasiSurat;
use App\Http\Controllers\Controller;
use App\Http\Resources\SuratResource;
use App\Models\Surat;
use App\Models\DataDesa;
use App\Models\Penduduk;
use App\Models\Surat;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Enums\StatusVerifikasiSurat;
use App\Http\Controllers\Controller;
use App\Http\Resources\SuratResource;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Validator;

class SuratController extends Controller
Expand All @@ -67,7 +68,7 @@ public function index(Request $request)
return response()->json("Kode desa {$request->desa_id} tidak terdaftar di kecamatan", 400);
}

$surat = Surat::where('desa_id', $request->desa_id)->get(['file', 'nama', 'nik', 'pengurus_id', 'log_verifikasi', 'keterangan']);
$surat = Surat::where('desa_id', $request->desa_id)->get(['nomor', 'file', 'nama', 'nik', 'pengurus_id', 'log_verifikasi', 'keterangan']);
return new SuratResource(true, 'Daftar Surat', $surat);
}

Expand Down Expand Up @@ -127,4 +128,39 @@ public function store(Request $request)

return new SuratResource(true, 'Surat Berhasil Dikirim!', $surat);
}

/**
* index
*
* @return void
*/
public function download(Request $request)
{
if (! $this->settings['tte']) {
return response()->json('Kecamatan belum mengaktifkan modul TTE', 400);
}

$validator = Validator::make($request->all(), [
'desa_id' => 'required',
'nomor' => 'required',
]);

if ($validator->fails()) {
return response()->json($validator->errors(), 422);
}

if (! in_array($request->desa_id, Arr::flatten(DataDesa::pluck('desa_id')))) {
Log::debug("Kode desa {$request->desa_id} tidak terdaftar di kecamatan");
return response()->json("Kode desa {$request->desa_id} tidak terdaftar di kecamatan", 400);
}

$surat = Surat::where('desa_id', $request->desa_id)->where('nomor', $request->nomor)->firstOrFail();

$file = public_path("storage/surat/{$surat->file}");

return Response::make(file_get_contents($file), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$surat->file.'"'
]);
}
}
10 changes: 7 additions & 3 deletions catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
Di rilis v23.01.01, menyediakan fitur Widget Perangkat Kecamatan dan Tombol Reset Peta. Rilis ini juga berisi perbaikan lain yang diminta Komunitas OpenDK.

#### Penambahan Fitur
1. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan log sukses atau gagal saat proses TTE.
2. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan fungsi pengiriman dokumen ke bsre untuk ditandatangani
1. [#589](https://github.com/OpenSID/OpenDK/issues/589) Tambahkan Link QRCode.
2. [#584](https://github.com/OpenSID/OpenDK/issues/584) Tambahkan API pengiriman surat yang telah di TTE ke OpenSID
3. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan log sukses atau gagal saat proses TTE.
4. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan fungsi pengiriman dokumen ke bsre untuk ditandatangani
5. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan log sukses atau gagal saat proses TTE.
6. [#618](https://github.com/OpenSID/OpenDK/pull/618) Sediakan fungsi pengiriman dokumen ke bsre untuk ditandatangani
7. [#584](https://github.com/OpenSID/OpenDK/issues/584) Sediakan fungsi pengiriman dokumen ke bsre untuk ditandatangani API pengiriman surat yang telah di TTE ke OpenSID

#### Perbaikan bug

1. [#609](https://github.com/OpenSID/OpenDK/issues/609) Perbaikan foto dan nama camat di menu profil tidak tampil.
2. [#605](https://github.com/OpenSID/OpenDK/issues/605) Perbaikan eror migrasi pada tabel prosedur.
3. [#605](https://github.com/OpenSID/OpenDK/issues/615) Perbaikan validasi prosedur, judul prosedur tidak boleh lebih dari 150 karakter.

1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
Route::group(['prefix' => 'surat'], function () {
Route::get('/', 'Api\SuratController@index');
Route::post('kirim', 'Api\SuratController@store');
Route::get('download', 'Api\SuratController@download');
});
});
});

0 comments on commit aa7edfc

Please sign in to comment.