diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index e2401668..faf84d66 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -158,6 +158,8 @@ class GasRefillProvider extends ChangeNotifier { "building": building?.toJson(includeFloors: false), "floor": floor?.toJson(includeDepartments: false), "department": department?.toJson(), + "engSignature": newModel.signatureEngineer, + "nurseSignature": newModel.signatureNurse, }; body["gazRefillDetails"] = newModel.details diff --git a/lib/models/gas_refill/gas_refill_model.dart b/lib/models/gas_refill/gas_refill_model.dart index 13a6e6b8..291ee5ad 100644 --- a/lib/models/gas_refill/gas_refill_model.dart +++ b/lib/models/gas_refill/gas_refill_model.dart @@ -1,6 +1,9 @@ +import 'dart:typed_data'; + import 'package:test_sa/models/gas_refill/gas_refill_details.dart'; import 'package:test_sa/models/lookup.dart'; +import '../../controllers/api_routes/urls.dart'; import '../call_request_for_work_order_model.dart'; class GasRefillModel { @@ -14,6 +17,10 @@ class GasRefillModel { Department department; List details; AssignedEmployee assignedEmployee; + String signatureNurse; + String signatureEngineer; + Uint8List localNurseSignature; + Uint8List localEngineerSignature; DateTime startDate, endDate, expectedDate; GasRefillModel({ @@ -30,6 +37,10 @@ class GasRefillModel { this.expectedDate, this.department, this.assignedEmployee, + this.signatureNurse, + this.signatureEngineer, + this.localEngineerSignature, + this.localNurseSignature, }); bool validate() { @@ -58,6 +69,10 @@ class GasRefillModel { endDate = model.endDate; expectedDate = model.expectedDate; assignedEmployee = model.assignedEmployee; + localEngineerSignature = model.localEngineerSignature; + localNurseSignature = model.localNurseSignature; + signatureEngineer = model.signatureEngineer; + signatureNurse = model.signatureNurse; } factory GasRefillModel.fromJson(Map parsedJson) { @@ -80,6 +95,8 @@ class GasRefillModel { endDate: DateTime.tryParse(parsedJson['endDate'] ?? ""), expectedDate: DateTime.tryParse(parsedJson['expectedDate'] ?? ""), assignedEmployee: AssignedEmployee.fromJson(parsedJson['assignedEmployee'] ?? {}), + signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]), + signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]), ); } } diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index a5f2e15e..cb186466 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; @@ -29,6 +31,7 @@ import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; 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'; class RequestGasRefill extends StatefulWidget { static const String id = "/request-gas-refill"; @@ -483,14 +486,43 @@ class _RequestGasRefillState extends State { }, ); }), + if (widget.gasRefillModel != null) const SizedBox(height: 16), + if (widget.gasRefillModel != null) const ASubTitle("Nurse Signature"), + if (widget.gasRefillModel != null) + ESignature( + oldSignature: _formModel.signatureNurse, + newSignature: _formModel.localNurseSignature, + onChange: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + _formModel.localNurseSignature = signature; + _formModel.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), + if (widget.gasRefillModel != null) + const SizedBox( + height: 8, + ), + if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"), + if (widget.gasRefillModel != null) + ESignature( + oldSignature: _formModel.signatureEngineer, + newSignature: _formModel.localNurseSignature, + onChange: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + _formModel.localNurseSignature = signature; + _formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), const SizedBox(height: 16), AButton( text: widget.gasRefillModel == null ? _subtitle.submit : _subtitle.update, onPressed: _onSubmit, ), - const SizedBox( - height: 100, - ) + const SizedBox(height: 100) ], ), ),