|
|
|
|
@ -134,7 +134,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
var body = {
|
|
|
|
|
"id": 0,
|
|
|
|
|
"calNo": "",
|
|
|
|
|
"callCreatedBy": {"id": user.id, "name": user.userName},
|
|
|
|
|
"callCreatedBy": {"id": user.id, "name": user.userName ?? ""},
|
|
|
|
|
"assets": serviceRequest.deviceId == null ? [] : [serviceRequest.deviceId],
|
|
|
|
|
"requestedDate": DateTime.now().toIso8601String(),
|
|
|
|
|
"requestedTime": DateTime.now().toIso8601String(),
|
|
|
|
|
@ -150,7 +150,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"callSiteContactPerson": [
|
|
|
|
|
{
|
|
|
|
|
"id": 0,
|
|
|
|
|
"employeeCode": user.email,
|
|
|
|
|
// "employeeCode": user.email,
|
|
|
|
|
"name": user.userName,
|
|
|
|
|
"telephone": user.phoneNumber,
|
|
|
|
|
// "job": "",
|
|
|
|
|
@ -215,12 +215,15 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
@required ServiceRequest request,
|
|
|
|
|
DateTime date,
|
|
|
|
|
}) async {
|
|
|
|
|
String callNo = await getServiceRequestCallNoById(requestId: request.id) ?? "";
|
|
|
|
|
Map<String, dynamic> serviceRequest = await getServiceRequestById(requestId: request.id) ?? "";
|
|
|
|
|
final List callSiteContacts = (serviceRequest['callSiteContactPerson'] as List);
|
|
|
|
|
final Map<String, dynamic> callSiteContactPerson = callSiteContacts.isEmpty ? {} : callSiteContacts[0];
|
|
|
|
|
print(callSiteContactPerson);
|
|
|
|
|
Response response;
|
|
|
|
|
var body = {
|
|
|
|
|
"id": request.id,
|
|
|
|
|
"callNo": callNo,
|
|
|
|
|
"callCreatedBy": {"id": user.id, "name": user.userName},
|
|
|
|
|
"callNo": serviceRequest['callNo'],
|
|
|
|
|
"callCreatedBy": serviceRequest['callCreatedBy'],
|
|
|
|
|
"requestedDate": date?.toIso8601String() ?? "",
|
|
|
|
|
"requestedTime": date?.toIso8601String() ?? "",
|
|
|
|
|
"priority": request.priority?.toMap(),
|
|
|
|
|
@ -232,13 +235,13 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"attachmentsCallRequest": request.devicePhotos?.map((e) => {"name": e})?.toList(),
|
|
|
|
|
"callSiteContactPerson": [
|
|
|
|
|
{
|
|
|
|
|
"id": 0,
|
|
|
|
|
"employeeCode": user.email,
|
|
|
|
|
"name": user.userName,
|
|
|
|
|
"telephone": user.phoneNumber,
|
|
|
|
|
// "job": "",
|
|
|
|
|
"email": user.email,
|
|
|
|
|
// "land": "",
|
|
|
|
|
"id": callSiteContactPerson['id'] ?? 0,
|
|
|
|
|
"employeeCode": callSiteContactPerson['employeeCode'],
|
|
|
|
|
"name": callSiteContactPerson['name'] ?? user.userName,
|
|
|
|
|
"telephone": callSiteContactPerson['telephone'] ?? user.phoneNumber,
|
|
|
|
|
"job": callSiteContactPerson['job'],
|
|
|
|
|
"email": callSiteContactPerson['email'] ?? user.email,
|
|
|
|
|
"land": callSiteContactPerson['land'],
|
|
|
|
|
"contactUserId": user.id,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
@ -249,8 +252,8 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
"firstAction": request.firstAction?.toMap(),
|
|
|
|
|
"loanAvailablity": request.loanAvailability?.toMap(),
|
|
|
|
|
"comments": request.comment,
|
|
|
|
|
"firstActionDate": null,
|
|
|
|
|
"visitDate": null,
|
|
|
|
|
"firstActionDate": serviceRequest['firstActionDate'],
|
|
|
|
|
"visitDate": date?.toIso8601String() ?? "",
|
|
|
|
|
"callReview": null,
|
|
|
|
|
"reviewComment": null,
|
|
|
|
|
};
|
|
|
|
|
@ -419,7 +422,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> getServiceRequestCallNoById({@required String requestId}) async {
|
|
|
|
|
Future<Map<String, dynamic>> getServiceRequestById({@required String requestId}) async {
|
|
|
|
|
Response response;
|
|
|
|
|
try {
|
|
|
|
|
response = await ApiManager.instance.get(
|
|
|
|
|
@ -427,16 +430,20 @@ class ServiceRequestsProvider extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
|
return "";
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the call to the server was successful, parse the JSON.
|
|
|
|
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
|
|
|
// If the call to the server was successful, parse the JSON.
|
|
|
|
|
print(json.decode(response.body)["data"]);
|
|
|
|
|
return json.decode(response.body)["data"]["callNo"] as String;
|
|
|
|
|
return {
|
|
|
|
|
"callNo": json.decode(response.body)["data"]["callNo"],
|
|
|
|
|
"callCreatedBy": json.decode(response.body)["data"]["callCreatedBy"],
|
|
|
|
|
"callSiteContactPerson": json.decode(response.body)["data"]["callSiteContactPerson"],
|
|
|
|
|
"firstActionDate": json.decode(response.body)["data"]["firstActionDate"],
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|