1)Udpate code
This commit is contained in:
parent
476bfc4035
commit
9bf45659dc
@ -30,5 +30,37 @@ class GetProductRDController extends GetxController {
|
||||
isLoading(false); // End loading
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> getRDPendingProduct() async {
|
||||
try {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
isLoading(true); // Start loading
|
||||
final response = await GetProductRDService().getRDPendingProduct(token!); // Fetch products from API
|
||||
if (response != null) {
|
||||
productRDList.assignAll(response); // Assign products to the observable list
|
||||
}
|
||||
} finally {
|
||||
isLoading(false); // End loading
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> getRDCancleProduct() async {
|
||||
try {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
isLoading(true); // Start loading
|
||||
final response = await GetProductRDService().getRDCancleProduct(token!); // Fetch products from API
|
||||
if (response != null) {
|
||||
productRDList.assignAll(response); // Assign products to the observable list
|
||||
}
|
||||
} finally {
|
||||
isLoading(false); // End loading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,74 @@ class GetProductRDService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<List<PlacedOrdersResponse>?> getRDPendingProduct(String token) async {
|
||||
try {
|
||||
String url = ApiUrls.getRdPendingOrdergUrl; // Base URL to fetch product manuals
|
||||
|
||||
final response = await commonApiService<List<PlacedOrdersResponse>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
additionalHeaders: { // Pass the token here
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
fromJson: (json) {
|
||||
if (json['plcaedOrders'] != null) {
|
||||
// If the productManuals key is present, map the response to a list of ProductManualModel objects
|
||||
final List<PlacedOrdersResponse> productManuals = (json['plcaedOrders'] as List)
|
||||
.map((manualJson) => PlacedOrdersResponse.fromJson(manualJson))
|
||||
.toList();
|
||||
return productManuals; // Return the list of product manuals
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
|
||||
print("fkfgghgh ,${e.toString()}");
|
||||
//print(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<PlacedOrdersResponse>?> getRDCancleProduct(String token) async {
|
||||
try {
|
||||
String url = ApiUrls.getrdCancleOrderUrl; // Base URL to fetch product manuals
|
||||
|
||||
final response = await commonApiService<List<PlacedOrdersResponse>>(
|
||||
method: "GET",
|
||||
url: url,
|
||||
additionalHeaders: { // Pass the token here
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
fromJson: (json) {
|
||||
if (json['plcaedOrders'] != null) {
|
||||
// If the productManuals key is present, map the response to a list of ProductManualModel objects
|
||||
final List<PlacedOrdersResponse> productManuals = (json['plcaedOrders'] as List)
|
||||
.map((manualJson) => PlacedOrdersResponse.fromJson(manualJson))
|
||||
.toList();
|
||||
return productManuals; // Return the list of product manuals
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
|
||||
print("fkfgghgh ,${e.toString()}");
|
||||
//print(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../models/rd_order_item_model.dart';
|
||||
import '../models/rd_placed_order_model.dart';
|
||||
import '../utils/show_snackbar.dart';
|
||||
|
||||
class RDOrderPlacedController extends GetxController {
|
||||
final RDOrderPlacedService _rdOrderPlacedService = RDOrderPlacedService();
|
||||
@ -41,15 +42,39 @@ class RDOrderPlacedController extends GetxController {
|
||||
try {
|
||||
// Construct the order details from the observable variable
|
||||
PlacedOrdersProcessing orderDetails = placedOrder1.value;
|
||||
print("Order Details: ${orderDetails.toJson()}"); // Debugging the order details
|
||||
print("Order Details: ${orderDetails
|
||||
.toJson()}"); // Debugging the order details
|
||||
|
||||
// Call the service to place the order
|
||||
await _rdOrderPlacedService.placRDeOrder(orderDetails, token!);
|
||||
|
||||
} catch (e) {
|
||||
print("Error placing order: $e");
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> CancleRDProduct(String orderId, String reason) async {
|
||||
try {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token'); // Get the token
|
||||
|
||||
if (token == null || token.isEmpty) {
|
||||
throw Exception("Token is missing. Please login again.");
|
||||
}
|
||||
|
||||
isLoading(true); // Show loading indicator
|
||||
|
||||
// Call the service function and pass the token, orderId, and reason
|
||||
await _rdOrderPlacedService.RDOrderCancel(token, orderId, reason);
|
||||
|
||||
// Optionally refresh the data or show success message
|
||||
print("Order cancellation process complete.");
|
||||
} catch (e) {
|
||||
print("Error: $e");
|
||||
} finally {
|
||||
isLoading(false); // Hide loading indicator
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,8 +10,8 @@
|
||||
final int hsnCode; // Ensure HSN_Code is int
|
||||
final String description;
|
||||
final List<String> image;
|
||||
final int quantity;
|
||||
final int remainingQuantity;
|
||||
int? quantity;
|
||||
int? remainingQuantity;
|
||||
int? processquantity;
|
||||
RDOrderItem({
|
||||
required this.productId,
|
||||
@ -24,8 +24,8 @@
|
||||
required this.hsnCode,
|
||||
required this.description,
|
||||
required this.image,
|
||||
required this.quantity,
|
||||
required this.remainingQuantity,
|
||||
this.quantity,
|
||||
this.remainingQuantity,
|
||||
this.processquantity,
|
||||
});
|
||||
|
||||
|
271
lib/screens/rd orders/partial_processing_dialog_screen.dart
Normal file
271
lib/screens/rd orders/partial_processing_dialog_screen.dart
Normal file
@ -0,0 +1,271 @@
|
||||
import 'package:cheminova/controller/get_order_placed_controller.dart';
|
||||
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
||||
import 'package:cheminova/models/rd_get_order_model.dart';
|
||||
import 'package:cheminova/models/rd_order_item_model.dart';
|
||||
import 'package:cheminova/models/rd_placed_order_model.dart';
|
||||
import 'package:cheminova/screens/order/checkout_screen.dart';
|
||||
import 'package:cheminova/widgets/my_drawer.dart';
|
||||
import 'package:cheminova/widgets/product_card.dart';
|
||||
import 'package:cheminova/widgets/product_card1.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 '../../controller/cart_controller.dart';
|
||||
import '../../controller/rd_processing_order_controller.dart';
|
||||
import '../../models/oder_place_model.dart';
|
||||
import '../../models/product_model1.dart';
|
||||
import '../../utils/show_snackbar.dart';
|
||||
|
||||
class PartialProcessingDialogScreen extends StatefulWidget {
|
||||
PlacedOrdersResponse? productModel;
|
||||
|
||||
PartialProcessingDialogScreen({super.key, this.productModel});
|
||||
|
||||
@override
|
||||
State<PartialProcessingDialogScreen> createState() => _PartialProcessingDialogScreenState();
|
||||
}
|
||||
|
||||
class _PartialProcessingDialogScreenState extends State<PartialProcessingDialogScreen> {
|
||||
final RDOrderPlacedController controller = Get.put(RDOrderPlacedController());
|
||||
bool _selectAll = true; // Default to true to select all products
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _showPartialOrderDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Confirm Partial Order"),
|
||||
content: Text("Do you want to place a partial order for the selected items?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// Create a map to store order items
|
||||
Map<String, RDOrderItem> orderItemMap = {};
|
||||
|
||||
// Populate the map with items and their quantities
|
||||
for (var item in widget.productModel!.orderItem) {
|
||||
var productId = item.productId; // Adjust if needed
|
||||
|
||||
if (orderItemMap.containsKey(productId)) {
|
||||
// If the product already exists, aggregate the quantity
|
||||
var existingItem = orderItemMap[productId]!;
|
||||
existingItem.quantity = (existingItem.quantity ?? 0) + (item.quantity ?? 0);
|
||||
} else {
|
||||
// If it's a new product, add it to the map
|
||||
orderItemMap[productId] = RDOrderItem(
|
||||
productId: productId,
|
||||
sku: item.sku,
|
||||
name: item.name,
|
||||
categoryName: item.categoryName,
|
||||
brandName: item.brandName,
|
||||
price: item.price,
|
||||
gst: item.gst,
|
||||
hsnCode: item.hsnCode,
|
||||
description: item.description,
|
||||
image: [], // Handle images appropriately
|
||||
quantity: item.quantity ?? 0,
|
||||
remainingQuantity: item.remainingQuantity ?? 0,
|
||||
processquantity: item.processquantity ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the map to a list
|
||||
List<RDOrderItem> orderItems = orderItemMap.values.toList();
|
||||
|
||||
controller.placedOrder1.value = PlacedOrdersProcessing(
|
||||
orderId: widget.productModel!.id,
|
||||
invoiceItems: orderItems,
|
||||
);
|
||||
|
||||
// Debugging: Print the JSON payload
|
||||
print(controller.placedOrder1.value.toJson());
|
||||
|
||||
await controller.placeRDOrder();
|
||||
// Show confirmation snackbar
|
||||
showSnackbar( "Partial Order processed and invoice created successfully");
|
||||
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Get.back(); // Close the dialog
|
||||
});
|
||||
|
||||
setState(() {}); // Refresh the UI
|
||||
},
|
||||
child: Text("Confirm"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back(); // Close the dialog
|
||||
},
|
||||
child: Text("Cancel"),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
leading: Builder(
|
||||
builder: (context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Scaffold.of(context).openDrawer(),
|
||||
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 Center(
|
||||
child: Text(
|
||||
"Modify Product Availability",
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: MyDrawer(),
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/image_1.png',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
SafeArea(
|
||||
child: Column(
|
||||
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: [
|
||||
SizedBox(
|
||||
height: Get.height * 0.6,
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: widget.productModel!.orderItem.length,
|
||||
itemBuilder: (context, index) {
|
||||
final orderItem = widget.productModel!.orderItem[index];
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProductCard1(
|
||||
productModel: orderItem,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Subtotal ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.productModel!.subtotal ?? 0}"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"GST ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.productModel!.gstTotal ?? 0}"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Total Amount ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text("₹ ${widget.productModel!.grandTotal ?? 0}"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: Get.height * 0.020),
|
||||
SizedBox(
|
||||
width: Get.width * 0.9,
|
||||
height: Get.height * 0.06,
|
||||
child: ElevatedButton(
|
||||
onPressed: _showPartialOrderDialog, // Show dialog when pressed
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: const Color(0xFF00784C),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Submit",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -51,11 +51,30 @@ class _RdOrderDetailScreenState
|
||||
"cancelled",
|
||||
"delivered",
|
||||
];
|
||||
String selectedStatus = "All";
|
||||
|
||||
|
||||
List<String> _statusList = ["new", "processing", "partial processing", "cancelled"]; // Default status list
|
||||
|
||||
// Define different status lists for different categories
|
||||
final Map<String, List<String>> statusLists = {
|
||||
"new": ["new", "processing", "partial processing", "cancelled"],
|
||||
"pending": ["pending", "processing", "dispatched", "cancelled"],
|
||||
"dispatched": ["dispatched", "delivered", "returned", "cancelled"],
|
||||
"delivered": ["delivered", "returned", "cancelled"],
|
||||
};
|
||||
String selectedStatus = "new";
|
||||
String _groupValue = "cheque";
|
||||
// Function to format date from the API to a more readable format
|
||||
|
||||
|
||||
// This function updates the dropdown list dynamically based on category selection
|
||||
void updateStatusList(String category) {
|
||||
setState(() {
|
||||
_statusList = statusLists[category]!; // Update status list based on the selected category
|
||||
selectedStatus = _statusList.first; // Set the default selection to the first item
|
||||
});
|
||||
}
|
||||
|
||||
String formatDate(String apiDate) {
|
||||
|
||||
DateTime parsedDate = DateTime.parse(apiDate);
|
||||
@ -121,7 +140,6 @@ class _RdOrderDetailScreenState
|
||||
// controller.fetchOrderItems(widget.placedOrderList!.id);
|
||||
}
|
||||
|
||||
// Method to show confirmation dialog
|
||||
void _showConfirmationDialog() {
|
||||
String dialogTitle;
|
||||
String dialogContent;
|
||||
@ -157,9 +175,9 @@ class _RdOrderDetailScreenState
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(dialogContent),
|
||||
SizedBox(height: 10), // Space between text and text field
|
||||
SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: reasonController, // Text controller for cancellation reason
|
||||
controller: reasonController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Cancellation Reason',
|
||||
border: OutlineInputBorder(),
|
||||
@ -171,41 +189,74 @@ class _RdOrderDetailScreenState
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// Check if the selected status is "cancelled" and if necessary reason is provided
|
||||
if (selectedStatus == "cancelled" && reasonController.text.isEmpty) {
|
||||
// Show a warning if the reason is empty
|
||||
Get.snackbar("Error", "Please provide a reason for cancelling the order.");
|
||||
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");
|
||||
|
||||
// Update the status in your UI or backend to reflect the cancelled state
|
||||
setState(() {
|
||||
// Update the status in the local model/UI
|
||||
});
|
||||
|
||||
// Close the dialog after a short delay
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
Get.back(); // Close the dialog
|
||||
});
|
||||
|
||||
return; // Exit here to prevent further processing
|
||||
}
|
||||
|
||||
if (selectedStatus == "partial processing") {
|
||||
Get.to(() => PartialProcessingDialogScreen(productModel: widget.placedOrderList));
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle "partial processing" status
|
||||
if (selectedStatus == "partial processing") {
|
||||
// Navigate to the Partial Processing screen without dismissing the dialog
|
||||
Get.to(() => PartialProcessingDialogScreen(productModel: widget.placedOrderList));
|
||||
return; // Exit to ensure dialog doesn't close yet
|
||||
// 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 _getPlacedOrderController.productRDList) {
|
||||
var productId = item.orderItem[0].productId;
|
||||
|
||||
if (orderItemMap.containsKey(productId)) {
|
||||
// If the product already exists, aggregate the quantity
|
||||
var existingItem = orderItemMap[productId]!; // Get the existing item
|
||||
existingItem.quantity = (existingItem.quantity ?? 0) + (item.orderItem[0].quantity ?? 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,
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
List<RDOrderItem> orderItems = _getPlacedOrderController.productRDList.map<RDOrderItem>((product) {
|
||||
return RDOrderItem(
|
||||
productId: product.orderItem[0].productId,
|
||||
sku: product.orderItem[0].sku,
|
||||
name: product.orderItem[0].name, // You had an empty name in your code
|
||||
categoryName: product.orderItem[0].categoryName,
|
||||
brandName: product.orderItem[0].brandName,
|
||||
price: product.orderItem[0].price,
|
||||
gst: product.orderItem[0].gst,
|
||||
hsnCode: product.orderItem[0].hsnCode, // Fixed hsnCode, hashCode was incorrect
|
||||
description: product.orderItem[0].description,
|
||||
image: [], // Ensure images are properly handled
|
||||
quantity: product.orderItem[0].quantity,
|
||||
remainingQuantity: product.orderItem[0].remainingQuantity,
|
||||
processquantity: product.orderItem[0].processquantity,
|
||||
);
|
||||
}).toList();
|
||||
// Convert the map to a list
|
||||
List<RDOrderItem> orderItems = orderItemMap.values.toList();
|
||||
|
||||
// Updating the placedOrder1 with orderId and items
|
||||
// Ensure the placed order contains the correct orderId and items
|
||||
controller.placedOrder1.value = PlacedOrdersProcessing(
|
||||
orderId: _getPlacedOrderController.productRDList[0].id,
|
||||
orderId: widget.placedOrderList!.id,
|
||||
invoiceItems: orderItems,
|
||||
);
|
||||
|
||||
@ -214,13 +265,10 @@ class _RdOrderDetailScreenState
|
||||
|
||||
await controller.placeRDOrder();
|
||||
|
||||
// Call your update status method here
|
||||
|
||||
showSnackbar("Order processed and invoice created successfully");
|
||||
|
||||
// Delay closing the dialog to ensure the user sees the success message
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
Get.back(); // Close the dialog after a delay
|
||||
Get.back(); // Close the dialog
|
||||
});
|
||||
|
||||
setState(() {}); // Refresh the UI
|
||||
@ -240,6 +288,8 @@ class _RdOrderDetailScreenState
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -558,13 +608,7 @@ class _RdOrderDetailScreenState
|
||||
),
|
||||
),
|
||||
),
|
||||
items: [
|
||||
"new",
|
||||
"processing",
|
||||
"partial processing",
|
||||
"cancelled",
|
||||
|
||||
].map((String status) {
|
||||
items: _statusList.map((String status) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: status,
|
||||
child: Text(capitalizeFirstLetter(status)),
|
||||
|
@ -42,11 +42,29 @@ class ApiUrls {
|
||||
//============================== Rd Order Details ==============================//
|
||||
static const String getRdOrderUrl = '/api/pd-get-new-orders';
|
||||
|
||||
//============================== Rd Single Order Details ==============================//
|
||||
static const String getRdSingleOrderUrl = '/api/pd-get-single-place-order';
|
||||
|
||||
|
||||
//============================== Rd Processing Details ==============================//
|
||||
static const String getRdOrderProcessingUrl = '/api/pd-process-order';
|
||||
|
||||
//============================== Rd Cancel Details ==============================//
|
||||
static const String rdCancleOrderUrl = ' api/pd-cancel-order';
|
||||
static const String rdCancleOrderUrl = '/api/pd-cancel-order';
|
||||
static const String getrdCancleOrderUrl = '/api/pd-get-cancelled-orders';
|
||||
|
||||
//============================== Pending Order Details ==============================//
|
||||
static const String getRdPendingOrdergUrl = '/api/pd-get-pending-orders';
|
||||
|
||||
//============================== RD ProcessingInvoice Order Details ==============================//
|
||||
static const String getRdProcessingInvoiceOrdergUrl = '/api/pd-get-processing-invoices';
|
||||
|
||||
//============================== RD dispatched Order Details ==============================//
|
||||
static const String getRdDispatchedOrdergUrl = '/api/pd-get-dispatched-invoices';
|
||||
|
||||
|
||||
//============================== RD delivered Order Details ==============================//
|
||||
static const String getRdDliveredOrdergUrl = '/api/pd-get-delivered-invoices';
|
||||
|
||||
|
||||
|
||||
|
201
lib/widgets/product_card1.dart
Normal file
201
lib/widgets/product_card1.dart
Normal file
@ -0,0 +1,201 @@
|
||||
import 'package:cheminova/controller/cart_controller.dart';
|
||||
import 'package:cheminova/controller/rd_get_order_controller.dart';
|
||||
import 'package:cheminova/models/rd_get_order_model.dart';
|
||||
import 'package:cheminova/models/rd_order_item_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
class ProductCard1 extends StatefulWidget {
|
||||
final RDOrderItem productModel; // The specific product to be displayed
|
||||
int? quantity;
|
||||
|
||||
ProductCard1({
|
||||
super.key,
|
||||
required this.productModel, // Pass the product model explicitly
|
||||
this.quantity = 1,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ProductCard1> createState() => _ProductCard1State();
|
||||
}
|
||||
|
||||
class _ProductCard1State extends State<ProductCard1> {
|
||||
String capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final CartController _cartController = Get.put(CartController());
|
||||
|
||||
// Current quantity the user wants to process
|
||||
int processQuantity = widget.productModel.processquantity ?? 1;
|
||||
|
||||
// Total available quantity
|
||||
int availableQuantity = widget.productModel.remainingQuantity ?? 1;
|
||||
|
||||
return Card(
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
child: Container(
|
||||
height: Get.height * 0.15,
|
||||
width: Get.width * 0.31,
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/images/product.png"),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display product name with capitalization
|
||||
Text(
|
||||
capitalizeFirstLetter(widget.productModel.name),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
// Display category name
|
||||
Text(
|
||||
capitalizeFirstLetter(widget.productModel.categoryName),
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
// Display the price of the product
|
||||
Text(
|
||||
"₹ ${widget.productModel.price.toString()}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"Ordered Quantity : ",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
" ${widget.productModel.quantity}",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Quantity adjustment buttons
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Availability :",
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: Get.height * 0.04,
|
||||
width: Get.width * 0.21,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF004791),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
// Decrease quantity button
|
||||
SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (processQuantity > 1) {
|
||||
processQuantity--;
|
||||
widget.productModel.processquantity = processQuantity;
|
||||
}
|
||||
});
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'-',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Display the current process quantity
|
||||
Text(
|
||||
"$processQuantity",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
// Increase quantity button
|
||||
SizedBox(
|
||||
height: 22,
|
||||
width: 22,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (processQuantity < availableQuantity) {
|
||||
processQuantity++;
|
||||
widget.productModel.processquantity = processQuantity;
|
||||
}
|
||||
});
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'+',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user