Compare commits
No commits in common. '42677a72b3663027db05f5561f9eaaf8923c1034' and 'c69bcc284355c174ca8889cd2fb9fee989ed5869' have entirely different histories.
42677a72b3
...
c69bcc2843
@ -1,7 +0,0 @@
|
|||||||
enum DemoRequestStepEnum {
|
|
||||||
qAuditorRejectAccept, // 5 quality auditor accept reject
|
|
||||||
updateRequest, //7
|
|
||||||
extendDemoPeriod, //15 extent
|
|
||||||
viewOnly, // need to check when show view only
|
|
||||||
submitEvaluation, //18
|
|
||||||
}
|
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/new_models/building.dart';
|
||||||
|
import 'package:test_sa/models/new_models/department.dart';
|
||||||
|
import 'package:test_sa/models/new_models/floor.dart';
|
||||||
|
import 'package:test_sa/models/new_models/site.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
||||||
|
|
||||||
|
class DemoFormModel {
|
||||||
|
String? docName;
|
||||||
|
String? docNumber;
|
||||||
|
String? docEmail;
|
||||||
|
String? itemDescription;
|
||||||
|
String? requestDescription;
|
||||||
|
String? model;
|
||||||
|
String? manufacturer;
|
||||||
|
Lookup? loanProvided;
|
||||||
|
String? vendorName;
|
||||||
|
String? vendorRepresentativeName;
|
||||||
|
String? vendorNumber;
|
||||||
|
String? vendorEmail;
|
||||||
|
Site? site;
|
||||||
|
MedicalDepartmentModel? department;
|
||||||
|
List<DemoAttachments>? demoAttachment;
|
||||||
|
|
||||||
|
DemoFormModel({
|
||||||
|
this.docName,
|
||||||
|
this.docNumber,
|
||||||
|
this.docEmail,
|
||||||
|
this.itemDescription,
|
||||||
|
this.requestDescription,
|
||||||
|
this.model,
|
||||||
|
this.manufacturer,
|
||||||
|
this.loanProvided,
|
||||||
|
this.vendorName,
|
||||||
|
this.vendorRepresentativeName,
|
||||||
|
this.vendorNumber,
|
||||||
|
this.vendorEmail,
|
||||||
|
this.demoAttachment,
|
||||||
|
this.site,
|
||||||
|
this.department,
|
||||||
|
});
|
||||||
|
|
||||||
|
//{
|
||||||
|
// "id": 0,
|
||||||
|
// "employeeId": "fa29a9de-1337-4729-b823-68c6ecffdd33",
|
||||||
|
// "requestorUserID": "fa29a9de-1337-4729-b823-68c6ecffdd33",
|
||||||
|
// "employeeName": "engineer-dev",
|
||||||
|
// "employeeEmail": "Engineer_Dev@yahoo.com",
|
||||||
|
// "positionName": "High",
|
||||||
|
// "requesterExtensionNumber": "7726",
|
||||||
|
// "requesterContactNumber": "72132197",
|
||||||
|
// "siteId": 1,
|
||||||
|
// "departmentId": 5,
|
||||||
|
// "loanTypeId": 6448,
|
||||||
|
// "doctorName": "Doctor A",
|
||||||
|
// "doctorContact": "0561432451",
|
||||||
|
// "doctorEmail": "doctor@test.com",
|
||||||
|
// "itemDescription": "Test item",
|
||||||
|
// "requestDescription": "Test request",
|
||||||
|
// "loanPeriodId": 6453,
|
||||||
|
// "assetId": null,
|
||||||
|
// "assetNumber": "",
|
||||||
|
// "assetName": "",
|
||||||
|
// "assetSerialNumber": "",
|
||||||
|
// "model": "Model A",
|
||||||
|
// "manufacturer": "Siemens",
|
||||||
|
// "vendorName": "Vendor A",
|
||||||
|
// "vendorRepName": "Vendor Rep A",
|
||||||
|
// "vendorContact": "0561432455",
|
||||||
|
// "vendorEmail": "vendor@test.com",
|
||||||
|
// "loanStatusId": 1,
|
||||||
|
// "loanAttachments": [],
|
||||||
|
// "submittedAt": "2025-11-13T12:11:12.673Z",
|
||||||
|
// "updatedAt": null,
|
||||||
|
// "cMWOItemId": null
|
||||||
|
// }
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
var abc = {
|
||||||
|
"id": 0,
|
||||||
|
"siteId": 0,
|
||||||
|
"buildingId": 0,
|
||||||
|
"floorId": 0,
|
||||||
|
"departmentId": 0,
|
||||||
|
"assetName": "string",
|
||||||
|
"model": "string",
|
||||||
|
"manufacturer": "string",
|
||||||
|
"doctorName": "string",
|
||||||
|
"doctorContactNumber": "string",
|
||||||
|
"doctorContactEmail": "string",
|
||||||
|
"itemDescription": "string",
|
||||||
|
"requestDescription": "string",
|
||||||
|
"demoPeriodId": 0,
|
||||||
|
"supplierId": 0,
|
||||||
|
"suppPersonId": 0,
|
||||||
|
"isSubmit": true,
|
||||||
|
"demoAttachments": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"attachmentName": "string",
|
||||||
|
"originalName": "string",
|
||||||
|
"demoRequestId": 0,
|
||||||
|
"attachmentTypeId": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
"doctorName": docName,
|
||||||
|
"doctorContact": docNumber,
|
||||||
|
"doctorEmail": docEmail,
|
||||||
|
"itemDescription": itemDescription,
|
||||||
|
"requestDescription": requestDescription,
|
||||||
|
"model": model,
|
||||||
|
"manufacturer": manufacturer,
|
||||||
|
"demoPeriodId": loanProvided?.id,
|
||||||
|
"vendorName": vendorName,
|
||||||
|
"vendorRepresentativeName": vendorRepresentativeName,
|
||||||
|
"vendorRepName": vendorRepresentativeName,
|
||||||
|
"vendorNumber": vendorNumber,
|
||||||
|
"vendorContact": vendorNumber,
|
||||||
|
"vendorEmail": vendorEmail,
|
||||||
|
'siteId': site?.id,
|
||||||
|
'departmentId': department?.id,
|
||||||
|
"demoAttachments": demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DemoAttachments {
|
||||||
|
num? id;
|
||||||
|
num? demoRequestId;
|
||||||
|
num? attachmentTypeId;
|
||||||
|
String? attachmentName;
|
||||||
|
String? originalName;
|
||||||
|
|
||||||
|
DemoAttachments({this.id, this.attachmentTypeId, this.attachmentName, this.demoRequestId, this.originalName});
|
||||||
|
|
||||||
|
DemoAttachments.fromJson(dynamic json) {
|
||||||
|
id = json['id'];
|
||||||
|
attachmentTypeId = json['attachmentTypeId'];
|
||||||
|
demoRequestId = json['demoRequestId'];
|
||||||
|
attachmentName = json['attachmentName'];
|
||||||
|
originalName = json['originalName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final map = <String, dynamic>{};
|
||||||
|
map['id'] = id;
|
||||||
|
map['attachmentTypeId'] = attachmentTypeId;
|
||||||
|
map['attachmentName'] = attachmentName;
|
||||||
|
map['demoRequestId'] = demoRequestId;
|
||||||
|
map['originalName'] = originalName;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/loan_request_model.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class DemoProvider extends ChangeNotifier {
|
||||||
|
Future<bool> addLoanRequest(Map<String, dynamic> body) async {
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.post(URLs.addLoan, body: body, showToast: false);
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
||||||
|
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
Future<LoanRequestModel?> getLoanById(int id) async {
|
||||||
|
LoanRequestModel? loanData;
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.getLoanById + "?loanId=$id");
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
loanData = LoanRequestModel.fromJson(json.decode(response.body)["data"]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
print(error);
|
||||||
|
}
|
||||||
|
return loanData;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> addDemoTrialOutcome(Map<String, dynamic> body) async {
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.post(URLs.addDemoTrialOutcome, body: body, showToast: false);
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
||||||
|
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,119 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
|
||||||
import 'package:test_sa/extensions/int_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/string_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/text_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
||||||
import 'package:test_sa/models/all_requests_and_count_model.dart';
|
|
||||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
|
||||||
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_page.dart';
|
|
||||||
import 'package:test_sa/modules/asset_inventory_module/pages/asset_inventory_page.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/demo_detail_view_page.dart';
|
|
||||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
||||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
||||||
|
|
||||||
class DemoRequestItemView extends StatelessWidget {
|
|
||||||
final Data? requestData;
|
|
||||||
final RequestsDetails? requestDetails;
|
|
||||||
final bool showShadow;
|
|
||||||
|
|
||||||
const DemoRequestItemView({Key? key, this.requestData, this.requestDetails, this.showShadow = true}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (requestData != null) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
StatusLabel(
|
|
||||||
label: requestData!.statusName!,
|
|
||||||
textColor: AppColor.demoRequestStatusTextColor(context, requestData?.statusValue ?? 0),
|
|
||||||
backgroundColor: AppColor.demoRequestStatus(context, requestData?.statusValue ?? 0),
|
|
||||||
),
|
|
||||||
1.width.expanded,
|
|
||||||
Text(
|
|
||||||
requestData!.transactionDate?.toServiceRequestCardFormat ?? "",
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// 8.height,
|
|
||||||
(requestData?.typeTransaction ?? 'Demo Request').heading5(context),
|
|
||||||
infoWidget(label: 'Request No'.addTranslation, value: requestData?.requestNo ?? '-', context: context),
|
|
||||||
infoWidget(label: context.translation.requestType, value: requestData?.requestTypeName, context: context),
|
|
||||||
// infoWidget(label: 'No of Sites'.addTranslation, value: requestData?.numberOfSites != null ? requestData?.numberOfSites.toString() : '-', context: context),
|
|
||||||
8.height,
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
context.translation.viewDetails,
|
|
||||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
|
||||||
),
|
|
||||||
4.width,
|
|
||||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (_) => DemoDetailViewPage(
|
|
||||||
demoId: requestData!.id!,
|
|
||||||
)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
StatusLabel(
|
|
||||||
label: requestDetails!.status!,
|
|
||||||
textColor: AppColor.demoRequestStatusTextColor(context, requestDetails?.statusValue ?? 0),
|
|
||||||
backgroundColor: AppColor.demoRequestStatus(context, requestDetails?.statusValue ?? 0),
|
|
||||||
),
|
|
||||||
1.width.expanded,
|
|
||||||
Text(
|
|
||||||
requestDetails!.date?.toServiceRequestCardFormat ?? "",
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// 8.height,
|
|
||||||
(requestDetails?.nameOfType ?? 'Demo Request').heading5(context),
|
|
||||||
// infoWidget(label: context.translation.requestType, value: requestDetails!.requestType, context: context),
|
|
||||||
infoWidget(label: context.translation.requestNo, value: requestDetails!.requestNo, context: context),
|
|
||||||
infoWidget(label: context.translation.site, value: requestDetails!.site, context: context),
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
context.translation.viewDetails,
|
|
||||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
|
||||||
),
|
|
||||||
4.width,
|
|
||||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (_) => DemoDetailViewPage(
|
|
||||||
demoId: requestDetails!.id!,
|
|
||||||
)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget infoWidget({required String label, String? value, required BuildContext context}) {
|
|
||||||
if (value != null && value.isNotEmpty) {
|
|
||||||
return '$label: $value'.bodyText(context);
|
|
||||||
}
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
class DemoAttachments {
|
|
||||||
int? id;
|
|
||||||
num? demoRequestId;
|
|
||||||
num? documentTypeId;
|
|
||||||
String? attachmentName;
|
|
||||||
String? originalName;
|
|
||||||
|
|
||||||
DemoAttachments({this.id, this.documentTypeId, this.attachmentName, this.demoRequestId, this.originalName});
|
|
||||||
|
|
||||||
DemoAttachments.fromJson(dynamic json) {
|
|
||||||
id = json['id'];
|
|
||||||
documentTypeId = json['documentTypeId'];
|
|
||||||
demoRequestId = json['demoRequestId'];
|
|
||||||
attachmentName = json['attachmentName'];
|
|
||||||
originalName = json['originalName'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final map = <String, dynamic>{};
|
|
||||||
map['id'] = id;
|
|
||||||
map['documentTypeId'] = documentTypeId;
|
|
||||||
map['attachmentName'] = attachmentName;
|
|
||||||
map['demoRequestId'] = demoRequestId;
|
|
||||||
map['originalName'] = originalName;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,95 +0,0 @@
|
|||||||
import 'package:test_sa/models/lookup.dart';
|
|
||||||
import 'package:test_sa/models/new_models/building.dart';
|
|
||||||
import 'package:test_sa/models/new_models/floor.dart';
|
|
||||||
import 'package:test_sa/models/new_models/room_model.dart';
|
|
||||||
import 'package:test_sa/models/new_models/site.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
|
|
||||||
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
|
||||||
|
|
||||||
import '../../../models/new_models/department.dart';
|
|
||||||
|
|
||||||
class DemoFormModel {
|
|
||||||
String? docName;
|
|
||||||
int? id;
|
|
||||||
String? docNumber;
|
|
||||||
String? docEmail;
|
|
||||||
String? itemDescription;
|
|
||||||
String? requestDescription;
|
|
||||||
String? model;
|
|
||||||
String? assetName;
|
|
||||||
String? manufacturer;
|
|
||||||
Lookup? demoPeriod;
|
|
||||||
String? vendorRepresentativeName;
|
|
||||||
String? vendorName;
|
|
||||||
String? vendorContactNumber;
|
|
||||||
String? vendorEmail;
|
|
||||||
Site? site;
|
|
||||||
Building? building; // Now nullable
|
|
||||||
Floor? floor; // Now nullable
|
|
||||||
Department? department; // Now nullable
|
|
||||||
Rooms? room;
|
|
||||||
SuppEngineerWorkOrders? supEngineer;
|
|
||||||
SupplierDetails? vendor;
|
|
||||||
List<DemoAttachments>? demoAttachment;
|
|
||||||
|
|
||||||
DemoFormModel({
|
|
||||||
this.id,
|
|
||||||
this.docName,
|
|
||||||
this.docNumber,
|
|
||||||
this.docEmail,
|
|
||||||
this.itemDescription,
|
|
||||||
this.requestDescription,
|
|
||||||
this.model,
|
|
||||||
this.assetName,
|
|
||||||
this.manufacturer,
|
|
||||||
this.demoPeriod,
|
|
||||||
this.vendorRepresentativeName,
|
|
||||||
this.vendorName,
|
|
||||||
this.vendorContactNumber,
|
|
||||||
this.vendorEmail,
|
|
||||||
this.demoAttachment,
|
|
||||||
this.site,
|
|
||||||
this.vendor,
|
|
||||||
this.supEngineer,
|
|
||||||
this.department,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
"id": 0,
|
|
||||||
'siteId': site?.id,
|
|
||||||
'departmentId': department?.id,
|
|
||||||
"buildingId": building?.id,
|
|
||||||
"floorId": floor?.id,
|
|
||||||
"assetName": assetName,
|
|
||||||
"isSubmit": true,
|
|
||||||
"doctorName": docName,
|
|
||||||
"doctorContactNumber": docNumber,
|
|
||||||
"doctorContactEmail": docEmail,
|
|
||||||
"itemDescription": itemDescription,
|
|
||||||
"requestDescription": requestDescription,
|
|
||||||
"model": model,
|
|
||||||
"vendorName": vendorName,
|
|
||||||
"vendorContactNumber": vendorContactNumber,
|
|
||||||
"vendorEmail": vendorEmail,
|
|
||||||
"vendorRepresentativeName": vendorRepresentativeName,
|
|
||||||
"manufacturer": manufacturer,
|
|
||||||
"demoPeriodId": demoPeriod?.id,
|
|
||||||
"supplierId": vendor?.id,
|
|
||||||
"suppPersonId": supEngineer?.id,
|
|
||||||
// "vendorEmail": vendorEmail,
|
|
||||||
"demoAttachments": demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toUpdateJson() {
|
|
||||||
return {
|
|
||||||
"id": id,
|
|
||||||
"supplierId": vendor?.id,
|
|
||||||
"suppPersonId": supEngineer?.id,
|
|
||||||
"demoAttachments": demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,139 +0,0 @@
|
|||||||
import 'package:test_sa/models/device/asset_by_id_model.dart';
|
|
||||||
import 'package:test_sa/models/lookup.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
|
|
||||||
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
|
||||||
|
|
||||||
class DemoRequestModel {
|
|
||||||
int? id;
|
|
||||||
RequesterUserModel? requesterUser;
|
|
||||||
Site? site;
|
|
||||||
Lookup? building;
|
|
||||||
Lookup? floor;
|
|
||||||
MedicalDepartmentModel? department;
|
|
||||||
String? assetName;
|
|
||||||
String? model;
|
|
||||||
String? manufacturer;
|
|
||||||
String? doctorName;
|
|
||||||
String? doctorContactNumber;
|
|
||||||
String? doctorContactEmail;
|
|
||||||
String? itemDescription;
|
|
||||||
String? requestDescription;
|
|
||||||
String? vendorName;
|
|
||||||
String? vendorRepresentativeName;
|
|
||||||
String? vendorContactNumber;
|
|
||||||
String? vendorEmail;
|
|
||||||
Lookup? demoPeriod;
|
|
||||||
SupplierDetails? supplier;
|
|
||||||
SuppEngineerWorkOrders? suppPerson;
|
|
||||||
Lookup? status;
|
|
||||||
List<DemoAttachments>? demoAttachments;
|
|
||||||
dynamic demoAsset;
|
|
||||||
dynamic demoInstallationTaskJob;
|
|
||||||
dynamic demoPullOutTaskJob;
|
|
||||||
bool? isDemoPeriodExpired;
|
|
||||||
|
|
||||||
DemoRequestModel({
|
|
||||||
this.id,
|
|
||||||
this.requesterUser,
|
|
||||||
this.site,
|
|
||||||
this.building,
|
|
||||||
this.floor,
|
|
||||||
this.department,
|
|
||||||
this.assetName,
|
|
||||||
this.model,
|
|
||||||
this.manufacturer,
|
|
||||||
this.doctorName,
|
|
||||||
this.doctorContactNumber,
|
|
||||||
this.doctorContactEmail,
|
|
||||||
this.itemDescription,
|
|
||||||
this.requestDescription,
|
|
||||||
this.vendorName,
|
|
||||||
this.vendorRepresentativeName,
|
|
||||||
this.vendorEmail,
|
|
||||||
this.vendorContactNumber,
|
|
||||||
this.demoPeriod,
|
|
||||||
this.supplier,
|
|
||||||
this.suppPerson,
|
|
||||||
this.status,
|
|
||||||
this.demoAttachments,
|
|
||||||
this.demoAsset,
|
|
||||||
this.demoInstallationTaskJob,
|
|
||||||
this.demoPullOutTaskJob,
|
|
||||||
this.isDemoPeriodExpired,
|
|
||||||
});
|
|
||||||
|
|
||||||
DemoRequestModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
requesterUser = json['requesterUser'] != null ? (RequesterUserModel()..fromJson(json['requesterUser'])) : null;
|
|
||||||
site = json['site'] != null ? (Site.fromJson(json['site'])) : null;
|
|
||||||
building = json['building'] != null ? (Lookup.fromJson(json['building'])) : null;
|
|
||||||
floor = json['floor'] != null ? (Lookup.fromJson(json['floor'])) : null;
|
|
||||||
department = json['department'] != null ? (MedicalDepartmentModel.fromJson(json['department'])) : null;
|
|
||||||
assetName = json['assetName'];
|
|
||||||
model = json['model'];
|
|
||||||
manufacturer = json['manufacturer'];
|
|
||||||
doctorName = json['doctorName'];
|
|
||||||
doctorContactNumber = json['doctorContactNumber'];
|
|
||||||
doctorContactEmail = json['doctorContactEmail'];
|
|
||||||
itemDescription = json['itemDescription'];
|
|
||||||
requestDescription = json['requestDescription'];
|
|
||||||
vendorName = json['vendorName'];
|
|
||||||
vendorRepresentativeName = json['vendorRepresentativeName'];
|
|
||||||
vendorContactNumber = json['vendorContactNumber'];
|
|
||||||
vendorEmail = json['vendorEmail'];
|
|
||||||
demoPeriod = json['demoPeriod'] != null ? (Lookup.fromJson(json['demoPeriod'])) : null;
|
|
||||||
supplier = json['supplier'] != null ? (SupplierDetails.fromJson(json['supplier'])) : null;
|
|
||||||
suppPerson = json['suppPerson'] != null ? (SuppEngineerWorkOrders.fromJson(json['suppPerson'])) : null;
|
|
||||||
status = json['status'] != null ? (Lookup.fromJson(json['status'])) : null;
|
|
||||||
demoAttachments = json['demoAttachments'] != null ? (json['demoAttachments'] as List).map((e) => DemoAttachments.fromJson(e)).toList() : null;
|
|
||||||
demoAsset = json['demoAsset'];
|
|
||||||
demoInstallationTaskJob = json['demoInstallationTaskJob'];
|
|
||||||
demoPullOutTaskJob = json['demoPullOutTaskJob'];
|
|
||||||
isDemoPeriodExpired = json['isDemoPeriodExpired'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
"id": 0,
|
|
||||||
'siteId': site?.id,
|
|
||||||
'departmentId': department?.id,
|
|
||||||
"buildingId": 0,
|
|
||||||
"floorId": 0,
|
|
||||||
"assetName": assetName,
|
|
||||||
"isSubmit": true,
|
|
||||||
"itemDescription": itemDescription,
|
|
||||||
"requestDescription": requestDescription,
|
|
||||||
"model": model,
|
|
||||||
"manufacturer": manufacturer,
|
|
||||||
"demoPeriodId": demoPeriod?.id,
|
|
||||||
"supplierId": supplier?.id,
|
|
||||||
"suppPersonId": suppPerson?.id,
|
|
||||||
"demoAttachments": demoAttachments != null ? demoAttachments!.map((v) => v.toJson()).toList() : [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RequesterUserModel {
|
|
||||||
String? requesterUserId;
|
|
||||||
String? requesterName;
|
|
||||||
String? requesterEmail;
|
|
||||||
String? requesterMobile;
|
|
||||||
|
|
||||||
RequesterUserModel();
|
|
||||||
|
|
||||||
void fromJson(Map<String, dynamic> json) {
|
|
||||||
requesterUserId = json['requesterUserId'];
|
|
||||||
requesterName = json['requesterName'];
|
|
||||||
requesterEmail = json['requesterEmail'];
|
|
||||||
requesterMobile = json['requesterMobile'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
'requesterUserId': requesterUserId,
|
|
||||||
'requesterName': requesterName,
|
|
||||||
'requesterEmail': requesterEmail,
|
|
||||||
'requesterMobile': requesterMobile,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,168 +0,0 @@
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
|
||||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
|
||||||
import 'package:test_sa/models/new_models/site.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/models/demo_request_model.dart';
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class DemoProvider extends ChangeNotifier {
|
|
||||||
Future<bool> addDemoRequest(Map<String, dynamic> body) async {
|
|
||||||
try {
|
|
||||||
Response response = await ApiManager.instance.post(URLs.addDemoRequest, body: body, showToast: false);
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
// String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
String message = (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isLoading = false;
|
|
||||||
bool isSiteLoading = false;
|
|
||||||
|
|
||||||
Future<DemoRequestModel?> getDemoById(int id) async {
|
|
||||||
DemoRequestModel? demoRequestModel;
|
|
||||||
try {
|
|
||||||
Response response = await ApiManager.instance.get(URLs.getDemoRequestById + "/$id");
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
demoRequestModel = DemoRequestModel.fromJson(json.decode(response.body)["data"]);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
print(error);
|
|
||||||
}
|
|
||||||
return demoRequestModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> acceptRejectRequest({required int requestId, required bool status}) async {
|
|
||||||
try {
|
|
||||||
Map<String, dynamic> payload = {"demoRequestId": requestId, "isApproved": status};
|
|
||||||
Response response = await ApiManager.instance.post(URLs.updateDemoRequestByAssessor, body: payload, showToast: false);
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> updateDemoRequest(Map<String, dynamic> body) async {
|
|
||||||
try {
|
|
||||||
Response response = await ApiManager.instance.post(URLs.updateDemoRequest, body: body, showToast: false);
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> updateDemoPeriod({required int demoPeriodId, required int requestId, required bool isUpdateRequired}) async {
|
|
||||||
try {
|
|
||||||
Map<String, dynamic> payload = {"demoRequestId": requestId, "demoPeriodId": demoPeriodId, "isDemoPeriodExtentionRequired": isUpdateRequired};
|
|
||||||
Response response = await ApiManager.instance.post(URLs.updateDemoPeriodByRequester, body: payload, showToast: false);
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Site> getSiteData({required num? siteId}) async {
|
|
||||||
Site siteObj = Site();
|
|
||||||
isSiteLoading = true;
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final response = await ApiManager.instance.get(
|
|
||||||
"${URLs.getSiteAutoCompleteWithoutConditionSites}?id=$siteId",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
final List? siteData = json.decode(response.body)["data"];
|
|
||||||
if (siteData != null && siteData.isNotEmpty) {
|
|
||||||
siteObj = Site.fromJson(siteData.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
isSiteLoading = false;
|
|
||||||
notifyListeners();
|
|
||||||
return siteObj;
|
|
||||||
}
|
|
||||||
Future<bool> addDemoTrialOutcome(Map<String, dynamic> body) async {
|
|
||||||
try {
|
|
||||||
Response response = await ApiManager.instance.post(URLs.addDemoTrialOutcome, body: body, showToast: false);
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
|
||||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Future<DemoFormModel> getSiteData({
|
|
||||||
// required num? siteId,
|
|
||||||
// }) async {
|
|
||||||
// isSiteLoading = true;
|
|
||||||
// DemoFormModel model=DemoFormModel();
|
|
||||||
// notifyListeners();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// final response = await ApiManager.instance.get(
|
|
||||||
// "${URLs.getSiteAutoCompleteWithoutConditionSites}?id=$siteId",
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
||||||
// final List? siteData = json.decode(response.body)["data"];
|
|
||||||
//
|
|
||||||
// if (siteData != null && siteData.isNotEmpty) {
|
|
||||||
// model.site = Site.fromJson(siteData.first);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// model.building = model.site?.buildings?.firstWhere(
|
|
||||||
// (e) => e.value == model.building?.value,
|
|
||||||
// orElse: () => Building(),
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// model.floor = model.building?.floors?.firstWhere(
|
|
||||||
// (e) => e.value == model.floor?.value,
|
|
||||||
// orElse: () => Floor(),
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// model.department = model.floor?.departments?.firstWhere(
|
|
||||||
// (e) => e.departmentName == model.department?.departmentName,
|
|
||||||
// orElse: () => Department(),
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// isSiteLoading = false;
|
|
||||||
// notifyListeners();
|
|
||||||
// return model;
|
|
||||||
// } catch (e) {
|
|
||||||
// isSiteLoading = false;
|
|
||||||
// notifyListeners();
|
|
||||||
// return model;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@ -1,597 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:test_sa/controllers/validator/validator.dart';
|
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
|
||||||
import 'package:test_sa/extensions/int_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/string_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/text_extensions.dart';
|
|
||||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
||||||
import 'package:test_sa/helper/utils.dart';
|
|
||||||
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
||||||
import 'package:test_sa/models/lookup.dart';
|
|
||||||
import 'package:test_sa/models/new_models/building.dart';
|
|
||||||
import 'package:test_sa/models/new_models/floor.dart';
|
|
||||||
import 'package:test_sa/models/new_models/site.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
|
||||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
||||||
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
|
|
||||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/models/demo_attachment_model.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/models/demo_request_model.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/provider/demo_period_lookup_provider.dart';
|
|
||||||
import 'package:test_sa/modules/demo_module/provider/demo_provider.dart';
|
|
||||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
||||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
||||||
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
||||||
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
||||||
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
|
|
||||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
||||||
import 'package:test_sa/providers/work_order/vendor_provider.dart';
|
|
||||||
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
|
||||||
import '../../../../../../new_views/common_widgets/default_app_bar.dart';
|
|
||||||
import '../../models/new_models/department.dart';
|
|
||||||
import 'models/demo_form_model.dart';
|
|
||||||
|
|
||||||
class UpdateDemoRequestView extends StatefulWidget {
|
|
||||||
static const String id = "/update-demo-request";
|
|
||||||
DemoRequestModel dataModel;
|
|
||||||
|
|
||||||
UpdateDemoRequestView({Key? key, required this.dataModel}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_UpdateDemoRequestViewState createState() => _UpdateDemoRequestViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with TickerProviderStateMixin {
|
|
||||||
final List<GenericAttachmentModel> attachments = [];
|
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
||||||
DemoFormModel _demoFormModel = DemoFormModel();
|
|
||||||
|
|
||||||
late TextEditingController doctorName;
|
|
||||||
late TextEditingController doctorPhone;
|
|
||||||
late TextEditingController doctorEmail;
|
|
||||||
late TextEditingController assetName;
|
|
||||||
late TextEditingController model;
|
|
||||||
late TextEditingController manufacturer;
|
|
||||||
late TextEditingController itemDesc;
|
|
||||||
late TextEditingController requestDesc;
|
|
||||||
late TextEditingController vendorPhone;
|
|
||||||
late TextEditingController vendorEmail;
|
|
||||||
late SiteProvider siteProvider;
|
|
||||||
late DemoProvider demoProvider;
|
|
||||||
bool isLoading = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
doctorName = TextEditingController();
|
|
||||||
doctorPhone = TextEditingController();
|
|
||||||
doctorEmail = TextEditingController();
|
|
||||||
assetName = TextEditingController();
|
|
||||||
model = TextEditingController();
|
|
||||||
manufacturer = TextEditingController();
|
|
||||||
itemDesc = TextEditingController();
|
|
||||||
requestDesc = TextEditingController();
|
|
||||||
vendorPhone = TextEditingController();
|
|
||||||
vendorEmail = TextEditingController();
|
|
||||||
siteProvider = Provider.of<SiteProvider>(context, listen: false);
|
|
||||||
demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
fillData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void fillData() async {
|
|
||||||
final vendorProvider = Provider.of<VendorProvider>(context, listen: false);
|
|
||||||
if (vendorProvider.items.isEmpty) {
|
|
||||||
if (mounted) {
|
|
||||||
await vendorProvider.getData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final d = widget.dataModel;
|
|
||||||
|
|
||||||
if (d.site?.id != null) {
|
|
||||||
_demoFormModel.site = await demoProvider.getSiteData(
|
|
||||||
siteId: d.site?.id,
|
|
||||||
);
|
|
||||||
_demoFormModel.building = _demoFormModel.site?.buildings?.firstWhere(
|
|
||||||
(e) => e.id == d.building?.id,
|
|
||||||
orElse: () => Building(),
|
|
||||||
);
|
|
||||||
|
|
||||||
_demoFormModel.floor = _demoFormModel.building?.floors?.firstWhere(
|
|
||||||
(e) => e.id == d.floor?.id,
|
|
||||||
orElse: () => Floor(),
|
|
||||||
);
|
|
||||||
|
|
||||||
_demoFormModel.department = _demoFormModel.floor?.departments?.firstWhere(
|
|
||||||
(e) => e.id == d.department?.id,
|
|
||||||
orElse: () => Department(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
doctorName.text = d.doctorName ?? '';
|
|
||||||
doctorPhone.text = d.doctorContactNumber ?? '';
|
|
||||||
doctorEmail.text = d.doctorContactEmail ?? '';
|
|
||||||
assetName.text = d.assetName ?? '';
|
|
||||||
model.text = d.model ?? '';
|
|
||||||
manufacturer.text = d.manufacturer ?? '';
|
|
||||||
itemDesc.text = d.itemDescription ?? '';
|
|
||||||
requestDesc.text = d.requestDescription ?? '';
|
|
||||||
vendorPhone.text = d.supplier?.contact ?? d.vendorContactNumber ?? '';
|
|
||||||
vendorEmail.text = d.supplier?.email ?? d.vendorEmail ?? '';
|
|
||||||
_demoFormModel
|
|
||||||
..docName = d.doctorName
|
|
||||||
..docNumber = d.doctorContactNumber
|
|
||||||
..docEmail = d.doctorContactEmail
|
|
||||||
..assetName = d.assetName
|
|
||||||
..model = d.model
|
|
||||||
..manufacturer = d.manufacturer
|
|
||||||
..itemDescription = d.itemDescription
|
|
||||||
..requestDescription = d.requestDescription
|
|
||||||
..vendor = d.supplier
|
|
||||||
..vendorName = d.vendorName
|
|
||||||
..vendorRepresentativeName = d.vendorRepresentativeName
|
|
||||||
..vendorEmail = d.vendorEmail
|
|
||||||
..vendorContactNumber = d.vendorContactNumber;
|
|
||||||
_demoFormModel.id = widget.dataModel.id;
|
|
||||||
_demoFormModel.demoPeriod = widget.dataModel.demoPeriod;
|
|
||||||
if (d.supplier != null) {
|
|
||||||
final supplier = d.supplier;
|
|
||||||
_demoFormModel.vendor = supplier;
|
|
||||||
final selectedVendor = vendorProvider.items.firstWhere(
|
|
||||||
(element) => element.id == supplier?.id,
|
|
||||||
orElse: () => SupplierDetails(),
|
|
||||||
);
|
|
||||||
_demoFormModel.vendor?.suppPersons = selectedVendor.suppPersons;
|
|
||||||
_demoFormModel.supEngineer = widget.dataModel.suppPerson;
|
|
||||||
_demoFormModel.vendorEmail = supplier?.email;
|
|
||||||
_demoFormModel.vendorContactNumber = supplier?.contact;
|
|
||||||
vendorPhone.text = supplier?.email ?? '';
|
|
||||||
vendorEmail.text = supplier?.contact ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
attachments.clear();
|
|
||||||
if (widget.dataModel.demoAttachments?.isNotEmpty ?? false) {
|
|
||||||
for (final item in widget.dataModel.demoAttachments!) {
|
|
||||||
if ((item.attachmentName ?? '').isNotEmpty) {
|
|
||||||
attachments.add(
|
|
||||||
GenericAttachmentModel(name: item.attachmentName, id: item.id ?? 0, originalName: item.originalName),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
key: _scaffoldKey,
|
|
||||||
appBar: DefaultAppBar(title: 'Update Request'.addTranslation),
|
|
||||||
body: isLoading
|
|
||||||
? const CircularProgressIndicator(color: AppColor.primary10).center
|
|
||||||
: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
...siteSection(),
|
|
||||||
16.height,
|
|
||||||
...doctorInfoSection(),
|
|
||||||
16.height,
|
|
||||||
...assetSection(),
|
|
||||||
16.height,
|
|
||||||
...vendorDetailsSection(),
|
|
||||||
16.height,
|
|
||||||
AttachmentPicker(
|
|
||||||
label: context.translation.attachments,
|
|
||||||
attachment: attachments,
|
|
||||||
buttonColor: AppColor.black10,
|
|
||||||
onlyImages: false,
|
|
||||||
showAsListView: true,
|
|
||||||
buttonIcon: 'image-plus'.toSvgAsset(color: context.isDark ? AppColor.primary10 : AppColor.neutral120),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).toShadowContainer(context, borderRadius: 20),
|
|
||||||
).expanded,
|
|
||||||
FooterActionButton.footerContainer(
|
|
||||||
context: context,
|
|
||||||
child: AppFilledButton(
|
|
||||||
buttonColor: AppColor.primary10,
|
|
||||||
label: context.translation.update,
|
|
||||||
onPressed: _update,
|
|
||||||
// buttonColor: AppColor.primary10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> siteSection() {
|
|
||||||
return [
|
|
||||||
'Site Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Site, SiteProvider>(
|
|
||||||
context: context,
|
|
||||||
title: context.translation.site,
|
|
||||||
initialValue: _demoFormModel.site,
|
|
||||||
showShadow: false,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null) return "Please select a site";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
onSelect: (value) {
|
|
||||||
_demoFormModel.site = value;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Building, NullableLoadingProvider>(
|
|
||||||
context: context,
|
|
||||||
title: context.translation.building,
|
|
||||||
initialValue: _demoFormModel.building,
|
|
||||||
showShadow: false,
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null) return "Please select a building";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
enabled: _demoFormModel.site?.buildings?.isNotEmpty ?? false,
|
|
||||||
staticData: _demoFormModel.site?.buildings ?? [],
|
|
||||||
onSelect: (value) {
|
|
||||||
_demoFormModel.building = value;
|
|
||||||
_demoFormModel.floor = null;
|
|
||||||
_demoFormModel.department = null;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Floor, NullableLoadingProvider>(
|
|
||||||
context: context,
|
|
||||||
title: context.translation.floor,
|
|
||||||
showShadow: false,
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
initialValue: _demoFormModel.floor,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
enabled: _demoFormModel.building?.floors?.isNotEmpty ?? false,
|
|
||||||
staticData: _demoFormModel.building?.floors ?? [],
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null) return "Please select a floor";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onSelect: (value) {
|
|
||||||
_demoFormModel.floor = value;
|
|
||||||
_demoFormModel.department = null;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
|
|
||||||
context: context,
|
|
||||||
title: context.translation.department,
|
|
||||||
showShadow: false,
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
initialValue: _demoFormModel.department,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
enabled: _demoFormModel.floor?.departments?.isNotEmpty ?? false,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null) return "Please select a department";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
staticData: _demoFormModel.floor?.departments ?? [],
|
|
||||||
onSelect: (value) {
|
|
||||||
_demoFormModel.department = value;
|
|
||||||
_demoFormModel.room = null;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> doctorInfoSection() {
|
|
||||||
return [
|
|
||||||
"Doctor Details".bodyText(context).custom(color: AppColor.black10),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: doctorName,
|
|
||||||
labelText: "Name",
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.docName = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: doctorPhone,
|
|
||||||
labelText: "Contact Number",
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.phone,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.docNumber = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: doctorEmail,
|
|
||||||
labelText: "Email",
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) {
|
|
||||||
return "Mandatory";
|
|
||||||
} else {
|
|
||||||
return Validator.isEmail(value!) ? null : context.translation.emailValidateMessage;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.emailAddress,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.docEmail = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: itemDesc,
|
|
||||||
labelText: "Item Description",
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.itemDescription = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: requestDesc,
|
|
||||||
labelText: "Request Description",
|
|
||||||
// validator: (value) {
|
|
||||||
// if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
// return null;
|
|
||||||
// },
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.requestDescription = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> assetSection() {
|
|
||||||
return [
|
|
||||||
'Asset Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
labelText: "Asset Name",
|
|
||||||
controller: assetName,
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.assetName = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
labelText: "Model",
|
|
||||||
controller: model,
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.model = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
labelText: "Manufacturer",
|
|
||||||
controller: manufacturer,
|
|
||||||
validator: (value) {
|
|
||||||
if ((value ?? "").isEmpty) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.text,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.manufacturer = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<Lookup, DemoPeriodLookupProvider>(
|
|
||||||
context: context,
|
|
||||||
height: 56.toScreenHeight,
|
|
||||||
title: "Demo Period",
|
|
||||||
initialValue: _demoFormModel.demoPeriod,
|
|
||||||
showShadow: false,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null) return "Mandatory";
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
onSelect: (value) {
|
|
||||||
_demoFormModel.demoPeriod = value;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> vendorDetailsSection() {
|
|
||||||
return [
|
|
||||||
'Vendor Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
||||||
//TODO show this only if supplier id and suppler person id is null..
|
|
||||||
if (_demoFormModel.vendor == null) ...[
|
|
||||||
8.height,
|
|
||||||
Text(
|
|
||||||
'${'Vendor Name'.addTranslation}: ${_demoFormModel.vendorName?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
||||||
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
Text(
|
|
||||||
'${'Representative Name'.addTranslation}: ${_demoFormModel.vendorRepresentativeName?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
||||||
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
|
|
||||||
context: context,
|
|
||||||
title: 'Vendor Name'.addTranslation,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
initialValue: _demoFormModel.vendor,
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
showShadow: false,
|
|
||||||
showCancel: true,
|
|
||||||
onSelect: (person) {
|
|
||||||
_demoFormModel.vendor = person;
|
|
||||||
_demoFormModel.supEngineer = null;
|
|
||||||
vendorPhone.text = person?.contact ?? '';
|
|
||||||
vendorEmail.text = person?.email ?? '';
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
|
|
||||||
context: context,
|
|
||||||
backgroundColor: _demoFormModel.vendor?.suppliername == null
|
|
||||||
? context.isDark
|
|
||||||
? AppColor.neutral20
|
|
||||||
: AppColor.neutral40
|
|
||||||
: AppColor.fieldBgColor(context),
|
|
||||||
title: "Representative Name".addTranslation,
|
|
||||||
showShadow: false,
|
|
||||||
enabled: _demoFormModel.vendor?.suppPersons?.isNotEmpty ?? false,
|
|
||||||
staticData: _demoFormModel.vendor?.suppPersons,
|
|
||||||
showAsBottomSheet: true,
|
|
||||||
initialValue: _demoFormModel.supEngineer == null ? null : SuppPersons.fromJson(_demoFormModel.supEngineer?.toJson()),
|
|
||||||
onSelect: (suppPerson) {
|
|
||||||
if (suppPerson != null) {
|
|
||||||
_demoFormModel.supEngineer = SuppEngineerWorkOrders.fromJson(suppPerson.toJson());
|
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
controller: vendorPhone,
|
|
||||||
enable: false,
|
|
||||||
labelText: "Contact Number",
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.phone,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.vendorContactNumber = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
8.height,
|
|
||||||
AppTextFormField(
|
|
||||||
labelText: "Email",
|
|
||||||
controller: vendorEmail,
|
|
||||||
enable: false,
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
backgroundColor: AppColor.fieldBgColor(context),
|
|
||||||
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
||||||
showShadow: false,
|
|
||||||
textInputType: TextInputType.emailAddress,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
onChange: (value) {
|
|
||||||
_demoFormModel.vendorEmail = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _update() async {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
_demoFormModel.demoAttachment = [];
|
|
||||||
for (var item in attachments) {
|
|
||||||
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
||||||
//Todo need to pass attachmentType id as well.
|
|
||||||
_demoFormModel.demoAttachment?.add(DemoAttachments(id: item.id, demoRequestId: _demoFormModel.id ?? 0, attachmentName: fileName));
|
|
||||||
}
|
|
||||||
Utils.showLoading(context);
|
|
||||||
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
||||||
bool isSuccess = await demoProvider.updateDemoRequest(_demoFormModel.toJson());
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
if (isSuccess) {
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue