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. 175
      lib/pages/home/home_page.dart
  8. 78
      lib/pages/home/main_page.dart
  9. 87
      lib/pages/home/peminjaman_stock_page.dart
  10. 6
      lib/pages/home/setting_page.dart
  11. 359
      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/peminjaman_stock_page.dart';
import 'pages/peminjaman_barang/create.dart';
import 'pages/peminjaman_barang/show.dart';
import 'pages/sign_in_page.dart';
import 'pages/splash_page.dart';
import 'providers/asset_status_provider.dart';
@ -51,6 +52,8 @@ class MyApp extends StatelessWidget {
'/home': (context) => MainPage(),
'/peminjaman-barang': (context) => AssetStatusPage(),
'/peminjaman-barang/create': (context) => CreatePeminjamanBarang(),
// '/peminjaman-barang/show': (context) =>
// DetailPeminjamanBarangPage(assetId: 0),
// '/category': (context) => SurveyDetailPage(),
// '/map': (context) => GeoMapPage(),
},

51
lib/models/asset_status_model.dart

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

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

175
lib/pages/home/home_page.dart

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

78
lib/pages/home/main_page.dart

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

87
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 '../../connection/connection.dart';
import '../peminjaman_barang/show.dart';
class AssetStatusPage extends StatefulWidget {
const AssetStatusPage({super.key});
@ -102,15 +103,12 @@ class AssetStatusPageState extends State<AssetStatusPage> {
style: TextStyle(
fontSize: 16,
)),
actions: [
IconButton(
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
// Tambahkan logika untuk tindakan ketika tombol + ditekan
Navigator.pushNamed(context, '/peminjaman-barang/create');
Navigator.pushNamed(context, '/home');
},
icon: Icon(Icons.add),
),
],
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
@ -128,12 +126,45 @@ class AssetStatusPageState extends State<AssetStatusPage> {
},
columns: const [
DataColumn(label: Text('No')),
DataColumn(label: Text('Asset')),
DataColumn(label: Text('Exit At')),
DataColumn(label: Text('Exit Pic')),
DataColumn(label: Text('Exit warehouse')),
DataColumn(label: Text('Kode Peti')),
DataColumn(label: Text('Nama Customer')),
DataColumn(label: Text('Tgl Peminjaman')),
DataColumn(label: Text('PJ Peminjaman')),
DataColumn(label: Text('Asal Gudang')),
],
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,
),
),
),
],
source: _DataSource(data: _data),
),
),
),
@ -143,9 +174,9 @@ class AssetStatusPageState extends State<AssetStatusPage> {
class _DataSource extends DataTableSource {
final List<AssetStatusModel> data;
final BuildContext context;
_DataSource({required this.data});
_DataSource({required this.data, required this.context});
@override
DataRow? getRow(int index) {
if (index >= data.length) {
@ -157,12 +188,36 @@ class _DataSource extends DataTableSource {
return DataRow(cells: [
DataCell(
Text(
item.id.toString(),
(index + 1).toString(),
),
),
DataCell(
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(
@ -177,7 +232,7 @@ class _DataSource extends DataTableSource {
),
),
DataCell(
Text(item.warehouse.name.toString()),
Text(item.warehouse!.name.toString()),
),
]);
}

6
lib/pages/home/setting_page.dart

@ -158,9 +158,8 @@ class SettingPageState extends State<SettingPage> {
AuthProvider authProvider = Provider.of<AuthProvider>(context);
UserModel user = authProvider.user;
return Theme(
data: _isDark ? ThemeData.dark() : ThemeData.light(),
child: Scaffold(
return Scaffold(
backgroundColor: Colors.grey[200],
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.indigo[700],
@ -206,7 +205,6 @@ class SettingPageState extends State<SettingPage> {
),
),
),
),
);
}
}

359
lib/pages/peminjaman_barang/create.dart

@ -2,7 +2,7 @@ import 'dart:convert';
import 'dart:core';
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:provider/provider.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/warehouse_mode.dart';
import 'package:siopas/providers/asset_status_provider.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import '../../connection/connection.dart';
import 'package:http/http.dart' as http;
@ -27,14 +28,16 @@ class CreatePeminjamanBarang extends StatefulWidget {
}
class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
List<M_assetStatusModel> _dataAsset = [];
List<PetiAssetModel> _dataAsset = [];
List<WarehouseModel> _dataWarehouse = [];
bool _isLoading = false;
String? token;
M_assetStatusModel? _valAsset;
PetiAssetModel? _valAsset;
WarehouseModel? _valWarehouse;
TextEditingController _tanggalController = TextEditingController();
TextEditingController _exit_atController = TextEditingController();
TextEditingController _est_pengembalianController = TextEditingController();
TextEditingController _penanggungJawabController = TextEditingController();
final _formKey = GlobalKey<FormState>();
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
Barcode? result;
@ -62,15 +65,15 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
_isLoading = true;
});
final response = await http.get(Uri.parse('$baseUrl/m-asset'));
final response = await http.get(Uri.parse('$baseUrl/peti-asset'));
if (mounted) {
// Periksa apakah widget masih "mounted"
if (response.statusCode == 200) {
final jsonData = json.decode(response.body)['data']['asset'];
final List<M_assetStatusModel> newDataAsset = (jsonData as List)
.map((item) => M_assetStatusModel.fromJson(item))
final List<PetiAssetModel> newDataAsset = (jsonData as List)
.map((item) => PetiAssetModel.fromJson(item))
.toList();
if (mounted) {
@ -136,11 +139,11 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
List<String> lines = result!.code!.split('\n');
for (String line in lines) {
if (line.startsWith('ID Asset:')) {
String idAsset = line.split(': ')[1];
if (line.startsWith('ID Peti')) {
String idPeti = line.split(': ')[1];
// Isi formulir dropdown asset
_valAsset = _dataAsset
.firstWhere((asset) => asset.id == int.parse(idAsset));
.firstWhere((peti) => peti.id == int.parse(idPeti));
} else if (line.startsWith('Date:')) {
String datePeminjaman = line.split(': ')[1];
try {
@ -148,12 +151,12 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
DateFormat('dd-MM-yyyy').parse(datePeminjaman);
String formattedDate =
DateFormat('yyyy-MM-dd HH:mm:ss.SSS').format(parsedDate);
_tanggalController.text = formattedDate;
_exit_atController.text = formattedDate;
} catch (e) {
print('Error parsing date: $e');
// Lakukan penanganan jika format tanggal tidak sesuai
}
} else if (line.startsWith('ID WH:')) {
} else if (line.startsWith('ID Warehouse')) {
String idWarehouse = line.split(': ')[1];
// Isi formulir dropdown gudang
_valWarehouse = _dataWarehouse.firstWhere(
@ -206,10 +209,11 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
'Authorization': token!,
},
body: jsonEncode({
'asset_id': _valAsset!.id,
'exit_at': _tanggalController.text,
'peti_id': _valAsset!.id,
'exit_at': _exit_atController.text,
'exit_pic': _penanggungJawabController.text,
'exit_warehouse': _valWarehouse!.id,
'est_pengembalian': _est_pengembalianController.text,
'created_by': user.id,
'updated_by': user.id,
}),
@ -239,15 +243,13 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
);
// Reset form input
_tanggalController.text = '';
_penanggungJawabController.text = '';
_exit_atController.text = '';
_valAsset = null;
_valWarehouse = null;
result = null;
} else {
// Reset form input
_tanggalController.text = '';
_penanggungJawabController.text = '';
_exit_atController.text = '';
_valAsset = null;
_valWarehouse = null;
result = null;
@ -282,6 +284,7 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.indigo[700],
elevation: 0,
title: Text('Buat Peminjaman Barang',
@ -294,45 +297,164 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Form(
key: _formKey,
child: Column(
children: [
Card(
Row(
children: [
Expanded(
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(8),
child: DropdownButtonFormField<M_assetStatusModel>(
child: Container(
margin: EdgeInsets.all(8),
child: DropdownButtonFormField<PetiAssetModel>(
validator: (value) {
if (value == null) {
return 'Harus diisi';
}
return null;
},
decoration: InputDecoration(
labelText: 'Select Asset',
labelText: 'Peti',
border: OutlineInputBorder(),
),
hint: Text("Select Asset"),
hint: Text("Pilih Peti"),
value: _valAsset,
items: _dataAsset.map((M_assetStatusModel item) {
return DropdownMenuItem(
child: Text('${item.name}'),
items: _dataAsset.map((PetiAssetModel item) {
return DropdownMenuItem<PetiAssetModel>(
child: Text('${item.fix_lot}'),
value: item,
);
}).toList(),
onChanged: (M_assetStatusModel? value) {
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(
controller: _tanggalController,
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',
labelText: 'Tanggal Peminjaman',
border: OutlineInputBorder(),
suffixIcon: Icon(Icons.calendar_today),
),
@ -344,14 +466,62 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(8),
child: TextField(
child: FormBuilderDateTimePicker(
validator: (value) {
if (_est_pengembalianController.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(
'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),
Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(8),
child: TextFormField(
controller: _penanggungJawabController =
TextEditingController(text: user.fullname),
decoration: InputDecoration(
labelText: 'Penanggung Jawab',
border: OutlineInputBorder(),
),
)),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Harus diisi';
}
return null; // Return null jika tidak ada kesalahan
},
),
),
),
SizedBox(height: 16),
Card(
@ -359,14 +529,21 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
child: Padding(
padding: const EdgeInsets.all(8),
child: DropdownButtonFormField<WarehouseModel>(
validator: (value) {
if (value == null) {
return 'Harus diisi';
}
return null;
},
decoration: InputDecoration(
labelText: 'Pilih Gudang',
border: OutlineInputBorder(),
),
hint: Text("Pilih Gudang"),
value: _valWarehouse,
items: _dataWarehouse.map((WarehouseModel warehouse) {
return DropdownMenuItem(
items:
_dataWarehouse.map((WarehouseModel warehouse) {
return DropdownMenuItem<WarehouseModel>(
child: Text('${warehouse.name}'),
value: warehouse,
);
@ -412,9 +589,10 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
),
),
),
),
bottomNavigationBar: BottomAppBar(
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(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -432,7 +610,8 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
),
child: IconButton(
onPressed: () {
Navigator.pop(context);
// Navigator.pop(context);
Navigator.pushNamed(context, '/peminjaman-barang');
},
icon: Icon(Icons.close, color: Colors.white),
),
@ -440,58 +619,58 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
],
),
),
Container(
// width: 50, // Lebar sesuai kebutuhan
width: MediaQuery.of(context).size.width / 3,
height: 50, // Tinggi sesuai kebutuhan
decoration: BoxDecoration(
color: Colors.indigoAccent, // Warna latar belakang
shape: BoxShape.circle, // Membuat lingkaran
),
child: IconButton(
onPressed: () {
showModalBottomSheet(
context: context,
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: 16,
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Tutup'),
),
),
],
);
},
);
},
icon: Icon(
Icons.qr_code,
size: 30,
),
color: Colors.white, // Warna ikon
),
),
// Container(
// // width: 50, // Lebar sesuai kebutuhan
// width: 65.0,
// height: 50, // Tinggi sesuai kebutuhan
// decoration: BoxDecoration(
// color: Colors.indigoAccent, // Warna latar belakang
// shape: BoxShape.circle, // Membuat lingkaran
// ),
// child: IconButton(
// onPressed: () {
// showModalBottomSheet(
// context: context,
// 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: 16,
// child: ElevatedButton(
// onPressed: () {
// Navigator.of(context).pop();
// },
// child: Text('Tutup'),
// ),
// ),
// ],
// );
// },
// );
// },
// icon: Icon(
// Icons.qr_code,
// size: 30,
// ),
// color: Colors.white, // Warna ikon
// ),
// ),
Container(
width: MediaQuery.of(context).size.width / 3,
child: Column(
@ -506,11 +685,15 @@ class _CreatePeminjamanBarangState extends State<CreatePeminjamanBarang> {
),
child: IconButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
try {
if (_exit_atController.text.isNotEmpty) {
_storePeminjaman();
}
} catch (e) {
print('Error storing data: $e');
}
}
},
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;
handleSignIn() async {
setState(() {
isLoading = true;
});
// setState(() {
// isLoading = true;
// });
if (await authProvider.login(
email: emailController.text,
@ -40,7 +40,7 @@ class _SignInPageState extends State<SignInPage> {
// Simpan token pengguna ke SharedPreferences
SharedPreferences prefs = await SharedPreferences.getInstance();
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
if (user.role_id == "1") {
@ -64,9 +64,9 @@ class _SignInPageState extends State<SignInPage> {
);
}
setState(() {
isLoading = false;
});
// setState(() {
// isLoading = false;
// });
}
Widget header() {
@ -74,13 +74,9 @@ class _SignInPageState extends State<SignInPage> {
margin: EdgeInsets.only(top: 30),
child: Column(
children: [
// Image.asset(
// 'assets/gps_samara.jpeg',
// height: 100, // Sesuaikan tinggi gambar sesuai kebutuhan
// ),
FlutterLogo(
size: 100,
Image.asset(
'assets/logo_login.png',
height: 100, // Sesuaikan tinggi gambar sesuai kebutuhan
),
SizedBox(height: 10),
Text(
@ -254,11 +250,35 @@ class _Logo extends StatelessWidget {
return Column(
mainAxisSize: MainAxisSize.min,
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: const EdgeInsets.all(16.0),
child: Text(
"Welcome to Flutter!",
"Welcome To Siopas!",
textAlign: TextAlign.center,
style: isSmallScreen
? Theme.of(context).textTheme.headline5
@ -267,7 +287,8 @@ class _Logo extends StatelessWidget {
.headline4
?.copyWith(color: Colors.black),
),
)
),
SizedBox(height: 2),
],
);
}
@ -396,20 +417,20 @@ class __FormContentState extends State<_FormContent> {
)),
),
// _gap(),
CheckboxListTile(
value: _rememberMe,
onChanged: (value) {
if (value == null) return;
setState(() {
_rememberMe = value;
});
},
title: const Text('Remember me'),
controlAffinity: ListTileControlAffinity.leading,
dense: true,
contentPadding: const EdgeInsets.all(0),
),
// _gap(),
// CheckboxListTile(
// value: _rememberMe,
// onChanged: (value) {
// if (value == null) return;
// setState(() {
// _rememberMe = value;
// });
// },
// title: const Text('Remember me'),
// controlAffinity: ListTileControlAffinity.leading,
// dense: true,
// contentPadding: const EdgeInsets.all(0),
// ),
_gap(),
SizedBox(
width: double.infinity,
child: ElevatedButton(
@ -420,7 +441,7 @@ class __FormContentState extends State<_FormContent> {
child: const Padding(
padding: EdgeInsets.all(10.0),
child: Text(
'Sign in',
'Login',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
),

11
lib/pages/splash_page.dart

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

6
lib/services/m_status_service.dart

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

6
pubspec.yaml

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

Loading…
Cancel
Save