You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
445 lines
23 KiB
Dart
445 lines
23 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/models/enums/user_types.dart';
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
import 'package:test_sa/views/pages/user/requests/create_request.dart';
|
|
import 'package:test_sa/views/pages/user/requests/report/create_service_report.dart';
|
|
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
|
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
|
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
|
|
import 'package:test_sa/views/widgets/images/images_list.dart';
|
|
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
|
|
import 'package:test_sa/views/widgets/requests/info_row.dart';
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
import 'package:test_sa/views/widgets/sound/sound_player.dart';
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
import '../../../../models/service_request/search_work_order.dart';
|
|
import 'report/future_service_report.dart';
|
|
|
|
class RequestDetailsPage extends StatelessWidget {
|
|
static final String id = "/call-details";
|
|
final ServiceRequest serviceRequest;
|
|
|
|
const RequestDetailsPage({Key key, this.serviceRequest}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Subtitle _subtitle = AppLocalization.of(context).subtitle;
|
|
UserProvider _userProvider = Provider.of<UserProvider>(context);
|
|
SettingProvider _settingProvider = Provider.of<SettingProvider>(context);
|
|
List<SearchWorkOrder> workOrders = [];
|
|
ServiceRequestsProvider _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
|
return DefaultTabController(
|
|
length: 2,
|
|
child: Scaffold(
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
color: AColors.primaryColor,
|
|
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
|
child: Row(
|
|
children: [
|
|
ABackButton(),
|
|
Expanded(
|
|
child: Center(
|
|
child: Text(
|
|
_subtitle.details,
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
|
),
|
|
),
|
|
),
|
|
_userProvider.user.type == UsersTypes.normal_user
|
|
?
|
|
// AIconButton(
|
|
// iconData: Icons.warning_amber_rounded,
|
|
// color: AColors.white,
|
|
// buttonSize: 42,
|
|
// backgroundColor: AColors.deepOrange,
|
|
// onPressed: (){
|
|
// Navigator.of(context).push(
|
|
// MaterialPageRoute(
|
|
// builder: (_) => ReportIssuesPage(serviceRequest: serviceRequest,)
|
|
// )
|
|
// );
|
|
// },
|
|
// )
|
|
const SizedBox(
|
|
width: 48,
|
|
)
|
|
: AIconButton(
|
|
iconData: Icons.edit,
|
|
color: AColors.white,
|
|
buttonSize: 42,
|
|
backgroundColor: AColors.green,
|
|
onPressed: () async {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(builder: (_) => CreateRequestPage(serviceRequest: serviceRequest)),
|
|
);
|
|
// showModalBottomSheet(
|
|
// context: context,
|
|
// builder: (context) {
|
|
// return ServiceRequestsUpdateDialog(
|
|
// request: serviceRequest,
|
|
// );
|
|
// });
|
|
// DateTime picked = await showDatePicker(
|
|
// context: context,
|
|
// initialDate: DateTime.now(),
|
|
// firstDate: DateTime.now(),
|
|
// lastDate: DateTime.now().add(Duration(days: 182))
|
|
// );
|
|
// if(picked == null){return;}
|
|
// showDialog<void>(
|
|
// context: context,
|
|
// barrierDismissible: false,
|
|
// builder: (BuildContext context) {
|
|
// return CupertinoAlertDialog(
|
|
// title: Text(_subtitle.updatingDots),
|
|
// content: Center(child: CircularProgressIndicator()),
|
|
// );
|
|
// },
|
|
// );
|
|
// int status = await _serviceRequestsProvider.updateDate(
|
|
// user: _userProvider.user,
|
|
// host: _settingProvider.host,
|
|
// request: serviceRequest,
|
|
// newDate: picked.toString().split(" ").first
|
|
// );
|
|
// Navigator.of(context).pop();
|
|
// Fluttertoast.showToast(
|
|
// msg: HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle),
|
|
// );
|
|
},
|
|
),
|
|
SizedBox(
|
|
width: 16,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
serviceRequest.devicePhotos.isEmpty
|
|
? SizedBox.shrink()
|
|
: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
MaterialButton(
|
|
padding: EdgeInsets.zero,
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (_) => Scaffold(
|
|
body: InteractiveViewer(
|
|
child: Center(
|
|
child: ImageLoader(
|
|
url: serviceRequest.devicePhotos.first,
|
|
boxFit: BoxFit.contain,
|
|
),
|
|
),
|
|
),
|
|
)));
|
|
},
|
|
child: SizedBox(
|
|
height: 140 * AppStyle.getScaleFactor(context),
|
|
width: MediaQuery.of(context).size.width,
|
|
child: ImageLoader(
|
|
url: serviceRequest.devicePhotos.first,
|
|
boxFit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
SizedBox(
|
|
height: 60 * AppStyle.getScaleFactor(context),
|
|
child: ImagesList(
|
|
images: serviceRequest.devicePhotos,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
TabBar(labelColor: AColors.primaryColor, tabs: [
|
|
Tab(
|
|
text: _subtitle.general,
|
|
),
|
|
Tab(
|
|
text: _subtitle.serviceRequestInformation,
|
|
),
|
|
]),
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
Expanded(
|
|
child: TabBarView(
|
|
children: [
|
|
ListView(
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
children: [
|
|
RequestInfoRow(
|
|
title: _subtitle.code,
|
|
info: serviceRequest.requestCode,
|
|
),
|
|
RequestInfoRow(
|
|
title: "Asset Number",
|
|
info: serviceRequest.deviceNumber,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.assetName,
|
|
info: serviceRequest.deviceEnName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.deviceModel,
|
|
info: serviceRequest.deviceModel,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.engineerName,
|
|
info: serviceRequest.engineerName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.engineerPhone,
|
|
info: serviceRequest.engineerMobile,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.date,
|
|
info: serviceRequest.date,
|
|
),
|
|
serviceRequest.nextVisitDate == null
|
|
? SizedBox.shrink()
|
|
: RequestInfoRow(
|
|
title: _subtitle.nextVisitDate,
|
|
info: DateFormat('EE dd/MM/yyyy').format(serviceRequest.nextVisitDate),
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
"${_subtitle.status} : ",
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
textScaleFactor: AppStyle.getScaleFactor(context),
|
|
),
|
|
),
|
|
StatusLabel(label: serviceRequest.statusLabel, color: AColors.getRequestStatusColor(serviceRequest.statusValue)),
|
|
],
|
|
),
|
|
Divider(
|
|
color: Theme.of(context).primaryColor,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.hospital,
|
|
info: serviceRequest.hospitalName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.unite,
|
|
info: serviceRequest.departmentName,
|
|
),
|
|
// RequestInfoRow(
|
|
// title: _subtitle.deviceArName,
|
|
// content: serviceRequest.deviceArName,
|
|
// ),
|
|
RequestInfoRow(
|
|
title: _subtitle.deviceName,
|
|
content: serviceRequest.deviceEnName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.maintenanceIssue,
|
|
content: serviceRequest.callComments,
|
|
),
|
|
if (serviceRequest.audio?.isNotEmpty == true)
|
|
ASoundPlayer(
|
|
audio: serviceRequest.audio,
|
|
),
|
|
//
|
|
// Center(
|
|
// child: Padding(
|
|
// padding: EdgeInsets.all(32),
|
|
// child: AButton(
|
|
// text: _subtitle.duplicateRequest,
|
|
// onPressed: () async {
|
|
// bool result = await showDialog(
|
|
// context: context,
|
|
// builder: (_) => AAlertDialog(
|
|
// title: _subtitle.duplicateAlert,
|
|
// content: _subtitle.duplicateAlertMessage,
|
|
// )
|
|
// );
|
|
// if(result == true){
|
|
// showDialog(
|
|
// context: context,
|
|
// builder: (context){
|
|
// return Center(child: CircularProgressIndicator());
|
|
// }
|
|
// );
|
|
// int status = await _serviceRequestsProvider.createDuplicatedReport(
|
|
// host: _settingProvider.host,
|
|
// user: _userProvider.user,
|
|
// request: serviceRequest
|
|
// );
|
|
// Navigator.of(context).pop();
|
|
// ScaffoldMessenger.of(context).showSnackBar(
|
|
// SnackBar(
|
|
// content: Text(
|
|
// HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle)
|
|
// )
|
|
// )
|
|
// );
|
|
// }
|
|
// },
|
|
// ),
|
|
// ),
|
|
// )
|
|
],
|
|
),
|
|
// workOrders.isEmpty ?
|
|
FutureBuilder(
|
|
future: _serviceRequestsProvider.searchWorkOrders(callId: serviceRequest.requestCode),
|
|
builder: (context, snap) {
|
|
workOrders = snap.data as List<SearchWorkOrder>;
|
|
if (snap.connectionState == ConnectionState.waiting) return Center(child: CircularProgressIndicator());
|
|
if (snap.connectionState == ConnectionState.done && (snap.data?.length ?? 0) != 0) {
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
ListView.separated(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
padding: EdgeInsets.all(21),
|
|
itemCount: workOrders.length,
|
|
separatorBuilder: (czt, index) => 21.height,
|
|
itemBuilder: (context, index) {
|
|
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
return ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
primary: itemColor.withOpacity(.7),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
),
|
|
),
|
|
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
|
|
onPressed: () {
|
|
// onPressed(request);
|
|
},
|
|
child: Column(
|
|
children: [
|
|
RequestInfoRow(
|
|
title: _subtitle.callId,
|
|
content: serviceRequest.requestCode,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.orderWorkNumber,
|
|
info: workOrders[index].workOrderNo.toString(),
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.visitDate,
|
|
info: workOrders[index].visitDate,
|
|
),
|
|
RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name ?? ""),
|
|
RequestInfoRow(
|
|
title: _subtitle.assetSN,
|
|
info: workOrders[index].callRequest.asset.assetSerialNo,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.assetName,
|
|
info: workOrders[index].callRequest.asset.modelDefinition.assetName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.model,
|
|
info: workOrders[index].callRequest.asset.modelDefinition.modelName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.site,
|
|
info: workOrders[index].callRequest.asset.site.custName,
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.maintenanceSituation,
|
|
info: workOrders[index].calllastSituation.name ?? '',
|
|
),
|
|
RequestInfoRow(
|
|
title: _subtitle.currentSituation,
|
|
info: workOrders[index].currentSituation.name ?? '',
|
|
),
|
|
_userProvider.user.type == UsersTypes.engineer && workOrders[index].workOrderNo != null
|
|
? Padding(
|
|
padding: EdgeInsets.all(32),
|
|
child: AButton(
|
|
text: _subtitle.editServiceReport,
|
|
onPressed: () {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => FutureServiceReport(
|
|
request: serviceRequest,
|
|
workOrder: workOrders[index],
|
|
)),
|
|
);
|
|
},
|
|
),
|
|
)
|
|
: SizedBox.shrink(),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
if (_userProvider.user.type == UsersTypes.engineer)
|
|
Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32),
|
|
child: AButton(
|
|
text: "Create Work Order",
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CreateServiceReport(request: serviceRequest)));
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
return Column(
|
|
children: [
|
|
Expanded(
|
|
child: Center(
|
|
child: ASubTitle(_subtitle.dataNotFound),
|
|
),
|
|
),
|
|
if (_userProvider.user.type == UsersTypes.engineer)
|
|
Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32),
|
|
child: AButton(
|
|
text: "Create Work Order",
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CreateServiceReport(request: serviceRequest)));
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|