After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 407 B |
After Width: | Height: | Size: 851 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<background android:drawable="@color/ic_launcher_background"/> |
||||
<background android:drawable="@drawable/ic_launcher_background"/> |
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> |
||||
</adaptive-icon> |
||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 22 KiB |
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<color name="ic_launcher_background">#ffffff</color> |
||||
</resources> |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 259 KiB |
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 725 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,367 @@
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
||||
import 'package:siopas/models/asset_status_model.dart'; |
||||
import 'package:siopas/models/customer_model.dart'; |
||||
import 'package:siopas/models/m_asset_status_model.dart'; |
||||
import 'package:siopas/models/transfer_peti_model.dart'; |
||||
import 'package:siopas/pages/peminjaman_barang/controller/peminjaman_controller.dart'; |
||||
import 'package:intl/date_symbol_data_local.dart'; |
||||
import 'package:intl/intl.dart'; |
||||
import 'package:collection/collection.dart'; |
||||
import 'package:siopas/pages/transfer_peti/controller/transfer_peti_controller.dart'; |
||||
|
||||
import '../../models/warehouse_mode.dart'; |
||||
import '../../services/controllerApi.dart'; |
||||
|
||||
class DetailTransferPetiPage extends StatefulWidget { |
||||
final int transferPetiId; |
||||
|
||||
const DetailTransferPetiPage({Key? key, required this.transferPetiId}) |
||||
: super(key: key); |
||||
|
||||
@override |
||||
_DetailTransferPetiPageState createState() => _DetailTransferPetiPageState(); |
||||
} |
||||
|
||||
class _DetailTransferPetiPageState extends State<DetailTransferPetiPage> { |
||||
TransferPetiModel? transferInfo; |
||||
WarehouseModel? warehouseInfo; |
||||
|
||||
List<PetiAssetModel>? petiData; |
||||
List<CustomerModel>? customerData; |
||||
List<WarehouseModel>? warehouseData; |
||||
bool loading = true; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
|
||||
// Pemanggilan fungsi-fungsi yang diperlukan |
||||
getTransferIdData(); |
||||
customerListAPI(); |
||||
petiListAPI(); |
||||
warehouseListAPI(); |
||||
initializeDateFormatting('id_ID', null); |
||||
|
||||
// Mengatur loading ke false setelah tugas selesai |
||||
setState(() { |
||||
loading = false; |
||||
}); |
||||
} |
||||
|
||||
Future customerListAPI() async { |
||||
if (mounted) { |
||||
await ControllerApi().fetchCustomerDataAPI().then((value) { |
||||
setState(() { |
||||
customerData = (value as List<dynamic>) |
||||
.map((item) => CustomerModel.fromJson(item)) |
||||
.toList(); |
||||
loading = false; |
||||
}); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
Future petiListAPI() async { |
||||
if (mounted) { |
||||
await ControllerApi().fetchPetiDataAPI().then((value) { |
||||
setState(() { |
||||
petiData = (value as List<dynamic>) |
||||
.map((item) => PetiAssetModel.fromJson(item)) |
||||
.toList(); |
||||
loading = false; |
||||
}); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
Future warehouseListAPI() async { |
||||
if (mounted) { |
||||
await ControllerApi().fetchWarehouseDataAPI().then((value) { |
||||
setState(() { |
||||
warehouseData = (value as List<dynamic>) |
||||
.map((item) => WarehouseModel.fromJson(item)) |
||||
.toList(); |
||||
loading = false; |
||||
}); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
Future<void> getTransferIdData() async { |
||||
List<TransferPetiModel> transfers = |
||||
await ControllerTransferPeti().fetchTransferPetiDataId(); |
||||
transferInfo = transfers.firstWhereOrNull( |
||||
(transfer) => transfer.id.toString() == widget.transferPetiId.toString(), |
||||
); |
||||
|
||||
if (mounted) { |
||||
setState(() {}); |
||||
} |
||||
} |
||||
|
||||
String _formatDate(String? date) { |
||||
if (date != null) { |
||||
DateTime parsedDate = DateTime.parse(date); |
||||
String formattedDate = |
||||
DateFormat('EEEE, dd MMMM yyyy', 'id_ID').format(parsedDate); |
||||
return formattedDate; |
||||
} else { |
||||
return ''; |
||||
} |
||||
} |
||||
|
||||
Future<void> _deleteTransferPeti() async { |
||||
try { |
||||
// Panggil fungsi untuk menghapus peminjaman berdasarkan ID |
||||
await ControllerTransferPeti() |
||||
.deleteTransferPetiById(widget.transferPetiId.toString()); |
||||
// Navigasi kembali ke halaman sebelumnya atau halaman yang sesuai |
||||
Navigator.pushNamed(context, '/transfer-peti'); |
||||
} catch (e) { |
||||
// Tangani kesalahan jika terjadi |
||||
print('Gagal menghapus transfer peti: $e'); |
||||
} |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
PetiAssetModel? petiSqfliteApi; |
||||
petiSqfliteApi = petiData?.firstWhereOrNull( |
||||
(peti) => peti.id == transferInfo?.peti_id, |
||||
); |
||||
|
||||
CustomerModel? customerSqfliteApi; |
||||
customerSqfliteApi = customerData?.firstWhereOrNull( |
||||
(customer) => customer.id == transferInfo?.name_customer, |
||||
); |
||||
|
||||
WarehouseModel? warehouseSqfliteApi; |
||||
warehouseSqfliteApi = warehouseData?.firstWhereOrNull( |
||||
(warehouse) => warehouse.id == transferInfo?.source_warehouse, |
||||
); |
||||
WarehouseModel? warehouseTujuanSqfliteApi; |
||||
warehouseTujuanSqfliteApi = warehouseData?.firstWhereOrNull( |
||||
(warehouse) => warehouse.id == transferInfo?.destination_warehouse, |
||||
); |
||||
|
||||
Future<void> _showDeleteConfirmationDialog() async { |
||||
return showDialog<void>( |
||||
context: context, |
||||
builder: (BuildContext context) { |
||||
return AlertDialog( |
||||
shape: RoundedRectangleBorder( |
||||
borderRadius: BorderRadius.circular(16.0), |
||||
), |
||||
title: Row( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Icon( |
||||
Icons.info, |
||||
color: Colors.blue, |
||||
), |
||||
SizedBox(width: 8), |
||||
Text( |
||||
'Konfirmasi Hapus', |
||||
style: TextStyle( |
||||
fontSize: 18, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
IconButton( |
||||
icon: Icon( |
||||
Icons.close, |
||||
color: Colors.black54, |
||||
), |
||||
onPressed: () { |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
), |
||||
], |
||||
), |
||||
content: SingleChildScrollView( |
||||
child: ListBody( |
||||
children: <Widget>[ |
||||
Text( |
||||
'Anda yakin ingin menghapus pengembalian ini? ${petiSqfliteApi!.fix_lot.toString()}', |
||||
style: TextStyle( |
||||
fontSize: 16, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
actions: <Widget>[ |
||||
Container( |
||||
margin: EdgeInsets.only(right: 3.0), |
||||
child: ElevatedButton( |
||||
child: Text('Hapus'), |
||||
onPressed: () { |
||||
// Panggil fungsi untuk menghapus peminjaman berdasarkan ID |
||||
_deleteTransferPeti(); |
||||
Navigator.pushNamed(context, '/transfer-peti'); |
||||
EasyLoading.showSuccess( |
||||
'Berhasil menghapus data transfer peti'); |
||||
}, |
||||
style: ElevatedButton.styleFrom( |
||||
primary: Colors.red, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
); |
||||
}, |
||||
); |
||||
} |
||||
|
||||
return Scaffold( |
||||
backgroundColor: Colors.grey[200], |
||||
appBar: AppBar( |
||||
backgroundColor: Colors.indigo[700], |
||||
elevation: 0, |
||||
title: Text( |
||||
'Detail Transfer Peti', |
||||
style: TextStyle( |
||||
color: Colors.white, |
||||
fontSize: 16, |
||||
), |
||||
), |
||||
leading: IconButton( |
||||
icon: Icon(Icons.arrow_back, color: Colors.white), |
||||
onPressed: () { |
||||
Navigator.pushNamed(context, '/transfer-peti'); |
||||
}, |
||||
), |
||||
actions: [ |
||||
IconButton( |
||||
icon: Icon(Icons.delete, color: Colors.redAccent), |
||||
onPressed: () { |
||||
_showDeleteConfirmationDialog(); |
||||
}, |
||||
), |
||||
], |
||||
), |
||||
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: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Icon(Icons.article, size: 30, color: Colors.white), |
||||
SizedBox(width: 10), |
||||
Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Text( |
||||
'ID:', |
||||
style: TextStyle( |
||||
fontSize: 12, |
||||
fontWeight: FontWeight.bold, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
SizedBox(height: 5), |
||||
Text( |
||||
petiSqfliteApi != null && |
||||
petiSqfliteApi.fix_lot != null |
||||
? petiSqfliteApi!.fix_lot.toString() |
||||
: '-', |
||||
style: TextStyle( |
||||
fontSize: 12, |
||||
fontWeight: FontWeight.bold, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
], |
||||
), |
||||
], |
||||
), |
||||
), |
||||
), |
||||
SizedBox(height: 10), |
||||
if (transferInfo != null) ...[ |
||||
_buildDetailItem( |
||||
'Kode Peti', |
||||
petiSqfliteApi != null && petiSqfliteApi.fix_lot != null |
||||
? petiSqfliteApi!.fix_lot.toString() |
||||
: '-', |
||||
), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem( |
||||
'Nama Customer', |
||||
customerSqfliteApi != null && customerSqfliteApi.name != null |
||||
? customerSqfliteApi!.name.toString() |
||||
: '-', |
||||
), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem( |
||||
'Tgl Transfer', _formatDate(transferInfo!.date.toString())), |
||||
Divider(thickness: 1), |
||||
|
||||
_buildDetailItem( |
||||
'Asal Gudang', |
||||
// peminjamanInfo!.exit_warehouse.toString()), |
||||
warehouseSqfliteApi != null && |
||||
warehouseSqfliteApi.name != null |
||||
? warehouseSqfliteApi!.name.toString() |
||||
: '-'), |
||||
Divider(thickness: 1), |
||||
_buildDetailItem( |
||||
'Tujuan Gudang', |
||||
// peminjamanInfo!.exit_warehouse.toString()), |
||||
warehouseTujuanSqfliteApi != null && |
||||
warehouseTujuanSqfliteApi.name != null |
||||
? warehouseTujuanSqfliteApi!.name.toString() |
||||
: '-'), |
||||
Divider(thickness: 1), |
||||
// ... 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: 12, fontWeight: FontWeight.bold), |
||||
), |
||||
Text( |
||||
value, |
||||
style: TextStyle(fontSize: 12), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |