Perbarui dependensi dan tambahkan fungsionalitas laporan penyaluran. Tambahkan paket baru seperti file_picker, pdf, dan open_file ke dalam pubspec.yaml. Hapus model LaporanModel yang tidak digunakan dan ganti dengan LaporanPenyaluranModel. Modifikasi tampilan dan controller untuk mendukung pengelolaan laporan penyaluran, termasuk navigasi dan ekspor ke PDF. Perbarui rute aplikasi untuk mencakup halaman laporan penyaluran baru.

This commit is contained in:
Khafidh Fuadi
2025-03-20 05:19:04 +07:00
parent 3b12c7af86
commit 54c4660302
29 changed files with 4702 additions and 539 deletions

View File

@ -1,89 +0,0 @@
import 'dart:convert';
class LaporanModel {
final String? id;
final String? judul;
final String? deskripsi;
final String? jenis; // Contoh: 'PENYALURAN', 'STOK_BANTUAN', 'PENERIMA'
final String?
referensiId; // ID dari entitas yang dilaporkan (penyaluran, penitipan, dll)
final String? status; // Contoh: 'draft', 'final', 'disetujui'
final String? petugasId; // Pengguna yang membuat laporan
final List<String>? fileUrls; // URL file laporan (PDF, Excel, dll)
final DateTime? tanggalMulai;
final DateTime? tanggalSelesai;
final DateTime? tanggalLaporan;
final DateTime? createdAt;
final DateTime? updatedAt;
LaporanModel({
this.id,
this.judul,
this.deskripsi,
this.jenis,
this.referensiId,
this.status,
this.petugasId,
this.fileUrls,
this.tanggalMulai,
this.tanggalSelesai,
this.tanggalLaporan,
this.createdAt,
this.updatedAt,
});
factory LaporanModel.fromRawJson(String str) =>
LaporanModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LaporanModel.fromJson(Map<String, dynamic> json) => LaporanModel(
id: json["id"],
judul: json["judul"],
deskripsi: json["deskripsi"],
jenis: json["jenis"],
referensiId: json["referensi_id"],
status: json["status"],
petugasId: json["petugas_id"] ?? json["user_id"],
fileUrls: json["file_urls"] == null
? null
: List<String>.from(json["file_urls"].map((x) => x)),
tanggalMulai: json["tanggal_mulai"] != null
? DateTime.parse(json["tanggal_mulai"])
: json["periode_awal"] != null
? DateTime.parse(json["periode_awal"])
: null,
tanggalSelesai: json["tanggal_selesai"] != null
? DateTime.parse(json["tanggal_selesai"])
: json["periode_akhir"] != null
? DateTime.parse(json["periode_akhir"])
: null,
tanggalLaporan: json["tanggal_laporan"] != null
? DateTime.parse(json["tanggal_laporan"])
: null,
createdAt: json["created_at"] != null
? DateTime.parse(json["created_at"])
: null,
updatedAt: json["updated_at"] != null
? DateTime.parse(json["updated_at"])
: null,
);
Map<String, dynamic> toJson() => {
"id": id,
"judul": judul,
"deskripsi": deskripsi,
"jenis": jenis,
"referensi_id": referensiId,
"status": status,
"petugas_id": petugasId,
"file_urls": fileUrls == null
? null
: List<dynamic>.from(fileUrls!.map((x) => x)),
"tanggal_mulai": tanggalMulai?.toIso8601String(),
"tanggal_selesai": tanggalSelesai?.toIso8601String(),
"tanggal_laporan": tanggalLaporan?.toIso8601String(),
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
}

View File

@ -0,0 +1,61 @@
import 'dart:convert';
class LaporanPenyaluranModel {
final String? id;
final String penyaluranBantuanId;
final String judul;
final String? dokumentasiUrl;
final String? beritaAcaraUrl;
final DateTime? tanggalLaporan;
final String? status;
final DateTime? createdAt;
final DateTime? updatedAt;
LaporanPenyaluranModel({
this.id,
required this.penyaluranBantuanId,
required this.judul,
this.dokumentasiUrl,
this.beritaAcaraUrl,
this.tanggalLaporan,
this.status,
this.createdAt,
this.updatedAt,
});
factory LaporanPenyaluranModel.fromRawJson(String str) =>
LaporanPenyaluranModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LaporanPenyaluranModel.fromJson(Map<String, dynamic> json) =>
LaporanPenyaluranModel(
id: json["id"],
penyaluranBantuanId: json["penyaluran_bantuan_id"],
judul: json["judul"],
dokumentasiUrl: json["dokumentasi_url"],
beritaAcaraUrl: json["berita_acara_url"],
tanggalLaporan: json["tanggal_laporan"] != null
? DateTime.parse(json["tanggal_laporan"]).toUtc()
: null,
status: json["status"],
createdAt: json["created_at"] != null
? DateTime.parse(json["created_at"]).toUtc()
: null,
updatedAt: json["updated_at"] != null
? DateTime.parse(json["updated_at"]).toUtc()
: null,
);
Map<String, dynamic> toJson() => {
"id": id,
"penyaluran_bantuan_id": penyaluranBantuanId,
"judul": judul,
"dokumentasi_url": dokumentasiUrl,
"berita_acara_url": beritaAcaraUrl,
"tanggal_laporan": tanggalLaporan?.toUtc().toIso8601String(),
"status": status,
"created_at": createdAt?.toUtc().toIso8601String(),
"updated_at": updatedAt?.toUtc().toIso8601String(),
};
}