In track gas refill update:

- add timer for working hours.
 - enable the engineer to add start and end date.
main_design2.0
zaid_daoud 2 years ago
parent b8f2a72cad
commit bec9c38269

@ -6,6 +6,7 @@ import 'package:test_sa/controllers/api_routes/api_manager.dart';
import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/models/user.dart'; import 'package:test_sa/models/user.dart';
class GasRefillProvider extends ChangeNotifier { class GasRefillProvider extends ChangeNotifier {
@ -158,11 +159,12 @@ class GasRefillProvider extends ChangeNotifier {
"status": newModel.status.toMap(), "status": newModel.status.toMap(),
"expectedDate": newModel.expectedDate?.toIso8601String(), "expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate?.toIso8601String(), "expectedTime": newModel.expectedDate?.toIso8601String(),
"startDate": startDate?.toIso8601String(), "startDate": newModel.startDate?.toIso8601String(),
"startTime": startDate?.toIso8601String(), "startTime": newModel.startDate?.toIso8601String(),
"endDate": endDate?.toIso8601String(), "endDate": newModel.endDate?.toIso8601String(),
"endTime": endDate?.toIso8601String(), "endTime": newModel.endDate?.toIso8601String(),
"workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60), // "workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60),
'workingHours': newModel.workingHours,
"assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(), "assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(),
"site": hospital?.toMap(), "site": hospital?.toMap(),
"building": building?.toJson(includeFloors: false), "building": building?.toJson(includeFloors: false),
@ -208,4 +210,5 @@ class GasRefillProvider extends ChangeNotifier {
DateTime expectedDateTime; DateTime expectedDateTime;
DateTime startDate; DateTime startDate;
DateTime endDate; DateTime endDate;
TimerModel timer;
} }

@ -21,8 +21,9 @@ class GasRefillModel {
String signatureEngineer; String signatureEngineer;
Uint8List localNurseSignature; Uint8List localNurseSignature;
Uint8List localEngineerSignature; Uint8List localEngineerSignature;
num workingHours;
DateTime startDate, endDate, expectedDate; DateTime startDate, endDate, expectedDate;
GasRefillModel({ GasRefillModel({
this.id, this.id,
//this.userId, //this.userId,
@ -41,6 +42,7 @@ class GasRefillModel {
this.signatureEngineer, this.signatureEngineer,
this.localEngineerSignature, this.localEngineerSignature,
this.localNurseSignature, this.localNurseSignature,
this.workingHours,
}); });
bool validate() { bool validate() {
@ -73,6 +75,7 @@ class GasRefillModel {
localNurseSignature = model.localNurseSignature; localNurseSignature = model.localNurseSignature;
signatureEngineer = model.signatureEngineer; signatureEngineer = model.signatureEngineer;
signatureNurse = model.signatureNurse; signatureNurse = model.signatureNurse;
workingHours = model.workingHours;
} }
factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) { factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) {
@ -97,6 +100,7 @@ class GasRefillModel {
assignedEmployee: AssignedEmployee.fromJson(parsedJson['assignedEmployee'] ?? {}), assignedEmployee: AssignedEmployee.fromJson(parsedJson['assignedEmployee'] ?? {}),
signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]), signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]),
signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]), signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]),
workingHours: parsedJson["workingHours"],
); );
} }
} }

@ -32,6 +32,7 @@ import '../../../../controllers/localization/localization.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart'; import '../../../../controllers/providers/api/hospitals_provider.dart';
import '../../../../models/enums/user_types.dart'; import '../../../../models/enums/user_types.dart';
import '../../../widgets/e_signature/e_signature.dart'; import '../../../widgets/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart';
class RequestGasRefill extends StatefulWidget { class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill"; static const String id = "/request-gas-refill";
@ -275,11 +276,31 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}, },
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
ASubTitle(_subtitle.workingHours),
if (widget.gasRefillModel != null) const SizedBox(height: 8),
if (widget.gasRefillModel != null)
Row(
children: [
Expanded(
child: AppTimer(
timer: _gasRefillProvider.timer,
onChange: (timer) async {
_gasRefillProvider.timer = timer;
_formModel.startDate ??= timer.startAt;
_gasRefillProvider.endDate = timer.endAt;
_formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
return true;
},
),
),
],
),
const SizedBox(height: 8),
if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null) if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
Column( Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const ASubTitle("Expected Date Time"), const ASubTitle("Expected Date"),
SizedBox( SizedBox(
height: 8 * AppStyle.getScaleFactor(context), height: 8 * AppStyle.getScaleFactor(context),
), ),

Loading…
Cancel
Save