add work order improvements.

merge-requests/31/merge
Sikander Saleem 3 years ago
parent 5d4da1961f
commit 74b7fc4130

@ -319,11 +319,11 @@ class ServiceRequestsProvider extends ChangeNotifier {
"reason": report.reason?.toMap(),
"startofWorkTime": report.startDate?.toIso8601String() ?? "",
"endofWorkTime": report.endDate?.toIso8601String() ?? "",
"workingHours": report.timer?.durationInSecond,
"workingHours": ((report?.endDate?.difference(report?.startDate)?.inMinutes ?? 0) / 60),
"travelingHours": report.travelingHours,
"travelingExpenses": report.travelingExpense ?? 0,
"faultDescription": {
"id": report.faultDescriptionId ?? 0,
"id": report.faultDescriptionId,
"defectName": report.type?.name,
"workPerformed": report.workPreformed,
"estimatedTime": report.operatingHours,
@ -331,8 +331,8 @@ class ServiceRequestsProvider extends ChangeNotifier {
"sparePartsWorkOrders": report.parts
?.map(
(p) => {
"id": p.id,
"sparePart": {"id": p.reportPartID ?? 0, "partNo": p.code, "partName": p.name},
"id": p.reportPartID ?? 0,
"sparePart": {"id": p.id, "partNo": p.code, "partName": p.name},
"qty": p.quantity
},
)

@ -10,7 +10,7 @@ import 'package:test_sa/models/timer_model.dart';
class ServiceReport {
int id;
String operatingHours;
double operatingHours;
DateTime visitDate;
DateTime endDate;
DateTime startDate;
@ -25,7 +25,7 @@ class ServiceReport {
String workPreformed;
//String workHours;
String travelingHours;
double travelingHours;
String invoiceNumber;
String invoiceCode;
List<Part> parts;
@ -89,7 +89,7 @@ class ServiceReport {
_map["endofWorkTime"] = (timer.endAt ?? DateTime.now()).toIso8601String();
_map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
}
if (travelingHours != null && travelingHours.isNotEmpty) _map["traveling_hours"] = travelingHours;
if (travelingHours != null && travelingHours.toString().isNotEmpty) _map["traveling_hours"] = travelingHours;
// if(workPreformed != null && workPreformed.isNotEmpty){
// _map["faultDescription"] = {
// //"id":faultDescriptionId ?? 0,

@ -101,6 +101,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Stack(
children: [
ListView(
padding: const EdgeInsets.all(16),
children: [
//AppNameBar(),
const SizedBox(
@ -115,22 +116,22 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle("Caller Info"),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
const BoxShadow(
width: double.infinity,
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: const [
BoxShadow(
color: AColors.grey,
offset: Offset(0, -1),
)
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8,
),
Wrap(
child: Wrap(
spacing: 10,
children: [
ASubTitle(
@ -153,8 +154,22 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
)
],
),
const Divider(),
),
ASubTitle("Work Order Details"),
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
BoxShadow(
color: AColors.grey,
offset: Offset(0, -1),
),
]),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Report type and Reasons
Row(
children: [
@ -383,7 +398,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
ATextFormField(
initialValue: null,
textAlign: TextAlign.center,
hintText: _serviceReport.startDate == null ? "0" : _serviceReport?.endDate?.difference(_serviceReport?.startDate)?.inHours?.toString() ?? "0",
hintText: _serviceReport.startDate == null
? "0"
: ((_serviceReport?.endDate?.difference(_serviceReport?.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0",
enable: false,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.isNumeric(value) ? null : _subtitle.requiredWord,
@ -396,28 +413,22 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
// const ASubTitle("Assigned Employee"),
// const SizedBox(
// height: 8,
// ),
// _validate && _serviceReport.engineer == null
// ? ASubTitle(
// _subtitle.requiredWord,
// color: Colors.red,
// )
// : const SizedBox.shrink(),
// const SizedBox(
// height: 4,
// ),
// EngineersMenu(
// initialValue: _serviceReport.engineer,
// onSelect: (engineer) {
// _serviceReport.engineer = engineer;
// },
// ),
// const SizedBox(
// height: 8,
// ),
const ASubTitle("Assigned Employee"),
const SizedBox(height: 8),
_validate && _serviceReport.engineer == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(height: 4),
EngineersMenu(
initialValue: _serviceReport.engineer,
onSelect: (engineer) {
_serviceReport.engineer = engineer;
},
),
const SizedBox(height: 8),
// invoice number & code
_serviceReport.callLastSituation?.id != 12
? const SizedBox.shrink()
@ -444,17 +455,13 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
],
),
),
const SizedBox(
width: 8,
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
@ -485,9 +492,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
],
),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.faultDescriptionId?.toString(),
textAlign: TextAlign.center,
@ -499,9 +504,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_serviceReport.faultDescriptionId = int.tryParse(value) ?? 0;
},
),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
Row(
children: [
ASubTitle(_subtitle.workPreformed),
@ -516,9 +519,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
],
),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.workPreformed,
textAlign: TextAlign.center,
@ -530,13 +531,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_serviceReport.workPreformed = value;
},
),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
Row(
children: [
// reasons
@ -545,9 +542,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reasons),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status) {
@ -557,9 +552,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
],
),
),
const SizedBox(
width: 8,
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -578,22 +571,16 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
],
),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
ASubTitle(_subtitle.repairLocation),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ServiceReportRepairLocation(
initialValue: _serviceReport.repairLocation,
onSelect: (status) {
_serviceReport.repairLocation = status;
},
),
const SizedBox(
height: 16,
),
const SizedBox(height: 16),
ASubTitle(_subtitle.travelingExpense),
const SizedBox(
height: 4,
@ -662,7 +649,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
height: 4,
),
ATextFormField(
initialValue: _serviceReport?.travelingHours,
initialValue: _serviceReport?.travelingHours?.toString(),
textAlign: TextAlign.center,
hintText: "i.e 3, 3.5, 4",
style: Theme.of(context).textTheme.subtitle1,
@ -671,7 +658,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value) {
_serviceReport.travelingHours = value;
_serviceReport.travelingHours = double.tryParse(value) ?? 0.0;
},
),
],
@ -729,13 +716,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ],
// ),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
ASubTitle(_subtitle.comment),
const SizedBox(
height: 4,
),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.comment,
hintText: "Technical Comment",
@ -759,9 +742,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
const ASubTitle("Engineer Signature"),
ESignature(
oldSignature: _serviceReport.signatureEngineer,
@ -777,7 +758,25 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
const SizedBox(
height: 8,
),
],
),
),
// Part Number and Quantity
ASubTitle("Spare Parts"),
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
BoxShadow(
color: AColors.grey,
offset: Offset(0, -1),
)
]),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Expanded(
@ -832,16 +831,16 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
],
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: AButton(
],
),
AButton(
text: _subtitle.submit,
onPressed: () async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return;
}
// if (!_formKey.currentState.validate()) {
// setState(() {});
// return;
// }
if (!_serviceReport.validate()) return;
_formKey.currentState.save();
@ -872,7 +871,6 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
}
},
),
),
const SizedBox(
height: 300,
)

Loading…
Cancel
Save