Siopas Inventory PETI for ISTW Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

175 lines
5.5 KiB

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:siopas/connection/connection.dart';
import 'package:http/http.dart' as http;
class DetailTransferPetiPage extends StatefulWidget {
final int petiId;
const DetailTransferPetiPage({Key? key, required this.petiId})
: super(key: key);
@override
State<DetailTransferPetiPage> createState() => _DetailTransferPetiPageState();
}
class _DetailTransferPetiPageState extends State<DetailTransferPetiPage> {
Map<String, dynamic>? petiStatusData;
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();
_fetchAssetStatusDataPengembalian();
}
Future<void> _fetchAssetStatusDataPengembalian() async {
try {
final response = await http.get(
Uri.parse('$baseUrl/peti-asset/show/${widget.petiId}'),
headers: {
'Content-Type': 'application/json',
},
);
if (response.statusCode == 200) {
setState(() {
petiStatusData = json.decode(response.body)['data']['peti'];
});
} 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 Peti',
style: TextStyle(
color: Colors.white,
fontSize: 16,
)),
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
Navigator.pushNamed(context, '/transfer-peti');
},
),
),
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.petiId}',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
),
),
SizedBox(height: 10),
if (petiStatusData != null) ...[
_buildDetailItem(
'Tipe Peti',
petiStatusData!['tipe_peti']['type'],
),
Divider(thickness: 1),
_buildDetailItem(
'Warna Peti',
petiStatusData!['warna'] != null
? petiStatusData!['warna'].toString()
: '-'),
Divider(thickness: 1),
_buildDetailItem(
'Customer',
petiStatusData!['customer']['name'] != null
? petiStatusData!['customer']['name'].toString()
: '-'),
Divider(thickness: 1),
_buildDetailItem(
'Warehouse',
petiStatusData!['warehouse']['name'] != null
? petiStatusData!['warehouse']['name'].toString()
: '-'),
Divider(thickness: 1),
_buildDetailItem(
'Status Peti',
petiStatusData!['status_disposal'] != null
? petiStatusData!['status_disposal'].toString()
: '-'),
Divider(thickness: 1),
_buildDetailItem(
'Jumlah Peti',
petiStatusData!['jumlah'] != null
? petiStatusData!['jumlah'].toString()
: '-',
),
Divider(thickness: 1),
_buildDetailItem(
'Tgl Pembuatan Peti',
petiStatusData!['created_at'] != null
? _formatDate(petiStatusData!['created_at'])
: '-'),
],
],
),
),
),
);
}
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.5, fontWeight: FontWeight.bold),
),
Text(value),
],
),
);
}
}