|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
@ -113,10 +114,10 @@ class GasRefillProvider extends ChangeNotifier {
|
|
|
|
|
"floor": {"id": floor?.id, "name": floor?.name, "value": floor?.value},
|
|
|
|
|
if (expectedDateTime != null) "expectedDate": expectedDateTime?.toIso8601String(),
|
|
|
|
|
if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(),
|
|
|
|
|
if (startDate != null) "startDate": startDate?.toIso8601String(),
|
|
|
|
|
if (startDate != null) "startTime": startDate?.toIso8601String(),
|
|
|
|
|
if (endDate != null) "endDate": endDate?.toIso8601String(),
|
|
|
|
|
if (endDate != null) "endTime": endDate?.toIso8601String(),
|
|
|
|
|
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
|
|
|
|
|
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
|
|
|
|
|
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
|
|
|
|
|
if (timer?.endAt != null) "endTime": timer.endAt.toIso8601String(),
|
|
|
|
|
"department": {"id": department?.id, "departmentName": department?.name, "departmentCode": "", "ntCode": ""},
|
|
|
|
|
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
|
|
|
|
|
"status": model.status.toMap(),
|
|
|
|
|
@ -159,12 +160,12 @@ class GasRefillProvider extends ChangeNotifier {
|
|
|
|
|
"status": newModel.status.toMap(),
|
|
|
|
|
"expectedDate": newModel.expectedDate?.toIso8601String(),
|
|
|
|
|
"expectedTime": newModel.expectedDate?.toIso8601String(),
|
|
|
|
|
"startDate": newModel.startDate?.toIso8601String(),
|
|
|
|
|
"startTime": newModel.startDate?.toIso8601String(),
|
|
|
|
|
"endDate": newModel.endDate?.toIso8601String(),
|
|
|
|
|
"endTime": newModel.endDate?.toIso8601String(),
|
|
|
|
|
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
|
|
|
|
|
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
|
|
|
|
|
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
|
|
|
|
|
if (timer?.endAt != null) "endTime": timer.endAt.toIso8601String(),
|
|
|
|
|
// "workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60),
|
|
|
|
|
'workingHours': newModel.workingHours,
|
|
|
|
|
'workingHours': timer.durationInSecond != null ? timer.durationInSecond / 60 / 60 : newModel.workingHours,
|
|
|
|
|
"assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(),
|
|
|
|
|
"site": hospital?.toMap(),
|
|
|
|
|
"building": building?.toJson(includeFloors: false),
|
|
|
|
|
@ -183,24 +184,25 @@ class GasRefillProvider extends ChangeNotifier {
|
|
|
|
|
"deliverdQty": model.deliveredQuantity,
|
|
|
|
|
})
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
response = await ApiManager.instance.put(URLs.updateGasRefill, body: body);
|
|
|
|
|
// response = await post(
|
|
|
|
|
// Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"),
|
|
|
|
|
// body: body,
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
stateCode = response.statusCode;
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
oldModel.fromGasRefillModel(newModel);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
return response.statusCode;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
log(body.toString());
|
|
|
|
|
return -1;
|
|
|
|
|
// Response response;
|
|
|
|
|
// try {
|
|
|
|
|
// response = await ApiManager.instance.put(URLs.updateGasRefill, body: body);
|
|
|
|
|
// // response = await post(
|
|
|
|
|
// // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"),
|
|
|
|
|
// // body: body,
|
|
|
|
|
// // );
|
|
|
|
|
//
|
|
|
|
|
// stateCode = response.statusCode;
|
|
|
|
|
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
// oldModel.fromGasRefillModel(newModel);
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
// }
|
|
|
|
|
// return response.statusCode;
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// return -1;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Hospital hospital;
|
|
|
|
|
@ -208,7 +210,5 @@ class GasRefillProvider extends ChangeNotifier {
|
|
|
|
|
Floors floor;
|
|
|
|
|
Departments department;
|
|
|
|
|
DateTime expectedDateTime;
|
|
|
|
|
DateTime startDate;
|
|
|
|
|
DateTime endDate;
|
|
|
|
|
TimerModel timer;
|
|
|
|
|
}
|
|
|
|
|
|