Remove Search Work Order Module and add the following filters in search service request:

○ Assigned Employee
○ Call ID
○ Call Date (Service Request Date)
main_design2.0
zaid_daoud 3 years ago
parent ca114f5cf8
commit 4d3c128191

@ -1,7 +1,10 @@
import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
import '../call_request_for_work_order_model.dart';
class ServiceRequestSearch { class ServiceRequestSearch {
String callId;
String deviceSerialNumber; String deviceSerialNumber;
String deviceNumber; String deviceNumber;
String deviceName; String deviceName;
@ -9,6 +12,9 @@ class ServiceRequestSearch {
String model; String model;
Lookup statusValue; Lookup statusValue;
bool mostRecent; bool mostRecent;
String from, to;
Lookup dateOperator;
AssignedEmployee assignedEmployee;
ServiceRequestSearch({ ServiceRequestSearch({
this.deviceSerialNumber, this.deviceSerialNumber,
@ -18,6 +24,11 @@ class ServiceRequestSearch {
this.model, this.model,
this.hospital, this.hospital,
this.mostRecent, this.mostRecent,
this.callId,
this.from,
this.to,
this.assignedEmployee,
this.dateOperator,
}); });
fromSearch(ServiceRequestSearch newSearch) { fromSearch(ServiceRequestSearch newSearch) {
@ -27,6 +38,11 @@ class ServiceRequestSearch {
hospital = newSearch.hospital; hospital = newSearch.hospital;
model = newSearch.model; model = newSearch.model;
mostRecent = newSearch.mostRecent; mostRecent = newSearch.mostRecent;
callId = newSearch.callId;
from = newSearch.from;
to = newSearch.to;
assignedEmployee = newSearch.assignedEmployee;
dateOperator = newSearch.dateOperator;
} }
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -51,9 +67,24 @@ class ServiceRequestSearch {
search["site"] = hospital.name; search["site"] = hospital.name;
} }
if (model != null) { if (model != null && model.isNotEmpty) {
search["modelDefinition"] = model; search["modelDefinition"] = model;
} }
if (callId != null && callId.isNotEmpty) {
search["callId"] = callId;
}
if (dateOperator != null && from != null) {
search["requestedDateSymbol"] = dateOperator.toMap();
search["requestedDateFrom"] = from;
}
if (dateOperator != null && to != null) {
search["requestedDateTo"] = to;
}
if (assignedEmployee != null) {
search["assignedEmployee"] = assignedEmployee.toJson();
}
return search; return search;
} }
} }

@ -23,7 +23,6 @@ import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/pages/device_transfer/request_device_transfer.dart'; import 'package:test_sa/views/pages/device_transfer/request_device_transfer.dart';
import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart'; import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart';
import 'package:test_sa/views/pages/sub_workorder/search_sub_workorder_page.dart';
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart'; import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart'; import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart';
import 'package:test_sa/views/pages/user/requests/create_request.dart'; import 'package:test_sa/views/pages/user/requests/create_request.dart';
@ -212,14 +211,14 @@ class _LandPageState extends State<LandPage> {
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
}, },
), ),
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) // if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
LandPageItem( // LandPageItem(
text: "Search Work Order", // text: "Search Work Order",
svgPath: "assets/images/sub_workorder_icon.svg", // svgPath: "assets/images/sub_workorder_icon.svg",
onPressed: () { // onPressed: () {
Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); // Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
}, // },
), // ),
], ],
), ),
], ],

@ -11,7 +11,12 @@ import 'package:test_sa/views/widgets/status/service_request/service_request_sta
import 'package:test_sa/views/widgets/switch_button.dart'; import 'package:test_sa/views/widgets/switch_button.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../models/call_request_for_work_order_model.dart';
import '../../../models/engineer.dart';
import '../app_text_form_field.dart'; import '../app_text_form_field.dart';
import '../date_and_time/date_picker.dart';
import '../status/report/service_report_all_users.dart';
import '../status/report/service_report_visit_date_operator.dart';
class ServiceRequestsSearchDialog extends StatefulWidget { class ServiceRequestsSearchDialog extends StatefulWidget {
final ServiceRequestSearch initialSearchValue; final ServiceRequestSearch initialSearchValue;
@ -63,168 +68,239 @@ class _ServiceRequestsSearchDialogState extends State<ServiceRequestsSearchDialo
key: _formKey, key: _formKey,
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Column( child: SingleChildScrollView(
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
ASmallButton( children: [
text: _subtitle.cancel, ASmallButton(
onPressed: () { text: _subtitle.cancel,
Navigator.of(context).pop(); onPressed: () {
}, Navigator.of(context).pop();
), },
ASmallButton( ),
text: _subtitle.search, ASmallButton(
onPressed: () { text: _subtitle.search,
if (!_formKey.currentState.validate()) { onPressed: () {
return; if (!_formKey.currentState.validate()) {
} return;
_formKey.currentState.save(); }
Navigator.of(context).pop(_search); _formKey.currentState.save();
}, Navigator.of(context).pop(_search);
) },
], )
), ],
SizedBox( ),
height: 8.0 * AppStyle.getScaleFactor(context), SizedBox(
), height: 8.0 * AppStyle.getScaleFactor(context),
ASwitchButton( ),
title: "Most Recent", ASwitchButton(
value: _search.mostRecent ?? false, title: "Most Recent",
onChange: (value) { value: _search.mostRecent ?? false,
_search.mostRecent = value; onChange: (value) {
setState(() {}); _search.mostRecent = value;
}, setState(() {});
), },
SizedBox( ),
height: 8.0 * AppStyle.getScaleFactor(context), SizedBox(
), height: 8.0 * AppStyle.getScaleFactor(context),
ATextFormField( ),
initialValue: _search.deviceSerialNumber, ATextFormField(
hintText: _subtitle.serialNumber, labelText: "Call ID",
style: Theme.of(context).textTheme.headline6, onSaved: (value) {
textInputAction: TextInputAction.search, _search.callId = value;
onAction: () { },
if (!_formKey.currentState.validate()) { ),
return; SizedBox(
} height: 8.0 * AppStyle.getScaleFactor(context),
_formKey.currentState.save(); ),
Navigator.of(context).pop(_search); ATextFormField(
}, initialValue: _search.deviceSerialNumber,
onSaved: (value) { hintText: _subtitle.serialNumber,
_search.deviceSerialNumber = value; style: Theme.of(context).textTheme.headline6,
}, textInputAction: TextInputAction.search,
), onAction: () {
SizedBox( if (!_formKey.currentState.validate()) {
height: 8.0 * AppStyle.getScaleFactor(context), return;
), }
HospitalAutoCompleteField( _formKey.currentState.save();
initialValue: _search.hospital?.name, Navigator.of(context).pop(_search);
// onSave: (value){ },
// _search.hospital = value; onSaved: (value) {
// }, _search.deviceSerialNumber = value;
onSearch: (value) { },
_search.hospital = value; ),
Navigator.of(context).pop(_search); SizedBox(
}, height: 8.0 * AppStyle.getScaleFactor(context),
), ),
SizedBox( HospitalAutoCompleteField(
height: 8.0 * AppStyle.getScaleFactor(context), initialValue: _search.hospital?.name,
), // onSave: (value){
ATextFormField( // _search.hospital = value;
initialValue: _search.deviceName, // },
hintText: _subtitle.deviceName, onSearch: (value) {
style: Theme.of(context).textTheme.headline6, _search.hospital = value;
textInputAction: TextInputAction.search, Navigator.of(context).pop(_search);
onAction: () { },
if (!_formKey.currentState.validate()) { ),
return; SizedBox(
} height: 8.0 * AppStyle.getScaleFactor(context),
_formKey.currentState.save(); ),
Navigator.of(context).pop(_search); ATextFormField(
}, initialValue: _search.deviceName,
onSaved: (value) { hintText: _subtitle.deviceName,
_search.deviceName = value; style: Theme.of(context).textTheme.headline6,
}, textInputAction: TextInputAction.search,
), onAction: () {
SizedBox( if (!_formKey.currentState.validate()) {
height: 8.0 * AppStyle.getScaleFactor(context), return;
), }
ATextFormField( _formKey.currentState.save();
initialValue: _search.model, Navigator.of(context).pop(_search);
hintText: _subtitle.model, },
style: Theme.of(context).textTheme.headline6, onSaved: (value) {
textInputAction: TextInputAction.search, _search.deviceName = value;
onAction: () { },
if (!_formKey.currentState.validate()) { ),
return; SizedBox(
} height: 8.0 * AppStyle.getScaleFactor(context),
_formKey.currentState.save(); ),
Navigator.of(context).pop(_search); ATextFormField(
}, initialValue: _search.model,
onSaved: (value) { hintText: _subtitle.model,
_search.model = value; style: Theme.of(context).textTheme.headline6,
}, textInputAction: TextInputAction.search,
), onAction: () {
SizedBox( if (!_formKey.currentState.validate()) {
height: 16 * AppStyle.getScaleFactor(context), return;
), }
const ASubTitle("Status"), _formKey.currentState.save();
const SizedBox( Navigator.of(context).pop(_search);
height: 4, },
), onSaved: (value) {
ServiceRequestStatusMenu( _search.model = value;
initialValue: _search.statusValue, },
onSelect: (status) { ),
_search.statusValue = status; SizedBox(
}, height: 16 * AppStyle.getScaleFactor(context),
), ),
// Padding( const ASubTitle("Status"),
// padding: const EdgeInsets.symmetric(horizontal: 12), const SizedBox(height: 4),
// child: Wrap( ServiceRequestStatusMenu(
// spacing: 10, initialValue: _search.statusValue,
// runSpacing: 10, onSelect: (status) {
// alignment: WrapAlignment.spaceEvenly, _search.statusValue = status;
// children: List.generate( },
// status.length, ),
// (index) { SizedBox(
// bool isSelected = _search.statusValue == status[index]; height: 16 * AppStyle.getScaleFactor(context),
// return FilterItem( ),
// isSelected: isSelected, ASubTitle(_subtitle.assignedEmployee),
// onSelected: (){ const SizedBox(height: 4),
// if(isSelected) { ServiceReportAllUsers(
// _search.statusValue = null; initialValue: _search.assignedEmployee == null ? null : Engineer(id: _search.assignedEmployee.id, name: _search.assignedEmployee.name),
// } else { onSelect: (engineer) {
// _search.statusValue = status[index]; _search.assignedEmployee = AssignedEmployee(id: engineer.id, name: engineer.name);
// } },
// ),
// setState(() {}); SizedBox(
// }, height: 16 * AppStyle.getScaleFactor(context),
// status: status[index], ),
// ); const ASubTitle("Request Date"),
// } const SizedBox(height: 4),
// ServiceReportVisitDateOperator(
// ), initialValue: _search.dateOperator,
// ), onSelect: (status) {
// ), _search.dateOperator = status;
setState(() {});
},
),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const ASubTitle("From"),
ADatePicker(
date: DateTime.tryParse(_search.from ?? ""),
from: DateTime(1950),
onDatePicker: (date) {
_search.from = date?.toIso8601String();
setState(() {});
},
),
],
),
),
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const SizedBox(width: 16),
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false)
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const ASubTitle("To"),
ADatePicker(
date: DateTime.tryParse(_search.to ?? ""),
from: DateTime(1950),
onDatePicker: (date) {
_search.to = date?.toIso8601String();
setState(() {});
},
),
],
),
),
],
),
const SizedBox(width: 16),
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 12),
// child: Wrap(
// spacing: 10,
// runSpacing: 10,
// alignment: WrapAlignment.spaceEvenly,
// children: List.generate(
// status.length,
// (index) {
// bool isSelected = _search.statusValue == status[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected) {
// _search.statusValue = null;
// } else {
// _search.statusValue = status[index];
// }
//
// setState(() {});
// },
// status: status[index],
// );
// }
//
// ),
// ),
// ),
Visibility( Visibility(
visible: widget.initialSearchValue.toMap().isNotEmpty, visible: widget.initialSearchValue.toMap().isNotEmpty,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton( child: AButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
text: _subtitle.clearSearch, text: _subtitle.clearSearch,
onPressed: () { onPressed: () {
_search = ServiceRequestSearch(); _search = ServiceRequestSearch();
Navigator.of(context).pop(_search); Navigator.of(context).pop(_search);
}, },
),
), ),
), ),
), ],
], ),
), ),
), ),
), ),

Loading…
Cancel
Save