Browse Source

Update: perubahan ke Peti, juga SCAN Qr Code

master
unknown 1 year ago
parent
commit
d5525efbc8
  1. BIN
      assets/logo_login.png
  2. 3
      lib/main.dart
  3. 51
      lib/models/asset_status_model.dart
  4. 60
      lib/models/customer_model.dart
  5. 112
      lib/models/m_asset_status_model.dart
  6. 39
      lib/models/type_peti_model.dart
  7. 185
      lib/pages/home/home_page.dart
  8. 78
      lib/pages/home/main_page.dart
  9. 93
      lib/pages/home/peminjaman_stock_page.dart
  10. 88
      lib/pages/home/setting_page.dart
  11. 521
      lib/pages/peminjaman_barang/create.dart
  12. 148
      lib/pages/peminjaman_barang/show.dart
  13. 85
      lib/pages/sign_in_page.dart
  14. 11
      lib/pages/splash_page.dart
  15. 6
      lib/services/m_status_service.dart
  16. 8
      pubspec.lock
  17. 6
      pubspec.yaml

BIN
assets/logo_login.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

3
lib/main.dart

@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'pages/home/main_page.dart'; import 'pages/home/main_page.dart';
import 'pages/home/peminjaman_stock_page.dart'; import 'pages/home/peminjaman_stock_page.dart';
import 'pages/peminjaman_barang/create.dart'; import 'pages/peminjaman_barang/create.dart';
import 'pages/peminjaman_barang/show.dart';
import 'pages/sign_in_page.dart'; import 'pages/sign_in_page.dart';
import 'pages/splash_page.dart'; import 'pages/splash_page.dart';
import 'providers/asset_status_provider.dart'; import 'providers/asset_status_provider.dart';
@ -51,6 +52,8 @@ class MyApp extends StatelessWidget {
'/home': (context) => MainPage(), '/home': (context) => MainPage(),
'/peminjaman-barang': (context) => AssetStatusPage(), '/peminjaman-barang': (context) => AssetStatusPage(),
'/peminjaman-barang/create': (context) => CreatePeminjamanBarang(), '/peminjaman-barang/create': (context) => CreatePeminjamanBarang(),
// '/peminjaman-barang/show': (context) =>
// DetailPeminjamanBarangPage(assetId: 0),
// '/category': (context) => SurveyDetailPage(), // '/category': (context) => SurveyDetailPage(),
// '/map': (context) => GeoMapPage(), // '/map': (context) => GeoMapPage(),
}, },

51
lib/models/asset_status_model.dart

@ -3,57 +3,62 @@ import 'warehouse_mode.dart';
class AssetStatusModel { class AssetStatusModel {
int? id; int? id;
int? asset_id; int? peti_id;
DateTime? exit_at; DateTime? exit_at;
String? exit_pic; String? exit_pic;
int? exit_warehouse; int? exit_warehouse;
String? enter_at; DateTime? enter_at;
String? enter_pic; String? enter_pic;
int? enter_warehouse; int? enter_warehouse;
int? created_by; DateTime? est_pengembalian;
int? updated_by; String? kondisi_peti;
late M_assetStatusModel asset; String? created_by;
late WarehouseModel warehouse; String? updated_by;
PetiAssetModel? peti;
WarehouseModel? warehouse;
AssetStatusModel({ AssetStatusModel({
this.id, this.id,
this.asset_id, this.peti_id,
this.exit_at, this.exit_at,
this.exit_pic, this.exit_pic,
this.exit_warehouse, this.exit_warehouse,
this.enter_at, this.enter_at,
this.enter_pic, this.enter_pic,
this.enter_warehouse, this.enter_warehouse,
this.est_pengembalian,
this.kondisi_peti,
this.created_by, this.created_by,
this.updated_by, this.updated_by,
required this.asset, required this.peti,
required this.warehouse, required this.warehouse,
}); });
factory AssetStatusModel.fromJson(Map<String, dynamic> json) { factory AssetStatusModel.fromJson(Map<String, dynamic> json) {
return AssetStatusModel( return AssetStatusModel(
id: json['id'], id: json['id'],
asset_id: json['asset_id'] != null peti_id: json['peti_id'] != null
? int.parse(json['asset_id'].toString()) ? int.parse(json['peti_id'].toString())
: null, : null,
exit_at: json['exit_at'] != null ? DateTime.parse(json['exit_at']) : null, exit_at: json['exit_at'] != null ? DateTime.parse(json['exit_at']) : null,
exit_pic: json['exit_pic'], exit_pic: json['exit_pic'],
exit_warehouse: json['exit_warehouse'] != null exit_warehouse: json['exit_warehouse'] != null
? int.parse(json['exit_warehouse'].toString()) ? int.parse(json['exit_warehouse'].toString())
: null, : null,
enter_at: json['enter_at'], enter_at:
enter_pic: json['enter_pic'], json['enter_at'] != null ? DateTime.parse(json['enter_at']) : null,
enter_pic: json['enter_pic'] != null ? json['enter_pic'] : null,
enter_warehouse: json['enter_warehouse'] != null enter_warehouse: json['enter_warehouse'] != null
? int.parse(json['enter_warehouse'].toString()) ? int.parse(json['enter_warehouse'].toString())
: null, : null,
created_by: json['created_by'] != null est_pengembalian: json['est_pengembalian'] != null
? int.parse(json['created_by'].toString()) ? DateTime.parse(json['est_pengembalian'])
: null, : null,
updated_by: json['updated_by'] != null kondisi_peti:
? int.parse(json['updated_by'].toString()) json['kondisi_peti'] != null ? json['kondisi_peti'] : 'null',
: null, created_by: json['created_by'] != null ? json['created_by'] : 'null',
asset: M_assetStatusModel.fromJson( updated_by: json['updated_by'] != null ? json['updated_by'] : 'null',
json['asset'] != null ? json['asset'] : {'id': 0, 'name': 'null'}), peti: PetiAssetModel.fromJson(json['peti'] != null ? json['peti'] : null),
warehouse: WarehouseModel.fromJson(json['warehouse'] != null warehouse: WarehouseModel.fromJson(json['warehouse'] != null
? json['warehouse'] ? json['warehouse']
: {'id': 0, 'name': 'null'}), : {'id': 0, 'name': 'null'}),
@ -62,16 +67,18 @@ class AssetStatusModel {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
'asset_id': asset_id, 'peti_id': peti_id,
'exit_at': exit_at, 'exit_at': exit_at,
'exit_pic': exit_pic, 'exit_pic': exit_pic,
'exit_warehouse': exit_warehouse, 'exit_warehouse': exit_warehouse,
'enter_at': enter_at, 'enter_at': enter_at,
'enter_pic': enter_pic, 'enter_pic': enter_pic,
'enter_warehouse': enter_warehouse, 'enter_warehouse': enter_warehouse,
'est_pengembalian': est_pengembalian,
'kondisi_peti': kondisi_peti,
'created_by': created_by, 'created_by': created_by,
'updated_by': updated_by, 'updated_by': updated_by,
'asset': asset.toJson(), 'peti': peti!.toJson(),
'warehouse': warehouse.toJson(), 'warehouse': warehouse!.toJson(),
}; };
} }

60
lib/models/customer_model.dart

@ -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,
};
}

112
lib/models/m_asset_status_model.dart

@ -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'; import 'package:siopas/models/warehouse_mode.dart';
class M_assetStatusModel { class PetiAssetModel {
late int id; int? id;
String? seri; String? tipe_peti_id;
String? name; String? warna;
String? description; String? fix_lot;
int? warehouseId; int? packing_no;
DateTime? date; int? customer_id;
String? qr_count; 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; // late WarehouseModel warehouse;
M_assetStatusModel({ PetiAssetModel({
required this.id, this.id,
this.seri, this.tipe_peti_id,
this.name, this.warna,
this.description, this.fix_lot,
this.warehouseId, this.packing_no,
this.date, this.customer_id,
this.qr_count, 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, // required this.warehouse,
}); });
factory M_assetStatusModel.fromJson(Map<String, dynamic> json) { factory PetiAssetModel.fromJson(Map<String, dynamic> json) {
return M_assetStatusModel( return PetiAssetModel(
id: json['id'], id: json['id'],
seri: json['seri'], tipe_peti_id: json['tipe_peti_id'],
name: json['name'], warna: json['warna'],
description: json['description'], fix_lot: json['fix_lot'],
warehouseId: json['warehouse_id'] != null 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()) ? int.parse(json['warehouse_id'].toString())
: null, : null,
date: json['date'] != null ? DateTime.parse(json['date']) : null, jumlah:
qr_count: json['qr_count'], json['jumlah'] != null ? int.parse(json['jumlah'].toString()) : null,
// warehouse: WarehouseModel.fromJson(json['warehouse']), 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() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
'seri': seri, 'tipe_peti_id': tipe_peti_id,
'name': name, 'warna': warna,
'description': description, 'fix_lot': fix_lot,
'warehouse_id': warehouseId, 'packing_no': packing_no,
'date': date, 'customer_id': customer_id,
'qr_count': qr_count, 'warehouse_id': warehouse_id,
// 'warehouse': warehouse.toJson(), '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,
}; };
} }

39
lib/models/type_peti_model.dart

@ -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,
};
}

185
lib/pages/home/home_page.dart

@ -205,25 +205,72 @@ class _HomePageState extends State<HomePage> {
); );
} }
Widget cardMenu(String title, IconData icon, Function() onTap) { Widget cardMenuPeminjaman() {
return Card( return Container(
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
child: InkWell( child: Card(
onTap: onTap, shape: RoundedRectangleBorder(
child: Container( borderRadius: BorderRadius.circular(15.0),
padding: EdgeInsets.all(10), // Mengurangi padding ),
child: Column( elevation: 5,
mainAxisAlignment: MainAxisAlignment.center, child: InkWell(
children: <Widget>[ onTap: () {
Icon(icon, size: 20), // Mengurangi ukuran ikon // Aksi ketika card diklik
SizedBox(height: 5), // Mengurangi jarak Navigator.pushNamed(context, '/peminjaman-barang');
Center( },
child: Text( child: Container(
title, padding: EdgeInsets.all(16.0),
style: TextStyle(fontSize: 12), // Mengurangi ukuran teks child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.vertical_align_top,
size: 50,
color: Colors.greenAccent[700],
), ),
), SizedBox(height: 10),
], Text(
'Peminjaman',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
),
),
),
);
}
Widget cardMenuPengembalian() {
return Container(
margin: EdgeInsets.all(10),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: InkWell(
onTap: () {
// Aksi ketika card diklik
// Navigator.pushNamed(context, '/peminjaman-barang');
},
child: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.vertical_align_bottom,
size: 50,
color: Colors.blueAccent[700],
),
SizedBox(height: 10),
Text(
'Pengembalian',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
), ),
), ),
), ),
@ -349,10 +396,10 @@ class _HomePageState extends State<HomePage> {
} }
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[100], backgroundColor: Colors.grey[200],
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
// automaticallyImplyLeading: true, automaticallyImplyLeading: false,
backgroundColor: Colors.indigo[700], backgroundColor: Colors.indigo[700],
title: Row( title: Row(
children: [ children: [
@ -377,69 +424,61 @@ class _HomePageState extends State<HomePage> {
), ),
], ],
), ),
actions: [ // actions: [
Align( // Align(
alignment: Alignment.center, // alignment: Alignment.center,
child: Stack( // child: Stack(
children: [ // children: [
GestureDetector( // GestureDetector(
onTap: () { // onTap: () {
// Tambahkan aksi yang diinginkan saat ikon ditekan // // Tambahkan aksi yang diinginkan saat ikon ditekan
}, // },
child: Icon( // child: Icon(
Icons.notifications, // Icons.notifications,
color: Colors.white, // color: Colors.white,
size: 30, // size: 30,
), // ),
), // ),
Positioned( // Positioned(
right: 0, // right: 0,
top: 0, // top: 0,
child: Container( // child: Container(
padding: EdgeInsets.all(4), // padding: EdgeInsets.all(4),
decoration: BoxDecoration( // decoration: BoxDecoration(
shape: BoxShape.circle, // shape: BoxShape.circle,
color: Colors.red, // Warna latar belakang notifikasi // color: Colors.red, // Warna latar belakang notifikasi
), // ),
child: Text( // child: Text(
'5', // '5',
style: TextStyle( // style: TextStyle(
color: Colors.white, // Warna teks notifikasi // color: Colors.white, // Warna teks notifikasi
fontSize: 12, // fontSize: 12,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
), // ),
), // ),
), // ),
], // ],
), // ),
), // ),
SizedBox(width: 10), // SizedBox(width: 10),
], // ],
), ),
drawer: _buildDrawer(), // drawer: _buildDrawer(),
body: ListView( body: ListView(
children: [ children: [
// header(), // header(),
subHeader(), // subHeader(),
SizedBox(height: 10), // SizedBox(height: 10),
cardRow(), // cardRow(),
titleMenu(), // titleMenu(),
GridView.count( GridView.count(
crossAxisCount: 2, crossAxisCount: 2,
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
children: [ children: [
cardMenu("Return Stock", Icons.access_alarm, () { cardMenuPeminjaman(),
// Aksi yang ingin Anda tambahkan untuk Menu 1 cardMenuPengembalian(),
Navigator.pushNamed(context, '/peminjaman-barang');
}),
cardMenu("Receive Stock", Icons.accessibility, () {
// Aksi yang ingin Anda tambahkan untuk Menu 2
}),
cardMenu("Menu 3", Icons.account_balance, () {
// Aksi yang ingin Anda tambahkan untuk Menu 3
}),
], ],
), ),
], ],

78
lib/pages/home/main_page.dart

@ -37,35 +37,35 @@ class _MainPageState extends State<MainPage> {
icon: Icon(Icons.home), icon: Icon(Icons.home),
label: 'Beranda', label: 'Beranda',
), ),
BottomNavigationBarItem( // BottomNavigationBarItem(
icon: Icon(Icons.assignment_return), // icon: Icon(Icons.assignment_return),
label: 'Return', // label: 'Return',
), // ),
BottomNavigationBarItem( // BottomNavigationBarItem(
icon: GestureDetector( // icon: GestureDetector(
onTap: () { // onTap: () {
setState(() { // setState(() {
currentIndex = 2; // currentIndex = 2;
}); // });
}, // },
child: Container( // child: Container(
width: 60.0, // width: 60.0,
height: 60.0, // height: 60.0,
decoration: BoxDecoration( // decoration: BoxDecoration(
color: Colors.indigoAccent, // color: Colors.indigoAccent,
shape: BoxShape.circle, // shape: BoxShape.circle,
), // ),
child: Center( // child: Center(
child: Icon(Icons.qr_code, size: 30.0, color: Colors.white), // child: Icon(Icons.qr_code, size: 30.0, color: Colors.white),
), // ),
), // ),
), // ),
label: '', // Menghilangkan teks label // label: '', // Menghilangkan teks label
), // ),
BottomNavigationBarItem( // BottomNavigationBarItem(
icon: Icon(Icons.markunread_mailbox), // icon: Icon(Icons.markunread_mailbox),
label: 'Receive', // label: 'Receive',
), // ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.person), icon: Icon(Icons.person),
label: 'Pengaturan', label: 'Pengaturan',
@ -81,16 +81,16 @@ class _MainPageState extends State<MainPage> {
return HomePage(); return HomePage();
case 1: case 1:
// Return your MapsPage here // Return your MapsPage here
return AssetStatusPage(); // Ganti dengan MapsPage return SettingPage(); // Ganti dengan MapsPage
case 2: // case 2:
// Add your QR Code page here // // Add your QR Code page here
return Placeholder(); // Ganti dengan halaman QR Code // return Placeholder(); // Ganti dengan halaman QR Code
case 3: // case 3:
// Return your HistoryPage here // // Return your HistoryPage here
return Placeholder(); // Ganti dengan HistoryPage // return Placeholder(); // Ganti dengan HistoryPage
case 4: // case 4:
// Return your ProfilePage here // // Return your ProfilePage here
return SettingPage(); // Ganti dengan ProfilePage // return SettingPage(); // Ganti dengan ProfilePage
default: default:
return Container(); // Add more cases if needed return Container(); // Add more cases if needed
} }

93
lib/pages/home/peminjaman_stock_page.dart

@ -11,6 +11,7 @@ import 'package:siopas/widget/peminjaman_tile.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../../connection/connection.dart'; import '../../connection/connection.dart';
import '../peminjaman_barang/show.dart';
class AssetStatusPage extends StatefulWidget { class AssetStatusPage extends StatefulWidget {
const AssetStatusPage({super.key}); const AssetStatusPage({super.key});
@ -102,15 +103,12 @@ class AssetStatusPageState extends State<AssetStatusPage> {
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
)), )),
actions: [ leading: IconButton(
IconButton( icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () { onPressed: () {
// Tambahkan logika untuk tindakan ketika tombol + ditekan Navigator.pushNamed(context, '/home');
Navigator.pushNamed(context, '/peminjaman-barang/create'); },
}, ),
icon: Icon(Icons.add),
),
],
), ),
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
@ -128,24 +126,57 @@ class AssetStatusPageState extends State<AssetStatusPage> {
}, },
columns: const [ columns: const [
DataColumn(label: Text('No')), DataColumn(label: Text('No')),
DataColumn(label: Text('Asset')), DataColumn(label: Text('Kode Peti')),
DataColumn(label: Text('Exit At')), DataColumn(label: Text('Nama Customer')),
DataColumn(label: Text('Exit Pic')), DataColumn(label: Text('Tgl Peminjaman')),
DataColumn(label: Text('Exit warehouse')), DataColumn(label: Text('PJ Peminjaman')),
DataColumn(label: Text('Asal Gudang')),
], ],
source: _DataSource(data: _data), source: _DataSource(data: _data, context: context),
), ),
), ),
), ),
bottomNavigationBar: BottomAppBar(
color: Color.fromARGB(255, 5, 28, 158), // Warna latar belakang
child: Container(
height: 65.0,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
customBorder: CircleBorder(),
onTap: () {
// Aksi ketika ikon diklik
Navigator.pushNamed(context, '/peminjaman-barang/create');
},
child: Container(
width: 45,
height: 45,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.greenAccent[700],
),
child: Icon(
Icons.add,
size: 30,
color: Colors.white,
),
),
),
],
),
),
),
); );
} }
} }
class _DataSource extends DataTableSource { class _DataSource extends DataTableSource {
final List<AssetStatusModel> data; final List<AssetStatusModel> data;
final BuildContext context;
_DataSource({required this.data}); _DataSource({required this.data, required this.context});
@override @override
DataRow? getRow(int index) { DataRow? getRow(int index) {
if (index >= data.length) { if (index >= data.length) {
@ -157,12 +188,36 @@ class _DataSource extends DataTableSource {
return DataRow(cells: [ return DataRow(cells: [
DataCell( DataCell(
Text( Text(
item.id.toString(), (index + 1).toString(),
), ),
), ),
DataCell( DataCell(
Text( Text(
item.asset.name.toString(), // item.asset.exit_at.toString(),
item.peti!.customer!.code_customer.toString() +
'-' +
item.peti!.tipe_peti!.type.toString(),
),
),
DataCell(
GestureDetector(
onTap: () {
if (item.id != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPeminjamanBarangPage(
assetId: item.id!,
),
),
);
print('asset id: ${item.id}');
}
},
child: Text(
item.peti!.customer!.name.toString(),
),
), ),
), ),
DataCell( DataCell(
@ -177,7 +232,7 @@ class _DataSource extends DataTableSource {
), ),
), ),
DataCell( DataCell(
Text(item.warehouse.name.toString()), Text(item.warehouse!.name.toString()),
), ),
]); ]);
} }

88
lib/pages/home/setting_page.dart

@ -158,52 +158,50 @@ class SettingPageState extends State<SettingPage> {
AuthProvider authProvider = Provider.of<AuthProvider>(context); AuthProvider authProvider = Provider.of<AuthProvider>(context);
UserModel user = authProvider.user; UserModel user = authProvider.user;
return Theme( return Scaffold(
data: _isDark ? ThemeData.dark() : ThemeData.light(), backgroundColor: Colors.grey[200],
child: Scaffold( appBar: AppBar(
appBar: AppBar( elevation: 0,
elevation: 0, backgroundColor: Colors.indigo[700],
backgroundColor: Colors.indigo[700], title: const Text("Settings"),
title: const Text("Settings"), automaticallyImplyLeading: false,
automaticallyImplyLeading: false, ),
), body: Center(
body: Center( child: Container(
child: Container( constraints: const BoxConstraints(maxWidth: 400),
constraints: const BoxConstraints(maxWidth: 400), child: ListView(
child: ListView( children: [
children: [ SizedBox(
SizedBox( height: 20,
height: 20, ),
), _SingleSection(
_SingleSection( title: "General",
title: "General", children: [
children: [ _CustomListTile(
_CustomListTile( title: "Dark Mode",
title: "Dark Mode", icon: Icons.dark_mode_outlined,
icon: Icons.dark_mode_outlined, trailing: Switch(
trailing: Switch( value: _isDark,
value: _isDark, onChanged: (value) {
onChanged: (value) { setState(() {
setState(() { _isDark = value;
_isDark = value; });
}); },
},
),
),
],
),
const Divider(),
_SingleSection(
children: [
_Logout(
title: "Sign out",
icon: Icons.exit_to_app_rounded,
handleLogout: handleGetLogout,
), ),
], ),
), ],
], ),
), const Divider(),
_SingleSection(
children: [
_Logout(
title: "Sign out",
icon: Icons.exit_to_app_rounded,
handleLogout: handleGetLogout,
),
],
),
],
), ),
), ),
), ),

521
lib/pages/peminjaman_barang/create.dart

@ -2,7 +2,7 @@ import 'dart:convert';
import 'dart:core'; import 'dart:core';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; // import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart';
@ -10,6 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:siopas/models/m_asset_status_model.dart'; import 'package:siopas/models/m_asset_status_model.dart';
import 'package:siopas/models/warehouse_mode.dart'; import 'package:siopas/models/warehouse_mode.dart';
import 'package:siopas/providers/asset_status_provider.dart'; import 'package:siopas/providers/asset_status_provider.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import '../../connection/connection.dart'; import '../../connection/connection.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
@ -27,14 +28,16 @@ class CreatePeminjamanBarang extends StatefulWidget {
} }
class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> { class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
List<M_assetStatusModel> _dataAsset = []; List<PetiAssetModel> _dataAsset = [];
List<WarehouseModel> _dataWarehouse = []; List<WarehouseModel> _dataWarehouse = [];
bool _isLoading = false; bool _isLoading = false;
String? token; String? token;
M_assetStatusModel? _valAsset; PetiAssetModel? _valAsset;
WarehouseModel? _valWarehouse; WarehouseModel? _valWarehouse;
TextEditingController _tanggalController = TextEditingController(); TextEditingController _exit_atController = TextEditingController();
TextEditingController _est_pengembalianController = TextEditingController();
TextEditingController _penanggungJawabController = TextEditingController(); TextEditingController _penanggungJawabController = TextEditingController();
final _formKey = GlobalKey<FormState>();
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
Barcode? result; Barcode? result;
@ -62,15 +65,15 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
_isLoading = true; _isLoading = true;
}); });
final response = await http.get(Uri.parse('$baseUrl/m-asset')); final response = await http.get(Uri.parse('$baseUrl/peti-asset'));
if (mounted) { if (mounted) {
// Periksa apakah widget masih "mounted" // Periksa apakah widget masih "mounted"
if (response.statusCode == 200) { if (response.statusCode == 200) {
final jsonData = json.decode(response.body)['data']['asset']; final jsonData = json.decode(response.body)['data']['asset'];
final List<M_assetStatusModel> newDataAsset = (jsonData as List) final List<PetiAssetModel> newDataAsset = (jsonData as List)
.map((item) => M_assetStatusModel.fromJson(item)) .map((item) => PetiAssetModel.fromJson(item))
.toList(); .toList();
if (mounted) { if (mounted) {
@ -136,11 +139,11 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
List<String> lines = result!.code!.split('\n'); List<String> lines = result!.code!.split('\n');
for (String line in lines) { for (String line in lines) {
if (line.startsWith('ID Asset:')) { if (line.startsWith('ID Peti')) {
String idAsset = line.split(': ')[1]; String idPeti = line.split(': ')[1];
// Isi formulir dropdown asset // Isi formulir dropdown asset
_valAsset = _dataAsset _valAsset = _dataAsset
.firstWhere((asset) => asset.id == int.parse(idAsset)); .firstWhere((peti) => peti.id == int.parse(idPeti));
} else if (line.startsWith('Date:')) { } else if (line.startsWith('Date:')) {
String datePeminjaman = line.split(': ')[1]; String datePeminjaman = line.split(': ')[1];
try { try {
@ -148,12 +151,12 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
DateFormat('dd-MM-yyyy').parse(datePeminjaman); DateFormat('dd-MM-yyyy').parse(datePeminjaman);
String formattedDate = String formattedDate =
DateFormat('yyyy-MM-dd HH:mm:ss.SSS').format(parsedDate); DateFormat('yyyy-MM-dd HH:mm:ss.SSS').format(parsedDate);
_tanggalController.text = formattedDate; _exit_atController.text = formattedDate;
} catch (e) { } catch (e) {
print('Error parsing date: $e'); print('Error parsing date: $e');
// Lakukan penanganan jika format tanggal tidak sesuai // Lakukan penanganan jika format tanggal tidak sesuai
} }
} else if (line.startsWith('ID WH:')) { } else if (line.startsWith('ID Warehouse')) {
String idWarehouse = line.split(': ')[1]; String idWarehouse = line.split(': ')[1];
// Isi formulir dropdown gudang // Isi formulir dropdown gudang
_valWarehouse = _dataWarehouse.firstWhere( _valWarehouse = _dataWarehouse.firstWhere(
@ -206,10 +209,11 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
'Authorization': token!, 'Authorization': token!,
}, },
body: jsonEncode({ body: jsonEncode({
'asset_id': _valAsset!.id, 'peti_id': _valAsset!.id,
'exit_at': _tanggalController.text, 'exit_at': _exit_atController.text,
'exit_pic': _penanggungJawabController.text, 'exit_pic': _penanggungJawabController.text,
'exit_warehouse': _valWarehouse!.id, 'exit_warehouse': _valWarehouse!.id,
'est_pengembalian': _est_pengembalianController.text,
'created_by': user.id, 'created_by': user.id,
'updated_by': user.id, 'updated_by': user.id,
}), }),
@ -239,15 +243,13 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
); );
// Reset form input // Reset form input
_tanggalController.text = ''; _exit_atController.text = '';
_penanggungJawabController.text = '';
_valAsset = null; _valAsset = null;
_valWarehouse = null; _valWarehouse = null;
result = null; result = null;
} else { } else {
// Reset form input // Reset form input
_tanggalController.text = ''; _exit_atController.text = '';
_penanggungJawabController.text = '';
_valAsset = null; _valAsset = null;
_valWarehouse = null; _valWarehouse = null;
result = null; result = null;
@ -282,6 +284,7 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.indigo[700], backgroundColor: Colors.indigo[700],
elevation: 0, elevation: 0,
title: Text('Buat Peminjaman Barang', title: Text('Buat Peminjaman Barang',
@ -294,127 +297,302 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
: SingleChildScrollView( : SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Form(
children: [ key: _formKey,
Card( child: Column(
elevation: 2, children: [
child: Padding( Row(
padding: const EdgeInsets.all(8), children: [
child: DropdownButtonFormField<M_assetStatusModel>( Expanded(
decoration: InputDecoration( child: Card(
labelText: 'Select Asset', elevation: 2,
border: OutlineInputBorder(), child: Container(
margin: EdgeInsets.all(8),
child: DropdownButtonFormField<PetiAssetModel>(
validator: (value) {
if (value == null) {
return 'Harus diisi';
}
return null;
},
decoration: InputDecoration(
labelText: 'Peti',
border: OutlineInputBorder(),
),
hint: Text("Pilih Peti"),
value: _valAsset,
items: _dataAsset.map((PetiAssetModel item) {
return DropdownMenuItem<PetiAssetModel>(
child: Text('${item.fix_lot}'),
value: item,
);
}).toList(),
onChanged: (PetiAssetModel? value) {
setState(() {
_valAsset = value;
if (value != null) {
// Set _valWarehouse berdasarkan warehouse_id dari PetiAssetModel
_valWarehouse =
_dataWarehouse.firstWhere(
(warehouse) =>
warehouse.id ==
int.parse(value.warehouse_id
.toString()),
);
}
});
},
),
),
),
),
SizedBox(width: 8), // Spacer antara dua card
Card(
elevation: 2,
child: Container(
margin: EdgeInsets.all(8),
height: MediaQuery.of(context).size.height / 10,
decoration: BoxDecoration(
color: Colors.indigoAccent,
borderRadius: BorderRadius.circular(5),
),
child: IconButton(
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled:
true, // Set modal menjadi fullscreen
builder: (BuildContext context) {
return Stack(
alignment: Alignment.center,
children: [
Container(
height: double.infinity,
width: double.infinity,
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape(
borderColor: Colors.red,
borderRadius: 10,
borderLength: 30,
borderWidth: 10,
cutOutSize: 300,
),
),
),
Positioned(
bottom: 30,
height: 60,
child: Container(
height:
60, // Lebar dan tinggi sesuai kebutuhan
width: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors
.red, // Warna merah untuk close
),
child: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: Icon(
Icons.close,
size: 40,
),
color: Colors.white,
),
),
),
],
);
},
);
},
icon: Icon(
Icons.qr_code,
size: 30,
),
color: Colors.white, // Warna ikon
),
),
),
],
),
SizedBox(height: 16),
Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(8),
child: FormBuilderDateTimePicker(
validator: (value) {
if (_exit_atController.text.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.redAccent[700],
content: Row(
children: [
Icon(
Icons.error_outline,
color: Colors.white,
),
SizedBox(width: 5),
Text('Tanggal Peminjaman harus diisi'),
],
),
duration: Duration(seconds: 2),
),
);
return null; // Return null jika ada kesalahan
}
return null; // Return null jika tidak ada kesalahan
},
controller: _exit_atController,
name: 'tanggal',
inputType: InputType.date,
format: DateFormat('yyyy-MM-dd HH:mm:ss'),
decoration: InputDecoration(
labelText: 'Tanggal Peminjaman',
border: OutlineInputBorder(),
suffixIcon: Icon(Icons.calendar_today),
),
), ),
hint: Text("Select Asset"),
value: _valAsset,
items: _dataAsset.map((M_assetStatusModel item) {
return DropdownMenuItem(
child: Text('${item.name}'),
value: item,
);
}).toList(),
onChanged: (M_assetStatusModel? value) {
setState(() {
_valAsset = value;
});
},
), ),
), ),
), SizedBox(height: 16),
SizedBox(height: 16), Card(
Card( elevation: 2,
elevation: 2, child: Padding(
child: Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: FormBuilderDateTimePicker(
child: FormBuilderDateTimePicker( validator: (value) {
controller: _tanggalController, if (_est_pengembalianController.text.isEmpty) {
name: 'tanggal', ScaffoldMessenger.of(context).showSnackBar(
inputType: InputType.date, SnackBar(
format: DateFormat('yyyy-MM-dd HH:mm:ss'), backgroundColor: Colors.redAccent[700],
decoration: InputDecoration( content: Row(
labelText: 'Tanggal', children: [
border: OutlineInputBorder(), Icon(
suffixIcon: Icon(Icons.calendar_today), Icons.error_outline,
color: Colors.white,
),
SizedBox(width: 5),
Text(
'Estimasi Tanggal Pengembalian harus diisi'),
],
),
duration: Duration(seconds: 2),
),
);
return null; // Return null jika ada kesalahan
}
return null; // Return null jika tidak ada kesalahan
},
controller: _est_pengembalianController,
name: 'tanggal',
inputType: InputType.date,
format: DateFormat('yyyy-MM-dd HH:mm:ss'),
decoration: InputDecoration(
labelText: 'Estimasi Tanggal Pengembalian',
border: OutlineInputBorder(),
suffixIcon: Icon(Icons.calendar_today),
),
), ),
), ),
), ),
), SizedBox(height: 16),
SizedBox(height: 16), Card(
Card( elevation: 2,
elevation: 2, child: Padding(
child: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: TextField( child: TextFormField(
controller: _penanggungJawabController = controller: _penanggungJawabController =
TextEditingController(text: user.fullname), TextEditingController(text: user.fullname),
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Penanggung Jawab', labelText: 'Penanggung Jawab',
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
)), validator: (value) {
), if (value == null || value.isEmpty) {
SizedBox(height: 16), return 'Harus diisi';
Card( }
elevation: 2, return null; // Return null jika tidak ada kesalahan
child: Padding( },
padding: const EdgeInsets.all(8),
child: DropdownButtonFormField<WarehouseModel>(
decoration: InputDecoration(
labelText: 'Pilih Gudang',
border: OutlineInputBorder(),
), ),
hint: Text("Pilih Gudang"),
value: _valWarehouse,
items: _dataWarehouse.map((WarehouseModel warehouse) {
return DropdownMenuItem(
child: Text('${warehouse.name}'),
value: warehouse,
);
}).toList(),
onChanged: (WarehouseModel? value) {
setState(() {
_valWarehouse = value;
});
},
), ),
), ),
), SizedBox(height: 16),
SizedBox(height: 16), Card(
FractionallySizedBox( elevation: 2,
widthFactor: 1.0, // Lebar penuh
child: Card(
elevation: 1,
child: Padding( child: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Column( child: DropdownButtonFormField<WarehouseModel>(
children: [ validator: (value) {
Text( if (value == null) {
'Data dari QR Code:', return 'Harus diisi';
style: TextStyle( }
fontSize: 16, return null;
fontWeight: FontWeight.bold, },
decoration: InputDecoration(
labelText: 'Pilih Gudang',
border: OutlineInputBorder(),
),
hint: Text("Pilih Gudang"),
value: _valWarehouse,
items:
_dataWarehouse.map((WarehouseModel warehouse) {
return DropdownMenuItem<WarehouseModel>(
child: Text('${warehouse.name}'),
value: warehouse,
);
}).toList(),
onChanged: (WarehouseModel? value) {
setState(() {
_valWarehouse = value;
});
},
),
),
),
SizedBox(height: 16),
FractionallySizedBox(
widthFactor: 1.0, // Lebar penuh
child: Card(
elevation: 1,
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: [
Text(
'Data dari QR Code:',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
), ),
), SizedBox(height: 8),
SizedBox(height: 8), Text(
Text( result != null
result != null ? result!.code ??
? result!.code ?? 'Belum ada data QR Code terpindai'
'Belum ada data QR Code terpindai' : 'Belum ada data QR Code terpindai',
: 'Belum ada data QR Code terpindai', style: TextStyle(fontSize: 14),
style: TextStyle(fontSize: 14), ),
), ],
], ),
), ),
), ),
), ),
), ],
], ),
), ),
), ),
), ),
bottomNavigationBar: BottomAppBar( bottomNavigationBar: BottomAppBar(
height: MediaQuery.of(context).size.height / 8, height: MediaQuery.of(context).size.height / 8,
color: Colors.white, // Warna latar belakang color: Color.fromARGB(255, 5, 28, 158), // Warna latar belakang
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -432,7 +610,8 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
), ),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
Navigator.pop(context); // Navigator.pop(context);
Navigator.pushNamed(context, '/peminjaman-barang');
}, },
icon: Icon(Icons.close, color: Colors.white), icon: Icon(Icons.close, color: Colors.white),
), ),
@ -440,58 +619,58 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
], ],
), ),
), ),
Container( // Container(
// width: 50, // Lebar sesuai kebutuhan // // width: 50, // Lebar sesuai kebutuhan
width: MediaQuery.of(context).size.width / 3, // width: 65.0,
height: 50, // Tinggi sesuai kebutuhan // height: 50, // Tinggi sesuai kebutuhan
decoration: BoxDecoration( // decoration: BoxDecoration(
color: Colors.indigoAccent, // Warna latar belakang // color: Colors.indigoAccent, // Warna latar belakang
shape: BoxShape.circle, // Membuat lingkaran // shape: BoxShape.circle, // Membuat lingkaran
), // ),
child: IconButton( // child: IconButton(
onPressed: () { // onPressed: () {
showModalBottomSheet( // showModalBottomSheet(
context: context, // context: context,
builder: (BuildContext context) { // builder: (BuildContext context) {
return Stack( // return Stack(
alignment: Alignment.center, // alignment: Alignment.center,
children: [ // children: [
Container( // Container(
height: double.infinity, // height: double.infinity,
width: double.infinity, // width: double.infinity,
child: QRView( // child: QRView(
key: qrKey, // key: qrKey,
onQRViewCreated: _onQRViewCreated, // onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape( // overlay: QrScannerOverlayShape(
borderColor: Colors.red, // borderColor: Colors.red,
borderRadius: 10, // borderRadius: 10,
borderLength: 30, // borderLength: 30,
borderWidth: 10, // borderWidth: 10,
cutOutSize: 300, // cutOutSize: 300,
), // ),
), // ),
), // ),
Positioned( // Positioned(
bottom: 16, // bottom: 16,
child: ElevatedButton( // child: ElevatedButton(
onPressed: () { // onPressed: () {
Navigator.of(context).pop(); // Navigator.of(context).pop();
}, // },
child: Text('Tutup'), // child: Text('Tutup'),
), // ),
), // ),
], // ],
); // );
}, // },
); // );
}, // },
icon: Icon( // icon: Icon(
Icons.qr_code, // Icons.qr_code,
size: 30, // size: 30,
), // ),
color: Colors.white, // Warna ikon // color: Colors.white, // Warna ikon
), // ),
), // ),
Container( Container(
width: MediaQuery.of(context).size.width / 3, width: MediaQuery.of(context).size.width / 3,
child: Column( child: Column(
@ -506,10 +685,14 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
), ),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
try { if (_formKey.currentState!.validate()) {
_storePeminjaman(); try {
} catch (e) { if (_exit_atController.text.isNotEmpty) {
print('Error storing data: $e'); _storePeminjaman();
}
} catch (e) {
print('Error storing data: $e');
}
} }
}, },
icon: Icon(Icons.save, color: Colors.white), icon: Icon(Icons.save, color: Colors.white),

148
lib/pages/peminjaman_barang/show.dart

@ -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),
],
),
);
}
}

85
lib/pages/sign_in_page.dart

@ -28,9 +28,9 @@ class _SignInPageState extends State<SignInPage> {
UserModel user = authProvider.user; UserModel user = authProvider.user;
handleSignIn() async { handleSignIn() async {
setState(() { // setState(() {
isLoading = true; // isLoading = true;
}); // });
if (await authProvider.login( if (await authProvider.login(
email: emailController.text, email: emailController.text,
@ -40,7 +40,7 @@ class _SignInPageState extends State<SignInPage> {
// Simpan token pengguna ke SharedPreferences // Simpan token pengguna ke SharedPreferences
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('token', user.token!); // Pastikan user.token tidak null prefs.setString('token', user.token!); // Pastikan user.token tidak null
print('token dapat login: ${user.token}'); // print('token dapat login: ${user.token}');
// Periksa apakah pengguna memiliki roles // Periksa apakah pengguna memiliki roles
if (user.role_id == "1") { if (user.role_id == "1") {
@ -64,9 +64,9 @@ class _SignInPageState extends State<SignInPage> {
); );
} }
setState(() { // setState(() {
isLoading = false; // isLoading = false;
}); // });
} }
Widget header() { Widget header() {
@ -74,13 +74,9 @@ class _SignInPageState extends State<SignInPage> {
margin: EdgeInsets.only(top: 30), margin: EdgeInsets.only(top: 30),
child: Column( child: Column(
children: [ children: [
// Image.asset( Image.asset(
// 'assets/gps_samara.jpeg', 'assets/logo_login.png',
// height: 100, // Sesuaikan tinggi gambar sesuai kebutuhan height: 100, // Sesuaikan tinggi gambar sesuai kebutuhan
// ),
FlutterLogo(
size: 100,
), ),
SizedBox(height: 10), SizedBox(height: 10),
Text( Text(
@ -254,11 +250,35 @@ class _Logo extends StatelessWidget {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
FlutterLogo(size: isSmallScreen ? 100 : 200), // FlutterLogo(size: isSmallScreen ? 100 : 200),
Container(
margin: EdgeInsets.only(top: 30),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(10), // Mengatur sudut menjadi bulat
border: Border.all(
color: Colors.black, // Warna garis tepi
width: 2, // Lebar garis tepi
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
child: Image.asset(
'assets/logo_login.png',
height: isSmallScreen ? 100 : 200,
),
),
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Text( child: Text(
"Welcome to Flutter!", "Welcome To Siopas!",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: isSmallScreen style: isSmallScreen
? Theme.of(context).textTheme.headline5 ? Theme.of(context).textTheme.headline5
@ -267,7 +287,8 @@ class _Logo extends StatelessWidget {
.headline4 .headline4
?.copyWith(color: Colors.black), ?.copyWith(color: Colors.black),
), ),
) ),
SizedBox(height: 2),
], ],
); );
} }
@ -396,20 +417,20 @@ class __FormContentState extends State<_FormContent> {
)), )),
), ),
// _gap(), // _gap(),
CheckboxListTile( // CheckboxListTile(
value: _rememberMe, // value: _rememberMe,
onChanged: (value) { // onChanged: (value) {
if (value == null) return; // if (value == null) return;
setState(() { // setState(() {
_rememberMe = value; // _rememberMe = value;
}); // });
}, // },
title: const Text('Remember me'), // title: const Text('Remember me'),
controlAffinity: ListTileControlAffinity.leading, // controlAffinity: ListTileControlAffinity.leading,
dense: true, // dense: true,
contentPadding: const EdgeInsets.all(0), // contentPadding: const EdgeInsets.all(0),
), // ),
// _gap(), _gap(),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: ElevatedButton( child: ElevatedButton(
@ -420,7 +441,7 @@ class __FormContentState extends State<_FormContent> {
child: const Padding( child: const Padding(
padding: EdgeInsets.all(10.0), padding: EdgeInsets.all(10.0),
child: Text( child: Text(
'Sign in', 'Login',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
), ),
), ),

11
lib/pages/splash_page.dart

@ -93,12 +93,11 @@ class _SplashPageState extends State<SplashPage> {
child: Container( child: Container(
width: 130, width: 130,
height: 150, height: 150,
child: FlutterLogo(), decoration: BoxDecoration(
// decoration: BoxDecoration( image: DecorationImage(
// image: DecorationImage( image: AssetImage('assets/logo_login.png'),
// image: AssetImage('assets/gps_samara.jpeg'), ),
// ), ),
// ),
), ),
), ),
); );

6
lib/services/m_status_service.dart

@ -7,7 +7,7 @@ import 'dart:convert';
import 'dart:async'; import 'dart:async';
class M_assetStatusService { class M_assetStatusService {
Future<List<M_assetStatusModel>> getAssetStatus() async { Future<List<PetiAssetModel>> getAssetStatus() async {
var url = Uri.parse("$baseUrl/m-status"); var url = Uri.parse("$baseUrl/m-status");
var headers = {'Content-Type': 'application/json'}; var headers = {'Content-Type': 'application/json'};
@ -18,11 +18,11 @@ class M_assetStatusService {
if (response.statusCode == 200) { if (response.statusCode == 200) {
List data = jsonDecode(response.body)['data']['asset']; List data = jsonDecode(response.body)['data']['asset'];
List<M_assetStatusModel> m_assetStatus = []; List<PetiAssetModel> m_assetStatus = [];
if (data != null) { if (data != null) {
for (var item in data) { for (var item in data) {
m_assetStatus.add(M_assetStatusModel.fromJson(item)); m_assetStatus.add(PetiAssetModel.fromJson(item));
} }
} }

8
pubspec.lock

@ -89,14 +89,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.5.8" version: "2.5.8"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1
url: "https://pub.dev"
source: hosted
version: "2.3.9"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:

6
pubspec.yaml

@ -45,7 +45,7 @@ dependencies:
qr_code_scanner: ^1.0.1 qr_code_scanner: ^1.0.1
data_table_2: ^2.5.8 data_table_2: ^2.5.8
flutter_form_builder: ^9.1.1 flutter_form_builder: ^9.1.1
dropdown_button2: ^2.3.9 # dropdown_button2: ^2.3.9
dev_dependencies: dev_dependencies:
@ -71,8 +71,8 @@ flutter:
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: assets:
# - images/a_dot_burr.jpeg - assets/
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see

Loading…
Cancel
Save