1043 lines
47 KiB
Dart
1043 lines
47 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:cheminova/controller/get_order_placed_controller.dart';
|
|
import 'package:cheminova/controller/get_rd_pending_controller.dart';
|
|
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
|
import 'package:cheminova/models/get_rd_pennding_model.dart';
|
|
import 'package:cheminova/models/oder_place_model.dart';
|
|
import 'package:cheminova/models/order_item_model.dart';
|
|
import 'package:cheminova/models/place_order_list_model.dart';
|
|
import 'package:cheminova/models/rd_get_order_model.dart';
|
|
import 'package:cheminova/models/single_get_order_model.dart';
|
|
import 'package:cheminova/screens/rd%20orders/partial_pending_dialog.dart';
|
|
import 'package:cheminova/screens/rd%20orders/partial_processing_dialog_screen.dart';
|
|
import 'package:cheminova/screens/rd%20orders/rd_cancelled_screen.dart';
|
|
import 'package:cheminova/screens/rd%20orders/rd_processing_screen.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../../controller/cart_controller.dart';
|
|
import '../../controller/get_single_invoice_controller.dart';
|
|
import '../../controller/rd_processing_order_controller.dart';
|
|
import '../../models/get_invoice_model.dart';
|
|
import '../../models/product_model1.dart';
|
|
import '../../models/rd_order_item_model.dart';
|
|
import '../../models/rd_placed_order_model.dart';
|
|
import '../../utils/show_snackbar.dart';
|
|
|
|
class RdOrderPendingScreenDetailScreen extends StatefulWidget {
|
|
//final Product? productModel;
|
|
// PlacedOrderList and PlacedOrderModel are optional parameters passed to this screen
|
|
final SingleGetOrderModel? placedOrderList;
|
|
// GetRdPendingModel? productpendingModel;
|
|
final String orderId;
|
|
// GetInvoiceModel? placeInvoiceList;
|
|
|
|
// PlacedOrderModel? placedOrderModel;
|
|
// Constructor for initializing the screen with placed order details
|
|
RdOrderPendingScreenDetailScreen({super.key,this.placedOrderList,required this.orderId});
|
|
|
|
@override
|
|
State<RdOrderPendingScreenDetailScreen> createState() =>
|
|
_RdOrderPendingScreenDetailScreenState();
|
|
}
|
|
|
|
|
|
class _RdOrderPendingScreenDetailScreenState
|
|
extends State<RdOrderPendingScreenDetailScreen> {
|
|
// Controllers for managing cart and placed orders
|
|
final CartController _cartController = Get.put(CartController());
|
|
final GetRdPendingController _getRdPendingController = Get.put(GetRdPendingController());
|
|
final GetSingleInvoiceController _getSingleInvoiceController = Get.put(GetSingleInvoiceController());
|
|
final GetProductRDController _getProductRDController = Get.put(GetProductRDController());
|
|
final RDOrderPlacedController controller = Get.put(RDOrderPlacedController());
|
|
|
|
final List<String> statusOptions = [
|
|
"new",
|
|
"pending",
|
|
"processing",
|
|
"dispatched",
|
|
"cancelled",
|
|
"delivered",
|
|
];
|
|
String selectedStatus = "pending";
|
|
String _groupValue = "cheque";
|
|
// Function to format date from the API to a more readable format
|
|
|
|
List<String> _statusList = ["pending", "processing", "partial processing", "cancelled"];
|
|
String formatDate(String apiDate) {
|
|
// Parse the API date string into a DateTime object
|
|
DateTime parsedDate = DateTime.parse(apiDate).toLocal(); // Convert to local time
|
|
|
|
// Format the date and time according to your specified format
|
|
String formattedDate = DateFormat('EEE MMM dd yyyy').format(parsedDate);
|
|
|
|
return formattedDate; // Return the formatted date string
|
|
}
|
|
|
|
// Function to capitalize the first letter of a string
|
|
String capitalizeFirstLetter(String text) {
|
|
if (text.isEmpty) return text;
|
|
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
|
}
|
|
|
|
|
|
void _onPaymentModeChanged(String? value) {
|
|
setState(() {
|
|
_groupValue = value!;
|
|
});
|
|
_saveSelectedPaymentMode();
|
|
}
|
|
|
|
|
|
void _saveSelectedPaymentMode() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
await prefs.setString('selectedPaymentMode', _groupValue);
|
|
}
|
|
|
|
void _loadSelectedPaymentMode() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
setState(() {
|
|
_groupValue = prefs.getString('selectedPaymentMode') ?? 'cheque';
|
|
});
|
|
}
|
|
// Function to collect unique order IDs and corresponding order details
|
|
Future<void> adduni()async {
|
|
final Set<String> uniqueOrderIds = {};
|
|
final List<GetRdPendingModel> uniqueOrders = [];
|
|
// Loop through placed orders and add unique orders to the list
|
|
for (var order in _getRdPendingController.productRDList) {
|
|
if (uniqueOrderIds.add(order.uniqueId)) {
|
|
uniqueOrders.add(order);
|
|
}
|
|
}
|
|
final order = uniqueOrders[0];
|
|
|
|
// Combine product names, categories, and quantities into strings
|
|
final productNames = order.orderItem
|
|
.map((item) => (item.name))
|
|
.join(', ');
|
|
final categotyName = order.orderItem
|
|
.map((item) => (item.categoryName))
|
|
.join(', ');
|
|
final quantity = order.orderItem
|
|
.map((item) => (item.quantity))
|
|
.join(', ');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
//getOrder1();
|
|
selectedStatus= widget.placedOrderList?.status ?? 'new';
|
|
}
|
|
|
|
|
|
// Future<void> getOrder1() async {
|
|
// await _getSingleInvoiceController.fetchInvoice(widget.placedOrderList!.id);
|
|
// if (_getSingleInvoiceController.invoice.isEmpty) {
|
|
// print("No orders found.");
|
|
// } else {
|
|
// print(" New Orders fetched successfully");
|
|
// }
|
|
// }
|
|
|
|
void _showConfirmationDialog() {
|
|
String dialogTitle;
|
|
String dialogContent;
|
|
TextEditingController reasonController = TextEditingController();
|
|
|
|
// Set dialog title and content based on selected status
|
|
switch (selectedStatus) {
|
|
case "processing":
|
|
dialogTitle = "Update Order Status";
|
|
dialogContent = "Are you sure you want to update the status to processing?";
|
|
break;
|
|
case "partial processing":
|
|
dialogTitle = "Update to Partial Processing";
|
|
dialogContent = "Are you sure you want to update the status to 'Partial Processing'?";
|
|
break;
|
|
case "cancelled":
|
|
dialogTitle = "Cancellation Reason";
|
|
dialogContent = "Please provide a reason for cancelling the order:";
|
|
break;
|
|
default:
|
|
dialogTitle = "Update Order Status";
|
|
dialogContent = "Are you sure you want to update the status to '$selectedStatus'?";
|
|
break;
|
|
}
|
|
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text(dialogTitle),
|
|
content: selectedStatus == "cancelled"
|
|
? Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(dialogContent),
|
|
SizedBox(height: 10),
|
|
TextField(
|
|
controller: reasonController,
|
|
decoration: InputDecoration(
|
|
labelText: 'Cancellation Reason',
|
|
border: OutlineInputBorder(),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: Text(dialogContent),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () async {
|
|
{
|
|
if (selectedStatus == "cancelled") {
|
|
// Ensure the reason is provided for cancellation
|
|
if (reasonController.text.isEmpty) {
|
|
showSnackbar("Please provide a reason for cancelling the order.");
|
|
return; // Exit early if reason is empty
|
|
}
|
|
|
|
// Proceed with cancellation
|
|
await controller.CancleRDProduct(widget.placedOrderList!.id, reasonController.text);
|
|
|
|
// Notify user about successful cancellation
|
|
showSnackbar("Order cancelled successfully");
|
|
Get.to(RdCancelledScreen());
|
|
// Update the status in your UI or backend to reflect the cancelled state
|
|
setState(() {});
|
|
|
|
// Close the dialog after a short delay
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
Navigator.of(context).pop(); // Close the dialog
|
|
});
|
|
|
|
|
|
}
|
|
|
|
if (selectedStatus == "partial processing") {
|
|
Get.to(() => PartialPendingDialogScreen(placedOrderList: widget.placedOrderList));
|
|
return;
|
|
}
|
|
|
|
// Create a map to track products by their IDs and aggregate quantities
|
|
Map<String, RDOrderItem> orderItemMap = {};
|
|
|
|
// Populate the map with items and their quantities
|
|
for (var item in _getProductRDController.productRDList) {
|
|
var productId = item.orderItem[0].productId;
|
|
|
|
if (orderItemMap.containsKey(productId)) {
|
|
// If the product already exists, aggregate the quantity
|
|
var existingItem = orderItemMap[productId]!;
|
|
existingItem.quantity = (existingItem.quantity ?? 0) + (item.orderItem[0].quantity ?? 0);
|
|
existingItem.remainingQuantity = (existingItem.remainingQuantity ?? 0) + (item.orderItem[0].remainingQuantity ?? 0);
|
|
existingItem.processquantity = (existingItem.processquantity ?? 0) + (item.orderItem[0].processquantity ?? 0);
|
|
} else {
|
|
// If it's a new product, add it to the map
|
|
orderItemMap[productId] = RDOrderItem(
|
|
productId: productId,
|
|
sku: item.orderItem[0].sku,
|
|
name: item.orderItem[0].name,
|
|
categoryName: item.orderItem[0].categoryName,
|
|
brandName: item.orderItem[0].brandName,
|
|
price: item.orderItem[0].price,
|
|
gst: item.orderItem[0].gst.toInt(),
|
|
hsnCode: item.orderItem[0].hsnCode,
|
|
description: item.orderItem[0].description,
|
|
image: [], // Handle images appropriately
|
|
quantity: item.orderItem[0].quantity ?? 0,
|
|
remainingQuantity: item.orderItem[0].remainingQuantity ?? 0,
|
|
processquantity: item.orderItem[0].processquantity ?? 0,
|
|
);
|
|
}
|
|
}
|
|
|
|
// Convert the map to a list
|
|
List<RDOrderItem> orderItems = orderItemMap.values.toList();
|
|
|
|
// Ensure the placed order contains the correct orderId and items
|
|
controller.placedOrder1.value = PlacedOrdersProcessing(
|
|
orderId: widget.placedOrderList!.id,
|
|
invoiceItems: orderItems,
|
|
);
|
|
|
|
// Debugging: Print the JSON payload
|
|
print("Sending order payload: ${controller.placedOrder1.value.toJson()}");
|
|
|
|
// Place the order and catch any errors
|
|
await controller.placeRDOrder();
|
|
|
|
showSnackbar("Order processed and invoice created successfully");
|
|
Get.to(RdOrderProcessingScreen());
|
|
|
|
//Navigator.of(context).pop();
|
|
// Close the dialog after a short delay
|
|
|
|
// Close the dialog
|
|
|
|
|
|
// Refresh the UI
|
|
|
|
}
|
|
// catch (e) {
|
|
// print("Error placing order: $e");
|
|
// showSnackbar("Failed to place the order. Please try again.");
|
|
// }
|
|
},
|
|
child: Text("Confirm"),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop(); // Close the dialog
|
|
},
|
|
child: Text("Cancel"),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Color _getCourierStatusColor(String status) {
|
|
switch (status.toLowerCase()) {
|
|
case 'processing':
|
|
return Colors.orange;
|
|
case 'dispatched':
|
|
return Colors.lightBlue;
|
|
case 'delivered':
|
|
return Colors.green;
|
|
default:
|
|
return Colors.grey; // Default color for unknown statuses
|
|
}
|
|
}
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (widget.placedOrderList == null) {
|
|
return Center(child: Text('No order details available'));
|
|
}
|
|
|
|
// Safely get the order and invoice list
|
|
final order = widget.placedOrderList!;
|
|
final invoices = order.invoices;
|
|
|
|
// Check if the invoices list contains at least 4 items
|
|
List<String>? invoiceIds;
|
|
if (invoices.isNotEmpty) {
|
|
// Ensure there are at least 4 invoices
|
|
if (invoices.length >= 4) {
|
|
// Get the ID of the 4th invoice (index 3)
|
|
invoiceIds = [invoices[3].invoiceId!]; // Assuming invoiceId is a String
|
|
} else {
|
|
invoiceIds = []; // Fallback if not enough invoices
|
|
}
|
|
} else {
|
|
invoiceIds = []; // Fallback if no invoices available
|
|
}
|
|
//int remainingQuantity = (widget.placedOrderList!.orderItem![0].quantity)! -(widget.placedOrderList!.orderItem![0].remainingQuantity!.toInt());
|
|
return Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.transparent,
|
|
elevation: 0,
|
|
leading: GestureDetector(
|
|
onTap: () {},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: SvgPicture.asset(
|
|
'assets/svg/menu.svg',
|
|
),
|
|
),
|
|
),
|
|
actions: [
|
|
GestureDetector(
|
|
onTap: () => Get.back(),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: SvgPicture.asset(
|
|
'assets/svg/back_arrow.svg',
|
|
),
|
|
),
|
|
),
|
|
],
|
|
title: const Text(
|
|
"RDPending Order Details",
|
|
),
|
|
),
|
|
body: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Image.asset(
|
|
'assets/images/image_1.png',
|
|
fit: BoxFit.cover,
|
|
),
|
|
SafeArea(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: Get.height * 0.02,
|
|
),
|
|
Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 18),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(19),
|
|
side: const BorderSide(color: Color(0xFFFDFDFD)),
|
|
),
|
|
color: const Color(0xFFB4D1E5).withOpacity(0.9),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
|
|
Card(
|
|
child:
|
|
Column(
|
|
children: [
|
|
SizedBox(
|
|
width: Get.width,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
child: Text(
|
|
"Invoices",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.05,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// Displaying each invoice in a separate card
|
|
if (widget.placedOrderList!.invoices.isNotEmpty)
|
|
...widget.placedOrderList!.invoices.map((invoice) {
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Invoice ID
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Invoice ID:",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text(invoice.invoiceId.toString()),
|
|
],
|
|
),
|
|
const SizedBox(height: 10), // Add spacing
|
|
|
|
// Items for this invoice
|
|
Text(
|
|
"Items: ",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 10), // Add spacing between title and items
|
|
|
|
// List of items in this invoice
|
|
Column(
|
|
children: invoice.items!.map((item) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
"${item.name.toString()} (${item.sku.toString()})",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.03,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
Text("x ${item.processQuantity.toString()}"),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
|
|
const SizedBox(height: 10), // Add spacing between sections
|
|
|
|
// Sub Total
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Sub Total:",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text("₹ ${invoice.subtotal}"),
|
|
],
|
|
),
|
|
|
|
// GST
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"GST:",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text("₹ ${invoice.gstTotal}"),
|
|
],
|
|
),
|
|
|
|
// Invoice Amount
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Invoice Amount:",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text("₹ ${invoice.invoiceAmount}"),
|
|
],
|
|
),
|
|
|
|
// Courier Status
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Courier Status:",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {},
|
|
style: ElevatedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
backgroundColor: _getCourierStatusColor(invoice.courierStatus.toString()),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
),
|
|
child: Text(
|
|
capitalizeFirstLetter(invoice.courierStatus.toString()),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
],
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Card(
|
|
child: SizedBox(
|
|
height: Get.height * 0.35, // Adjust the height as per your requirement
|
|
child: Padding(
|
|
padding: EdgeInsets.all(Get.width * 0.02),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Add title here
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0), // Adjust padding if needed
|
|
child: Text(
|
|
"Order Summary", // Title text
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.05, // Adjust font size as needed
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
itemCount: order.orderItem!.length ?? 0,
|
|
itemBuilder: (context, index) {
|
|
final orderItem =order.orderItem![index];
|
|
final subTotal = orderItem.price * orderItem.quantity!.toInt();
|
|
final GstTotalAmount = (orderItem.price * orderItem.quantity!.toInt()) *(orderItem.gst/100 );
|
|
final grandTotal = subTotal + GstTotalAmount;
|
|
return orderItem != null
|
|
? Card(
|
|
margin: const EdgeInsets.symmetric(vertical: 5.0),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
"assets/images/product.png",
|
|
height: 50,
|
|
width: 50,
|
|
fit: BoxFit.cover,
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
capitalizeFirstLetter(orderItem.name.toString()),
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text(
|
|
"Quantity: ${orderItem.quantity}",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.03,
|
|
),
|
|
),
|
|
|
|
Text("Price: ${orderItem.price}"),
|
|
Text("Subtotal: ${subTotal}"),
|
|
Text("GSt: ${orderItem.gst}%"),
|
|
Text("GST Amount (₹): ${GstTotalAmount}"),
|
|
Text("Total Amount (₹): ${grandTotal}"),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox.shrink();
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
Card(
|
|
child: SizedBox(
|
|
height: Get.height * 0.35, // Adjust the height as per your requirement
|
|
child: Padding(
|
|
padding: EdgeInsets.all(Get.width * 0.02),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Add title here
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0), // Adjust padding if needed
|
|
child: Text(
|
|
"Order Items to be processed", // Title text
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.05, // Adjust font size as needed
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
itemCount: order.orderItem
|
|
?.where((item) => item.remainingQuantity! > 0)
|
|
.length ?? 0,
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
// Filter items with non-zero quantities
|
|
final filteredItems =order!.orderItem!
|
|
.where((item) => item.remainingQuantity! > 0)
|
|
.toList();
|
|
|
|
final orderItem = filteredItems[index];
|
|
final subTotalProcesssItem = orderItem.price! * orderItem.remainingQuantity!.toInt();
|
|
final GstTotalAmounProcessItem = (orderItem.price! * orderItem.remainingQuantity!.toInt()) *(orderItem.gst!/100 );
|
|
final grandTotalProcessItem = subTotalProcesssItem + GstTotalAmounProcessItem;
|
|
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(vertical: 5.0),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
"assets/images/product.png",
|
|
height: 50,
|
|
width: 50,
|
|
fit: BoxFit.cover,
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
capitalizeFirstLetter(orderItem.name.toString()),
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text("Quantity: ${orderItem.remainingQuantity}"),
|
|
Text("Price: ${orderItem.price}"),
|
|
Text("Subtotal: ${subTotalProcesssItem}"),
|
|
Text("Gst: ${orderItem.gst}%"),
|
|
Text("GST Total: ${GstTotalAmounProcessItem}"),
|
|
Text("Total Amount: ${grandTotalProcessItem}"),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
SizedBox(
|
|
height: Get.height* 0.19,
|
|
child:_buildCustomerDetails(),
|
|
|
|
),
|
|
const SizedBox(height: 8),
|
|
_buildBillingInfo(),
|
|
|
|
const SizedBox(height: 8),
|
|
_buildShippingInfo(),
|
|
|
|
const SizedBox(height: 8),
|
|
Card(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
width: Get.width,
|
|
height: Get.height*0.05,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
"Payment Mode : ",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
Text(capitalizeFirstLetter(widget.placedOrderList!.paymentMode.toString())),
|
|
// Text("${widget.placedOrderList!.paymentMode}",maxLines: 4,
|
|
// overflow:TextOverflow.ellipsis,)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Card(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
width: Get.width,
|
|
height: Get.height*0.05,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
"Order Status :",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
SizedBox(width: Get.width*0.01,),
|
|
//Text(capitalizeFirstLetter(widget.placedOrderList!.status)),
|
|
Text(capitalizeFirstLetter(order!.status.toString()),maxLines: 4,
|
|
overflow:TextOverflow.ellipsis,)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
SizedBox(
|
|
height: Get.height * 0.05,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
const Text(
|
|
"Status: ",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
SizedBox(width: 10), // Space between label and dropdown
|
|
Expanded(
|
|
child: DropdownButtonFormField<String>(
|
|
value: selectedStatus,
|
|
decoration: InputDecoration(
|
|
filled: true,
|
|
fillColor: Colors.white, // White background
|
|
contentPadding: EdgeInsets.symmetric(
|
|
vertical: 10, horizontal: 12),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
borderSide: BorderSide(
|
|
color: Colors.grey,
|
|
width: 1,
|
|
),
|
|
),
|
|
),
|
|
items: _statusList.map((String status) {
|
|
return DropdownMenuItem<String>(
|
|
value: status,
|
|
child: Text(capitalizeFirstLetter(status)),
|
|
);
|
|
}).toList(),
|
|
onChanged: (newValue) {
|
|
setState(() {
|
|
selectedStatus = newValue!;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: Get.width * 0.4,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
onPressed: (){
|
|
_showConfirmationDialog();
|
|
},
|
|
// Get.to(() =>
|
|
// RdOrderDetailScreen(
|
|
// placedOrderList: uniqueOrders[index])), // Navigate to detail screen
|
|
style: ElevatedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
backgroundColor: const Color(0xFF004791),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10)),
|
|
),
|
|
child: Text("Update Status", style: GoogleFonts.roboto(fontSize: 14, fontWeight: FontWeight.w400)),
|
|
),
|
|
),
|
|
)
|
|
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: Get.height * 0.04),
|
|
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBillingInfo() {
|
|
return Card(
|
|
child: Column(
|
|
children: [
|
|
_buildSectionTitle("Billing Information"),
|
|
_buildInfoRow("Address", widget.placedOrderList!.billTo.toString(), Get.width * 0.04),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildShippingInfo() {
|
|
return Card(
|
|
child: Column(
|
|
children: [
|
|
_buildSectionTitle("Shipping Information"),
|
|
_buildInfoRow("Address", widget.placedOrderList!.shipTo.toString(), Get.width * 0.04),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildCustomerDetails() {
|
|
return Card(
|
|
child: Column(
|
|
children: [
|
|
_buildSectionTitle("Customer Details"),
|
|
_buildRow("Name:", widget.placedOrderList!.addedBy!.name, Get.width * 0.04),
|
|
_buildRow("Email:", widget.placedOrderList!.addedBy!.email, Get.width * 0.04),
|
|
_buildRow("Mobile Number:", widget.placedOrderList!.addedBy!.mobileNumber, Get.width * 0.04),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Widget _buildInfoRow(String label, String value, double fontSize) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"$label: ",
|
|
style: GoogleFonts.roboto(fontSize: fontSize, fontWeight: FontWeight.w500),
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
value,
|
|
style: GoogleFonts.roboto(fontSize: fontSize),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildRow(String label, String value, double fontSize) {
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: GoogleFonts.roboto(fontSize: fontSize,fontWeight: FontWeight.bold),
|
|
),
|
|
Text(
|
|
value,
|
|
style: GoogleFonts.roboto(fontSize: fontSize),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildSectionTitle(String title) {
|
|
return SizedBox(
|
|
width: Get.width,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
child: Text(
|
|
title,
|
|
style: GoogleFonts.roboto(fontSize: Get.width * 0.05, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
class simple extends State<RdOrderPendingScreenDetailScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: Get.width,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Courier Status : ",
|
|
style: GoogleFonts.roboto(
|
|
fontSize: Get.width * 0.04,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {},
|
|
style: ElevatedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
backgroundColor: _getCourierStatusColor(widget.placedOrderList!.invoices[0]!.courierStatus.toString()), // Call the method here
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
),
|
|
child: Text(widget.placedOrderList!.invoices[0]!.courierStatus.toString()),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Method to get the color based on the status
|
|
Color _getCourierStatusColor(String status) {
|
|
switch (status.toLowerCase()) {
|
|
case 'processing':
|
|
return Colors.orange; // Orange for processing
|
|
case 'dispatched':
|
|
return Colors.lightBlue; // Light blue for dispatched
|
|
case 'delivered':
|
|
return Colors.green; // Green for delivered
|
|
default:
|
|
return Colors.grey; // Default color if status doesn't match
|
|
}
|
|
}
|
|
}
|