update service request & work order attachment issue fix.

design_3.0_demo_module
Sikander Saleem 2 years ago
parent 06cee34657
commit 494087ef18

@ -272,7 +272,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
"requestedThrough": request.requestedThrough?.toJson(), "requestedThrough": request.requestedThrough?.toJson(),
"voiceNote": request.audio, "voiceNote": request.audio,
"assets": request.deviceId == null ? [] : [request.deviceId], "assets": request.deviceId == null ? [] : [request.deviceId],
"attachmentsCallRequest": request.devicePhotos?.map((e) => {"name": e})?.toList(), "attachmentsCallRequest": (request.devicePhotos?.isNotEmpty ?? false) ? request.devicePhotos?.map((e) => {"name": e.getFileName})?.toList() : [],
"assignedEmployee": { "assignedEmployee": {
"id": request.engineerId, "id": request.engineerId,
"name": request.engineerName, "name": request.engineerName,

@ -20,7 +20,6 @@ extension StringExtensions on String {
} }
} }
String get toFirstActionFormat { String get toFirstActionFormat {
try { try {
DateTime dateTime = DateTime.tryParse(this); DateTime dateTime = DateTime.tryParse(this);
@ -29,6 +28,7 @@ extension StringExtensions on String {
return ""; return "";
} }
} }
String get toAssetDetailsFormat { String get toAssetDetailsFormat {
try { try {
DateTime dateTime = DateTime.tryParse(this); DateTime dateTime = DateTime.tryParse(this);
@ -37,4 +37,18 @@ extension StringExtensions on String {
return "-"; return "-";
} }
} }
String get getFileName {
try {
if (this.contains("fileName=")) {
String sub = this.substring(this.indexOf("fileName="), this.length);
sub = sub.replaceAll("fileName=", "");
return sub;
} else {
this;
}
} catch (e) {
return this;
}
}
} }

@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/spare_parts.dart'; import 'package:test_sa/models/service_request/spare_parts.dart';
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart'; import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
@ -310,7 +311,7 @@ class ServiceReport {
map['reviewComment'] = reviewComment; map['reviewComment'] = reviewComment;
map['comment'] = comment; map['comment'] = comment;
if (attachmentsWorkOrder != null) { if (attachmentsWorkOrder != null) {
map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => {"name": v.name}).toList(); map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => {"name": v.name.getFileName}).toList();
} }
if (equipmentStatus != null) { if (equipmentStatus != null) {
map['equipmentStatus'] = equipmentStatus.toJson(); map['equipmentStatus'] = equipmentStatus.toJson();

@ -140,8 +140,12 @@ class ServiceRequest {
jobSheetNumber: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["jobSheetNumber"] : null, jobSheetNumber: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["jobSheetNumber"] : null,
visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first, visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first,
startDate: DateTime.tryParse(parsedJson["startDate"] ?? "").toString().split(" ").first, startDate: parsedJson["startDate"] == null ? null : DateTime.tryParse(parsedJson["startDate"] ?? "").toString().split(" ").first,
endDate: DateTime.tryParse(parsedJson["endDate"] ?? "").toString().split(" ").first, endDate:
parsedJson["endDate"] == null ? null :
DateTime.tryParse(parsedJson["endDate"] ?? "").toString().split(" ").first,
workingHours: parsedJson["workingHours"], workingHours: parsedJson["workingHours"],

@ -42,19 +42,19 @@ class ContactUsBottomSheet extends StatelessWidget {
), ),
), ),
16.height, 16.height,
Row( // Row(
children: [ // children: [
contactItem(context, context.isDark, "phone", context.translation.callUs, contactNumber).onPress(() { // contactItem(context, context.isDark, "phone", context.translation.callUs, contactNumber).onPress(() {
//
return; // return;
launchUrlString("tel://$contactNumber"); // launchUrlString("tel://$contactNumber");
}).expanded, // }).expanded,
16.width, // 16.width,
contactItem(context, context.isDark, "whatsapp", context.translation.liveChat, context.translation.openWhatsapp).onPress(() { // contactItem(context, context.isDark, "whatsapp", context.translation.liveChat, context.translation.openWhatsapp).onPress(() {
_launchWhatsapp(contactNumber); // _launchWhatsapp(contactNumber);
}).expanded, // }).expanded,
], // ],
), // ),
32.height, 32.height,
], ],
), ),

@ -41,10 +41,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
widget.model?.files ??= []; widget.model?.files ??= [];
widget.model?.files = (widget.model.files ?? []) widget.model?.files = (widget.model.files ?? []).where((element) => element.attachmentName != null && element.attachmentName.isNotEmpty).toList();
.where((element) =>
element.attachmentName != null && element.attachmentName.isNotEmpty)
.toList();
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
@ -53,17 +50,11 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>( SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
context: context, context: context,
initialValue: widget.model.visitStatusId == null initialValue: widget.model.visitStatusId == null ? null : Lookup(name: widget.model.visitStatusName ?? "", id: widget.model.visitStatusId),
? null
: Lookup(
name: widget.model.visitStatusName ?? "",
id: widget.model.visitStatusId),
title: context.translation.ppmVisit, title: context.translation.ppmVisit,
onSelect: (value) { onSelect: (value) {
if (value?.value == 4) { if (value?.value == 4) {
"Status cannot be change to ${value.name}." "Status cannot be change to ${value.name}.".addTranslation.showToast;
.addTranslation
.showToast;
setState(() {}); setState(() {});
return; return;
} }
@ -90,11 +81,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>( SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
context: context, context: context,
initialValue: widget.model.deviceStatusId == null initialValue: widget.model.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId),
? null
: Lookup(
name: widget.model.deviceStatusName ?? "",
id: widget.model.deviceStatusId),
title: context.translation.deviceStatus, title: context.translation.deviceStatus,
onSelect: (value) { onSelect: (value) {
if (value != null) { if (value != null) {
@ -106,11 +93,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>( SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
context: context, context: context,
initialValue: widget.model.taskStatusId == null initialValue: widget.model.taskStatusId == null ? null : Lookup(name: widget.model.taskStatusName ?? "", id: widget.model.taskStatusId),
? null
: Lookup(
name: widget.model.taskStatusName ?? "",
id: widget.model.taskStatusId),
title: context.translation.taskStatus, title: context.translation.taskStatus,
onSelect: (value) { onSelect: (value) {
if (value != null) { if (value != null) {
@ -122,11 +105,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>( SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context, context: context,
initialValue: widget.model.assetAvailabilityId == null initialValue: widget.model.assetAvailabilityId == null ? null : Lookup(name: widget.model.assetAvailabilityName ?? "", id: widget.model.assetAvailabilityId),
? null
: Lookup(
name: widget.model.assetAvailabilityName ?? "",
id: widget.model.assetAvailabilityId),
title: "Asset Availability", title: "Asset Availability",
onSelect: (value) { onSelect: (value) {
if (value != null) { if (value != null) {
@ -136,21 +115,26 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
}, },
), ),
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context,
initialValue: widget.model.safetyId == null ? null : Lookup(name: widget.model.safetyName ?? "", id: widget.model.safetyId),
title: "Electrical Safety",
onSelect: (value) {
if (value != null) {
widget.model.safetyId = value.id;
widget.model.safetyName = value.name;
}
},
),
8.height,
SingleItemDropDownMenu<Lookup, PpmServiceProvider>( SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
context: context, context: context,
initialValue: widget.model.typeOfServiceId == null initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId),
? null
: Lookup(
name: widget.model.typeOfServiceName ?? "",
id: widget.model.typeOfServiceId),
title: context.translation.serviceType, title: context.translation.serviceType,
onSelect: (value) { onSelect: (value) {
if (value != null) { if (value != null) {
widget.model.typeOfServiceId = value.id; widget.model.typeOfServiceId = value.id;
widget.model.typeOfServiceName = value.name; widget.model.typeOfServiceName = value.name;
widget.model.safetyId = null;
widget.model.safetyName = null;
widget.model.supplierId = null; widget.model.supplierId = null;
widget.model.supplierName = null; widget.model.supplierName = null;
@ -159,30 +143,12 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
widget.model.suppPersonId = null; widget.model.suppPersonId = null;
widget.model.suppPerson = null; widget.model.suppPerson = null;
setState(() {}); setState(() {});
} }
}, },
), ),
8.height, 8.height,
if (widget.model?.typeOfServiceId != 66) ...[
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context,
initialValue: widget.model.safetyId == null
? null
: Lookup(
name: widget.model.safetyName ?? "",
id: widget.model.safetyId),
title: "Electrical Safety",
onSelect: (value) {
if (value != null) {
widget.model.safetyId = value.id;
widget.model.safetyName = value.name;
}
},
),
8.height,
],
if (widget.model?.typeOfServiceId == 66) ...[ if (widget.model?.typeOfServiceId == 66) ...[
SingleItemDropDownMenu<SupplierDetails, VendorProvider>( SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
context: context, context: context,
@ -230,7 +196,6 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
}, },
), ),
8.height, 8.height,
AppTimer( AppTimer(
label: "External Supplier Timer", label: "External Supplier Timer",
timer: widget.model.externalEngineerTimer, timer: widget.model.externalEngineerTimer,
@ -245,7 +210,6 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
), ),
8.height, 8.height,
], ],
ADatePicker( ADatePicker(
label: context.translation.actualVisitDate, label: context.translation.actualVisitDate,
date: DateTime.tryParse(widget.model.actualDate ?? ""), date: DateTime.tryParse(widget.model.actualDate ?? ""),
@ -253,8 +217,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
onDatePicker: (date) { onDatePicker: (date) {
if (date == null) return; if (date == null) return;
if (date.isBefore(DateTime.parse(widget.model.expectedDate))) { if (date.isBefore(DateTime.parse(widget.model.expectedDate))) {
"Actual visit date must be greater then expected date" "Actual visit date must be greater then expected date".showToast;
.showToast;
return; return;
} }
@ -288,12 +251,9 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
MultiFilesPicker( MultiFilesPicker(
label: context.translation.attachImage, label: context.translation.attachImage,
files: files: widget.model.files.map((e) => File(e.attachmentName)).toList(),
widget.model.files.map((e) => File(e.attachmentName)).toList(),
onChange: (files) { onChange: (files) {
widget.model.files = files widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
.map((e) => PpmAttachments(attachmentName: e.path))
.toList();
}, },
), ),
8.height, 8.height,
@ -313,8 +273,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
newSignature: widget.model.localNurseSignature, newSignature: widget.model.localNurseSignature,
onChange: (signature) { onChange: (signature) {
widget.model.localNurseSignature = signature; widget.model.localNurseSignature = signature;
widget.model.nurseSignature = widget.model.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
"${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
}, },
), ),
8.height, 8.height,
@ -324,8 +283,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
newSignature: widget.model.localEngineerSignature, newSignature: widget.model.localEngineerSignature,
onChange: (signature) { onChange: (signature) {
widget.model.localEngineerSignature = signature; widget.model.localEngineerSignature = signature;
widget.model.engSignature = widget.model.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
"${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
}, },
), ),
8.height, 8.height,

@ -693,6 +693,46 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
local_auth:
dependency: "direct main"
description:
name: local_auth
sha256: "0cf238be2bfa51a6c9e7e9cfc11c05ea39f2a3a4d3e5bb255d0ebc917da24401"
url: "https://pub.dev"
source: hosted
version: "2.1.6"
local_auth_android:
dependency: transitive
description:
name: local_auth_android
sha256: "523dd636ce061ddb296cbc3db410cb8f21efb7d8798f7b9532c8038ce2f8bad5"
url: "https://pub.dev"
source: hosted
version: "1.0.31"
local_auth_ios:
dependency: transitive
description:
name: local_auth_ios
sha256: edc2977c5145492f3451db9507a2f2f284ee4f408950b3e16670838726761940
url: "https://pub.dev"
source: hosted
version: "1.1.3"
local_auth_platform_interface:
dependency: transitive
description:
name: local_auth_platform_interface
sha256: fc5bd537970a324260fda506cfb61b33ad7426f37a8ea5c461cf612161ebba54
url: "https://pub.dev"
source: hosted
version: "1.0.8"
local_auth_windows:
dependency: transitive
description:
name: local_auth_windows
sha256: "19323b75ab781d5362dbb15dcb7e0916d2431c7a6dbdda016ec9708689877f73"
url: "https://pub.dev"
source: hosted
version: "1.0.8"
localization: localization:
dependency: "direct main" dependency: "direct main"
description: description:

Loading…
Cancel
Save