unknown
1 year ago
17 changed files with 1043 additions and 451 deletions
After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,60 @@
|
||||
class CustomerModel { |
||||
int? id; |
||||
String? name; |
||||
String? code_customer; |
||||
String? lot_no; |
||||
String? nip; |
||||
String? no_hp; |
||||
DateTime? tgl_lahir; |
||||
String? jenis_kelamin; |
||||
String? agama; |
||||
String? created_by; |
||||
String? updated_by; |
||||
|
||||
CustomerModel({ |
||||
this.id, |
||||
this.name, |
||||
this.code_customer, |
||||
this.lot_no, |
||||
this.nip, |
||||
this.no_hp, |
||||
this.tgl_lahir, |
||||
this.jenis_kelamin, |
||||
this.agama, |
||||
this.created_by, |
||||
this.updated_by, |
||||
}); |
||||
|
||||
factory CustomerModel.fromJson(Map<String, dynamic> json) { |
||||
return CustomerModel( |
||||
id: json['id'], |
||||
name: json['name'] != null ? json['name'] : null, |
||||
code_customer: |
||||
json['code_customer'] != null ? json['code_customer'] : null, |
||||
lot_no: json['lot_no'] != null ? json['lot_no'] : null, |
||||
nip: json['nip'] != null ? json['nip'] : null, |
||||
no_hp: json['no_hp'] != null ? json['no_hp'] : null, |
||||
tgl_lahir: |
||||
json['tgl_lahir'] != null ? DateTime.parse(json['tgl_lahir']) : null, |
||||
jenis_kelamin: |
||||
json['jenis_kelamin'] != null ? json['jenis_kelamin'] : null, |
||||
agama: json['agama'] != null ? json['agama'] : null, |
||||
created_by: json['created_by'] != null ? json['created_by'] : null, |
||||
updated_by: json['updated_by'] != null ? json['updated_by'] : null, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() => { |
||||
'id': id, |
||||
'name': name, |
||||
'code_customer': code_customer, |
||||
'lot_no': lot_no, |
||||
'nip': nip, |
||||
'no_hp': no_hp, |
||||
'tgl_lahir': tgl_lahir, |
||||
'jenis_kelamin': jenis_kelamin, |
||||
'agama': agama, |
||||
'created_by': created_by, |
||||
'updated_by': updated_by, |
||||
}; |
||||
} |
@ -1,49 +1,97 @@
|
||||
import 'package:siopas/models/customer_model.dart'; |
||||
import 'package:siopas/models/type_peti_model.dart'; |
||||
import 'package:siopas/models/warehouse_mode.dart'; |
||||
|
||||
class M_assetStatusModel { |
||||
late int id; |
||||
String? seri; |
||||
String? name; |
||||
String? description; |
||||
int? warehouseId; |
||||
DateTime? date; |
||||
String? qr_count; |
||||
class PetiAssetModel { |
||||
int? id; |
||||
String? tipe_peti_id; |
||||
String? warna; |
||||
String? fix_lot; |
||||
int? packing_no; |
||||
int? customer_id; |
||||
int? warehouse_id; |
||||
int? jumlah; |
||||
DateTime? date_pembuatan; |
||||
WarehouseModel? warehouse; |
||||
TypePetiModel? tipe_peti; |
||||
CustomerModel? customer; |
||||
|
||||
String? status_disposal; |
||||
String? created_by; |
||||
String? updated_by; |
||||
// late WarehouseModel warehouse; |
||||
|
||||
M_assetStatusModel({ |
||||
required this.id, |
||||
this.seri, |
||||
this.name, |
||||
this.description, |
||||
this.warehouseId, |
||||
this.date, |
||||
this.qr_count, |
||||
PetiAssetModel({ |
||||
this.id, |
||||
this.tipe_peti_id, |
||||
this.warna, |
||||
this.fix_lot, |
||||
this.packing_no, |
||||
this.customer_id, |
||||
this.warehouse_id, |
||||
this.jumlah, |
||||
this.date_pembuatan, |
||||
this.warehouse, |
||||
this.tipe_peti, |
||||
this.customer, |
||||
this.status_disposal, |
||||
this.created_by, |
||||
this.updated_by, |
||||
// required this.warehouse, |
||||
}); |
||||
|
||||
factory M_assetStatusModel.fromJson(Map<String, dynamic> json) { |
||||
return M_assetStatusModel( |
||||
factory PetiAssetModel.fromJson(Map<String, dynamic> json) { |
||||
return PetiAssetModel( |
||||
id: json['id'], |
||||
seri: json['seri'], |
||||
name: json['name'], |
||||
description: json['description'], |
||||
warehouseId: json['warehouse_id'] != null |
||||
tipe_peti_id: json['tipe_peti_id'], |
||||
warna: json['warna'], |
||||
fix_lot: json['fix_lot'], |
||||
packing_no: json['packing_no'] != null |
||||
? int.parse(json['packing_no'].toString()) |
||||
: null, |
||||
customer_id: json['customer_id'] != null |
||||
? int.parse(json['customer_id'].toString()) |
||||
: null, |
||||
warehouse_id: json['warehouse_id'] != null |
||||
? int.parse(json['warehouse_id'].toString()) |
||||
: null, |
||||
date: json['date'] != null ? DateTime.parse(json['date']) : null, |
||||
qr_count: json['qr_count'], |
||||
// warehouse: WarehouseModel.fromJson(json['warehouse']), |
||||
jumlah: |
||||
json['jumlah'] != null ? int.parse(json['jumlah'].toString()) : null, |
||||
date_pembuatan: DateTime.parse(json['date_pembuatan']), |
||||
warehouse: json['warehouse'] != null |
||||
? WarehouseModel.fromJson(json['warehouse']) |
||||
: null, |
||||
tipe_peti: json['tipe_peti'] != null |
||||
? TypePetiModel.fromJson(json['tipe_peti']) |
||||
: null, |
||||
customer: json['customer'] != null |
||||
? CustomerModel.fromJson(json['customer']) |
||||
: null, |
||||
status_disposal: json['status_disposal'], |
||||
created_by: json['created_by'] != null |
||||
? json['created_by'].toString() |
||||
: json['created_by'], |
||||
updated_by: json['updated_by'] != null |
||||
? json['updated_by'].toString() |
||||
: json['updated_by'], |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() => { |
||||
'id': id, |
||||
'seri': seri, |
||||
'name': name, |
||||
'description': description, |
||||
'warehouse_id': warehouseId, |
||||
'date': date, |
||||
'qr_count': qr_count, |
||||
// 'warehouse': warehouse.toJson(), |
||||
'tipe_peti_id': tipe_peti_id, |
||||
'warna': warna, |
||||
'fix_lot': fix_lot, |
||||
'packing_no': packing_no, |
||||
'customer_id': customer_id, |
||||
'warehouse_id': warehouse_id, |
||||
'jumlah': jumlah, |
||||
'date_pembuatan': date_pembuatan!.toIso8601String(), |
||||
'warehouse': warehouse!.toJson(), |
||||
'tipe_peti': tipe_peti!.toJson(), |
||||
'customer': customer!.toJson(), |
||||
'status_disposal': status_disposal, |
||||
'created_by': created_by, |
||||
'updated_by': updated_by, |
||||
}; |
||||
} |
||||
|
@ -0,0 +1,39 @@
|
||||
class TypePetiModel { |
||||
int? id; |
||||
String? type; |
||||
String? size_peti; |
||||
String? description; |
||||
String? created_by; |
||||
String? updated_by; |
||||
|
||||
TypePetiModel({ |
||||
this.id, |
||||
this.type, |
||||
this.size_peti, |
||||
this.description, |
||||
this.created_by, |
||||
this.updated_by, |
||||
}); |
||||
|
||||
factory TypePetiModel.fromJson(Map<String, dynamic> json) { |
||||
return TypePetiModel( |
||||
id: json['id'], |
||||
type: json['type'] != null ? json['type'] : null, |
||||
size_peti: json['size_peti'] != null ? json['size_peti'] : null, |
||||
description: json['description'] != null ? json['description'] : null, |
||||
created_by: |
||||
json['created_by'] != null ? json['created_by'] : json['created_by'], |
||||
updated_by: |
||||
json['updated_by'] != null ? json['updated_by'] : json['updated_by'], |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() => { |
||||
'id': id, |
||||
'type': type, |
||||
'size_peti': size_peti, |
||||
'description': description, |
||||
'created_by': created_by, |
||||
'updated_by': updated_by, |
||||
}; |
||||
} |
@ -0,0 +1,148 @@
|
||||
import 'dart:convert'; |
||||
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:http/http.dart' as http; |
||||
import 'package:intl/intl.dart'; |
||||
import 'package:siopas/connection/connection.dart'; |
||||
|
||||
class DetailPeminjamanBarangPage extends StatefulWidget { |
||||
final int assetId; |
||||
const DetailPeminjamanBarangPage({Key? key, required this.assetId}) |
||||
: super(key: key); |
||||
|
||||
@override |
||||
_DetailPeminjamanBarangPageState createState() => |
||||
_DetailPeminjamanBarangPageState(); |
||||
} |
||||
|
||||
class _DetailPeminjamanBarangPageState |
||||
extends State<DetailPeminjamanBarangPage> { |
||||
Map<String, dynamic>? assetStatusData; |
||||
|
||||
String _formatDate(String date) { |
||||
DateTime parsedDate = DateTime.parse(date); |
||||
String formattedDate = |
||||
DateFormat('EEEE, dd MMMM yyyy', 'id_ID').format(parsedDate); |
||||
return formattedDate; |
||||
} |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
_fetchAssetStatusData(); |
||||
} |
||||
|
||||
Future<void> _fetchAssetStatusData() async { |
||||
try { |
||||
final response = await http.get( |
||||
Uri.parse('$baseUrl/asset-status/show/${widget.assetId}'), |
||||
headers: { |
||||
'Content-Type': 'application/json', |
||||
}, |
||||
); |
||||
|
||||
if (response.statusCode == 200) { |
||||
setState(() { |
||||
assetStatusData = json.decode(response.body)['data']['asset_status']; |
||||
}); |
||||
} else { |
||||
throw Exception('Failed to load data'); |
||||
} |
||||
} catch (e) { |
||||
print('Error fetching data: $e'); |
||||
} |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
backgroundColor: Colors.grey[200], |
||||
appBar: AppBar( |
||||
backgroundColor: Colors.indigo[700], |
||||
elevation: 0, |
||||
title: Text('Detail Peminjaman Barang', |
||||
style: TextStyle( |
||||
color: Colors.white, |
||||
fontSize: 16, |
||||
)), |
||||
leading: IconButton( |
||||
icon: Icon(Icons.arrow_back, color: Colors.white), |
||||
onPressed: () { |
||||
Navigator.pushNamed(context, '/peminjaman-barang'); |
||||
}, |
||||
), |
||||
), |
||||
body: Padding( |
||||
padding: EdgeInsets.all(16.0), |
||||
child: Card( |
||||
shape: RoundedRectangleBorder( |
||||
borderRadius: BorderRadius.circular(15.0), |
||||
), |
||||
elevation: 5, |
||||
child: Column( |
||||
children: [ |
||||
Card( |
||||
shape: RoundedRectangleBorder( |
||||
borderRadius: |
||||
BorderRadius.vertical(top: Radius.circular(15.0)), |
||||
), |
||||
elevation: 0, |
||||
margin: EdgeInsets.all(0), |
||||
color: Colors.indigo[700], |
||||
child: Padding( |
||||
padding: const EdgeInsets.all(16.0), |
||||
child: Row( |
||||
children: [ |
||||
Icon(Icons.article, |
||||
size: 40, |
||||
color: Colors.white), // Ganti ikon sesuai kebutuhan |
||||
SizedBox(width: 10), |
||||
Text( |
||||
'ID: ${widget.assetId}', |
||||
style: TextStyle( |
||||
fontSize: 20, |
||||
fontWeight: FontWeight.bold, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
), |
||||
SizedBox(height: 10), |
||||
if (assetStatusData != null) ...[ |
||||
_buildDetailItem( |
||||
'Asset Name', assetStatusData!['asset']['name']), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem( |
||||
'Exit At', _formatDate(assetStatusData!['exit_at'])), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem('Exit Pic', assetStatusData!['exit_pic']), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem( |
||||
'Exit Warehouse', assetStatusData!['warehouse']['name']), |
||||
// ... tambahkan data lainnya sesuai kebutuhan |
||||
], |
||||
], |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget _buildDetailItem(String label, String value) { |
||||
return Padding( |
||||
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), |
||||
child: Row( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
children: [ |
||||
Text( |
||||
label, |
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), |
||||
), |
||||
Text(value), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue