Commit e92aa2ba authored by Jasa Digital's avatar Jasa Digital

02/11/22

parent 1d782096
......@@ -14,6 +14,7 @@ import 'package:byod/models/filter_menu.dart';
import 'package:byod/models/member_info.dart';
import 'package:byod/models/payment_list.dart';
import 'package:byod/models/voucher_list.dart';
import 'package:byod/ui/home/new_home2.dart';
import 'package:byod/ui/viewbill/view_bill_new.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -1020,6 +1021,9 @@ class Api {
jsonObject['data']['rdm_staff_courier_name'] ?? "",
"rdm_staff_courier_mobile":
jsonObject['data']['rdm_staff_courier_mobile'] ?? "",
"branch_name": jsonObject['data']['branch_name'],
"type": jsonObject['data']['type'],
"payment_mode": jsonObject['data']['payment_mode'],
};
if (jsonObject['data']['type'] == typeOrderDelivery) {
......@@ -1483,10 +1487,17 @@ class Api {
// MaterialPageRoute(
// builder: (_) => FinishOrder(pinOrder: jsonObject['pin'])));
context.read<OrdersBloc>().clearOrder();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const ViewBillNew()),
(route) => false);
if (getPaymentMode() == openBill) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const NewHome2()),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const ViewBillNew()),
(route) => false);
}
} else if (jsonObject['code'] == 'ORDER_LOCK') {
await EasyLoading.dismiss();
EasyLoading.showToast(jsonObject['msg']);
......@@ -2156,12 +2167,16 @@ class Api {
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
setBranch(newBranch);
setBranchName(jsonObject['data']['code']);
setBranchName(jsonObject['data']['name']);
setLatOutlet(jsonObject['data']['lat']);
setLongOutlet(jsonObject['data']['long']);
setOpenTime(jsonObject['data']['open_time']);
setCloseTime(jsonObject['data']['close_time']);
setServiceRadius(jsonObject['data']['service_radius']);
setAddressOutlet(jsonObject['data']['address']);
setIsDelivery(jsonObject['data']['is_delivery']);
setIsPickup(jsonObject['data']['is_pickup']);
setPhoneOutlet(jsonObject['data']['mobile']);
}
Map<String, dynamic> returnResult = {
"status": jsonObject['status'],
......@@ -2196,8 +2211,6 @@ class Api {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPointRdm}get_address/";
String sessionId = getSessionId();
Address defaultResult = Address(
id: '',
label: '',
......@@ -2209,6 +2222,7 @@ class Api {
recepientPhone: '',
notes: '',
);
String sessionId = getSessionId();
try {
Map data = {
"session_id": sessionId,
......
......@@ -80,6 +80,18 @@ String getOrderStatus(int status) {
}
}
String typeOrderString(int typeOrder) {
if (typeOrder == typeOrderDineIn) {
return 'Dine In';
} else if (typeOrder == typeOrderDelivery) {
return 'Delivery';
} else if (typeOrder == typeOrderPickup) {
return 'Pickup';
} else {
return 'Unknown';
}
}
Color getOrderStatusColor(int status) {
if (status == completeOrder) {
return successColor;
......@@ -185,7 +197,7 @@ String formatDate(String timeString, {toLocal = false}) {
}
void setIsCanChangeDeliveryPickupFunc(int orderState) {
if (orderState >= orderStatePaid) {
if (orderState >= orderStatePending) {
setIsCanChangeDeliveryPickup(false);
} else {
setIsCanChangeDeliveryPickup(true);
......
......@@ -201,7 +201,7 @@ class EmoticonRateNew extends StatelessWidget {
controller: rateNote,
maxLength: maxLengthTextField,
decoration: const InputDecoration(
labelText: 'Beri Masukan',
labelText: 'Beri Penilaian',
labelStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 12,
......@@ -280,7 +280,7 @@ class EmoticonRateNew extends StatelessWidget {
child: Center(
child: defaultText(
context,
'Kirim Masukan',
'Kirim Penilaian',
style: rincianPembayaran(
color: textInButton,
fontWeight: FontWeight.w400,
......
import 'package:byod/helper/helper.dart';
import 'package:byod/models/payment_list.dart';
import 'bill_detail.dart';
......@@ -29,6 +30,9 @@ class Bill {
int deliveryState;
String courierName;
String courierPhone;
String branchName;
int typeOrder;
int paymentMode;
// List<MemberInfo> memberInfo;
Bill({
......@@ -58,6 +62,9 @@ class Bill {
this.deliveryState = 0,
this.courierName = '',
this.courierPhone = '',
this.branchName = '',
this.typeOrder = typeOrderDineIn,
this.paymentMode = openBill
// this.memberInfo = const []
});
......@@ -89,6 +96,9 @@ class Bill {
deliveryState: json['delivery_state'] ?? 0,
courierName: json['rdm_staff_courier_name'] ?? '',
courierPhone: json['rdm_staff_courier_mobile'] ?? '',
branchName: json['branch_name'] ?? '',
typeOrder: json['type'] ?? typeOrderDineIn,
paymentMode: json['payment_mode'] ?? openBill,
// memberInfo: json['member_info']
);
}
......
......@@ -44,7 +44,7 @@ class CustomAppBarConfirm extends StatelessWidget {
Center(
child: defaultText(
context,
'Konfirmasi Orderan',
'Konfirmasi Pesanan',
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: appBarNameViewBill(),
......
......@@ -81,7 +81,7 @@ class HistoryOrderNew extends StatelessWidget {
borderRadius: BorderRadius.circular(6),
color: backgroundWhite,
),
height: 72,
// height: 72,
child: Container(
padding: const EdgeInsets.only(
left: 16,
......@@ -109,6 +109,14 @@ class HistoryOrderNew extends StatelessWidget {
context,
"Rp ${formatNumber().format(amountParseToInt(jsonDecodeHistory['total_order']))}",
style: historyOrderStyle(),
),
const SizedBox(
height: 4,
),
defaultText(
context,
jsonDecodeHistory['typeOrder'],
style: historyOrderStyle(),
)
],
),
......
......@@ -78,7 +78,9 @@ class MenuListUtama extends StatelessWidget {
categoryNonFav[i].name,
style: menuNameStyle(),
),
const Spacer(),
const SizedBox(
height: 10,
),
defaultText(
maxLines: 2,
overFlow: TextOverflow.ellipsis,
......@@ -86,6 +88,7 @@ class MenuListUtama extends StatelessWidget {
categoryNonFav[i].description,
style: deskripsiMenuStyle(),
),
const Spacer(),
const SizedBox(
height: 4,
),
......
......@@ -192,6 +192,10 @@ class _NewHome2State extends State<NewHome2> {
isCallDeliveryCharge: false,
isGetBranchList: true,
);
context
.read<ChangeDeliveryPickupBloc>()
.toDelivery(getIsCustomerDelivery());
}
// double heightTotal = MediaQuery.of(context).size.height;
double appBarHeight = 50;
......@@ -694,7 +698,7 @@ class _NewHome2State extends State<NewHome2> {
child: BlocBuilder<ChangeDeliveryPickupBloc, bool>(
builder: (ctx, isDelivery) {
return ComponentNameUser(
isDeliveryPickuup: true,
isDeliveryPickuup: getIsDeliveryPickup(),
backgroundColorComponent: backgroundColor,
isFromMenu: true,
isdelivery: isDelivery,
......
......@@ -49,7 +49,7 @@ class _SplashState extends State<Splash> {
}
}
int durationDelayBeforToMenu = 2000;
int durationDelayBeforToMenu = 3000;
@override
void initState() {
......@@ -82,13 +82,13 @@ class _SplashState extends State<Splash> {
}
widget.context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
'',
'',
getRole(),
getCashierName(),
'',
widget.context,
getBrancList: true,
// getBrancList: true,
);
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
......
......@@ -11,11 +11,13 @@ class RincianPembayaran extends StatelessWidget {
required this.dataBill,
required this.totalDiscount,
required this.outStandingAll,
this.serviceCharge = 0,
}) : super(key: key);
final List<Bill> dataBill;
final int totalDiscount;
final int outStandingAll;
final int serviceCharge;
@override
Widget build(BuildContext context) {
......@@ -89,15 +91,47 @@ class RincianPembayaran extends StatelessWidget {
),
],
),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
(dataBill[0].paymentMode == openBill)
? Column(
children: [
const SizedBox(
height: 8,
),
Row(
children: [
defaultText(
context,
'Service',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
const Spacer(),
defaultText(
context,
(serviceCharge == 0)
? '-'
: 'Rp ${formatNumber().format(serviceCharge)}',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
],
),
],
)
: const SizedBox(),
(dataBill[0].typeOrder != typeOrderDineIn)
? (dataBill[0].typeOrder== typeOrderDelivery)
? const SizedBox(
height: 8,
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
(dataBill[0].typeOrder != typeOrderDineIn)
? (dataBill[0].typeOrder== typeOrderDelivery)
? Row(
children: [
defaultText(
......@@ -123,12 +157,12 @@ class RincianPembayaran extends StatelessWidget {
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? const SizedBox(
height: 8,
)
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? Row(
children: [
defaultText(
......@@ -153,12 +187,12 @@ class RincianPembayaran extends StatelessWidget {
],
)
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? const SizedBox(
height: 8,
)
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? Row(
children: [
defaultText(
......
......@@ -18,6 +18,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:intl/intl.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:time_picker_widget/time_picker_widget.dart';
import '../../api/api.dart';
import '../../bloc/address_user_bloc.dart';
......@@ -73,7 +74,6 @@ class ViewBillNew extends StatefulWidget {
this.isRepeatViewBill = false,
}) : super(key: key);
@override
State<ViewBillNew> createState() => _ViewBillNewState();
}
......@@ -178,242 +178,300 @@ class _ViewBillNewState extends State<ViewBillNew> {
},
);
},
child: BlocBuilder<ViewBillBloc, List<Bill>>(
builder: (ctxViewBill, dataBill) {
if (dataBill.isNotEmpty) {
if (dataBill[0].id == defaultViewBill) {
return ScreenResponsive(
// widget: waitingBill(
// context,
// widthScreen,
// maxWidthScreen,
// ),
widget: ShimmerBill(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
} else {
saveBillDetail(dataBill);
// int totalService = 0;
// int totalServiceTax = 0;
// int individuTotalPayment = 0;
// int individuPaymentPaid = 0;
int outStandingIndividu = 0;
// int allPaymentPaid = 0;
int outStandingAll = 0;
int totalDiscount = 0;
// bool isIndividuHaveWaitingPayment = false;
// String paymentToRedirect = '';
// String paymentId = '';
// check payment pending ketika table di lock backend
// bool isStillHavePaymentPending = false;
child: BlocBuilder<AddressUser, Address>(
builder: (_, addressUser) {
return BlocBuilder<ViewBillBloc, List<Bill>>(
builder: (ctxViewBill, dataBill) {
if (dataBill.isNotEmpty) {
// karna dia looping 2x, jadi kalau orderID nya sama dengan current order ID baru diupdate, kalau gak berarti history
if (dataBill[0].id == getOrderId()) {
if (widget.isHistory == false) {
List<String> listHistoryOrder = getListHistory();
int indexListhIstory = listHistoryOrder.indexWhere(
(listHistoryOrders) =>
jsonDecode(listHistoryOrders)['order_id'] ==
dataBill[0].id);
if (indexListhIstory == -1) {
Map historyOrder = {
"order_id": dataBill[0].id,
"table": dataBill[0].tableName,
"user_name": dataBill[0].customerName,
"total_order": dataBill[0].totalSeluruhOrderan,
"date_order": localDate(
dataBill[0].dateOrder,
isHistory: true,
),
"branch_code": branchCode,
"brand": brandCode,
"token": widget.token,
};
String historySave = jsonEncode(historyOrder);
listHistoryOrder.add(historySave);
setListHistory(listHistoryOrder);
} else {
listHistoryOrder.removeAt(indexListhIstory);
Map historyOrder = {
"order_id": dataBill[0].id,
"table": dataBill[0].tableName,
"user_name": dataBill[0].customerName,
"total_order": dataBill[0].totalSeluruhOrderan,
"date_order": localDate(
dataBill[0].dateOrder,
isHistory: true,
),
"branch_code": branchCode,
"brand": brandCode,
"token": widget.token,
};
String historySave = jsonEncode(historyOrder);
listHistoryOrder.add(historySave);
setListHistory(listHistoryOrder);
if (dataBill[0].id == defaultViewBill) {
return ScreenResponsive(
// widget: waitingBill(
// context,
// widthScreen,
// maxWidthScreen,
// ),
widget: ShimmerBill(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
} else {
saveBillDetail(dataBill);
// int totalService = 0;
// int totalServiceTax = 0;
// int individuTotalPayment = 0;
// int individuPaymentPaid = 0;
int outStandingIndividu = 0;
// int allPaymentPaid = 0;
int outStandingAll = 0;
int totalDiscount = 0;
int serviceCharge = 0;
// bool isIndividuHaveWaitingPayment = false;
// String paymentToRedirect = '';
// String paymentId = '';
// check payment pending ketika table di lock backend
// bool isStillHavePaymentPending = false;
if (dataBill.isNotEmpty) {
// karna dia looping 2x, jadi kalau orderID nya sama dengan current order ID baru diupdate, kalau gak berarti history
if (dataBill[0].id == getOrderId()) {
if (widget.isHistory == false) {
List<String> listHistoryOrder = getListHistory();
int indexListhIstory = listHistoryOrder.indexWhere(
(listHistoryOrders) =>
jsonDecode(listHistoryOrders)['order_id'] ==
dataBill[0].id);
if (indexListhIstory == -1) {
Map historyOrder = {
"order_id": dataBill[0].id,
"table": dataBill[0].tableName,
"user_name": dataBill[0].customerName,
"total_order": dataBill[0].totalSeluruhOrderan,
"date_order": localDate(
dataBill[0].dateOrder,
isHistory: true,
),
"branch_code": branchCode,
"brand": brandCode,
"token": widget.token,
"typeOrder":
typeOrderString(dataBill[0].typeOrder),
"outlet_name": getBranchName()
};
if (dataBill[0].typeOrder != typeOrderDineIn) {
historyOrder['address_outlet'] =
getAddressOutlet();
historyOrder['phone_outlet'] = getPhoneOutlet();
historyOrder['open_hour'] =
"${getOpenTime().split(':')[0]}:${getOpenTime().split(':')[1]} - ${getCloseTime().split(':')[0]}:${getCloseTime().split(':')[1]}";
historyOrder['lat_outlet'] = getLatOutlet();
historyOrder['long_outlet'] = getLongOutlet();
if (dataBill[0].typeOrder ==
typeOrderDelivery &&
addressUser.id != '') {
historyOrder['recepient_name'] =
addressUser.recepientName;
historyOrder['recepient_phone'] =
addressUser.recepientPhone;
historyOrder['address'] = addressUser.address;
historyOrder['detail_loc'] =
addressUser.locationDetail;
historyOrder['note_loc'] = addressUser.notes;
}
}
String historySave = jsonEncode(historyOrder);
listHistoryOrder.add(historySave);
setListHistory(listHistoryOrder);
} else {
listHistoryOrder.removeAt(indexListhIstory);
Map historyOrder = {
"order_id": dataBill[0].id,
"table": dataBill[0].tableName,
"user_name": dataBill[0].customerName,
"total_order": dataBill[0].totalSeluruhOrderan,
"date_order": localDate(
dataBill[0].dateOrder,
isHistory: true,
),
"branch_code": branchCode,
"brand": brandCode,
"token": widget.token,
"typeOrder":
typeOrderString(dataBill[0].typeOrder),
"outlet_name": getBranchName()
};
if (dataBill[0].typeOrder != typeOrderDineIn) {
historyOrder['address_outlet'] =
getAddressOutlet();
historyOrder['phone_outlet'] = getPhoneOutlet();
historyOrder['open_hour'] =
"${getOpenTime().split(':')[0]}:${getOpenTime().split(':')[1]} - ${getCloseTime().split(':')[0]}:${getCloseTime().split(':')[1]}";
historyOrder['lat_outlet'] = getLatOutlet();
historyOrder['long_outlet'] = getLongOutlet();
if (dataBill[0].typeOrder ==
typeOrderDelivery &&
addressUser.id != '') {
historyOrder['recepient_name'] =
addressUser.recepientName;
historyOrder['recepient_phone'] =
addressUser.recepientPhone;
historyOrder['address'] = addressUser.address;
historyOrder['detail_loc'] =
addressUser.locationDetail;
historyOrder['note_loc'] = addressUser.notes;
}
}
String historySave = jsonEncode(historyOrder);
listHistoryOrder.add(historySave);
setListHistory(listHistoryOrder);
}
}
}
// int indexWherePendingPayment = dataBill[0]
// .paymentList
// .indexWhere((element) => element.isApproved == false);
// if (indexWherePendingPayment != -1) {
// isStillHavePaymentPending = true;
// }
//service and servicetax
// totalService = amountParseToInt(dataBill[0].totalService);
// totalServiceTax =
// amountParseToInt(dataBill[0].totalServiceTax);
// for (var x in dataBill) {
// if (x.customerName == customerName) {
// // individuTotalPayment = x.totalPerCustomer;
// }
// //service and tax
// // for (var bd in x.billDetail) {
// // totalService += amountParseToInt(bd.service);
// // totalServiceTax += amountParseToInt(bd.serviceTax);
// // }
// }
// if (dataBill[0].paymentList.isNotEmpty) {
// for (var p in dataBill[0].paymentList) {
// // if (p.isApproved && p.customerNamePay == customerName) {
// // individuPaymentPaid += amountParseToInt(p.amount);
// // }
// if (p.isApproved) {
// allPaymentPaid += amountParseToInt(p.amount);
// }
// if (!p.isApproved) {
// if (p.paymentUrl != '' &&
// p.customerNamePay == customerName) {
// isIndividuHaveWaitingPayment = true;
// paymentToRedirect = p.paymentUrl;
// paymentId = p.id;
// }
// }
// }
// }
outStandingAll =
amountParseToInt(dataBill[0].outStandingPay);
totalDiscount =
amountParseToInt(dataBill[0].discountTotal);
serviceCharge =
amountParseToInt(dataBill[0].totalService) +
amountParseToInt(dataBill[0].totalServiceTax);
outStandingIndividu =
amountParseToInt(dataBill[0].outStandingIndividu);
}
}
// int indexWherePendingPayment = dataBill[0]
// .paymentList
// .indexWhere((element) => element.isApproved == false);
// if (indexWherePendingPayment != -1) {
// isStillHavePaymentPending = true;
// }
//service and servicetax
// totalService = amountParseToInt(dataBill[0].totalService);
// totalServiceTax =
// amountParseToInt(dataBill[0].totalServiceTax);
// for (var x in dataBill) {
// if (x.customerName == customerName) {
// // individuTotalPayment = x.totalPerCustomer;
// }
// //service and tax
// // for (var bd in x.billDetail) {
// // totalService += amountParseToInt(bd.service);
// // totalServiceTax += amountParseToInt(bd.serviceTax);
// // }
// }
// if (dataBill[0].paymentList.isNotEmpty) {
// for (var p in dataBill[0].paymentList) {
// // if (p.isApproved && p.customerNamePay == customerName) {
// // individuPaymentPaid += amountParseToInt(p.amount);
// // }
// if (p.isApproved) {
// allPaymentPaid += amountParseToInt(p.amount);
// }
// if (!p.isApproved) {
// if (p.paymentUrl != '' &&
// p.customerNamePay == customerName) {
// isIndividuHaveWaitingPayment = true;
// paymentToRedirect = p.paymentUrl;
// paymentId = p.id;
// }
// }
// }
// }
outStandingAll =
amountParseToInt(dataBill[0].outStandingPay);
totalDiscount = amountParseToInt(dataBill[0].discountTotal);
outStandingIndividu =
amountParseToInt(dataBill[0].outStandingIndividu);
}
void ontapOkAfterCashier() async {
Api.addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCash,
fullPayment,
'',
outStandingAll,
).then((value) {
if (value == 'OK') {
ratingModal(
context,
dataBill,
widget.isHistory,
orderId: orderId,
);
}
});
Navigator.pop(context);
// Navigator.push(context,
// MaterialPageRoute(builder: (_) => FinishOrder()));
}
void ontapOkAfterCashier() async {
Api.addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCash,
fullPayment,
'',
outStandingAll,
).then((value) {
if (value == 'OK') {
ratingModal(
void ontapCancelAfterCashier() {
Navigator.pop(context);
}
void onTapCashier() {
String title;
String description;
String textOnOk = 'OK';
String textOnCancel = 'Batal';
// if (outStandingAll > 0) {
// Navigator.pop(context);
title = 'Tutup Pesanan';
description = '''
Selesaikan transaksi dan tutup pesanan ?
Mohon menuju kasir untuk meminta bukti pembayaran''';
// } else {
// // // Navigator.pop(context);
// // EasyLoading.showInfo('Tidak ada tagihan yang perlu dibayar');
// title = 'Tutup Pesanan & Minta Bill';
// description =
// 'Transaksi akan ditutup dan silakan meminta bill di kasir';
// }
buttonDialogGlobal(
context,
dataBill,
widget.isHistory,
orderId: orderId,
title,
description,
textOnOk,
textOnCancel,
ontapOkAfterCashier,
ontapCancelAfterCashier,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
);
}
});
Navigator.pop(context);
// Navigator.push(context,
// MaterialPageRoute(builder: (_) => FinishOrder()));
}
void ontapCancelAfterCashier() {
Navigator.pop(context);
}
void onTapCashier() {
String title;
String description;
String textOnOk = 'OK';
String textOnCancel = 'Batal';
// if (outStandingAll > 0) {
// Navigator.pop(context);
title = 'Tutup Pesanan';
description = '''
Selesaikan transaksi dan tutup pesanan ?
Mohon menuju kasir untuk meminta bukti pembayaran''';
// } else {
// // // Navigator.pop(context);
// // EasyLoading.showInfo('Tidak ada tagihan yang perlu dibayar');
// title = 'Tutup Pesanan & Minta Bill';
// description =
// 'Transaksi akan ditutup dan silakan meminta bill di kasir';
// }
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkAfterCashier,
ontapCancelAfterCashier,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
return BlocBuilder<ExpandDetailOutlet, bool>(
builder: (context, isShowOutletDetail) {
return ScreenResponsive(
widget: CoreBill(
widthScreen: widthScreen,
dataBill: dataBill,
outStandingAll: outStandingAll,
totalDiscount: totalDiscount,
isHistory: widget.isHistory,
customerName: customerName,
outStandingIndividu: outStandingIndividu,
paymentMode: paymentMode,
onTapCashier: onTapCashier,
branchCode: branchCode,
brandCode: brandCode,
orderId: orderId,
isShowOutletDetail: isShowOutletDetail,
serviceCharge: serviceCharge,
),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
);
},
);
}
} else {
return ScreenResponsive(
widget: EmptyBill(
widthScreen: widthScreen,
branchCode: branchCode,
brandCode: brandCode,
customerName: customerName,
isHistory: widget.isHistory,
historyOrder: historyOrder,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
}
return BlocBuilder<ExpandDetailOutlet, bool>(
builder: (context, isShowOutletDetail) {
return ScreenResponsive(
widget: CoreBill(
widthScreen: widthScreen,
dataBill: dataBill,
outStandingAll: outStandingAll,
totalDiscount: totalDiscount,
isHistory: widget.isHistory,
customerName: customerName,
outStandingIndividu: outStandingIndividu,
paymentMode: paymentMode,
onTapCashier: onTapCashier,
branchCode: branchCode,
brandCode: brandCode,
orderId: orderId,
isShowOutletDetail: isShowOutletDetail,
),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
);
},
);
}
} else {
return ScreenResponsive(
widget: EmptyBill(
widthScreen: widthScreen,
branchCode: branchCode,
brandCode: brandCode,
customerName: customerName,
isHistory: widget.isHistory,
historyOrder: historyOrder,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
}
},
);
},
),
),
......@@ -438,6 +496,7 @@ class CoreBill extends StatelessWidget {
required this.brandCode,
required this.orderId,
required this.isShowOutletDetail,
required this.serviceCharge,
}) : super(key: key);
final double widthScreen;
......@@ -453,6 +512,7 @@ class CoreBill extends StatelessWidget {
final String brandCode;
final String orderId;
final bool isShowOutletDetail;
final int serviceCharge;
void getBillFunction(BuildContext context) {
context.read<ViewBillBloc>().getBill();
......@@ -460,7 +520,8 @@ class CoreBill extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool isDeliveryPickuup = getIsDeliveryPickup();
final bool isDeliveryPickuup =
(dataBill[0].typeOrder != typeOrderDineIn) ? true : false;
return BlocBuilder<MemberInfoBloc, MemberInfo>(
builder: (contextMember, memberinfo) {
int outStandingTopayMember = 0;
......@@ -487,14 +548,14 @@ class CoreBill extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? (dataBill[0].state == orderStateDone)
? const SizedBox(
height: 24,
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? DeliveryPickupStatus(dataBill: dataBill)
: const SizedBox(),
ComponentNameUser(
......@@ -516,6 +577,7 @@ class CoreBill extends StatelessWidget {
? DeliveryPickupDetail(
isShowOutletDetail: isShowOutletDetail,
databill: dataBill,
isHistory: isHistory,
)
: const SizedBox(),
(isDeliveryPickuup)
......@@ -531,7 +593,10 @@ class CoreBill extends StatelessWidget {
: const SizedBox(),
(isDeliveryPickuup)
? (isShowOutletDetail)
? const OutletDetail()
? OutletDetail(
isHistory: isHistory,
dataBill: dataBill,
)
: const SizedBox()
: const SizedBox(),
const SizedBox(
......@@ -659,6 +724,7 @@ class CoreBill extends StatelessWidget {
dataBill: dataBill,
totalDiscount: totalDiscount,
outStandingAll: outStandingAll,
serviceCharge: serviceCharge,
),
(dataBill[0].paymentList.isNotEmpty)
? Column(
......@@ -963,7 +1029,7 @@ class CoreBill extends StatelessWidget {
width: widthScreen,
child: Column(
children: [
(!getIsDeliveryPickup() &&
(dataBill[0].typeOrder == typeOrderDineIn &&
dataBill[0].tableStatus == tableStatusOpen)
? ButtonPayment(
dataBill: dataBill,
......@@ -979,7 +1045,7 @@ class CoreBill extends StatelessWidget {
isHistory: isHistory,
)
: const SizedBox(),
(getIsDeliveryPickup())
(dataBill[0].typeOrder != typeOrderDineIn)
? ButtonPayment(
dataBill: dataBill,
paymentMode: paymentMode,
......@@ -994,7 +1060,7 @@ class CoreBill extends StatelessWidget {
isHistory: isHistory,
)
: const SizedBox(),
(!getIsDeliveryPickup())
(dataBill[0].typeOrder == typeOrderDineIn)
? (dataBill[0].tableStatus == tableStatusOpen &&
dataBill[0].state != orderStateDone)
? Column(
......@@ -1052,6 +1118,7 @@ class CoreBill extends StatelessWidget {
getOrderId(),
context,
);
setPickupTime('');
Navigator.pushReplacement(
context,
MaterialPageRoute(
......@@ -1182,7 +1249,7 @@ class ButtonPayment extends StatelessWidget {
if (dataBill[0].tableStatus == tableStatusOpen) {
if (isCanButtonCheckoutToTap(dataBill[0].state)) {
if (dataBill[0].state == orderStateCreated) {
if (getIsDeliveryPickup()) {
if (dataBill[0].typeOrder != typeOrderDineIn) {
if (getIsCustomerDelivery()) {
if (addressUser.id == '') {
EasyLoading.showToast(
......@@ -1238,7 +1305,10 @@ class ButtonPayment extends StatelessWidget {
getCashierName(),
getOrderId(),
context,
getMenu: true,
getBrancList: true,
);
setPickupTime('');
Navigator.pushReplacement(
context,
MaterialPageRoute(
......@@ -1607,11 +1677,35 @@ class OutletDetail extends StatelessWidget {
const OutletDetail({
super.key,
this.isFromMenu = false,
this.isHistory = false,
this.dataBill = const [],
});
final bool isFromMenu;
final bool isHistory;
final List<Bill> dataBill;
@override
Widget build(BuildContext context) {
List<String> listHistoryOrder = getListHistory();
int indexListhIstory = listHistoryOrder.indexWhere((listHistoryOrders) =>
jsonDecode(listHistoryOrders)['order_id'] == dataBill[0].id);
String openHours = "${timeHm(getOpenTime())} - ${timeHm(getCloseTime())}";
String phoneOutlet = getPhoneOutlet();
bool isDeliveryCustomer = getIsCustomerDelivery();
String latOutlet = getLatOutlet();
String longOutlet = getLongOutlet();
if (isHistory && indexListhIstory != -1) {
var historyOrder = jsonDecode(listHistoryOrder[indexListhIstory]);
openHours = historyOrder['open_hour'];
phoneOutlet = historyOrder['phone_outlet'];
latOutlet = historyOrder['lat_outlet'];
longOutlet = historyOrder['long_outlet'];
if (historyOrder['typeOrder'] == 'Delivery') {
isDeliveryCustomer = true;
} else {
isDeliveryCustomer = false;
}
}
return Container(
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight,
......@@ -1622,7 +1716,7 @@ class OutletDetail extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(getIsCustomerDelivery())
(isDeliveryCustomer)
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -1640,7 +1734,7 @@ class OutletDetail extends StatelessWidget {
children: [
defaultText(
context,
"Open Hour: ${timeHm(getOpenTime())} - ${timeHm(getCloseTime())}",
"Open Hour: $openHours",
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: viewbillStyle(),
......@@ -1664,7 +1758,7 @@ class OutletDetail extends StatelessWidget {
GestureDetector(
onTap: () {
htmlOpenLink(
'https://wa.me/${getPhoneOutlet()}',
'https://wa.me/$phoneOutlet',
self: false,
);
},
......@@ -1693,7 +1787,7 @@ class OutletDetail extends StatelessWidget {
String latUser = getLatitude();
String longUser = getLongitude();
String urlDirection =
'https://www.google.com/maps/dir/$latUser,$longUser/${getLatOutlet()},${getLongOutlet()}';
'https://www.google.com/maps/dir/$latUser,$longUser/$latOutlet,$longOutlet';
// Geolocator.getCurrentPosition().then((position) {
htmlOpenLink(
urlDirection,
......@@ -1743,12 +1837,14 @@ class DeliveryPickupDetail extends StatelessWidget {
required this.isShowOutletDetail,
this.isFromMenu = false,
this.databill = const [],
this.isHistory = false,
}) : super(key: key);
// final bool isDelivery = getIsCustomerDelivery();
final bool isShowOutletDetail;
final bool isFromMenu;
final List<Bill> databill;
final bool isHistory;
@override
Widget build(BuildContext context) {
......@@ -1761,20 +1857,46 @@ class DeliveryPickupDetail extends StatelessWidget {
),
color:
(isFromMenu) ? backgroundColor : backgroundWhite.withOpacity(0.9),
child: (isDelivery)
? deliveryOption(context, isFromMenu, databill)
: pickupOption(context),
child: (isHistory == false)
? (isDelivery)
? deliveryOption(
context,
isFromMenu,
databill,
)
: pickupOption(
context,
databill: databill,
)
: (databill[0].typeOrder == typeOrderDelivery)
? deliveryOption(
context,
isFromMenu,
databill,
isHistory: isHistory,
)
: (databill[0].typeOrder == typeOrderPickup)
? pickupOption(
context,
databill: databill,
isHistory: isHistory,
)
: const SizedBox(),
);
},
);
}
Row pickupOption(BuildContext context) {
Row pickupOption(
BuildContext context, {
List<Bill> databill = const [],
bool isHistory = false,
}) {
DateTime dateTime = DateTime.now().toLocal();
String hourTime = DateFormat.H().format(dateTime);
String minuteTime = DateFormat.m().format(dateTime);
TimeOfDay timeOfDayPickup =
TimeOfDay(hour: int.parse(hourTime) + 1, minute: int.parse(minuteTime));
TimeOfDay(hour: int.parse(hourTime) + 1, minute: 0);
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
......@@ -1794,44 +1916,52 @@ class DeliveryPickupDetail extends StatelessWidget {
children: [
defaultText(
context,
getBranchName(),
(isHistory) ? databill[0].branchName : getBranchName(),
maxLines: 2,
overFlow: TextOverflow.ellipsis,
),
const SizedBox(
height: 5,
),
Row(
children: [
defaultText(
context,
"Open Hour: ${timeHm(getOpenTime())} - ${timeHm(getCloseTime())}",
maxLines: 2,
overFlow: TextOverflow.ellipsis,
),
],
),
(isHistory == false)
? Column(
children: [
const SizedBox(
height: 5,
),
Row(
children: [
defaultText(
context,
"Open Hour: ${timeHm(getOpenTime())} - ${timeHm(getCloseTime())}",
maxLines: 2,
overFlow: TextOverflow.ellipsis,
),
],
),
],
)
: const SizedBox(),
const SizedBox(
height: 5,
),
BlocBuilder<TriggerRefresh, bool>(
builder: (_, trigger) {
return Row(
children: [
defaultText(
context,
"Pickup: ",
maxLines: 1,
overFlow: TextOverflow.ellipsis,
),
defaultText(
context,
getPickupTime(),
maxLines: 1,
overFlow: TextOverflow.ellipsis,
),
],
);
return (isHistory == false)
? Row(
children: [
defaultText(
context,
"Pickup: ",
maxLines: 1,
overFlow: TextOverflow.ellipsis,
),
defaultText(
context,
getPickupTime(),
maxLines: 1,
overFlow: TextOverflow.ellipsis,
),
],
)
: const SizedBox();
},
),
const SizedBox(
......@@ -1849,7 +1979,7 @@ class DeliveryPickupDetail extends StatelessWidget {
Navigator.pop(context);
}
void setPickupTimeUser(int time) {
void setPickupTimeUser(int time, {String typeSatuan = 'jam'}) {
String closeOutlet = getCloseTime();
String hourClose = closeOutlet.split(':')[0];
String minuteClose = closeOutlet.split(':')[1];
......@@ -1862,9 +1992,24 @@ class DeliveryPickupDetail extends StatelessWidget {
String hourTime = DateFormat.H().format(dateTime);
String minuteTime = DateFormat.m().format(dateTime);
DateTime dateSelectedPickupTime;
if (typeSatuan == 'jam') {
dateSelectedPickupTime = DateTime(now.year, now.month, now.day,
int.parse(hourTime) + time, int.parse(minuteTime));
} else {
int hourMod;
int minuteMod;
if (int.parse(minuteTime) + time > 60) {
hourMod = 1;
minuteMod = (int.parse(minuteTime) + time) % 60;
} else {
hourMod = 0;
minuteMod = int.parse(minuteTime) + time;
}
dateSelectedPickupTime = DateTime(now.year, now.month, now.day,
int.parse(hourTime) + hourMod, minuteMod);
}
DateTime dateSelectedPickupTime = DateTime(now.year, now.month,
now.day, int.parse(hourTime) + time, int.parse(minuteTime));
final differenceClose =
dateTimeCloseOutlet.difference(dateSelectedPickupTime);
......@@ -1881,10 +2026,28 @@ class DeliveryPickupDetail extends StatelessWidget {
);
return;
}
TimeOfDay timeOfDayPickup = TimeOfDay(
TimeOfDay timeOfDayPickup;
if (typeSatuan == 'jam') {
timeOfDayPickup = TimeOfDay(
hour: int.parse(hourTime) + time,
minute: int.parse(minuteTime));
minute: int.parse(minuteTime),
);
} else {
int hourMod;
int minuteMod;
if (int.parse(minuteTime) + time > 60) {
hourMod = 1;
minuteMod = (int.parse(minuteTime) + time) % 60;
} else {
hourMod = 0;
minuteMod = int.parse(minuteTime) + time;
}
timeOfDayPickup = TimeOfDay(
hour: int.parse(hourTime) + hourMod,
minute: minuteMod,
);
}
// String timeToset = timeOfDayPickup.format(context);
final hourString =
timeOfDayPickup.hour.toString().padLeft(2, '0');
......@@ -1920,11 +2083,14 @@ class DeliveryPickupDetail extends StatelessWidget {
children: [
GestureDetector(
onTap: () {
setPickupTimeUser(0);
setPickupTimeUser(
30,
typeSatuan: 'menit',
);
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton: 'Sekarang'),
teksButton: '30 Menit'),
),
const SizedBox(
height: 10,
......@@ -1940,34 +2106,19 @@ class DeliveryPickupDetail extends StatelessWidget {
const SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setPickupTimeUser(3);
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton: '3 Jam'),
),
const SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setPickupTimeUser(5);
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton: '5 Jam'),
),
const SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
Navigator.pop(context);
showTimePicker(
showCustomTimePicker(
context: context,
onFailValidation: (context) =>
EasyLoading.showToast(
'Unavailable selection time'),
initialTime: timeOfDayPickup,
selectableTimePredicate: (time) =>
time!.hour > 1 &&
time.hour < 25 &&
time.minute % 15 == 0,
).then((value) {
if (value == null) {
return;
......@@ -2193,14 +2344,25 @@ class DeliveryPickupDetail extends StatelessWidget {
onTap: () {
void ontapOkeChange() {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
EasyLoading.show(
status: 'Getting outlet...',
maskType: EasyLoadingMaskType.none,
);
Api.getBranchList().then((value) {
EasyLoading.dismiss();
if (value.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
);
} else {
EasyLoading.showToast('List outlet tidak ditemukan');
}
});
}
void onTapCancelChange() {
......@@ -2256,7 +2418,11 @@ Apakah ingin melanjutkan ?''';
}
BlocBuilder deliveryOption(
BuildContext context, bool isFromMenu, List<Bill> databill) {
BuildContext context,
bool isFromMenu,
List<Bill> databill, {
bool isHistory = false,
}) {
void ontapAddressDetail() {
Navigator.pop(context);
}
......@@ -2266,6 +2432,33 @@ Apakah ingin melanjutkan ?''';
if (address.id != '') {
setLatitude(address.lat);
setLongitude(address.long);
String recepientName = '';
String recepientPhone = '';
String recepientAddress = '';
String recepientDetailLoc = '';
String recepientNotes = '';
if (isHistory) {
List<String> listHistoryOrder = getListHistory();
int indexListhIstory = listHistoryOrder.indexWhere(
(listHistoryOrders) =>
jsonDecode(listHistoryOrders)['order_id'] ==
databill[0].id);
if (indexListhIstory != -1) {
var historyOrder = jsonDecode(listHistoryOrder[indexListhIstory]);
recepientName = historyOrder['recepient_name'] ?? '';
recepientPhone = historyOrder['recepient_phone'] ?? '';
recepientAddress = historyOrder['address'] ?? '';
recepientDetailLoc = historyOrder['detail_loc'] ?? '';
recepientNotes = historyOrder['note_loc'] ?? '';
}
} else {
recepientName = address.recepientName;
recepientPhone = address.recepientPhone;
recepientAddress = address.address;
recepientDetailLoc = address.locationDetail;
recepientNotes = address.notes;
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -2288,7 +2481,7 @@ Apakah ingin melanjutkan ?''';
),
defaultText(
context,
address.recepientName,
recepientName,
style: addressStyle(
font: 10,
),
......@@ -2298,7 +2491,7 @@ Apakah ingin melanjutkan ?''';
),
defaultText(
context,
address.recepientPhone,
recepientPhone,
style: addressStyle(
font: 10,
),
......@@ -2308,7 +2501,7 @@ Apakah ingin melanjutkan ?''';
),
defaultText(
context,
address.address,
recepientAddress,
style: addressStyle(
font: 10,
),
......@@ -2316,7 +2509,7 @@ Apakah ingin melanjutkan ?''';
(address.locationDetail != '')
? defaultText(
context,
"Detail Lokasi: ${address.locationDetail}",
"Detail Lokasi: $recepientDetailLoc",
style: addressStyle(
font: 10,
),
......@@ -2325,7 +2518,7 @@ Apakah ingin melanjutkan ?''';
(address.notes != '')
? defaultText(
context,
"Catatan : ${address.notes}",
"Catatan : $recepientNotes",
style: addressStyle(
font: 10,
),
......@@ -2343,7 +2536,7 @@ Apakah ingin melanjutkan ?''';
databill[0].courierPhone != '')
? defaultText(
context,
'Kurir Detail :',
'Detail Kurir :',
style: addressStyle(
font: 10,
),
......@@ -2352,7 +2545,7 @@ Apakah ingin melanjutkan ?''';
(databill.isNotEmpty && databill[0].courierName != '')
? defaultText(
context,
"Kurir Name : ${databill[0].courierName}",
"Nama : ${databill[0].courierName}",
style: addressStyle(
font: 10,
),
......@@ -2366,23 +2559,39 @@ Apakah ingin melanjutkan ?''';
self: false,
);
},
child: Row(
children: [
fontAwesomeNew(
phoneIcon,
phoneIconSize,
),
const SizedBox(
width: 5,
child: Container(
width: 120,
// height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: (isFromMenu)
? backgroundColor
: backgroundWhite,
border: Border.all(
color: buttonColor,
),
defaultText(
context,
"Kurir Mobile : ${databill[0].courierPhone}",
style: addressStyle(
font: 10,
),
padding: const EdgeInsets.all(3),
margin: const EdgeInsets.only(top: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
fontAwesomeNew(
phoneIcon,
phoneIconSize,
),
)
],
const SizedBox(
width: 5,
),
defaultText(
context,
databill[0].courierPhone,
style: addressStyle(
font: 10,
),
)
],
),
),
)
: const SizedBox(),
......@@ -2464,38 +2673,43 @@ Apakah ingin melanjutkan ?''';
),
GestureDetector(
onTap: () {
void ontapOkeChange() {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
if (getIsCanChangeDeliveryPickup()) {
void ontapOkeChange() {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
),
);
}
);
}
void onTapCancelChange() {
Navigator.pop(context);
}
void onTapCancelChange() {
Navigator.pop(context);
}
String textOnOk = 'OK';
String textOnCancel = 'Batal';
String title = 'Ganti Outlet';
String description = '''
String textOnOk = 'OK';
String textOnCancel = 'Batal';
String title = 'Ganti Outlet';
String description = '''
Ganti outlet akan menyebabkan orderan anda saat ini hilang.
Apakah ingin melanjutkan ?''';
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkeChange,
onTapCancelChange,
okButtonColor: buttonColor,
);
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkeChange,
onTapCancelChange,
okButtonColor: buttonColor,
);
} else {
EasyLoading.showToast(
'Tidak dapat ganti oulet karena status orderan sedang diproses / telah selesai');
}
},
child: Container(
width: 98,
......
......@@ -483,6 +483,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.12"
time_picker_widget:
dependency: "direct main"
description:
name: time_picker_widget
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0+10"
timeline_tile:
dependency: "direct main"
description:
......
......@@ -45,6 +45,7 @@ dependencies:
shared_preferences: ^2.0.15
shimmer: ^2.0.0
sliver_tools: ^0.2.8
time_picker_widget: ^1.0.0+10
timeline_tile: ^2.0.0
url_launcher: ^6.1.5
url_strategy: ^0.2.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment