|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|
|
|
import 'package:watermanagement/settings.dart';
|
|
|
|
import 'package:watermanagement/settings.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'models/booking_requests_model.dart';
|
|
|
|
import 'models/booking_requests_model.dart';
|
|
|
|
|
|
|
|
import 'models/getdeliveryboy_model.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class BookingRequets extends StatefulWidget {
|
|
|
|
class BookingRequets extends StatefulWidget {
|
|
|
|
const BookingRequets({Key? key}) : super(key: key);
|
|
|
|
const BookingRequets({Key? key}) : super(key: key);
|
|
|
@ -14,8 +15,10 @@ class BookingRequets extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _BookingRequetsState extends State<BookingRequets> {
|
|
|
|
class _BookingRequetsState extends State<BookingRequets> {
|
|
|
|
List<BookingRequestsModel> BookingRequestsList = [];
|
|
|
|
List<BookingRequestsModel> BookingRequestsList = [];
|
|
|
|
|
|
|
|
List<GetDeliveryboyDetailsModel> modeldeliveryboyList = [];
|
|
|
|
bool isSereverIssuePending = false;
|
|
|
|
bool isSereverIssuePending = false;
|
|
|
|
bool isDataLoading = false;
|
|
|
|
bool isDataLoading = false;
|
|
|
|
|
|
|
|
var dropdownAllDeliveryBoys;
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getBookingRequestsData() async {
|
|
|
|
Future<void> getBookingRequestsData() async {
|
|
|
|
isDataLoading = true;
|
|
|
|
isDataLoading = true;
|
|
|
@ -37,11 +40,22 @@ class _BookingRequetsState extends State<BookingRequets> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> getAllDeliveryBoys() async {
|
|
|
|
|
|
|
|
var response1= await AppSettings.getAllDeliverboy();
|
|
|
|
|
|
|
|
print(response1);
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
modeldeliveryboyList =
|
|
|
|
|
|
|
|
((jsonDecode(response1)['data']) as List).map((dynamic model) {
|
|
|
|
|
|
|
|
return GetDeliveryboyDetailsModel.fromJson(model);
|
|
|
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
dropdownAllDeliveryBoys=modeldeliveryboyList[0];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
isDataLoading = true;
|
|
|
|
isDataLoading = true;
|
|
|
|
getBookingRequestsData();
|
|
|
|
getBookingRequestsData();
|
|
|
|
|
|
|
|
getAllDeliveryBoys();
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -226,41 +240,121 @@ class _BookingRequetsState extends State<BookingRequets> {
|
|
|
|
primaryColor /*FilteredList[index].text_color*/),
|
|
|
|
primaryColor /*FilteredList[index].text_color*/),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
var payload = new Map<String, dynamic>();
|
|
|
|
|
|
|
|
payload["supplierName"] =
|
|
|
|
|
|
|
|
AppSettings.suppliername;
|
|
|
|
|
|
|
|
payload["supplierId"] =
|
|
|
|
|
|
|
|
AppSettings.supplierId;
|
|
|
|
|
|
|
|
payload["customerId"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].customer_id;
|
|
|
|
|
|
|
|
payload["capacity"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].capacity;
|
|
|
|
|
|
|
|
payload["customer_address"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index]
|
|
|
|
|
|
|
|
.customer_address;
|
|
|
|
|
|
|
|
payload["dateOfOrder"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].date_of_order;
|
|
|
|
|
|
|
|
payload["action"] = "accept";
|
|
|
|
|
|
|
|
payload["price"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].price;
|
|
|
|
|
|
|
|
payload["delivery_agent"] = '';
|
|
|
|
|
|
|
|
payload["agent_mobile"] = '';
|
|
|
|
|
|
|
|
payload["agent_alternative_mobile"] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool requestStatus =
|
|
|
|
return showDialog(
|
|
|
|
await AppSettings.acceptBookingRequests(
|
|
|
|
context: context,
|
|
|
|
BookingRequestsList[index].booking_id,
|
|
|
|
barrierDismissible: false,
|
|
|
|
payload);
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
|
|
|
return StatefulBuilder(
|
|
|
|
|
|
|
|
builder: (BuildContext context, StateSetter setState) {
|
|
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
|
|
|
title: const Text('Assign'),
|
|
|
|
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
|
|
|
|
child: ListBody(
|
|
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
|
|
|
|
|
|
child: DropdownButtonFormField<GetDeliveryboyDetailsModel>(
|
|
|
|
|
|
|
|
// Initial Value
|
|
|
|
|
|
|
|
value: dropdownAllDeliveryBoys,
|
|
|
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
|
|
|
prefixIcon: Icon(
|
|
|
|
|
|
|
|
Icons.water,
|
|
|
|
|
|
|
|
color: greyColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
|
|
|
borderSide: BorderSide(color: greyColor)),
|
|
|
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
labelText: 'Select delivery boy',
|
|
|
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
|
|
|
color: greyColor, //<-- SEE HERE
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hint: Text('Select delivery boy'),
|
|
|
|
|
|
|
|
// Down Arrow Icon
|
|
|
|
|
|
|
|
icon: const Icon(Icons.keyboard_arrow_down),
|
|
|
|
|
|
|
|
items: modeldeliveryboyList
|
|
|
|
|
|
|
|
.map<DropdownMenuItem<GetDeliveryboyDetailsModel>>(
|
|
|
|
|
|
|
|
(value) => new DropdownMenuItem<GetDeliveryboyDetailsModel>(
|
|
|
|
|
|
|
|
value: value,
|
|
|
|
|
|
|
|
child: new Text(value.deliveryboy_name),
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
.toList(),
|
|
|
|
|
|
|
|
onChanged: (GetDeliveryboyDetailsModel? newValue) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
dropdownAllDeliveryBoys = newValue;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
|
|
child: Text('cancel', style: textButtonStyle()),
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
|
|
child: Text('Accept', style: textButtonStyle()),
|
|
|
|
|
|
|
|
onPressed: () async{
|
|
|
|
|
|
|
|
var payload = new Map<String, dynamic>();
|
|
|
|
|
|
|
|
payload["supplierName"] =
|
|
|
|
|
|
|
|
AppSettings.suppliername;
|
|
|
|
|
|
|
|
payload["supplierId"] =
|
|
|
|
|
|
|
|
AppSettings.supplierId;
|
|
|
|
|
|
|
|
payload["customerId"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].customer_id;
|
|
|
|
|
|
|
|
payload["capacity"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].capacity;
|
|
|
|
|
|
|
|
payload["customer_address"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index]
|
|
|
|
|
|
|
|
.customer_address;
|
|
|
|
|
|
|
|
payload["dateOfOrder"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].date_of_order;
|
|
|
|
|
|
|
|
payload["action"] = "accept";
|
|
|
|
|
|
|
|
payload["price"] =
|
|
|
|
|
|
|
|
BookingRequestsList[index].price;
|
|
|
|
|
|
|
|
payload["delivery_agent"] = dropdownAllDeliveryBoys.deliveryboy_name;
|
|
|
|
|
|
|
|
payload["agent_mobile"] = dropdownAllDeliveryBoys.deliveryboy_phone;
|
|
|
|
|
|
|
|
payload["agent_alternative_mobile"] = dropdownAllDeliveryBoys.deliveryboy_alternativeContactNumber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool requestStatus =
|
|
|
|
|
|
|
|
await AppSettings.acceptBookingRequests(
|
|
|
|
|
|
|
|
BookingRequestsList[index].booking_id,
|
|
|
|
|
|
|
|
payload);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (requestStatus) {
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
AppSettings.longSuccessToast(
|
|
|
|
|
|
|
|
"Booking Accepted");
|
|
|
|
|
|
|
|
await getBookingRequestsData();
|
|
|
|
|
|
|
|
// getAllSuppliersData();
|
|
|
|
|
|
|
|
//await getConnectedSuppliersData();
|
|
|
|
|
|
|
|
//await getPendingSuppliersData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (requestStatus) {
|
|
|
|
|
|
|
|
AppSettings.longSuccessToast(
|
|
|
|
|
|
|
|
"Booking Accepted");
|
|
|
|
|
|
|
|
await getBookingRequestsData();
|
|
|
|
|
|
|
|
// getAllSuppliersData();
|
|
|
|
|
|
|
|
//await getConnectedSuppliersData();
|
|
|
|
|
|
|
|
//await getPendingSuppliersData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
TextButton(
|
|
|
|