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

@ -21,8 +21,9 @@ class GasRefillModel {
String signatureEngineer;
Uint8List localNurseSignature;
Uint8List localEngineerSignature;
num workingHours;
DateTime startDate, endDate, expectedDate;
GasRefillModel({
this.id,
//this.userId,
@ -41,6 +42,7 @@ class GasRefillModel {
this.signatureEngineer,
this.localEngineerSignature,
this.localNurseSignature,
this.workingHours,
});
bool validate() {
@ -73,6 +75,7 @@ class GasRefillModel {
localNurseSignature = model.localNurseSignature;
signatureEngineer = model.signatureEngineer;
signatureNurse = model.signatureNurse;
workingHours = model.workingHours;
}
factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) {
@ -97,6 +100,7 @@ class GasRefillModel {
assignedEmployee: AssignedEmployee.fromJson(parsedJson['assignedEmployee'] ?? {}),
signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]),
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 '../../../../models/enums/user_types.dart';
import '../../../widgets/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart';
class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill";
@ -275,11 +276,31 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
},
),
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)
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const ASubTitle("Expected Date Time"),
const ASubTitle("Expected Date"),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),

Loading…
Cancel
Save