Action duration implemented

merge-requests/60/head
haroon amjad 2 years ago
parent cffe185cda
commit 4ff3a5093b

@ -381,6 +381,30 @@ class DateUtil {
return "";
}
static String formatDuration(Duration d) {
var seconds = d.inSeconds;
var days = seconds ~/ Duration.secondsPerDay;
seconds -= days * Duration.secondsPerDay;
var hours = seconds ~/ Duration.secondsPerHour;
seconds -= hours * Duration.secondsPerHour;
var minutes = seconds ~/ Duration.secondsPerMinute;
seconds -= minutes * Duration.secondsPerMinute;
List<String> tokens = [];
if (days != 0) {
tokens.add('$days days');
}
if (tokens.isNotEmpty || hours != 0) {
tokens.add('$hours hours');
}
if (tokens.isNotEmpty || minutes != 0) {
tokens.add('$minutes mins');
}
tokens.add('$seconds secs');
return tokens.join(' ');
}
/// get data formatted like 26/4/2020
/// [dateTime] convert DateTime to data formatted according to language
static String getDayMonthYearDateFormattedLang(DateTime dateTime, bool isArabic) {
@ -431,30 +455,30 @@ class DateUtil {
return "/Date(" + DateFormat('mm-dd-yyy').parse(isoDate).millisecondsSinceEpoch.toString() + ")/";
}
// static String getDay(DayOfWeek dayOfWeek) {
// switch (dayOfWeek) {
// case DayOfWeek.Monday:
// return "Monday";
// break;
// case DayOfWeek.Tuesday:
// return "Tuesday";
// break;
// case DayOfWeek.Wednesday:
// return "Wednesday";
// break;
// case DayOfWeek.Thursday:
// return "Thursday";
// break;
// case DayOfWeek.Friday:
// return "Friday";
// break;
// case DayOfWeek.Saturday:
// return "Saturday";
// break;
// case DayOfWeek.Sunday:
// return "Sunday";
// break;
// }
// return "";
// }
// static String getDay(DayOfWeek dayOfWeek) {
// switch (dayOfWeek) {
// case DayOfWeek.Monday:
// return "Monday";
// break;
// case DayOfWeek.Tuesday:
// return "Tuesday";
// break;
// case DayOfWeek.Wednesday:
// return "Wednesday";
// break;
// case DayOfWeek.Thursday:
// return "Thursday";
// break;
// case DayOfWeek.Friday:
// return "Friday";
// break;
// case DayOfWeek.Saturday:
// return "Saturday";
// break;
// case DayOfWeek.Sunday:
// return "Sunday";
// break;
// }
// return "";
// }
}

@ -22,8 +22,9 @@ extension EmailValidator on String {
style: TextStyle(fontSize: 10, fontStyle: fontStyle ?? FontStyle.normal, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4),
);
Widget toText11({Color? color, FontWeight? weight, bool isUnderLine = false, bool isBold = false}) => Text(
Widget toText11({Color? color, FontWeight? weight, bool isUnderLine = false, bool isBold = false, int maxLine = 0}) => Text(
this,
maxLines: (maxLine > 0) ? maxLine : null,
style: TextStyle(
fontSize: 11,
fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600),

@ -86,9 +86,9 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
padding: const EdgeInsets.all(21),
physics: const BouncingScrollPhysics(),
children: [
if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData() else Utils.getNoDataWidget(context),
if (poItemHistoryList.isNotEmpty) loadPoItemHistoryData() else Utils.getNoDataWidget(context),
if (quotationAnalysisList.isNotEmpty) loadQuotationAnalysisData() else Utils.getNoDataWidget(context)
if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData(),
if (poItemHistoryList.isNotEmpty) loadPoItemHistoryData(),
if (quotationAnalysisList.isNotEmpty) loadQuotationAnalysisData()
],
),
);
@ -102,21 +102,39 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
ItemDetailView(LocaleKeys.requestNumber.tr(), moItemHistoryList[index].rEQUESTNUMBER ?? ""),
ItemDetailView(LocaleKeys.uom.tr(), moItemHistoryList[index].uNITOFMEASURE ?? ""),
ItemDetailView(LocaleKeys.quantity.tr(), moItemHistoryList[index].qUANTITY?.toString() ?? ""),
ItemDetailView(LocaleKeys.dateRequired.tr(), moItemHistoryList[index].dATEREQUIRED ?? ""),
ItemDetailView(LocaleKeys.lineStatus.tr(), moItemHistoryList[index].lINESTATUSDIS ?? ""),
ItemDetailView(LocaleKeys.statusDate.tr(), moItemHistoryList[index].sTATUSDATE ?? ""),
ItemDetailView(LocaleKeys.transactionType.tr(), moItemHistoryList[index].tRANSACTIONTYPENAME ?? ""),
ItemDetailView(LocaleKeys.organization.tr(), moItemHistoryList[index].oRGANIZATIONNAME ?? ""),
ItemDetailView(LocaleKeys.operatingCode.tr(), moItemHistoryList[index].oRGANIZATIONCODE ?? ""),
ItemDetailView(LocaleKeys.operatingUnit.tr(), moItemHistoryList[index].oPERATINGUNITNAME ?? ""),
ItemDetailView(LocaleKeys.fromSubInventory.tr(), moItemHistoryList[index].fROMSUBINVENTORYCODE ?? ""),
ItemDetailView(LocaleKeys.fromLocator.tr(), moItemHistoryList[index].fROMLOCATOR ?? ""),
ItemDetailView(LocaleKeys.toSubInventory.tr(), moItemHistoryList[index].tOSUBINVENTORYCODE ?? ""),
ItemDetailView(LocaleKeys.toLocator.tr(), moItemHistoryList[index].tOLOCATOR ?? ""),
ItemDetailView(LocaleKeys.shipToLocation.tr(), moItemHistoryList[index].sHIPTOLOCATION ?? ""),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.requestNumber.tr(), moItemHistoryList[index].rEQUESTNUMBER ?? ""),
ItemDetailViewCol(LocaleKeys.uom.tr(), moItemHistoryList[index].uNITOFMEASURE ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quantity.tr(), moItemHistoryList[index].qUANTITY?.toString() ?? ""),
ItemDetailViewCol(LocaleKeys.dateRequired.tr(), moItemHistoryList[index].dATEREQUIRED ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.lineStatus.tr(), moItemHistoryList[index].lINESTATUSDIS ?? ""),
ItemDetailViewCol(LocaleKeys.statusDate.tr(), moItemHistoryList[index].sTATUSDATE ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.transactionType.tr(), moItemHistoryList[index].tRANSACTIONTYPENAME ?? ""),
ItemDetailViewCol(LocaleKeys.organization.tr(), moItemHistoryList[index].oRGANIZATIONNAME ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.operatingCode.tr(), moItemHistoryList[index].oRGANIZATIONCODE ?? ""),
ItemDetailViewCol(LocaleKeys.operatingUnit.tr(), moItemHistoryList[index].oPERATINGUNITNAME ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.fromSubInventory.tr(), moItemHistoryList[index].fROMSUBINVENTORYCODE ?? ""),
ItemDetailViewCol(LocaleKeys.fromLocator.tr(), moItemHistoryList[index].fROMLOCATOR ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.toSubInventory.tr(), moItemHistoryList[index].tOSUBINVENTORYCODE ?? ""),
ItemDetailViewCol(LocaleKeys.toLocator.tr(), moItemHistoryList[index].tOLOCATOR ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.shipToLocation.tr(), moItemHistoryList[index].sHIPTOLOCATION ?? ""),
Container(),
isItLast: true,
),
],
).objectContainerView(),
separatorBuilder: (cxt, index) => 12.height,
@ -131,10 +149,6 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// ItemDetailGrid(
// ItemDetailViewCol(LocaleKeys.from.tr(), workListData!.fROMUSER ?? ""),
// ItemDetailViewCol(LocaleKeys.to.tr(), workListData!.tOUSER ?? ""),
// ),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.operatingUnit.tr(), poItemHistoryList[index].oUNAME ?? ""),
ItemDetailViewCol(LocaleKeys.poNumber.tr(), poItemHistoryList[index].pONUMBER ?? ""),
@ -182,20 +196,35 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
ItemDetailView(LocaleKeys.quotationNumber.tr(), quotationAnalysisList[index].qUOTNUM ?? ""),
ItemDetailView(LocaleKeys.vendorName.tr(), quotationAnalysisList[index].vENDORNAME ?? ""),
ItemDetailView(LocaleKeys.itemCode.tr(), quotationAnalysisList[index].iTEMCODE ?? ""),
ItemDetailView(LocaleKeys.description.tr(), quotationAnalysisList[index].iTEMDESC ?? ""),
ItemDetailView(LocaleKeys.quotationQty.tr(), quotationAnalysisList[index].qUOTQTY?.toString() ?? ""),
ItemDetailView(LocaleKeys.quotationUOM.tr(), quotationAnalysisList[index].qUOTUOM ?? ""),
ItemDetailView(LocaleKeys.quotationNetPrice.tr(), quotationAnalysisList[index].qUOTUNITPRICE?.toString() ?? ""),
ItemDetailView(LocaleKeys.quotationLineTotal.tr(), quotationAnalysisList[index].qUOTLINETOTAL?.toString() ?? ""),
ItemDetailView(LocaleKeys.quotationBonusQuantity.tr(), quotationAnalysisList[index].qUOTBONUSQTY ?? ""),
ItemDetailView(LocaleKeys.quotationDeliveryDate.tr(), quotationAnalysisList[index].qUOTDELIVERYDATE ?? ""),
ItemDetailView(LocaleKeys.quotationMFGPartNumber.tr(), quotationAnalysisList[index].qUOTMFGPARTNUM ?? ""),
ItemDetailView(LocaleKeys.rfqNumber.tr(), quotationAnalysisList[index].rFQNUM ?? ""),
ItemDetailView(LocaleKeys.rfqQty.tr(), quotationAnalysisList[index].rFQQTY?.toString() ?? ""),
ItemDetailView(LocaleKeys.rfqUOM.tr(), quotationAnalysisList[index].rFQUOM ?? ""),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quotationNumber.tr(), quotationAnalysisList[index].qUOTNUM ?? ""),
ItemDetailViewCol(LocaleKeys.vendorName.tr(), quotationAnalysisList[index].vENDORNAME ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.itemCode.tr(), quotationAnalysisList[index].iTEMCODE ?? ""),
ItemDetailViewCol(LocaleKeys.description.tr(), quotationAnalysisList[index].iTEMDESC ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quotationQty.tr(), quotationAnalysisList[index].qUOTQTY?.toString() ?? ""),
ItemDetailViewCol(LocaleKeys.quotationUOM.tr(), quotationAnalysisList[index].qUOTUOM ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quotationNetPrice.tr(), quotationAnalysisList[index].qUOTUNITPRICE?.toString() ?? ""),
ItemDetailViewCol(LocaleKeys.quotationLineTotal.tr(), quotationAnalysisList[index].qUOTLINETOTAL?.toString() ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quotationBonusQuantity.tr(), quotationAnalysisList[index].qUOTBONUSQTY ?? ""),
ItemDetailViewCol(LocaleKeys.quotationDeliveryDate.tr(), quotationAnalysisList[index].qUOTDELIVERYDATE ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.quotationMFGPartNumber.tr(), quotationAnalysisList[index].qUOTMFGPARTNUM ?? ""),
ItemDetailViewCol(LocaleKeys.rfqNumber.tr(), quotationAnalysisList[index].rFQNUM ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol(LocaleKeys.rfqQty.tr(), quotationAnalysisList[index].rFQQTY?.toString() ?? ""),
ItemDetailViewCol(LocaleKeys.rfqUOM.tr(), quotationAnalysisList[index].rFQUOM ?? ""),
isItLast: true,
)
],
).objectContainerView(title: "${quotationAnalysisList[index].iTEMCODE}-${quotationAnalysisList[index].iTEMDESC}"),
separatorBuilder: (cxt, index) => 12.height,

@ -27,7 +27,7 @@ class ActionsFragment extends StatelessWidget {
itemCount: actionHistoryList.length,
padding: EdgeInsets.all(21),
itemBuilder: (context, index) {
return showItem(context, actionHistoryList[index]);
return showItem(context, actionHistoryList[index], index);
},
separatorBuilder: (BuildContext context, int index) {
return 12.height;
@ -36,7 +36,7 @@ class ActionsFragment extends StatelessWidget {
);
}
Widget showItem(BuildContext context, GetActionHistoryList actionHistory) {
Widget showItem(BuildContext context, GetActionHistoryList actionHistory, int index) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
@ -89,7 +89,9 @@ class ActionsFragment extends StatelessWidget {
if (actionHistory.nOTIFICATIONDATE!.isNotEmpty)
DateUtil.formatDateToDate(DateUtil.convertSimpleStringDateToDateddMMyyyy(actionHistory.nOTIFICATIONDATE!), false).toText12(color: MyColors.lightTextColor),
],
)
),
10.height,
getActionDuration(index).toText11(maxLine: 1, color: const Color(0xff1FA269))
],
),
)
@ -127,8 +129,24 @@ class ActionsFragment extends StatelessWidget {
);
}
String getActionDuration(int index) {
if (actionHistoryList[index].aCTIONCODE == "SUBMIT") {
return "";
} else if(actionHistoryList[index].aCTIONCODE == "PENDING") {
DateTime dateTimeFrom = DateUtil.convertSimpleStringDateToDate(actionHistoryList[++index].nOTIFICATIONDATE!);
Duration duration = DateTime.now().difference(dateTimeFrom);
return "Action duration: " + DateUtil.formatDuration(duration);
} else {
DateTime dateTimeTo = DateUtil.convertSimpleStringDateToDate(actionHistoryList[index].nOTIFICATIONDATE!);
DateTime dateTimeFrom = DateUtil.convertSimpleStringDateToDate(actionHistoryList[++index].nOTIFICATIONDATE!);
Duration duration = dateTimeTo.difference(dateTimeFrom);
print(dateTimeTo);
print(dateTimeFrom);
return "Action duration: " + DateUtil.formatDuration(duration);
}
}
Color getStatusColor(String code) {
print("code:$code");
if (code == "SUBMIT") {
return const Color(0xff2E303A);
} else if (code == "REJECTED") {
@ -139,7 +157,7 @@ class ActionsFragment extends StatelessWidget {
return MyColors.orange;
} else if (code == "APPROVED" || code == "APPROVE" || code == "ANSWER_INFO") {
return const Color(0xff1FA269);
} else if (code == "REQUEST_INFO"|| code == "FORWARD") {
} else if (code == "REQUEST_INFO" || code == "FORWARD") {
return const Color(0xff2E303A);
} else if (code != "SUBMIT" && code != "REJECT" && code != "PENDING") {
return MyColors.orange;

Loading…
Cancel
Save