54 lines
1.5 KiB
Dart
54 lines
1.5 KiB
Dart
class DailyAccessApproval {
|
|
final String id;
|
|
final String userId;
|
|
final DateTime approvalDate;
|
|
final String status; // pending | approved | rejected
|
|
final String? approvedBy;
|
|
final DateTime? approvedAt;
|
|
final String? ipAddress;
|
|
final double? locationLat;
|
|
final double? locationLng;
|
|
|
|
DailyAccessApproval({
|
|
required this.id,
|
|
required this.userId,
|
|
required this.approvalDate,
|
|
required this.status,
|
|
this.approvedBy,
|
|
this.approvedAt,
|
|
this.ipAddress,
|
|
this.locationLat,
|
|
this.locationLng,
|
|
});
|
|
|
|
factory DailyAccessApproval.fromMap(Map<String, dynamic> map) {
|
|
return DailyAccessApproval(
|
|
id: map['id'] ?? '',
|
|
userId: map['user_id'] ?? '',
|
|
approvalDate: DateTime.tryParse(map['approval_date'] ?? '') ?? DateTime.now(),
|
|
status: map['status'] ?? 'pending',
|
|
approvedBy: map['approved_by'],
|
|
approvedAt: map['approved_at'] != null
|
|
? DateTime.tryParse(map['approved_at'])
|
|
: null,
|
|
ipAddress: map['ip_address'],
|
|
locationLat: map['location_lat']?.toDouble(),
|
|
locationLng: map['location_lng']?.toDouble(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'user_id': userId,
|
|
'approval_date': approvalDate.toIso8601String().split('T')[0],
|
|
'status': status,
|
|
'approved_by': approvedBy,
|
|
'approved_at': approvedAt?.toIso8601String(),
|
|
'ip_address': ipAddress,
|
|
'location_lat': locationLat,
|
|
'location_lng': locationLng,
|
|
};
|
|
}
|
|
}
|