Action duration implemented

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

@ -381,6 +381,30 @@ class DateUtil {
return ""; 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 /// get data formatted like 26/4/2020
/// [dateTime] convert DateTime to data formatted according to language /// [dateTime] convert DateTime to data formatted according to language
static String getDayMonthYearDateFormattedLang(DateTime dateTime, bool isArabic) { static String getDayMonthYearDateFormattedLang(DateTime dateTime, bool isArabic) {
@ -431,30 +455,30 @@ class DateUtil {
return "/Date(" + DateFormat('mm-dd-yyy').parse(isoDate).millisecondsSinceEpoch.toString() + ")/"; return "/Date(" + DateFormat('mm-dd-yyy').parse(isoDate).millisecondsSinceEpoch.toString() + ")/";
} }
// static String getDay(DayOfWeek dayOfWeek) { // static String getDay(DayOfWeek dayOfWeek) {
// switch (dayOfWeek) { // switch (dayOfWeek) {
// case DayOfWeek.Monday: // case DayOfWeek.Monday:
// return "Monday"; // return "Monday";
// break; // break;
// case DayOfWeek.Tuesday: // case DayOfWeek.Tuesday:
// return "Tuesday"; // return "Tuesday";
// break; // break;
// case DayOfWeek.Wednesday: // case DayOfWeek.Wednesday:
// return "Wednesday"; // return "Wednesday";
// break; // break;
// case DayOfWeek.Thursday: // case DayOfWeek.Thursday:
// return "Thursday"; // return "Thursday";
// break; // break;
// case DayOfWeek.Friday: // case DayOfWeek.Friday:
// return "Friday"; // return "Friday";
// break; // break;
// case DayOfWeek.Saturday: // case DayOfWeek.Saturday:
// return "Saturday"; // return "Saturday";
// break; // break;
// case DayOfWeek.Sunday: // case DayOfWeek.Sunday:
// return "Sunday"; // return "Sunday";
// break; // break;
// } // }
// return ""; // 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), 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, this,
maxLines: (maxLine > 0) ? maxLine : null,
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600), fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600),

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

@ -27,7 +27,7 @@ class ActionsFragment extends StatelessWidget {
itemCount: actionHistoryList.length, itemCount: actionHistoryList.length,
padding: EdgeInsets.all(21), padding: EdgeInsets.all(21),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return showItem(context, actionHistoryList[index]); return showItem(context, actionHistoryList[index], index);
}, },
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {
return 12.height; 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( return Container(
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -89,7 +89,9 @@ class ActionsFragment extends StatelessWidget {
if (actionHistory.nOTIFICATIONDATE!.isNotEmpty) if (actionHistory.nOTIFICATIONDATE!.isNotEmpty)
DateUtil.formatDateToDate(DateUtil.convertSimpleStringDateToDateddMMyyyy(actionHistory.nOTIFICATIONDATE!), false).toText12(color: MyColors.lightTextColor), 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) { Color getStatusColor(String code) {
print("code:$code");
if (code == "SUBMIT") { if (code == "SUBMIT") {
return const Color(0xff2E303A); return const Color(0xff2E303A);
} else if (code == "REJECTED") { } else if (code == "REJECTED") {
@ -139,7 +157,7 @@ class ActionsFragment extends StatelessWidget {
return MyColors.orange; return MyColors.orange;
} else if (code == "APPROVED" || code == "APPROVE" || code == "ANSWER_INFO") { } else if (code == "APPROVED" || code == "APPROVE" || code == "ANSWER_INFO") {
return const Color(0xff1FA269); return const Color(0xff1FA269);
} else if (code == "REQUEST_INFO"|| code == "FORWARD") { } else if (code == "REQUEST_INFO" || code == "FORWARD") {
return const Color(0xff2E303A); return const Color(0xff2E303A);
} else if (code != "SUBMIT" && code != "REJECT" && code != "PENDING") { } else if (code != "SUBMIT" && code != "REJECT" && code != "PENDING") {
return MyColors.orange; return MyColors.orange;

Loading…
Cancel
Save