Commit b29fe28b authored by Dio Maulana's avatar Dio Maulana

13/10/22

parent 63fcc40d
......@@ -20,6 +20,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:intl/intl.dart';
import 'package:uuid/uuid.dart';
import '../bloc/address_user_bloc.dart';
import '../bloc/order_bloc.dart';
import '../helper/widget/open_url.dart';
import '../main.dart';
......@@ -92,7 +93,7 @@ class Api {
"order_id": orderID,
"session_id": sessionId,
"from": fromByod,
"url_lookup": (urlType == typeUrlTiga) ? 'https://dimas.com' : '',
"url_lookup": (debug) ? 'https://www.ravintola.web.id/' : (urlType == typeUrlTiga) ? getUrlLookUp() : '',
"customer_lat": latitude,
"customer_long": longitude,
"type_url": urlType,
......@@ -167,6 +168,11 @@ class Api {
if (jsonObject['data']['table_mode'] != null) {
setTableMode(jsonObject['data']['table_mode']);
}
if (jsonObject['data']['type_order'] == typeOrderDelivery) {
setIsCustomerDelivery(true);
} else {
setIsCustomerDelivery(false);
}
return responseByodBranchExist;
} else if (jsonObject['status'] == 'error' &&
(jsonObject['code'] == 'BYOD_ALWAYS_OFF' ||
......@@ -779,6 +785,7 @@ class Api {
String token, {
String orderIdH = '',
String userNameH = '',
bool isCallGetAddress = false,
}) async {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPoint}get_bill";
......@@ -917,6 +924,7 @@ class Api {
"packaging_fee":
jsonObject['data']['packaging_fee'] ?? "0.00",
"platform_fee": jsonObject['data']['platform_fee'] ?? "0.00",
"delivery_fee": jsonObject['data']['delivery_fee'] ?? "0.00",
};
bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
......@@ -1162,6 +1170,7 @@ class Api {
"code_voucher": codeVoucher,
"secure_token": token,
"amount": amount,
"time_ready_for_pickup": getPickupTime(),
"from": fromByod
};
var bodies = jsonEncode(data);
......@@ -1609,6 +1618,7 @@ class Api {
"cashier_name": cashierName,
"amount": amount,
"secure_token": token,
"time_ready_for_pickup": getPickupTime(),
"from": fromByod
};
var bodies = jsonEncode(data);
......@@ -1913,6 +1923,7 @@ class Api {
"cashier_name": cashierName,
"customer_name": userName,
"from": fromByod,
"time_ready_for_pickup": getPickupTime(),
"order_id": orderID
};
var bodies = jsonEncode(data);
......@@ -2040,7 +2051,7 @@ class Api {
}
}
static Future<Address> getAddress() async {
static Future<Address> getAddress({context}) async {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPointRdm}get_address/";
......@@ -2068,6 +2079,11 @@ class Api {
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
Map<String, dynamic> data = jsonObject['data'];
if (getTypeOrder() == typeOrderDelivery) {
Api.getDeliveryCharge(
jsonObject['data']['lat'], jsonObject['data']['long'])
.then((value) {});
}
return Address.json(data);
}
......@@ -2092,9 +2108,9 @@ class Api {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
if (isAdd) {
apiUrl = "${baseUrl}romi/api/byod/add_promotions";
apiUrl = "$baseUrl${endPoint}add_promotions";
} else {
apiUrl = "${baseUrl}romi/api/byod/cancel_promotions";
apiUrl = "$baseUrl${endPoint}cancel_promotions";
}
String branchCode = getBranchPref();
String brandCode = getBrand();
......@@ -2102,8 +2118,15 @@ class Api {
String cashierName = getCashierName();
String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
......@@ -2142,4 +2165,109 @@ class Api {
return false;
}
}
static Future<bool> getDeliveryCharge(String lat, String long) async {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
apiUrl = "$baseUrl${endPoint}get_delivery_charge";
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
"customer_name": getCustomerName(),
"customer_address_lat": lat,
"customer_address_long": long,
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'getDeliveryCharge');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
return true;
} else {
EasyLoading.showToast(jsonObject['msg']);
return false;
}
} else {
EasyLoading.showToast('Something went wrong');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: getDeliveryCharge, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
static Future<bool> changeTypeOrder(int typeOrder) async {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
apiUrl = "$baseUrl${endPoint}change_type_order_dp";
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"type_order": typeOrder,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
"customer_name": getCustomerName(),
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'changeTypeOrder');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
return true;
} else {
EasyLoading.showToast(jsonObject['msg']);
return false;
}
} else {
EasyLoading.showToast('Something went wrong');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: changeTypeOrder, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
}
import 'package:byod/models/address_user.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart';
......
......@@ -36,6 +36,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
String tableNumberH = '',
String tokenH = '',
String userNameH = '',
isGetAddress = false,
}) async {
String branchCode;
String brandCode;
......@@ -60,6 +61,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
brandCode,
tableNumber,
token,
isCallGetAddress: isGetAddress,
);
} else {
bill = await Api.getBill(
......@@ -69,6 +71,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
token,
orderIdH: orderIdH,
userNameH: userNameH,
isCallGetAddress: isGetAddress,
);
}
......
......@@ -314,9 +314,19 @@ bool isVisibleAddMoreButton(int tableStatus, int orderState) {
return false;
}
bool isVisibleAddRemoveQuantityButtonCheckout(bool isHistory, int orderStatus) {
bool isVisibleAddRemoveQuantityButtonCheckout(
bool isHistory, int orderStatusBillDetail) {
int paymentMethod = getPaymentMode();
if (!isHistory && paymentMethod == closebill && orderStatus == pendingOrder) {
if (!isHistory &&
paymentMethod == closebill &&
orderStatusBillDetail == pendingOrder) {
return true;
}
return false;
}
iscanTapAddRemoveQtyViewBill(int orderState) {
if (orderState == orderStateCreated) {
return true;
}
return false;
......@@ -708,7 +718,7 @@ const int typeUrlTiga = 3;
//** Type ORder */
const int typeOrderDelivery = 0;
const int typeOrderDineIn = 1;
const int typeOrderPickup = 1;
const int typeOrderPickup = 2;
//** Type ORder */
//** END CONSTANT */
......@@ -296,7 +296,9 @@ class _EmoticonRateState extends State<EmoticonRate> {
).then((value) {
Navigator.pop(context);
if (!widget.isHistory) {
context.read<ViewBillBloc>().getBill();
context
.read<ViewBillBloc>()
.getBill();
} else {
List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) {
......
......@@ -240,7 +240,9 @@ 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) {
......
......@@ -15,6 +15,7 @@ class PlusMinusButton extends StatelessWidget {
this.backgroundAmountColor = backgroundColor,
this.isFromVariant = false,
this.widthInitialValue = 94,
this.isCanTap = true,
}) : super(key: key);
final int initialValue;
......@@ -23,6 +24,7 @@ class PlusMinusButton extends StatelessWidget {
final Color backgroundAmountColor;
final bool isFromVariant;
final double widthInitialValue;
final bool isCanTap;
@override
Widget build(BuildContext context) {
......@@ -60,7 +62,9 @@ class PlusMinusButton extends StatelessWidget {
width: 22,
height: 22,
child: Image(
image: AssetImage((initialValue < 2 && isFromVariant)
image: AssetImage((!isCanTap)
? 'assets/icons/minus.png'
: (initialValue < 2 && isFromVariant)
? 'assets/icons/minus.png'
: (isExcelso)
? 'assets/icons/minus-gold.png'
......@@ -84,7 +88,9 @@ class PlusMinusButton extends StatelessWidget {
width: 22,
height: 22,
child: Image(
image: AssetImage((isExcelso)
image: AssetImage((!isCanTap)
? 'assets/icons/plus-grey.png'
: (isExcelso)
? 'assets/icons/plus-gold.png'
: 'assets/icons/plus.png'),
),
......
......@@ -67,7 +67,6 @@ void main() async {
prefs = value;
configLoading();
for (int d = 0; d < Uri.base.pathSegments.length; d++) {
if (Uri.base.pathSegments[0] != 'byod-neo/') {
stringPath.add(Uri.base.pathSegments[d]);
if (d == Uri.base.pathSegments.length - 1) {
routesToAccess += Uri.base.pathSegments[d];
......@@ -75,7 +74,6 @@ void main() async {
routesToAccess += '${Uri.base.pathSegments[d]}/';
}
}
}
loadAssetConfig().then((title) {
setTitleWeb(title);
runApp(
......
......@@ -25,6 +25,7 @@ class Bill {
String dokuMinPay;
String packagingFee;
String platformFee;
String deliveryFee;
// List<MemberInfo> memberInfo;
Bill({
......@@ -50,6 +51,7 @@ class Bill {
required this.dokuMinPay,
this.packagingFee = "0.00",
this.platformFee = "0.00",
this.deliveryFee = "0.00",
// this.memberInfo = const []
});
......@@ -77,6 +79,7 @@ class Bill {
dateOrder: json['order_date'],
packagingFee: json['packaging_fee'],
platformFee: json['platform_fee'],
deliveryFee: json['delivery_fee']
// memberInfo: json['member_info']
);
}
......
......@@ -220,7 +220,7 @@ class _HomeState extends State<Home> {
double widthScreen,
double maxWidthScreen,
BuildContext context,
int tableMode,
int paymentMode,
List<FavoriteGroup> favList,
) {
return BlocBuilder<SearchMenu, List<dynamic>>(
......@@ -341,7 +341,7 @@ class _HomeState extends State<Home> {
totalItem,
totalHarga,
widthScreen,
tableMode,
paymentMode,
listOrders)
: const SizedBox()))
],
......
......@@ -32,6 +32,7 @@ class ListOrder extends StatelessWidget {
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
......
......@@ -12,11 +12,13 @@ import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/note_modal_bottom_sheet.dart';
import '../../helper/widget/plus_minus_button.dart';
import '../../helper/widget/style.dart';
import '../../models/bill.dart';
import '../../models/bill_detail.dart';
import 'view_bill_new.dart';
class OrderViewBillNew extends StatefulWidget {
final BillDetail billDetail;
final Bill bill;
final bool lastItem;
final bool isHistory;
final int tableStatus;
......@@ -24,6 +26,7 @@ class OrderViewBillNew extends StatefulWidget {
Key? key,
required this.billDetail,
required this.isHistory,
required this.bill,
this.lastItem = false,
required this.tableStatus,
}) : super(key: key);
......@@ -260,7 +263,10 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
children: [
GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (iscanTapAddRemoveQtyViewBill(widget.bill.state) ==
true) {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
......@@ -296,13 +302,18 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
);
},
);
}
},
child: Container(
height: 30,
width: 98,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21),
color: buttonColor,
color: (iscanTapAddRemoveQtyViewBill(
widget.bill.state) ==
true)
? buttonColor
: disabledColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
......@@ -339,6 +350,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
initialValue: widget.billDetail.quantity,
plus: plus,
minus: minus,
isCanTap:
iscanTapAddRemoveQtyViewBill(widget.bill.state),
),
const SizedBox(
width: 12,
......
......@@ -89,6 +89,40 @@ class RincianPembayaran extends StatelessWidget {
),
],
),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
? const SizedBox(
height: 8,
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
? Row(
children: [
defaultText(
context,
'Delivery Fee',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
const Spacer(),
defaultText(
context,
(amountParseToInt(dataBill[0].deliveryFee) == 0)
? '-'
: 'Rp ${formatNumber().format(amountParseToInt(dataBill[0].deliveryFee))}',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
],
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
? const SizedBox(
height: 8,
......
......@@ -51,6 +51,7 @@ class ViewBillNew extends StatelessWidget {
final String tableNumberH;
final String token;
final String userName;
final bool isRepeatViewBill;
const ViewBillNew({
Key? key,
this.isHistory = false,
......@@ -60,10 +61,18 @@ class ViewBillNew extends StatelessWidget {
this.tableNumberH = '',
this.token = '',
this.userName = '',
this.isRepeatViewBill = false,
}) : super(key: key);
// final RefreshController _refreshController =
// RefreshController(initialRefresh: false);
Future<void> getBillTwice(BuildContext context) async {
context.read<ViewBillBloc>().getBill();
}
Future<void> getAddressTwice(BuildContext context) async {
context.read<AddressUser>().getAddressUser();
}
void saveBillDetail(List<Bill> dataBill) async {
setTotalOrder(dataBill[0].totalSeluruhOrderan);
......@@ -72,8 +81,17 @@ class ViewBillNew extends StatelessWidget {
void getBillFunc(BuildContext context) {
if (!isHistory) {
context.read<ViewBillBloc>().getBill();
context.read<AddressUser>().getAddressUser();
getBillTwice(context).then((_) {
if (getTypeOrder() == typeOrderDelivery) {
getAddressTwice(context).then((_) {
if (isRepeatViewBill) {
Future.delayed(const Duration(milliseconds: 2000), () async {
getBillTwice(context);
});
}
});
}
});
} else {
context.read<ViewBillBloc>().getBill(
orderIdH: orderId,
......@@ -366,7 +384,7 @@ class CoreBill extends StatelessWidget {
final String brandCode;
final String orderId;
void getBillFunc(BuildContext context) {
void getBillFunction(BuildContext context) {
context.read<ViewBillBloc>().getBill();
}
......@@ -905,7 +923,7 @@ class CoreBill extends StatelessWidget {
if (isCanButtonCheckoutToTap(dataBill[0].state)) {
if (dataBill[0].state == orderStateCreated) {
Api.setToPendingOrder();
getBillFunc(context);
context.read<ViewBillBloc>().getBill();
} else if (dataBill[0].state ==
orderStatePending &&
getTableMode() == tableIndividu) {
......@@ -1416,7 +1434,12 @@ class CoreBill extends StatelessWidget {
onTap: () {
if (getIsPickup()) {
setIsCustomerDelivery(false);
getBillFunc(context);
Api.changeTypeOrder(typeOrderPickup).then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
setTypeOrder(typeOrderPickup);
}
});
Navigator.pop(context);
} else {
String textOnOk = 'OK';
......@@ -1484,7 +1507,13 @@ Note: Ganti outlet akan menyebabkan orderan anda saat ini hilang
);
} else {
setIsCustomerDelivery(true);
getBillFunc(context);
Api.changeTypeOrder(typeOrderDelivery).then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
setTypeOrder(typeOrderDelivery);
}
});
Navigator.pop(context);
}
},
......@@ -1903,6 +1932,8 @@ Apakah ingin melanjutkan ?''';
const SizedBox(
width: 10,
),
Column(
children: [
GestureDetector(
onTap: () {
Navigator.pushReplacement(
......@@ -1937,7 +1968,69 @@ Apakah ingin melanjutkan ?''';
),
),
),
)
),
const SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
void ontapOkeChange() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
);
}
void onTapCancelChange() {
Navigator.pop(context);
}
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,
);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Outlet',
style: addButton(
font: 8,
color: buttonColor,
),
),
),
),
),
],
),
],
),
const SizedBox(
......
// ignore_for_file: sized_box_for_whitespace
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';
import '../../bloc/address_user_bloc.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
......@@ -35,7 +31,9 @@ class CustomAppBar extends StatelessWidget {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const ViewBillNew(),
builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
),
);
},
......@@ -69,7 +67,9 @@ class CustomAppBar extends StatelessWidget {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const ViewBillNew(),
builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
),
);
},
......
......@@ -162,7 +162,9 @@ class _WebViewMapState extends State<WebViewMap> {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const ViewBillNew(),
builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
),
);
}
......
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