Commit 94c58a71 authored by Dio Maulana's avatar Dio Maulana

17/10/22

parent 7a75e7bb
......@@ -75,7 +75,7 @@ class Api {
if (indexTypeUrl != -1) {
currentOrderId = jsonDecode(listTypeUrl[indexTypeUrl])['order_id'];
} else {
currentOrderId = getOrderId();
currentOrderId = getOrderId();
}
var uuidOrderId = uuidInit.v4();
String orderID;
......@@ -100,6 +100,7 @@ class Api {
: '',
"customer_lat": latitude,
"customer_long": longitude,
"table_number": (getUrlType() == typeUrlDua) ? getTabelNumber() : '',
"type_url": urlType,
};
var bodies = json.encode(data);
......@@ -110,32 +111,32 @@ class Api {
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
//** save sessionID and Table Mode*/
List<String> listHistory = getListHistory();
String tableNumber = getTabelNumber();
String userName = getCustomerName();
String totalOrder = getTotalOrder();
String dateOrder = getOrderDate();
String branchCode = getBranchPref();
String brandCode = getBrand();
String token = getToken();
if (orderID != jsonObject['data']['order_id']) {
Map historyOrder = {
"order_id": orderId,
"table": tableNumber,
"user_name": userName,
"total_order": totalOrder,
"date_order": localDate(
dateOrder,
isHistory: true,
),
"branch_code": branchCode,
"brand": brandCode,
"token": token,
};
String historySave = jsonEncode(historyOrder);
listHistory.add(historySave);
setListHistory(listHistory);
}
// List<String> listHistory = getListHistory();
// String tableNumber = getTabelNumber();
// String userName = getCustomerName();
// String totalOrder = getTotalOrder();
// String dateOrder = getOrderDate();
// String branchCode = getBranchPref();
// String brandCode = getBrand();
// String token = getToken();
// if (orderID != jsonObject['data']['order_id']) {
// Map historyOrder = {
// "order_id": orderId,
// "table": tableNumber,
// "user_name": userName,
// "total_order": totalOrder,
// "date_order": localDate(
// dateOrder,
// isHistory: true,
// ),
// "branch_code": branchCode,
// "brand": brandCode,
// "token": token,
// };
// String historySave = jsonEncode(historyOrder);
// listHistory.add(historySave);
// setListHistory(listHistory);
// }
if (indexTypeUrl != -1) {
listTypeUrl.removeWhere(
......@@ -150,7 +151,7 @@ class Api {
);
setListTypeUrl(listTypeUrl);
setMqMessage('update-${jsonObject['data']['order_id']}');
setMqMessage('ORDER-ID-${jsonObject['data']['order_id']}');
setOrderId(jsonObject['data']['order_id']);
setTypeOrder(jsonObject['data']['type_order']);
setLogoUrl(jsonObject['data']['logo']);
......@@ -166,6 +167,8 @@ class Api {
setIsPickup(jsonObject['data']['is_pickup']);
setOpenTime(jsonObject['data']['open_time']);
setCloseTime(jsonObject['data']['close_time']);
setAddressOutlet(jsonObject['data']['address']);
setPhoneOutlet(jsonObject['data']['mobile']);
setTableNumber(jsonObject['data']['table_number'] ?? '');
if (jsonObject['data']['payment_mode'] != null) {
setPaymentMode(jsonObject['data']['payment_mode']);
......@@ -1335,7 +1338,8 @@ class Api {
"menu": variantData,
'secure_token': secureToken,
"from": fromByod,
"type_order": typeOrder
"type_order": typeOrder,
"type_url": getUrlType(),
};
var bodies = jsonEncode(data);
// var apiResult = await http.post(Uri.parse(urlCheckout), body: bodies);
......@@ -1358,7 +1362,7 @@ class Api {
timeOfDayPickup.minute.toString().padLeft(2, '0');
// String amPM = timeToset.split(' ')[1];
String setPickup = "$hourString:$minuteString";
setPickupTime(setPickup);
// setPickupTime(setPickup);
}
setStatusOrderCreated(true);
......
import 'package:flutter_bloc/flutter_bloc.dart';
class ExpandDetailOutlet extends Cubit<bool> {
ExpandDetailOutlet() : super(false);
void show(bool status) {
emit(status);
}
}
......@@ -298,6 +298,22 @@ bool isCanTapAddMoreButton(int orderState) {
return true;
}
bool isRemoveButtonBillShow(int orderState, int orderDetailState) {
int paymentMethod = getPaymentMode();
if (orderState == orderStateApproved &&
orderDetailState == approvedOrder &&
paymentMethod == closebill) {
return true;
} else {
return false;
}
}
String timeHm(String timeComplete) {
timeComplete.split(':');
return "${timeComplete.split(':')[0]}:${timeComplete.split(':')[1]}";
}
bool isVisibleAddMoreButton(int tableStatus, int orderState) {
int paymentMethod = getPaymentMode();
if (tableStatus == tableStatusOpen && getTableMode() == tableIndividu) {
......@@ -319,11 +335,12 @@ bool isVisibleAddMoreButton(int tableStatus, int orderState) {
}
bool isVisibleAddRemoveQuantityButtonCheckout(
bool isHistory, int orderStatusBillDetail) {
bool isHistory, int orderStatusBillDetail, int orderState) {
int paymentMethod = getPaymentMode();
if (!isHistory &&
paymentMethod == closebill &&
orderStatusBillDetail == pendingOrder) {
orderStatusBillDetail == pendingOrder &&
orderState == orderStateCreated) {
return true;
}
return false;
......@@ -339,7 +356,7 @@ iscanTapAddRemoveQtyViewBill(int orderState) {
String textButtonCheckout(int orderState) {
int paymentMethod = getPaymentMode();
if (paymentMethod == closebill && orderState == orderStateCreated) {
return 'Kirim Pesanan';
return 'Pesan';
} else if (paymentMethod == closebill &&
(orderState == orderStatePending ||
orderState == orderStateApproved) ||
......@@ -592,6 +609,7 @@ String defaultViewBill = 'default';
//** call from untuk notemenu */
String fromMenu = 'menu';
String fromBill = 'bill';
String fromConfirmationPage = 'confirmationPage';
//** call from untuk notemenu */
//**Rating Value */
......@@ -690,6 +708,15 @@ const double shopingBagSize = 0.03;
const String refreshIcon = '\uf2f9';
const double refreshIconSize = 0.02;
const String openLink = '\uf35d';
const double openLinkSize = 14;
const String phoneIcon = '\uf098';
const double phoneIconSize = 16;
const String trahsIcon = '\uf2ed';
const double trahsIconSize = 16;
//** fontawesome unicode */
//** max item menu */
......@@ -727,4 +754,10 @@ const int typeOrderDineIn = 1;
const int typeOrderPickup = 2;
//** Type ORder */
// String MQmessage
String mqMessage = getMqMessage();
// String MQmessage
//** END CONSTANT */
// ignore_for_file: unused_catch_clause
import 'dart:io';
import 'dart:js';
import 'package:byod/bloc/view_bill.dart';
import 'package:byod/helper/logger.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -13,12 +10,15 @@ import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:uuid/uuid.dart';
import '../bloc/view_bill.dart';
import 'helper.dart';
String mqttUrl = 'wss://mq.jasadigital.co.id';
final mqClient = MqttBrowserClient(mqttUrl, '');
const int mqttPort = 8083;
const String queueTopic = 'byod/bill/update';
String queueMessage = getMqMessage();
const String queueTopic = 'romi/byod/payment';
// String queueMessage = getMqMessage();
const String usernameMq = 'jasadigital';
const String passwordMq = 'jasadigital';
const uuidInit = Uuid();
......@@ -81,11 +81,11 @@ Future<int> runMqTT(BuildContext context) async {
MqttPublishPayload.bytesToStringAsString(recMess.payload.message);
// print('Notifikasi masuk dari topic <${c[0].topic}>, isinya adalah: $pt ');
// print('');
if (c[0].topic == topic && pt == queueMessage) {
if (c[0].topic == topic && pt == mqMessage) {
// update bill disini
context.read<ViewBillBloc>().getBill();
if (debug) {
logd('CHECK TOPIC', 'TOPIC MASUK::$topic , MESSAGE::$queueMessage');
logd('CHECK TOPIC', 'TOPIC MASUK::$topic , MESSAGE::$mqMessage');
}
} else {
if (debug) {
......
......@@ -39,6 +39,8 @@ const String _longOutlet = 'longO';
const String _openTime = 'oT';
const String _closeTime = 'cT';
const String _pickupTime = 'puT';
const String _addressOutlet = 'addressOutlet';
const String _phoneOutlet = 'phoneOutlet';
String getBaseUrl() {
return prefs.getString(_baseUrl) ?? '';
......@@ -339,3 +341,19 @@ String getPickupTime() {
Future<void> setPickupTime(String value) async {
prefs.setString(_pickupTime, value);
}
String getAddressOutlet() {
return prefs.getString(_addressOutlet) ?? '';
}
Future<void> setAddressOutlet(String value) async {
prefs.setString(_addressOutlet, value);
}
String getPhoneOutlet() {
return prefs.getString(_phoneOutlet) ?? '';
}
Future<void> setPhoneOutlet(String value) async {
prefs.setString(_phoneOutlet, value);
}
......@@ -73,7 +73,7 @@ class EmoticonRateNew extends StatelessWidget {
),
defaultText(
context,
'Bagaimana pengalaman anda bertransaksi di excelso ?',
'Bagaimana pengalaman anda bertransaksi di ${getBranchName()} ?',
textAlign: TextAlign.center,
style: emojiStyle(),
),
......@@ -240,9 +240,7 @@ class EmoticonRateNew extends StatelessWidget {
).then((value) {
Navigator.pop(context);
if (!isHistory) {
context
.read<ViewBillBloc>()
.getBill();
context.read<ViewBillBloc>().getBill();
} else {
List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) {
......
......@@ -23,6 +23,10 @@ class NoteModalBottomSheet extends StatelessWidget {
required this.from,
this.idOrderan = '',
this.noteInit = '',
this.idMenu = '',
this.menuName = '',
this.imageUrl = '',
this.priceMemu = 0,
required this.contextFrom,
}) : super(key: key);
......@@ -35,6 +39,10 @@ class NoteModalBottomSheet extends StatelessWidget {
final String idOrderan;
final String noteInit;
final BuildContext contextFrom;
final String idMenu;
final String menuName;
final String imageUrl;
final int priceMemu;
@override
Widget build(BuildContext context) {
......@@ -109,6 +117,19 @@ class NoteModalBottomSheet extends StatelessWidget {
context.read<ViewBillBloc>().getBill();
});
}
} else if (from == fromConfirmationPage) {
Map<String, dynamic> insertData = {
'menu_id': idMenu,
'menu_name': menuName,
'initvalue': initialValue,
'menu_price': priceMemu,
'old_order': lisrOrders,
'image_url': menuItem.imageUrlMedium,
'total_price': priceMemu,
'order_variant': orderVariants,
'note': noteController.text,
};
context.read<OrdersBloc>().insertData(insertData);
}
Navigator.pop(context);
},
......
......@@ -29,6 +29,7 @@ import 'bloc/menu_selected_bar.dart';
import 'bloc/order_detail_variant.dart';
import 'bloc/order_variant_temporary.dart';
import 'bloc/order_variant_value.dart';
import 'bloc/outlet_detail.dart';
import 'bloc/search_active.dart';
import 'bloc/search_branch.dart';
import 'bloc/search_history.dart';
......@@ -195,6 +196,7 @@ class _MyAppState extends State<MyApp> {
BlocProvider(create: (_) => BranchList()),
BlocProvider(create: (_) => SearchBranch()),
BlocProvider(create: (_) => AddressUser()),
BlocProvider(create: (_) => ExpandDetailOutlet()),
],
child: MaterialApp(
title: (widget.title == null) ? defaultTitle : widget.title,
......
This diff is collapsed.
......@@ -1057,62 +1057,86 @@ class _NewHome2State extends State<NewHome2> {
String userName,
bool isSearchActive) {
String barName;
if (userName != '') {
barName = 'Meja $tableNumber - $userName';
if (getIsDeliveryPickup()) {
if (getIsCustomerDelivery()) {
barName = "${getBranchName()} - Delivery";
} else {
barName = "${getBranchName()} - Pickup";
}
} else {
barName = "Meja $tableNumber";
if (userName != '') {
barName = 'Meja $tableNumber - $userName';
} else {
barName = "Meja $tableNumber";
}
}
return Container(
padding: const EdgeInsets.only(top: 10),
height: appBarHeight,
color: backgroundColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
defaultText(
context,
barName,
style: tableNameStyle(),
),
const Spacer(),
GestureDetector(
onTap: () {
context.read<SearchActive>().searchClick(isSearchActive);
context.read<MenuSelectedBar>().selectedBarMenu(0, '');
context.read<SearchMenu>().searchMenu(
categoryNonFav,
keyword: '',
isSearch: true,
);
_scrollController.animateTo(
(favList.isNotEmpty)
? heighScrollWithImage
: imageHeight, // 371 sudah dihituing pixelnya untuk awal banget dari menu item
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
);
},
child: const Image(
image: AssetImage('assets/icons/search.png'),
height: 24,
width: 24,
Expanded(
child: defaultText(
context,
barName,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: tableNameStyle(),
),
),
const SizedBox(
width: 16,
),
GestureDetector(
onTap: () {
// Navigator.push(
// context, MaterialPageRoute(builder: (_) => ViewBill()));
Navigator.push(context,
MaterialPageRoute(builder: (_) => const ViewBillNew()));
},
child: const Image(
image: AssetImage('assets/icons/book.png'),
height: 24,
width: 24,
// const Spacer(),
Container(
width: 64,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
GestureDetector(
onTap: () {
context.read<SearchActive>().searchClick(isSearchActive);
context.read<MenuSelectedBar>().selectedBarMenu(0, '');
context.read<SearchMenu>().searchMenu(
categoryNonFav,
keyword: '',
isSearch: true,
);
_scrollController.animateTo(
(favList.isNotEmpty)
? heighScrollWithImage
: imageHeight, // 371 sudah dihituing pixelnya untuk awal banget dari menu item
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
);
},
child: const Image(
image: AssetImage('assets/icons/search.png'),
height: 24,
width: 24,
),
),
const SizedBox(
width: 16,
),
GestureDetector(
onTap: () {
// Navigator.push(
// context, MaterialPageRoute(builder: (_) => ViewBill()));
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const ViewBillNew()));
},
child: const Image(
image: AssetImage('assets/icons/book.png'),
height: 24,
width: 24,
),
),
],
),
),
)
],
));
}
......
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/bill.dart';
import '../../models/bill_detail.dart';
import 'order_view_bill_new.dart';
class ListOrder extends StatelessWidget {
......@@ -24,23 +25,44 @@ class ListOrder extends StatelessWidget {
shrinkWrap: true,
itemCount: bill.length,
itemBuilder: (context, i) {
return ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable scrolling
shrinkWrap: true,
itemCount: bill[i].billDetail.length,
itemBuilder: (ctx, d) {
return OrderViewBillNew(
billDetail: bill[i].billDetail[d],
bill: bill[0],
lastItem:
(i + 1 == bill.length && d + 1 == bill[i].billDetail.length)
return Column(
children: [
Container(
width: double.infinity,
color: backgroundWhite,
padding: const EdgeInsets.only(
left: paddingLeftRight,
right: paddingLeftRight,
top: 16,
),
child: defaultText(
context,
bill[i].customerName,
style: viewbillStyle(
font: 14,
fontWeight: FontWeight.w600,
),
),
),
ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable scrolling
shrinkWrap: true,
itemCount: bill[i].billDetail.length,
itemBuilder: (ctx, d) {
return OrderViewBillNew(
billDetail: bill[i].billDetail[d],
bill: bill[0],
lastItem: (i + 1 == bill.length &&
d + 1 == bill[i].billDetail.length)
? true
: false,
isHistory: isHistory,
tableStatus: tableStatus,
);
},
isHistory: isHistory,
tableStatus: tableStatus,
);
},
),
],
);
});
}
......
......@@ -155,7 +155,7 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
left: paddingLeftRightBill, right: paddingLeftRightBill),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(5),
......@@ -181,64 +181,88 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(
context,
widget.billDetail.menuName,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameListViewBill(),
),
defaultText(
context,
getOrderStatus(widget.billDetail.orderStatus),
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
color: getOrderStatusColor(
widget.billDetail.orderStatus),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(
context,
widget.billDetail.menuName,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameListViewBill(),
),
),
const SizedBox(
height: 6,
),
defaultText(
context,
(paymentMode == openBill)
? 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))} | $itemQuantityString '
: 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))}',
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
defaultText(
context,
getOrderStatus(widget.billDetail.orderStatus),
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
color: getOrderStatusColor(
widget.billDetail.orderStatus),
),
),
),
const SizedBox(
height: 6,
),
(widget.billDetail.notes != '')
? defaultText(
context,
'Catatan: ${widget.billDetail.notes}',
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
),
)
: const SizedBox(),
],
))
const SizedBox(
height: 6,
),
defaultText(
context,
(paymentMode == openBill)
? 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))} | $itemQuantityString '
: 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))}',
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
),
),
const SizedBox(
height: 6,
),
(widget.billDetail.notes != '')
? defaultText(
context,
'Catatan: ${widget.billDetail.notes}',
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
),
)
: const SizedBox(),
],
),
),
(isRemoveButtonBillShow(
widget.bill.state, widget.billDetail.orderStatus))
? const SizedBox(
width: 5,
)
: const SizedBox(),
(isRemoveButtonBillShow(
widget.bill.state, widget.billDetail.orderStatus))
? GestureDetector(
onTap: () {
deleteOrder(context, widget.billDetail.menuName,
ontapOkDelete, ontapCancelDelete);
},
child: Container(
color: backgroundWhite,
child: fontAwesomeNew(
trahsIcon,
trahsIconSize,
color: dangerColor,
),
),
)
: const SizedBox()
],
),
),
],
),
),
isVisibleAddRemoveQuantityButtonCheckout(
widget.isHistory, widget.billDetail.orderStatus)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus, widget.bill.state)
? Container(
padding: EdgeInsets.only(
left: paddingLeftRightBill, right: paddingLeftRightBill),
......@@ -248,17 +272,19 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
),
)
: const SizedBox(),
isVisibleAddRemoveQuantityButtonCheckout(
widget.isHistory, widget.billDetail.orderStatus)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus, widget.bill.state)
? const SizedBox(
height: 11,
)
: const SizedBox(),
isVisibleAddRemoveQuantityButtonCheckout(
widget.isHistory, widget.billDetail.orderStatus)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus, widget.bill.state)
? Container(
padding: EdgeInsets.only(
left: paddingLeftRightBill, right: paddingLeftRightBill),
left: paddingLeftRightBill,
right: paddingLeftRightBill,
),
child: Row(
children: [
GestureDetector(
......
......@@ -23,6 +23,7 @@ import 'package:uuid/uuid.dart';
import '../../api/api.dart';
import '../../bloc/branch_exist.dart';
import '../../bloc/feedback_option.dart';
import '../../helper/prefs.dart';
import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/emoticon_rate.dart';
import '../../helper/widget/open_url.dart';
......@@ -323,7 +324,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
builder: (BuildContext context) => AlertDialog(
title: defaultText(
context,
'Bagaimana pengalaman anda bertransaksi di excelso ?',
'Bagaimana pengalaman anda bertransaksi di ${getBranchName()} ?',
style: textStyleNormalFont(context),
),
content: EmoticonRate(
......
This diff is collapsed.
......@@ -62,34 +62,34 @@ class CustomAppBar extends StatelessWidget {
),
],
),
GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
),
);
},
child: Row(
children: [
defaultText(
context,
'Simpan',
style: appBarNameViewBill(),
),
const SizedBox(
width: 5,
),
fontAwesomeNew(
saveIcon,
saveIconSize,
),
],
),
),
// GestureDetector(
// onTap: () {
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (_) => const ViewBillNew(
// isRepeatViewBill: true,
// ),
// ),
// );
// },
// child: Row(
// children: [
// defaultText(
// context,
// 'Simpan',
// style: appBarNameViewBill(),
// ),
// const SizedBox(
// width: 5,
// ),
// fontAwesomeNew(
// saveIcon,
// saveIconSize,
// ),
// ],
// ),
// ),
],
),
);
......
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